@cstar.help/js 0.1.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 +202 -0
- package/dist/chat/index.cjs +238 -0
- package/dist/chat/index.d.cts +172 -0
- package/dist/chat/index.d.ts +172 -0
- package/dist/chat/index.js +213 -0
- package/dist/index.cjs +364 -0
- package/dist/index.d.cts +519 -0
- package/dist/index.d.ts +519 -0
- package/dist/index.js +331 -0
- package/dist/library/index.cjs +97 -0
- package/dist/library/index.d.cts +82 -0
- package/dist/library/index.d.ts +82 -0
- package/dist/library/index.js +72 -0
- package/dist/webhook/index.cjs +84 -0
- package/dist/webhook/index.d.cts +163 -0
- package/dist/webhook/index.d.ts +163 -0
- package/dist/webhook/index.js +62 -0
- package/package.json +85 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
/** Configuration for the HTTP client. */
|
|
2
|
+
interface ClientConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
teamId: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
maxRetries?: number;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Options for a single request. */
|
|
11
|
+
interface FetchOptions {
|
|
12
|
+
body?: unknown;
|
|
13
|
+
query?: Record<string, string | string[] | number | boolean | undefined>;
|
|
14
|
+
idempotencyKey?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Low-level HTTP client for the cStar API.
|
|
18
|
+
* Handles authentication, retries, rate limiting, and error parsing.
|
|
19
|
+
*/
|
|
20
|
+
declare class HttpClient {
|
|
21
|
+
private readonly config;
|
|
22
|
+
/** Whether this client uses test mode keys. */
|
|
23
|
+
readonly environment: 'live' | 'test';
|
|
24
|
+
constructor(config: ClientConfig);
|
|
25
|
+
/**
|
|
26
|
+
* Make an authenticated request to the cStar API.
|
|
27
|
+
* Automatically retries on 5xx errors and rate limits.
|
|
28
|
+
*/
|
|
29
|
+
request<T>(method: string, path: string, options?: FetchOptions): Promise<T>;
|
|
30
|
+
private buildUrl;
|
|
31
|
+
private buildHeaders;
|
|
32
|
+
/** Exponential backoff: 500ms, 1s, 2s, 4s... capped at 8s, plus jitter. */
|
|
33
|
+
private getBackoffDelay;
|
|
34
|
+
private sleep;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Metadata: string key-value pairs. Max 50 keys, 40-char keys, 500-char values. */
|
|
38
|
+
type Metadata = Record<string, string>;
|
|
39
|
+
/** Standard pagination parameters accepted by list endpoints. */
|
|
40
|
+
interface PaginationParams {
|
|
41
|
+
page?: number;
|
|
42
|
+
pageSize?: number;
|
|
43
|
+
}
|
|
44
|
+
/** Pagination info returned in list responses. */
|
|
45
|
+
interface PaginationInfo {
|
|
46
|
+
total: number;
|
|
47
|
+
page: number;
|
|
48
|
+
pageSize: number;
|
|
49
|
+
hasMore: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** API response envelope for single objects. */
|
|
52
|
+
interface ApiResponse<T> {
|
|
53
|
+
success: true;
|
|
54
|
+
data: T;
|
|
55
|
+
meta: {
|
|
56
|
+
requestId: string;
|
|
57
|
+
timestamp: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** API response envelope for lists with pagination. */
|
|
61
|
+
interface ListResponse<T> {
|
|
62
|
+
success: true;
|
|
63
|
+
data: T[];
|
|
64
|
+
pagination: PaginationInfo;
|
|
65
|
+
meta: {
|
|
66
|
+
requestId: string;
|
|
67
|
+
timestamp: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Delete response body. */
|
|
71
|
+
interface DeleteResponse {
|
|
72
|
+
deleted: true;
|
|
73
|
+
id: string;
|
|
74
|
+
}
|
|
75
|
+
/** Per-request options passed to resource methods. */
|
|
76
|
+
interface RequestOptions {
|
|
77
|
+
/** Idempotency key for safe retries on POST/PATCH. */
|
|
78
|
+
idempotencyKey?: string;
|
|
79
|
+
/** Related resources to expand inline. */
|
|
80
|
+
expand?: string[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A message on a ticket. */
|
|
84
|
+
interface Message {
|
|
85
|
+
id: string;
|
|
86
|
+
object: 'message';
|
|
87
|
+
sender: 'customer' | 'agent' | 'system';
|
|
88
|
+
content: string;
|
|
89
|
+
senderId: string | null;
|
|
90
|
+
senderName: string | null;
|
|
91
|
+
senderAvatarUrl: string | null;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
mergedFromShortId: string | null;
|
|
94
|
+
}
|
|
95
|
+
/** Parameters for creating a message on a ticket. */
|
|
96
|
+
interface MessageCreateParams {
|
|
97
|
+
content: string;
|
|
98
|
+
sender?: 'customer' | 'agent' | 'system';
|
|
99
|
+
senderId?: string;
|
|
100
|
+
senderName?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A cStar support ticket. */
|
|
104
|
+
interface Ticket {
|
|
105
|
+
id: string;
|
|
106
|
+
object: 'ticket';
|
|
107
|
+
title: string;
|
|
108
|
+
priority: 'low' | 'normal' | 'high' | 'urgent';
|
|
109
|
+
status: string;
|
|
110
|
+
customerId: string | null;
|
|
111
|
+
customerName: string | null;
|
|
112
|
+
assignedTo: string | null;
|
|
113
|
+
tags: string[];
|
|
114
|
+
notes: string | null;
|
|
115
|
+
messageCount: number;
|
|
116
|
+
responseDeadline: string | null;
|
|
117
|
+
resolutionDeadline: string | null;
|
|
118
|
+
firstResponseAt: string | null;
|
|
119
|
+
responseTier: string | null;
|
|
120
|
+
resolutionTier: string | null;
|
|
121
|
+
slaPaused: boolean;
|
|
122
|
+
metadata: Metadata;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
closedAt: string | null;
|
|
125
|
+
updatedAt: string;
|
|
126
|
+
/** Present when expand includes 'messages' or on single-ticket GET. */
|
|
127
|
+
messages?: Message[];
|
|
128
|
+
/** Present when expand includes 'customer'. */
|
|
129
|
+
customer?: TicketCustomerSummary | null;
|
|
130
|
+
}
|
|
131
|
+
/** Inline customer summary when expanding on a ticket. */
|
|
132
|
+
interface TicketCustomerSummary {
|
|
133
|
+
id: string;
|
|
134
|
+
object: 'customer';
|
|
135
|
+
name: string;
|
|
136
|
+
email: string;
|
|
137
|
+
sentiment: string;
|
|
138
|
+
status: string;
|
|
139
|
+
}
|
|
140
|
+
/** Parameters for listing tickets. */
|
|
141
|
+
interface TicketListParams extends PaginationParams {
|
|
142
|
+
status?: string;
|
|
143
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
144
|
+
customerId?: string;
|
|
145
|
+
assignedTo?: string;
|
|
146
|
+
search?: string;
|
|
147
|
+
expand?: string[];
|
|
148
|
+
}
|
|
149
|
+
/** Parameters for creating a ticket. */
|
|
150
|
+
interface TicketCreateParams {
|
|
151
|
+
title: string;
|
|
152
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
153
|
+
status?: string;
|
|
154
|
+
customerId?: string;
|
|
155
|
+
customerName?: string;
|
|
156
|
+
tags?: string[];
|
|
157
|
+
notes?: string;
|
|
158
|
+
metadata?: Metadata;
|
|
159
|
+
}
|
|
160
|
+
/** Parameters for updating a ticket. */
|
|
161
|
+
interface TicketUpdateParams {
|
|
162
|
+
title?: string;
|
|
163
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
164
|
+
status?: string;
|
|
165
|
+
customerId?: string | null;
|
|
166
|
+
customerName?: string;
|
|
167
|
+
assignedTo?: string | null;
|
|
168
|
+
tags?: string[];
|
|
169
|
+
notes?: string;
|
|
170
|
+
metadata?: Record<string, string | null>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Base resource class implementing standard CRUD operations.
|
|
175
|
+
* Resource-specific classes extend this with their own type parameters.
|
|
176
|
+
*/
|
|
177
|
+
declare abstract class BaseResource<TEntity, TListParams extends PaginationParams, TCreateParams, TUpdateParams> {
|
|
178
|
+
protected readonly client: HttpClient;
|
|
179
|
+
protected readonly basePath: string;
|
|
180
|
+
constructor(client: HttpClient, basePath: string);
|
|
181
|
+
/** List resources with optional filtering and pagination. */
|
|
182
|
+
list(params?: TListParams & RequestOptions): Promise<ListResponse<TEntity>>;
|
|
183
|
+
/** Get a single resource by ID. */
|
|
184
|
+
get(id: string, options?: RequestOptions): Promise<ApiResponse<TEntity>>;
|
|
185
|
+
/** Create a new resource. */
|
|
186
|
+
create(params: TCreateParams, options?: RequestOptions): Promise<ApiResponse<TEntity>>;
|
|
187
|
+
/** Update an existing resource. */
|
|
188
|
+
update(id: string, params: TUpdateParams, options?: RequestOptions): Promise<ApiResponse<TEntity>>;
|
|
189
|
+
/** Delete a resource by ID. */
|
|
190
|
+
del(id: string): Promise<ApiResponse<DeleteResponse>>;
|
|
191
|
+
/**
|
|
192
|
+
* Auto-paginating async iterator that yields every item across all pages.
|
|
193
|
+
*
|
|
194
|
+
* ```typescript
|
|
195
|
+
* for await (const ticket of cstar.tickets.listAutoPaginating({ status: 'open' })) {
|
|
196
|
+
* console.log(ticket.title);
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
listAutoPaginating(params?: Omit<TListParams, 'page'> & RequestOptions): AsyncIterable<TEntity>;
|
|
201
|
+
/** Convert params to string values for query string serialization. */
|
|
202
|
+
protected serializeQuery(params: Record<string, unknown>): Record<string, string | string[] | undefined>;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Manage ticket messages as a sub-resource. */
|
|
206
|
+
declare class TicketMessagesResource {
|
|
207
|
+
private readonly client;
|
|
208
|
+
constructor(client: HttpClient);
|
|
209
|
+
/** List all messages on a ticket. */
|
|
210
|
+
list(ticketId: string): Promise<ApiResponse<Message[]>>;
|
|
211
|
+
/** Add a message to a ticket. */
|
|
212
|
+
create(ticketId: string, params: MessageCreateParams, options?: RequestOptions): Promise<ApiResponse<Message>>;
|
|
213
|
+
}
|
|
214
|
+
/** Manage support tickets. */
|
|
215
|
+
declare class TicketsResource extends BaseResource<Ticket, TicketListParams, TicketCreateParams, TicketUpdateParams> {
|
|
216
|
+
/** Sub-resource for ticket messages. */
|
|
217
|
+
readonly messages: TicketMessagesResource;
|
|
218
|
+
constructor(client: HttpClient);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** A cStar customer. */
|
|
222
|
+
interface Customer {
|
|
223
|
+
id: string;
|
|
224
|
+
object: 'customer';
|
|
225
|
+
name: string;
|
|
226
|
+
email: string;
|
|
227
|
+
sentiment: string;
|
|
228
|
+
status: string;
|
|
229
|
+
tags: string[];
|
|
230
|
+
notes: string | null;
|
|
231
|
+
customFields: Record<string, unknown>;
|
|
232
|
+
ticketCount: number;
|
|
233
|
+
metadata: Metadata;
|
|
234
|
+
createdAt: string;
|
|
235
|
+
updatedAt: string;
|
|
236
|
+
}
|
|
237
|
+
/** Parameters for listing customers. */
|
|
238
|
+
interface CustomerListParams extends PaginationParams {
|
|
239
|
+
status?: string;
|
|
240
|
+
sentiment?: string;
|
|
241
|
+
search?: string;
|
|
242
|
+
tag?: string;
|
|
243
|
+
expand?: string[];
|
|
244
|
+
}
|
|
245
|
+
/** Parameters for creating a customer. */
|
|
246
|
+
interface CustomerCreateParams {
|
|
247
|
+
name: string;
|
|
248
|
+
email: string;
|
|
249
|
+
sentiment?: string;
|
|
250
|
+
status?: string;
|
|
251
|
+
tags?: string[];
|
|
252
|
+
notes?: string;
|
|
253
|
+
customFields?: Record<string, unknown>;
|
|
254
|
+
metadata?: Metadata;
|
|
255
|
+
}
|
|
256
|
+
/** Parameters for updating a customer. */
|
|
257
|
+
interface CustomerUpdateParams {
|
|
258
|
+
name?: string;
|
|
259
|
+
email?: string;
|
|
260
|
+
sentiment?: string;
|
|
261
|
+
status?: string;
|
|
262
|
+
tags?: string[];
|
|
263
|
+
notes?: string;
|
|
264
|
+
customFields?: Record<string, unknown>;
|
|
265
|
+
metadata?: Record<string, string | null>;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Manage customers. */
|
|
269
|
+
declare class CustomersResource extends BaseResource<Customer, CustomerListParams, CustomerCreateParams, CustomerUpdateParams> {
|
|
270
|
+
constructor(client: HttpClient);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** A cStar knowledge base article. */
|
|
274
|
+
interface Article {
|
|
275
|
+
id: string;
|
|
276
|
+
object: 'article';
|
|
277
|
+
title: string;
|
|
278
|
+
slug: string | null;
|
|
279
|
+
excerpt: string | null;
|
|
280
|
+
content: string | null;
|
|
281
|
+
category: string;
|
|
282
|
+
status: 'draft' | 'published';
|
|
283
|
+
tags: string[];
|
|
284
|
+
notes: string | null;
|
|
285
|
+
viewCount: number;
|
|
286
|
+
useCount: number;
|
|
287
|
+
readTime: string;
|
|
288
|
+
isPublic: boolean;
|
|
289
|
+
publishedAt: string | null;
|
|
290
|
+
metaDescription: string | null;
|
|
291
|
+
metadata: Metadata;
|
|
292
|
+
createdAt: string;
|
|
293
|
+
updatedAt: string;
|
|
294
|
+
}
|
|
295
|
+
/** Parameters for listing articles. */
|
|
296
|
+
interface ArticleListParams extends PaginationParams {
|
|
297
|
+
category?: string;
|
|
298
|
+
status?: 'draft' | 'published';
|
|
299
|
+
isPublic?: boolean;
|
|
300
|
+
search?: string;
|
|
301
|
+
tag?: string;
|
|
302
|
+
expand?: string[];
|
|
303
|
+
}
|
|
304
|
+
/** Parameters for creating an article. */
|
|
305
|
+
interface ArticleCreateParams {
|
|
306
|
+
title: string;
|
|
307
|
+
content?: string;
|
|
308
|
+
excerpt?: string;
|
|
309
|
+
category?: string;
|
|
310
|
+
status?: 'draft' | 'published';
|
|
311
|
+
tags?: string[];
|
|
312
|
+
notes?: string;
|
|
313
|
+
isPublic?: boolean;
|
|
314
|
+
slug?: string;
|
|
315
|
+
metaDescription?: string;
|
|
316
|
+
metadata?: Metadata;
|
|
317
|
+
}
|
|
318
|
+
/** Parameters for updating an article. */
|
|
319
|
+
interface ArticleUpdateParams {
|
|
320
|
+
title?: string;
|
|
321
|
+
content?: string;
|
|
322
|
+
excerpt?: string;
|
|
323
|
+
category?: string;
|
|
324
|
+
status?: 'draft' | 'published';
|
|
325
|
+
tags?: string[];
|
|
326
|
+
notes?: string;
|
|
327
|
+
isPublic?: boolean;
|
|
328
|
+
slug?: string;
|
|
329
|
+
metaDescription?: string;
|
|
330
|
+
metadata?: Record<string, string | null>;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Manage knowledge base articles. */
|
|
334
|
+
declare class ArticlesResource extends BaseResource<Article, ArticleListParams, ArticleCreateParams, ArticleUpdateParams> {
|
|
335
|
+
constructor(client: HttpClient);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** All webhook event types supported by cStar. */
|
|
339
|
+
type WebhookEventType = 'ticket.created' | 'ticket.updated' | 'ticket.closed' | 'ticket.message_added' | 'customer.created' | 'customer.updated' | 'article.created' | 'article.published' | 'article.updated' | 'boss.spawned' | 'boss.defeated' | 'player.level_up' | 'achievement.unlocked' | 'survey.submitted';
|
|
340
|
+
/** A webhook event delivered to your endpoint. */
|
|
341
|
+
interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
|
|
342
|
+
/** Unique event ID (idempotency key). */
|
|
343
|
+
id: string;
|
|
344
|
+
/** Event type. */
|
|
345
|
+
type: T;
|
|
346
|
+
/** When the event was created (ISO 8601). */
|
|
347
|
+
created_at: string;
|
|
348
|
+
/** Team that owns this event. */
|
|
349
|
+
team_id: string;
|
|
350
|
+
/** Event-specific payload. */
|
|
351
|
+
data: WebhookEventData<T>;
|
|
352
|
+
}
|
|
353
|
+
/** Discriminated union mapping event types to their data payloads. */
|
|
354
|
+
type WebhookEventData<T extends WebhookEventType> = T extends 'ticket.created' | 'ticket.updated' | 'ticket.closed' ? {
|
|
355
|
+
ticket: Ticket;
|
|
356
|
+
} : T extends 'ticket.message_added' ? {
|
|
357
|
+
ticket: Ticket;
|
|
358
|
+
message: Message;
|
|
359
|
+
} : T extends 'customer.created' | 'customer.updated' ? {
|
|
360
|
+
customer: Customer;
|
|
361
|
+
} : T extends 'article.created' | 'article.published' | 'article.updated' ? {
|
|
362
|
+
article: Article;
|
|
363
|
+
} : Record<string, unknown>;
|
|
364
|
+
|
|
365
|
+
/** A cStar webhook endpoint. */
|
|
366
|
+
interface Webhook {
|
|
367
|
+
id: string;
|
|
368
|
+
object: 'webhook';
|
|
369
|
+
name: string;
|
|
370
|
+
url: string;
|
|
371
|
+
events: WebhookEventType[];
|
|
372
|
+
isActive: boolean;
|
|
373
|
+
isRestHooks: boolean;
|
|
374
|
+
includeFullObjects: boolean;
|
|
375
|
+
flatPayload: boolean;
|
|
376
|
+
lastTriggeredAt: string | null;
|
|
377
|
+
lastSuccessAt: string | null;
|
|
378
|
+
lastFailureAt: string | null;
|
|
379
|
+
consecutiveFailures: number;
|
|
380
|
+
autoDisabledAt: string | null;
|
|
381
|
+
autoDisableReason: string | null;
|
|
382
|
+
metadata: Metadata;
|
|
383
|
+
createdAt: string;
|
|
384
|
+
updatedAt: string;
|
|
385
|
+
/** Only returned on creation (POST). */
|
|
386
|
+
secret?: string;
|
|
387
|
+
}
|
|
388
|
+
/** Parameters for listing webhooks. */
|
|
389
|
+
interface WebhookListParams extends PaginationParams {
|
|
390
|
+
active?: boolean;
|
|
391
|
+
}
|
|
392
|
+
/** Parameters for creating a webhook. */
|
|
393
|
+
interface WebhookCreateParams {
|
|
394
|
+
name: string;
|
|
395
|
+
url: string;
|
|
396
|
+
events: WebhookEventType[];
|
|
397
|
+
isRestHooks?: boolean;
|
|
398
|
+
includeFullObjects?: boolean;
|
|
399
|
+
flatPayload?: boolean;
|
|
400
|
+
metadata?: Metadata;
|
|
401
|
+
}
|
|
402
|
+
/** Parameters for updating a webhook. */
|
|
403
|
+
interface WebhookUpdateParams {
|
|
404
|
+
name?: string;
|
|
405
|
+
url?: string;
|
|
406
|
+
events?: WebhookEventType[];
|
|
407
|
+
isActive?: boolean;
|
|
408
|
+
includeFullObjects?: boolean;
|
|
409
|
+
flatPayload?: boolean;
|
|
410
|
+
metadata?: Record<string, string | null>;
|
|
411
|
+
}
|
|
412
|
+
/** Result of testing a webhook delivery. */
|
|
413
|
+
interface WebhookTestResult {
|
|
414
|
+
deliveryId: string;
|
|
415
|
+
event: string;
|
|
416
|
+
url: string;
|
|
417
|
+
success: boolean;
|
|
418
|
+
status: number | null;
|
|
419
|
+
responseTimeMs: number;
|
|
420
|
+
error: string | null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Manage webhook endpoints. */
|
|
424
|
+
declare class WebhooksResource extends BaseResource<Webhook, WebhookListParams, WebhookCreateParams, WebhookUpdateParams> {
|
|
425
|
+
constructor(client: HttpClient);
|
|
426
|
+
/** Send a test delivery to a webhook endpoint. */
|
|
427
|
+
test(webhookId: string, params?: {
|
|
428
|
+
event?: WebhookEventType;
|
|
429
|
+
}): Promise<ApiResponse<WebhookTestResult>>;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Error type constants matching the cStar API. */
|
|
433
|
+
declare const ErrorType: {
|
|
434
|
+
readonly AUTHENTICATION_ERROR: "authentication_error";
|
|
435
|
+
readonly INVALID_REQUEST_ERROR: "invalid_request_error";
|
|
436
|
+
readonly NOT_FOUND_ERROR: "not_found_error";
|
|
437
|
+
readonly RATE_LIMIT_ERROR: "rate_limit_error";
|
|
438
|
+
readonly API_ERROR: "api_error";
|
|
439
|
+
};
|
|
440
|
+
/** Shape of the error object returned by the cStar API. */
|
|
441
|
+
interface ApiErrorBody {
|
|
442
|
+
type: string;
|
|
443
|
+
code: string;
|
|
444
|
+
message: string;
|
|
445
|
+
param?: string;
|
|
446
|
+
doc_url: string;
|
|
447
|
+
request_id?: string;
|
|
448
|
+
}
|
|
449
|
+
/** Base error class for all cStar API errors. */
|
|
450
|
+
declare class CStarError extends Error {
|
|
451
|
+
readonly type: string;
|
|
452
|
+
readonly code: string;
|
|
453
|
+
readonly param?: string;
|
|
454
|
+
readonly docUrl: string;
|
|
455
|
+
readonly requestId?: string;
|
|
456
|
+
readonly statusCode: number;
|
|
457
|
+
constructor(statusCode: number, body: ApiErrorBody);
|
|
458
|
+
}
|
|
459
|
+
/** Thrown when authentication fails (401/403). */
|
|
460
|
+
declare class CStarAuthenticationError extends CStarError {
|
|
461
|
+
constructor(statusCode: number, body: ApiErrorBody);
|
|
462
|
+
}
|
|
463
|
+
/** Thrown when rate limited (429). Includes retry timing. */
|
|
464
|
+
declare class CStarRateLimitError extends CStarError {
|
|
465
|
+
readonly retryAfter: number;
|
|
466
|
+
constructor(statusCode: number, body: ApiErrorBody, retryAfter: number);
|
|
467
|
+
}
|
|
468
|
+
/** Thrown when a resource is not found (404). */
|
|
469
|
+
declare class CStarNotFoundError extends CStarError {
|
|
470
|
+
constructor(statusCode: number, body: ApiErrorBody);
|
|
471
|
+
}
|
|
472
|
+
/** Thrown on invalid request parameters (400). */
|
|
473
|
+
declare class CStarValidationError extends CStarError {
|
|
474
|
+
constructor(statusCode: number, body: ApiErrorBody);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** Configuration for the CStarClient. */
|
|
478
|
+
interface CStarClientConfig {
|
|
479
|
+
/** Your API key (sk_live_*, sk_test_*, pk_live_*, or pk_test_*). */
|
|
480
|
+
apiKey: string;
|
|
481
|
+
/** Your team ID. */
|
|
482
|
+
teamId: string;
|
|
483
|
+
/** Override the base URL (defaults to https://app.cstar.help). */
|
|
484
|
+
baseUrl?: string;
|
|
485
|
+
/** API version header (defaults to 2026-03-01). */
|
|
486
|
+
version?: string;
|
|
487
|
+
/** Max retry attempts for failed requests (defaults to 3). */
|
|
488
|
+
maxRetries?: number;
|
|
489
|
+
/** Request timeout in ms (defaults to 30000). */
|
|
490
|
+
timeout?: number;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* The cStar API client.
|
|
494
|
+
*
|
|
495
|
+
* ```typescript
|
|
496
|
+
* const cstar = new CStarClient({
|
|
497
|
+
* apiKey: 'sk_test_abc123...',
|
|
498
|
+
* teamId: 'your-team-id',
|
|
499
|
+
* });
|
|
500
|
+
*
|
|
501
|
+
* const { data } = await cstar.tickets.list({ status: 'open' });
|
|
502
|
+
* ```
|
|
503
|
+
*/
|
|
504
|
+
declare class CStarClient {
|
|
505
|
+
/** Manage support tickets. */
|
|
506
|
+
readonly tickets: TicketsResource;
|
|
507
|
+
/** Manage customers. */
|
|
508
|
+
readonly customers: CustomersResource;
|
|
509
|
+
/** Manage knowledge base articles. */
|
|
510
|
+
readonly articles: ArticlesResource;
|
|
511
|
+
/** Manage webhook endpoints. */
|
|
512
|
+
readonly webhooks: WebhooksResource;
|
|
513
|
+
private readonly client;
|
|
514
|
+
constructor(config: CStarClientConfig);
|
|
515
|
+
/** Whether this client is using test mode keys (sk_test_* or pk_test_*). */
|
|
516
|
+
get isTestMode(): boolean;
|
|
517
|
+
}
|
|
518
|
+
|
|
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 };
|