@cstar.help/js 0.12.1 → 0.14.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/dist/auth/index.cjs +217 -3
- package/dist/auth/index.js +215 -3
- package/dist/chat/index.cjs +84 -29
- package/dist/chat/index.d.cts +72 -27
- package/dist/chat/index.d.ts +72 -27
- package/dist/chat/index.js +84 -29
- package/dist/community/index.cjs +233 -9
- package/dist/community/index.d.cts +11 -0
- package/dist/community/index.d.ts +11 -0
- package/dist/community/index.js +231 -9
- package/dist/index.cjs +309 -74
- package/dist/index.d.cts +3287 -0
- package/dist/index.d.ts +3287 -0
- package/dist/index.js +308 -74
- package/dist/library/index.cjs +254 -9
- package/dist/library/index.d.cts +26 -3
- package/dist/library/index.d.ts +26 -3
- package/dist/library/index.js +252 -9
- package/dist/quickhelp/index.cjs +220 -7
- package/dist/quickhelp/index.d.cts +37 -4
- package/dist/quickhelp/index.d.ts +37 -4
- package/dist/quickhelp/index.js +218 -7
- package/dist/webhook/index.cjs +0 -18
- package/dist/webhook/index.d.cts +440 -0
- package/dist/webhook/index.d.ts +440 -0
- package/dist/webhook/index.js +0 -23
- package/dist/webhook/node.cjs +57 -0
- package/dist/webhook/node.d.cts +440 -0
- package/dist/webhook/node.d.ts +440 -0
- package/dist/webhook/node.js +30 -0
- package/package.json +14 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3287 @@
|
|
|
1
|
+
/** Metadata: string key-value pairs. Max 50 keys, 40-char keys, 500-char values. */
|
|
2
|
+
type Metadata = Record<string, string>;
|
|
3
|
+
/** Standard pagination parameters accepted by list endpoints. */
|
|
4
|
+
interface PaginationParams {
|
|
5
|
+
page?: number;
|
|
6
|
+
pageSize?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Pagination info returned in list responses. */
|
|
9
|
+
interface PaginationInfo {
|
|
10
|
+
total: number;
|
|
11
|
+
page: number;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
hasMore: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resource response — unwrapped bare object.
|
|
17
|
+
*
|
|
18
|
+
* Closes F-016. The historical envelope (`{success, data, meta}`) is now
|
|
19
|
+
* unwrapped at the HTTP-client boundary so callers can `const t = await
|
|
20
|
+
* cstar.tickets.create(...); console.log(t.id)` instead of `t.data.id`.
|
|
21
|
+
*
|
|
22
|
+
* Side-channel access: read `client.lastMeta` immediately after a call to
|
|
23
|
+
* grab the server `requestId` for support escalations.
|
|
24
|
+
*
|
|
25
|
+
* Kept as a type alias rather than removed so existing user code that
|
|
26
|
+
* imports the name keeps compiling.
|
|
27
|
+
*/
|
|
28
|
+
type ApiResponse<T> = T;
|
|
29
|
+
/**
|
|
30
|
+
* List response — unwrapped to `{data, pagination, hasMore}` (matches
|
|
31
|
+
* Stripe-style auto-pagination cursors but keeps server `pagination` info
|
|
32
|
+
* for callers who want totals).
|
|
33
|
+
*/
|
|
34
|
+
interface ListResponse<T> {
|
|
35
|
+
data: T[];
|
|
36
|
+
pagination: PaginationInfo;
|
|
37
|
+
/** Convenience: same as `pagination.hasMore`. */
|
|
38
|
+
hasMore: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Side-channel metadata from the most recent response. Mutable per-call,
|
|
42
|
+
* so read it immediately after the awaited call. Documented on every
|
|
43
|
+
* resource page as the way to grab `requestId` for support tickets.
|
|
44
|
+
*/
|
|
45
|
+
interface LastMeta {
|
|
46
|
+
requestId: string | null;
|
|
47
|
+
timestamp: string | null;
|
|
48
|
+
pagination: PaginationInfo | null;
|
|
49
|
+
}
|
|
50
|
+
/** Delete response body. */
|
|
51
|
+
interface DeleteResponse {
|
|
52
|
+
deleted: true;
|
|
53
|
+
id: string;
|
|
54
|
+
}
|
|
55
|
+
/** Per-request options passed to resource methods. */
|
|
56
|
+
interface RequestOptions {
|
|
57
|
+
/** Idempotency key for safe retries on POST/PATCH. */
|
|
58
|
+
idempotencyKey?: string;
|
|
59
|
+
/** Related resources to expand inline. */
|
|
60
|
+
expand?: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Configuration for the HTTP client. */
|
|
64
|
+
interface ClientConfig {
|
|
65
|
+
apiKey: string;
|
|
66
|
+
teamId: string;
|
|
67
|
+
baseUrl?: string;
|
|
68
|
+
version?: string;
|
|
69
|
+
maxRetries?: number;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Options for a single request. */
|
|
73
|
+
interface FetchOptions {
|
|
74
|
+
body?: unknown;
|
|
75
|
+
query?: Record<string, string | string[] | number | boolean | undefined>;
|
|
76
|
+
idempotencyKey?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Low-level HTTP client for the cStar API.
|
|
80
|
+
* Handles authentication, retries, rate limiting, and error parsing.
|
|
81
|
+
*/
|
|
82
|
+
declare class HttpClient {
|
|
83
|
+
private readonly config;
|
|
84
|
+
/** Whether this client uses test mode keys. */
|
|
85
|
+
readonly environment: 'live' | 'test';
|
|
86
|
+
/**
|
|
87
|
+
* Side-channel metadata from the most recent response. Holds the server
|
|
88
|
+
* `requestId`, `timestamp`, and (for list endpoints) `pagination`. Mutable
|
|
89
|
+
* per-call — read it immediately after awaiting the call.
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* const ticket = await cstar.tickets.create({...});
|
|
93
|
+
* console.error('Created ticket', ticket.id, 'request:', cstar.lastMeta.requestId);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
lastMeta: LastMeta;
|
|
97
|
+
constructor(config: ClientConfig);
|
|
98
|
+
/**
|
|
99
|
+
* Make an authenticated request to the cStar API.
|
|
100
|
+
* Automatically retries on 5xx errors and rate limits.
|
|
101
|
+
*/
|
|
102
|
+
request<T>(method: string, path: string, options?: FetchOptions): Promise<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Like `request()` but skips the `/api/v1/teams/{teamId}` prefix. Used for
|
|
105
|
+
* the small set of non-team-scoped endpoints (`/auth/whoami`, etc).
|
|
106
|
+
*
|
|
107
|
+
* @internal — exposed to CStarClient for `whoami()` and similar; not part
|
|
108
|
+
* of the documented public surface.
|
|
109
|
+
*/
|
|
110
|
+
requestUnscoped<T>(method: string, path: string, options?: FetchOptions): Promise<T>;
|
|
111
|
+
private appendQuery;
|
|
112
|
+
private _sendRequest;
|
|
113
|
+
/**
|
|
114
|
+
* Capture `meta`, `requestId`, and `pagination` from the raw response
|
|
115
|
+
* into `this.lastMeta` before unwrapping the envelope.
|
|
116
|
+
*/
|
|
117
|
+
private captureMeta;
|
|
118
|
+
/**
|
|
119
|
+
* Unwrap the legacy `{success, data, meta, pagination?}` envelope.
|
|
120
|
+
* - `{success:true, data: array, pagination}` → `{data, pagination, hasMore}`
|
|
121
|
+
* - `{success:true, data: object}` → `data` (bare resource)
|
|
122
|
+
* - other shapes pass through unchanged so subpath SDKs (chat, library) keep
|
|
123
|
+
* their bespoke shapes for now.
|
|
124
|
+
*/
|
|
125
|
+
private unwrapEnvelope;
|
|
126
|
+
private buildUrl;
|
|
127
|
+
private buildHeaders;
|
|
128
|
+
/** Get the base URL for building SSE or other endpoints. */
|
|
129
|
+
getBaseUrl(): string;
|
|
130
|
+
/** Get authorization headers for non-fetch requests (e.g., SSE). */
|
|
131
|
+
getAuthHeaders(): Record<string, string>;
|
|
132
|
+
/** Exponential backoff: 500ms, 1s, 2s, 4s... capped at 8s, plus jitter. */
|
|
133
|
+
private getBackoffDelay;
|
|
134
|
+
private sleep;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The subset of the global `EventSource` constructor surface that the
|
|
139
|
+
* realtime client uses. Allows polyfill injection (e.g. the `eventsource`
|
|
140
|
+
* npm package on Node) without forcing the polyfill to satisfy the full
|
|
141
|
+
* lib.dom.d.ts shape.
|
|
142
|
+
*/
|
|
143
|
+
type EventSourceConstructor = new (url: string) => EventSource;
|
|
144
|
+
/** Options for configuring the realtime connection. */
|
|
145
|
+
interface RealtimeOptions {
|
|
146
|
+
/** Event types to subscribe to (e.g., ['ticket.*', 'boss.*']). Omit for all. */
|
|
147
|
+
types?: string[];
|
|
148
|
+
/** Auto-reconnect on disconnect (default: true). */
|
|
149
|
+
autoReconnect?: boolean;
|
|
150
|
+
/** Max reconnection attempts before giving up (default: 10). */
|
|
151
|
+
maxRetries?: number;
|
|
152
|
+
/**
|
|
153
|
+
* EventSource constructor to use. Defaults to `globalThis.EventSource`
|
|
154
|
+
* (browsers and Node 22+). Pass an explicit polyfill (e.g. the
|
|
155
|
+
* `eventsource` npm package) to subscribe from a Node environment that
|
|
156
|
+
* lacks the global. Closes NEW-v2-02.
|
|
157
|
+
*/
|
|
158
|
+
eventSource?: EventSourceConstructor;
|
|
159
|
+
}
|
|
160
|
+
/** A parsed realtime event from the SSE stream. */
|
|
161
|
+
interface RealtimeEvent<T = unknown> {
|
|
162
|
+
/** Event type (e.g., 'ticket.created'). */
|
|
163
|
+
type: string;
|
|
164
|
+
/** Unique event ID for reconnection. */
|
|
165
|
+
id: string;
|
|
166
|
+
/** Typed event payload. */
|
|
167
|
+
data: T;
|
|
168
|
+
/** ISO-8601 timestamp. */
|
|
169
|
+
timestamp: string;
|
|
170
|
+
/** Team ID that owns this event. */
|
|
171
|
+
teamId: string;
|
|
172
|
+
}
|
|
173
|
+
type EventHandler<T = unknown> = (event: RealtimeEvent<T>) => void;
|
|
174
|
+
type ErrorHandler = (error: Error) => void;
|
|
175
|
+
type ConnectionHandler = (connected: boolean) => void;
|
|
176
|
+
/**
|
|
177
|
+
* SSE-based realtime client for the cStar API.
|
|
178
|
+
*
|
|
179
|
+
* Manages a single EventSource connection to `/events/stream` and dispatches
|
|
180
|
+
* events to registered handlers. Supports wildcard matching (e.g., `ticket.*`),
|
|
181
|
+
* auto-reconnection with exponential backoff, and reconnection replay via
|
|
182
|
+
* `Last-Event-ID`.
|
|
183
|
+
*/
|
|
184
|
+
declare class CStarRealtime {
|
|
185
|
+
private readonly httpClient;
|
|
186
|
+
private eventSource;
|
|
187
|
+
private handlers;
|
|
188
|
+
private anyHandlers;
|
|
189
|
+
private errorHandlers;
|
|
190
|
+
private connectionHandlers;
|
|
191
|
+
private lastEventId;
|
|
192
|
+
private retryCount;
|
|
193
|
+
private retryTimer;
|
|
194
|
+
private _connected;
|
|
195
|
+
private destroyed;
|
|
196
|
+
private connecting;
|
|
197
|
+
/** Short-lived SSE token (exchanged from secret key). */
|
|
198
|
+
private sseToken;
|
|
199
|
+
/** When the current SSE token expires (epoch ms). */
|
|
200
|
+
private sseTokenExpiresAt;
|
|
201
|
+
/** Timer that refreshes the SSE token before it expires. */
|
|
202
|
+
private tokenRefreshTimer;
|
|
203
|
+
private readonly autoReconnect;
|
|
204
|
+
private readonly maxRetries;
|
|
205
|
+
private readonly types;
|
|
206
|
+
private readonly eventSourceCtor;
|
|
207
|
+
constructor(httpClient: HttpClient, options?: RealtimeOptions);
|
|
208
|
+
/**
|
|
209
|
+
* Resolve the EventSource constructor to use for this connection.
|
|
210
|
+
* Returns the explicit polyfill when one was injected, otherwise the
|
|
211
|
+
* global. Returns `undefined` when neither is available — callers must
|
|
212
|
+
* convert to `CStarRealtimeUnavailableError` before touching it.
|
|
213
|
+
*/
|
|
214
|
+
private resolveEventSource;
|
|
215
|
+
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). Returns an unsubscribe function. */
|
|
216
|
+
on<T = unknown>(eventType: string, handler: EventHandler<T>): () => void;
|
|
217
|
+
/** Subscribe to all events. Returns an unsubscribe function. */
|
|
218
|
+
onAny<T = unknown>(handler: EventHandler<T>): () => void;
|
|
219
|
+
/** Handle connection errors. */
|
|
220
|
+
onError(handler: ErrorHandler): this;
|
|
221
|
+
/** Handle connection state changes. */
|
|
222
|
+
onConnectionChange(handler: ConnectionHandler): this;
|
|
223
|
+
/** Remove a connection state handler. */
|
|
224
|
+
offConnectionChange(handler: ConnectionHandler): this;
|
|
225
|
+
/** Remove a handler for a specific event type. */
|
|
226
|
+
off<T = unknown>(eventType: string, handler: EventHandler<T>): this;
|
|
227
|
+
/** Remove a handler from the "any" subscription. */
|
|
228
|
+
offAny<T = unknown>(handler: EventHandler<T>): this;
|
|
229
|
+
/** Start the SSE connection. Called automatically on first handler registration. */
|
|
230
|
+
connect(): void;
|
|
231
|
+
/**
|
|
232
|
+
* Open the EventSource with the given auth token.
|
|
233
|
+
* Extracted so both the happy path and the fallback path share logic.
|
|
234
|
+
*/
|
|
235
|
+
private connectWithToken;
|
|
236
|
+
/** Stop listening and clean up all resources. */
|
|
237
|
+
disconnect(): void;
|
|
238
|
+
/** Whether the SSE connection is currently open. */
|
|
239
|
+
get connected(): boolean;
|
|
240
|
+
private ensureConnected;
|
|
241
|
+
private handleMessage;
|
|
242
|
+
private dispatch;
|
|
243
|
+
private scheduleReconnect;
|
|
244
|
+
private setConnected;
|
|
245
|
+
private emitError;
|
|
246
|
+
/** Whether we hold a token that won't expire for at least 30 seconds. */
|
|
247
|
+
private hasFreshSseToken;
|
|
248
|
+
/**
|
|
249
|
+
* Exchange the secret API key for a short-lived SSE token via
|
|
250
|
+
* POST /events/token. Schedules automatic refresh before expiry.
|
|
251
|
+
*/
|
|
252
|
+
private exchangeToken;
|
|
253
|
+
/**
|
|
254
|
+
* Schedule a background token refresh. On success the existing connection
|
|
255
|
+
* keeps working (tokens are validated at connect time). On the next
|
|
256
|
+
* reconnect the fresh token will be used automatically.
|
|
257
|
+
*/
|
|
258
|
+
private scheduleTokenRefresh;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** A message on a ticket. */
|
|
262
|
+
interface Message {
|
|
263
|
+
id: string;
|
|
264
|
+
object: 'message';
|
|
265
|
+
sender: 'customer' | 'agent' | 'system';
|
|
266
|
+
content: string;
|
|
267
|
+
senderId: string | null;
|
|
268
|
+
senderName: string | null;
|
|
269
|
+
senderAvatarUrl: string | null;
|
|
270
|
+
createdAt: string;
|
|
271
|
+
mergedFromShortId: string | null;
|
|
272
|
+
}
|
|
273
|
+
/** Parameters for creating a message on a ticket. */
|
|
274
|
+
interface MessageCreateParams {
|
|
275
|
+
content: string;
|
|
276
|
+
sender?: 'customer' | 'agent' | 'system';
|
|
277
|
+
senderId?: string;
|
|
278
|
+
senderName?: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** A cStar support ticket. */
|
|
282
|
+
interface Ticket {
|
|
283
|
+
id: string;
|
|
284
|
+
object: 'ticket';
|
|
285
|
+
title: string;
|
|
286
|
+
priority: 'low' | 'normal' | 'high' | 'urgent';
|
|
287
|
+
status: string;
|
|
288
|
+
customerId: string | null;
|
|
289
|
+
customerName: string | null;
|
|
290
|
+
assignedTo: string | null;
|
|
291
|
+
tags: string[];
|
|
292
|
+
notes: string | null;
|
|
293
|
+
messageCount: number;
|
|
294
|
+
responseDeadline: string | null;
|
|
295
|
+
resolutionDeadline: string | null;
|
|
296
|
+
firstResponseAt: string | null;
|
|
297
|
+
responseTier: string | null;
|
|
298
|
+
resolutionTier: string | null;
|
|
299
|
+
slaPaused: boolean;
|
|
300
|
+
metadata: Metadata;
|
|
301
|
+
createdAt: string;
|
|
302
|
+
closedAt: string | null;
|
|
303
|
+
updatedAt: string;
|
|
304
|
+
/** Present when expand includes 'messages' or on single-ticket GET. */
|
|
305
|
+
messages?: Message[];
|
|
306
|
+
/** Present when expand includes 'customer'. */
|
|
307
|
+
customer?: TicketCustomerSummary | null;
|
|
308
|
+
}
|
|
309
|
+
/** Inline customer summary when expanding on a ticket. */
|
|
310
|
+
interface TicketCustomerSummary {
|
|
311
|
+
id: string;
|
|
312
|
+
object: 'customer';
|
|
313
|
+
name: string;
|
|
314
|
+
email: string;
|
|
315
|
+
sentiment: string;
|
|
316
|
+
status: string;
|
|
317
|
+
}
|
|
318
|
+
/** Parameters for listing tickets. */
|
|
319
|
+
interface TicketListParams extends PaginationParams {
|
|
320
|
+
status?: string;
|
|
321
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
322
|
+
customerId?: string;
|
|
323
|
+
assignedTo?: string;
|
|
324
|
+
search?: string;
|
|
325
|
+
expand?: string[];
|
|
326
|
+
}
|
|
327
|
+
/** Parameters for creating a ticket. */
|
|
328
|
+
interface TicketCreateParams {
|
|
329
|
+
title: string;
|
|
330
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
331
|
+
status?: string;
|
|
332
|
+
customerId?: string;
|
|
333
|
+
customerName?: string;
|
|
334
|
+
tags?: string[];
|
|
335
|
+
notes?: string;
|
|
336
|
+
metadata?: Metadata;
|
|
337
|
+
}
|
|
338
|
+
/** Parameters for updating a ticket. */
|
|
339
|
+
interface TicketUpdateParams {
|
|
340
|
+
title?: string;
|
|
341
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
342
|
+
status?: string;
|
|
343
|
+
customerId?: string | null;
|
|
344
|
+
customerName?: string;
|
|
345
|
+
assignedTo?: string | null;
|
|
346
|
+
tags?: string[];
|
|
347
|
+
notes?: string;
|
|
348
|
+
metadata?: Record<string, string | null>;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
type ChangeHandler<T> = (data: T[]) => void;
|
|
352
|
+
type ErrorEventHandler = (error: Error) => void;
|
|
353
|
+
declare class Subscription$1<T = unknown> {
|
|
354
|
+
private readonly realtime;
|
|
355
|
+
private readonly fetchFn;
|
|
356
|
+
private readonly resourcePath;
|
|
357
|
+
private readonly filterFn?;
|
|
358
|
+
private _data;
|
|
359
|
+
private _loading;
|
|
360
|
+
private _error;
|
|
361
|
+
private changeHandlers;
|
|
362
|
+
private errorEventHandlers;
|
|
363
|
+
private boundEventHandler;
|
|
364
|
+
private destroyed;
|
|
365
|
+
/** Generation counter to prevent stale refresh() from overwriting SSE updates. */
|
|
366
|
+
private generation;
|
|
367
|
+
constructor(realtime: CStarRealtime, fetchFn: () => Promise<ListResponse<T>>, resourcePath: string, filterFn?: ((item: T) => boolean) | undefined);
|
|
368
|
+
/** Current data array (updated in real-time). */
|
|
369
|
+
get data(): T[];
|
|
370
|
+
/** True during initial data fetch. */
|
|
371
|
+
get loading(): boolean;
|
|
372
|
+
/** Last error, if any. */
|
|
373
|
+
get error(): Error | null;
|
|
374
|
+
/** Register a callback for data changes or errors. */
|
|
375
|
+
on(event: 'change', handler: ChangeHandler<T>): this;
|
|
376
|
+
on(event: 'error', handler: ErrorEventHandler): this;
|
|
377
|
+
/** Manually refresh data from the server. */
|
|
378
|
+
refresh(): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Apply an optimistic update to the local data.
|
|
381
|
+
* Returns a rollback function that reverts the change.
|
|
382
|
+
*/
|
|
383
|
+
optimisticUpdate(id: string, changes: Partial<T>): () => void;
|
|
384
|
+
/** Stop the subscription and clean up all listeners. */
|
|
385
|
+
unsubscribe(): void;
|
|
386
|
+
private init;
|
|
387
|
+
private handleEvent;
|
|
388
|
+
private handleCreated;
|
|
389
|
+
private handleDeleted;
|
|
390
|
+
private handleUpdated;
|
|
391
|
+
private extractEntity;
|
|
392
|
+
private emitChange;
|
|
393
|
+
private emitError;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Base resource class implementing standard CRUD operations.
|
|
398
|
+
* Resource-specific classes extend this with their own type parameters.
|
|
399
|
+
*
|
|
400
|
+
* As of 0.13.0 every method returns the unwrapped resource (or unwrapped
|
|
401
|
+
* `{data, pagination, hasMore}` for list endpoints). Closes F-016. Read
|
|
402
|
+
* `client.lastMeta.requestId` for the server request ID.
|
|
403
|
+
*/
|
|
404
|
+
declare abstract class BaseResource<TEntity, TListParams extends PaginationParams, TCreateParams, TUpdateParams> {
|
|
405
|
+
protected readonly client: HttpClient;
|
|
406
|
+
protected readonly basePath: string;
|
|
407
|
+
constructor(client: HttpClient, basePath: string);
|
|
408
|
+
/** List resources with optional filtering and pagination. */
|
|
409
|
+
list(params?: TListParams & RequestOptions): Promise<ListResponse<TEntity>>;
|
|
410
|
+
/** Get a single resource by ID. */
|
|
411
|
+
get(id: string, options?: RequestOptions): Promise<TEntity>;
|
|
412
|
+
/** Create a new resource. */
|
|
413
|
+
create(params: TCreateParams, options?: RequestOptions): Promise<TEntity>;
|
|
414
|
+
/** Update an existing resource. */
|
|
415
|
+
update(id: string, params: TUpdateParams, options?: RequestOptions): Promise<TEntity>;
|
|
416
|
+
/** Delete a resource by ID. */
|
|
417
|
+
del(id: string): Promise<DeleteResponse>;
|
|
418
|
+
/**
|
|
419
|
+
* Delete a resource by ID. Alias for `del()` — kept because IDE
|
|
420
|
+
* auto-complete and documentation both surface `delete` first. Closes
|
|
421
|
+
* NEW-v2-06.
|
|
422
|
+
*/
|
|
423
|
+
delete(id: string): Promise<DeleteResponse>;
|
|
424
|
+
/**
|
|
425
|
+
* Auto-paginating async iterator that yields every item across all pages.
|
|
426
|
+
*
|
|
427
|
+
* ```typescript
|
|
428
|
+
* for await (const ticket of cstar.tickets.listAutoPaginating({ status: 'open' })) {
|
|
429
|
+
* console.log(ticket.title);
|
|
430
|
+
* }
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
listAutoPaginating(params?: Omit<TListParams, 'page'> & RequestOptions): AsyncIterable<TEntity>;
|
|
434
|
+
/**
|
|
435
|
+
* Subscribe to real-time changes for this resource type.
|
|
436
|
+
*
|
|
437
|
+
* Fetches initial data, then auto-updates via SSE events.
|
|
438
|
+
* Requires a `CStarRealtime` instance (available from `CStarClient.realtime`).
|
|
439
|
+
*
|
|
440
|
+
* ```typescript
|
|
441
|
+
* const sub = cstar.tickets.subscribe(cstar.realtime, { status: 'open' });
|
|
442
|
+
* sub.on('change', (tickets) => console.log(tickets));
|
|
443
|
+
* // Later: sub.unsubscribe();
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
subscribe(realtime: CStarRealtime, params?: TListParams & RequestOptions, filterFn?: (item: TEntity) => boolean): Subscription$1<TEntity>;
|
|
447
|
+
/** Convert params to string values for query string serialization. */
|
|
448
|
+
protected serializeQuery(params: Record<string, unknown>): Record<string, string | string[] | undefined>;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** Manage ticket messages as a sub-resource. */
|
|
452
|
+
declare class TicketMessagesResource {
|
|
453
|
+
private readonly client;
|
|
454
|
+
constructor(client: HttpClient);
|
|
455
|
+
/** List all messages on a ticket. */
|
|
456
|
+
list(ticketId: string): Promise<ListResponse<Message>>;
|
|
457
|
+
/** Add a message to a ticket. */
|
|
458
|
+
create(ticketId: string, params: MessageCreateParams, options?: RequestOptions): Promise<Message>;
|
|
459
|
+
}
|
|
460
|
+
/** Manage support tickets. */
|
|
461
|
+
declare class TicketsResource extends BaseResource<Ticket, TicketListParams, TicketCreateParams, TicketUpdateParams> {
|
|
462
|
+
/** Sub-resource for ticket messages. */
|
|
463
|
+
readonly messages: TicketMessagesResource;
|
|
464
|
+
constructor(client: HttpClient);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** A cStar customer. */
|
|
468
|
+
interface Customer {
|
|
469
|
+
id: string;
|
|
470
|
+
object: 'customer';
|
|
471
|
+
name: string;
|
|
472
|
+
email: string;
|
|
473
|
+
sentiment: string;
|
|
474
|
+
status: string;
|
|
475
|
+
tags: string[];
|
|
476
|
+
notes: string | null;
|
|
477
|
+
customFields: Record<string, unknown>;
|
|
478
|
+
ticketCount: number;
|
|
479
|
+
metadata: Metadata;
|
|
480
|
+
createdAt: string;
|
|
481
|
+
updatedAt: string;
|
|
482
|
+
}
|
|
483
|
+
/** Parameters for listing customers. */
|
|
484
|
+
interface CustomerListParams extends PaginationParams {
|
|
485
|
+
status?: string;
|
|
486
|
+
sentiment?: string;
|
|
487
|
+
search?: string;
|
|
488
|
+
tag?: string;
|
|
489
|
+
expand?: string[];
|
|
490
|
+
}
|
|
491
|
+
/** Parameters for creating a customer. */
|
|
492
|
+
interface CustomerCreateParams {
|
|
493
|
+
name: string;
|
|
494
|
+
email: string;
|
|
495
|
+
sentiment?: string;
|
|
496
|
+
status?: string;
|
|
497
|
+
tags?: string[];
|
|
498
|
+
notes?: string;
|
|
499
|
+
customFields?: Record<string, unknown>;
|
|
500
|
+
metadata?: Metadata;
|
|
501
|
+
}
|
|
502
|
+
/** Parameters for updating a customer. */
|
|
503
|
+
interface CustomerUpdateParams {
|
|
504
|
+
name?: string;
|
|
505
|
+
email?: string;
|
|
506
|
+
sentiment?: string;
|
|
507
|
+
status?: string;
|
|
508
|
+
tags?: string[];
|
|
509
|
+
notes?: string;
|
|
510
|
+
customFields?: Record<string, unknown>;
|
|
511
|
+
metadata?: Record<string, string | null>;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** Manage customers. */
|
|
515
|
+
declare class CustomersResource extends BaseResource<Customer, CustomerListParams, CustomerCreateParams, CustomerUpdateParams> {
|
|
516
|
+
constructor(client: HttpClient);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** A cStar knowledge base article. */
|
|
520
|
+
interface Article {
|
|
521
|
+
id: string;
|
|
522
|
+
object: 'article';
|
|
523
|
+
title: string;
|
|
524
|
+
slug: string | null;
|
|
525
|
+
excerpt: string | null;
|
|
526
|
+
content: string | null;
|
|
527
|
+
categoryId: string | null;
|
|
528
|
+
status: 'draft' | 'published';
|
|
529
|
+
tags: string[];
|
|
530
|
+
notes: string | null;
|
|
531
|
+
viewCount: number;
|
|
532
|
+
useCount: number;
|
|
533
|
+
readTime: string;
|
|
534
|
+
isPublic: boolean;
|
|
535
|
+
publishedAt: string | null;
|
|
536
|
+
metaDescription: string | null;
|
|
537
|
+
metadata: Metadata;
|
|
538
|
+
createdAt: string;
|
|
539
|
+
updatedAt: string;
|
|
540
|
+
}
|
|
541
|
+
/** Parameters for listing articles. */
|
|
542
|
+
interface ArticleListParams extends PaginationParams {
|
|
543
|
+
category?: string;
|
|
544
|
+
status?: 'draft' | 'published';
|
|
545
|
+
isPublic?: boolean;
|
|
546
|
+
search?: string;
|
|
547
|
+
tag?: string;
|
|
548
|
+
expand?: string[];
|
|
549
|
+
}
|
|
550
|
+
/** Parameters for creating an article. */
|
|
551
|
+
interface ArticleCreateParams {
|
|
552
|
+
title: string;
|
|
553
|
+
content?: string;
|
|
554
|
+
excerpt?: string;
|
|
555
|
+
categoryId?: string;
|
|
556
|
+
status?: 'draft' | 'published';
|
|
557
|
+
tags?: string[];
|
|
558
|
+
notes?: string;
|
|
559
|
+
isPublic?: boolean;
|
|
560
|
+
slug?: string;
|
|
561
|
+
metaDescription?: string;
|
|
562
|
+
metadata?: Metadata;
|
|
563
|
+
}
|
|
564
|
+
/** Parameters for updating an article. */
|
|
565
|
+
interface ArticleUpdateParams {
|
|
566
|
+
title?: string;
|
|
567
|
+
content?: string;
|
|
568
|
+
excerpt?: string;
|
|
569
|
+
categoryId?: string;
|
|
570
|
+
status?: 'draft' | 'published';
|
|
571
|
+
tags?: string[];
|
|
572
|
+
notes?: string;
|
|
573
|
+
isPublic?: boolean;
|
|
574
|
+
slug?: string;
|
|
575
|
+
metaDescription?: string;
|
|
576
|
+
metadata?: Record<string, string | null>;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/** Manage knowledge base articles. */
|
|
580
|
+
declare class ArticlesResource extends BaseResource<Article, ArticleListParams, ArticleCreateParams, ArticleUpdateParams> {
|
|
581
|
+
constructor(client: HttpClient);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** Every webhook event type cStar can dispatch. */
|
|
585
|
+
type WebhookEventType = 'article.created' | 'article.deleted' | 'article.published' | 'article.updated' | 'boss.damaged' | 'boss.defeated' | 'boss.spawned' | 'community_post.commented' | 'community_post.created' | 'community_post.deleted' | 'community_post.status_changed' | 'community_post.updated' | 'community_post.voted' | 'customer.created' | 'customer.deleted' | 'customer.updated' | 'customer_group.created' | 'customer_group.deleted' | 'customer_group.updated' | 'player.achievement_unlocked' | 'player.level_up' | 'player.quest_completed' | 'player.streak_milestone' | 'player.xp_gained' | 'social.high_five_sent' | 'social.one_up_sent' | 'survey.submitted' | 'ticket.assigned' | 'ticket.closed' | 'ticket.created' | 'ticket.deleted' | 'ticket.message_added' | 'ticket.updated';
|
|
586
|
+
/** Payload for `article.created` events. */
|
|
587
|
+
interface ArticleCreatedPayload {
|
|
588
|
+
article: {
|
|
589
|
+
id: string;
|
|
590
|
+
title: string;
|
|
591
|
+
slug: string;
|
|
592
|
+
is_public: boolean;
|
|
593
|
+
created_at: string;
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
/** Payload for `article.deleted` events. */
|
|
597
|
+
interface ArticleDeletedPayload {
|
|
598
|
+
id: string;
|
|
599
|
+
}
|
|
600
|
+
/** Payload for `article.published` events. */
|
|
601
|
+
interface ArticlePublishedPayload {
|
|
602
|
+
article: {
|
|
603
|
+
id: string;
|
|
604
|
+
title: string;
|
|
605
|
+
slug: string;
|
|
606
|
+
is_public: boolean;
|
|
607
|
+
published_at: string;
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
/** Payload for `article.updated` events. */
|
|
611
|
+
interface ArticleUpdatedPayload {
|
|
612
|
+
article: {
|
|
613
|
+
id: string;
|
|
614
|
+
title: string;
|
|
615
|
+
slug: string;
|
|
616
|
+
is_public: boolean;
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
/** Payload for `boss.damaged` events. */
|
|
620
|
+
interface BossDamagedPayload {
|
|
621
|
+
boss: {
|
|
622
|
+
id: string;
|
|
623
|
+
current_hp: number;
|
|
624
|
+
};
|
|
625
|
+
damage: number;
|
|
626
|
+
by: {
|
|
627
|
+
agent_id: string;
|
|
628
|
+
name: string;
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
/** Payload for `boss.defeated` events. */
|
|
632
|
+
interface BossDefeatedPayload {
|
|
633
|
+
boss: {
|
|
634
|
+
id: string;
|
|
635
|
+
name: string;
|
|
636
|
+
};
|
|
637
|
+
final_blow_by: {
|
|
638
|
+
agent_id: string;
|
|
639
|
+
name: string;
|
|
640
|
+
};
|
|
641
|
+
team_xp_awarded: number;
|
|
642
|
+
}
|
|
643
|
+
/** Payload for `boss.spawned` events. */
|
|
644
|
+
interface BossSpawnedPayload {
|
|
645
|
+
boss: {
|
|
646
|
+
id: string;
|
|
647
|
+
name: string;
|
|
648
|
+
level: number;
|
|
649
|
+
max_hp: number;
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/** Payload for `community_post.commented` events. */
|
|
653
|
+
interface CommunityPostCommentedPayload {
|
|
654
|
+
comment: {
|
|
655
|
+
id: string;
|
|
656
|
+
post_id: string;
|
|
657
|
+
content: string;
|
|
658
|
+
author_id: string;
|
|
659
|
+
created_at: string;
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
/** Payload for `community_post.created` events. */
|
|
663
|
+
interface CommunityPostCreatedPayload {
|
|
664
|
+
post: {
|
|
665
|
+
id: string;
|
|
666
|
+
prefixed_id: string;
|
|
667
|
+
title: string;
|
|
668
|
+
status: string;
|
|
669
|
+
visibility: string;
|
|
670
|
+
topic: string;
|
|
671
|
+
created_at: string;
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
/** Payload for `community_post.deleted` events. */
|
|
675
|
+
interface CommunityPostDeletedPayload {
|
|
676
|
+
post: {
|
|
677
|
+
id: string;
|
|
678
|
+
prefixed_id?: string;
|
|
679
|
+
title?: string;
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
/** Payload for `community_post.status_changed` events. */
|
|
683
|
+
interface CommunityPostStatusChangedPayload {
|
|
684
|
+
post: {
|
|
685
|
+
id: string;
|
|
686
|
+
title: string;
|
|
687
|
+
status: string;
|
|
688
|
+
visibility: string;
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
/** Payload for `community_post.updated` events. */
|
|
692
|
+
interface CommunityPostUpdatedPayload {
|
|
693
|
+
post: {
|
|
694
|
+
id: string;
|
|
695
|
+
title: string;
|
|
696
|
+
status: string;
|
|
697
|
+
visibility: string;
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
/** Payload for `community_post.voted` events. */
|
|
701
|
+
interface CommunityPostVotedPayload {
|
|
702
|
+
post: {
|
|
703
|
+
id: string;
|
|
704
|
+
vote_count: number;
|
|
705
|
+
};
|
|
706
|
+
voter: {
|
|
707
|
+
id: string;
|
|
708
|
+
};
|
|
709
|
+
direction: string;
|
|
710
|
+
}
|
|
711
|
+
/** Payload for `customer.created` events. */
|
|
712
|
+
interface CustomerCreatedPayload {
|
|
713
|
+
customer: {
|
|
714
|
+
id: string;
|
|
715
|
+
name: string;
|
|
716
|
+
email: string;
|
|
717
|
+
status: string;
|
|
718
|
+
tags: Array<string>;
|
|
719
|
+
created_at: string;
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
/** Payload for `customer.deleted` events. */
|
|
723
|
+
interface CustomerDeletedPayload {
|
|
724
|
+
id: string;
|
|
725
|
+
}
|
|
726
|
+
/** Payload for `customer.updated` events. */
|
|
727
|
+
interface CustomerUpdatedPayload {
|
|
728
|
+
customer: {
|
|
729
|
+
id: string;
|
|
730
|
+
name: string;
|
|
731
|
+
email: string;
|
|
732
|
+
status: string;
|
|
733
|
+
tags: Array<string>;
|
|
734
|
+
};
|
|
735
|
+
changes: {
|
|
736
|
+
tags: {
|
|
737
|
+
from: Array<string>;
|
|
738
|
+
to: Array<string>;
|
|
739
|
+
};
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
/** Payload for `customer_group.created` events. */
|
|
743
|
+
interface CustomerGroupCreatedPayload {
|
|
744
|
+
group: {
|
|
745
|
+
id: string;
|
|
746
|
+
name: string;
|
|
747
|
+
color: string;
|
|
748
|
+
member_count: number;
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
/** Payload for `customer_group.deleted` events. */
|
|
752
|
+
interface CustomerGroupDeletedPayload {
|
|
753
|
+
customer_group: {
|
|
754
|
+
id: string;
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
/** Payload for `customer_group.updated` events. */
|
|
758
|
+
interface CustomerGroupUpdatedPayload {
|
|
759
|
+
group: {
|
|
760
|
+
id: string;
|
|
761
|
+
name: string;
|
|
762
|
+
color: string;
|
|
763
|
+
member_count: number;
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
/** Payload for `player.achievement_unlocked` events. */
|
|
767
|
+
interface PlayerAchievementUnlockedPayload {
|
|
768
|
+
player: {
|
|
769
|
+
agent_id: string;
|
|
770
|
+
name: string;
|
|
771
|
+
};
|
|
772
|
+
achievement: {
|
|
773
|
+
id: string;
|
|
774
|
+
name: string;
|
|
775
|
+
xp: number;
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
/** Payload for `player.level_up` events. */
|
|
779
|
+
interface PlayerLevelUpPayload {
|
|
780
|
+
player: {
|
|
781
|
+
agent_id: string;
|
|
782
|
+
name: string;
|
|
783
|
+
};
|
|
784
|
+
level: {
|
|
785
|
+
from: number;
|
|
786
|
+
to: number;
|
|
787
|
+
};
|
|
788
|
+
title_unlocked: string;
|
|
789
|
+
}
|
|
790
|
+
/** Payload for `player.quest_completed` events. */
|
|
791
|
+
interface PlayerQuestCompletedPayload {
|
|
792
|
+
player: {
|
|
793
|
+
agent_id: string;
|
|
794
|
+
name: string;
|
|
795
|
+
};
|
|
796
|
+
quest: {
|
|
797
|
+
id: string;
|
|
798
|
+
name: string;
|
|
799
|
+
xp: number;
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
/** Payload for `player.streak_milestone` events. */
|
|
803
|
+
interface PlayerStreakMilestonePayload {
|
|
804
|
+
player: {
|
|
805
|
+
agent_id: string;
|
|
806
|
+
name: string;
|
|
807
|
+
};
|
|
808
|
+
streak_days: number;
|
|
809
|
+
milestone: number;
|
|
810
|
+
}
|
|
811
|
+
/** Payload for `player.xp_gained` events. */
|
|
812
|
+
interface PlayerXpGainedPayload {
|
|
813
|
+
player: {
|
|
814
|
+
agent_id: string;
|
|
815
|
+
name: string;
|
|
816
|
+
};
|
|
817
|
+
amount: number;
|
|
818
|
+
reason: string;
|
|
819
|
+
ticket_id: string;
|
|
820
|
+
}
|
|
821
|
+
/** Payload for `social.high_five_sent` events. */
|
|
822
|
+
interface SocialHighFiveSentPayload {
|
|
823
|
+
from_team: {
|
|
824
|
+
id: string;
|
|
825
|
+
name: string;
|
|
826
|
+
};
|
|
827
|
+
to_team: {
|
|
828
|
+
id: string;
|
|
829
|
+
name: string;
|
|
830
|
+
};
|
|
831
|
+
message: string;
|
|
832
|
+
}
|
|
833
|
+
/** Payload for `social.one_up_sent` events. */
|
|
834
|
+
interface SocialOneUpSentPayload {
|
|
835
|
+
from: {
|
|
836
|
+
agent_id: string;
|
|
837
|
+
name: string;
|
|
838
|
+
};
|
|
839
|
+
to: {
|
|
840
|
+
agent_id: string;
|
|
841
|
+
name: string;
|
|
842
|
+
};
|
|
843
|
+
ticket_id: string;
|
|
844
|
+
message: string;
|
|
845
|
+
}
|
|
846
|
+
/** Payload for `survey.submitted` events. */
|
|
847
|
+
interface SurveySubmittedPayload {
|
|
848
|
+
survey: {
|
|
849
|
+
id: string;
|
|
850
|
+
ticket_id: string;
|
|
851
|
+
score: number;
|
|
852
|
+
comment: string;
|
|
853
|
+
submitted_at: string;
|
|
854
|
+
};
|
|
855
|
+
customer: {
|
|
856
|
+
id: string;
|
|
857
|
+
email: string;
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
/** Payload for `ticket.assigned` events. */
|
|
861
|
+
interface TicketAssignedPayload {
|
|
862
|
+
ticket: {
|
|
863
|
+
id: string;
|
|
864
|
+
prefixed_id: string;
|
|
865
|
+
};
|
|
866
|
+
assignee: {
|
|
867
|
+
id: string;
|
|
868
|
+
name: string;
|
|
869
|
+
email: string;
|
|
870
|
+
};
|
|
871
|
+
previous_assignee: null;
|
|
872
|
+
}
|
|
873
|
+
/** Payload for `ticket.closed` events. */
|
|
874
|
+
interface TicketClosedPayload {
|
|
875
|
+
ticket: {
|
|
876
|
+
id: string;
|
|
877
|
+
prefixed_id: string;
|
|
878
|
+
title: string;
|
|
879
|
+
status: string;
|
|
880
|
+
priority: string;
|
|
881
|
+
channel: string;
|
|
882
|
+
resolved_at: string;
|
|
883
|
+
};
|
|
884
|
+
changes?: Record<string, {
|
|
885
|
+
from: string;
|
|
886
|
+
to: string;
|
|
887
|
+
}>;
|
|
888
|
+
}
|
|
889
|
+
/** Payload for `ticket.created` events. */
|
|
890
|
+
interface TicketCreatedPayload {
|
|
891
|
+
ticket: {
|
|
892
|
+
id: string;
|
|
893
|
+
prefixed_id: string;
|
|
894
|
+
title: string;
|
|
895
|
+
status: string;
|
|
896
|
+
priority: string;
|
|
897
|
+
channel: string;
|
|
898
|
+
customer_id: string;
|
|
899
|
+
created_at: string;
|
|
900
|
+
};
|
|
901
|
+
customer: {
|
|
902
|
+
id: string;
|
|
903
|
+
name: string;
|
|
904
|
+
email: string;
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
/** Payload for `ticket.deleted` events. */
|
|
908
|
+
interface TicketDeletedPayload {
|
|
909
|
+
id: string;
|
|
910
|
+
}
|
|
911
|
+
/** Payload for `ticket.message_added` events. */
|
|
912
|
+
interface TicketMessageAddedPayload {
|
|
913
|
+
ticket: {
|
|
914
|
+
id: string;
|
|
915
|
+
dashboard_url: string | null;
|
|
916
|
+
};
|
|
917
|
+
message: {
|
|
918
|
+
id: string;
|
|
919
|
+
sender: string;
|
|
920
|
+
sender_name: string | null;
|
|
921
|
+
content: string;
|
|
922
|
+
created_at: string;
|
|
923
|
+
};
|
|
924
|
+
customer?: {
|
|
925
|
+
id: string;
|
|
926
|
+
name: string | null;
|
|
927
|
+
email: string | null;
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
/** Payload for `ticket.updated` events. */
|
|
931
|
+
interface TicketUpdatedPayload {
|
|
932
|
+
ticket: {
|
|
933
|
+
id: string;
|
|
934
|
+
prefixed_id: string;
|
|
935
|
+
title: string;
|
|
936
|
+
status: string;
|
|
937
|
+
priority: string;
|
|
938
|
+
channel: string;
|
|
939
|
+
};
|
|
940
|
+
changes?: Record<string, {
|
|
941
|
+
from: string;
|
|
942
|
+
to: string;
|
|
943
|
+
} | {
|
|
944
|
+
from: Array<string>;
|
|
945
|
+
to: Array<string>;
|
|
946
|
+
}>;
|
|
947
|
+
}
|
|
948
|
+
/** Maps each event type to its payload interface — used internally for the discriminated union. */
|
|
949
|
+
interface WebhookEventDataMap {
|
|
950
|
+
'article.created': ArticleCreatedPayload;
|
|
951
|
+
'article.deleted': ArticleDeletedPayload;
|
|
952
|
+
'article.published': ArticlePublishedPayload;
|
|
953
|
+
'article.updated': ArticleUpdatedPayload;
|
|
954
|
+
'boss.damaged': BossDamagedPayload;
|
|
955
|
+
'boss.defeated': BossDefeatedPayload;
|
|
956
|
+
'boss.spawned': BossSpawnedPayload;
|
|
957
|
+
'community_post.commented': CommunityPostCommentedPayload;
|
|
958
|
+
'community_post.created': CommunityPostCreatedPayload;
|
|
959
|
+
'community_post.deleted': CommunityPostDeletedPayload;
|
|
960
|
+
'community_post.status_changed': CommunityPostStatusChangedPayload;
|
|
961
|
+
'community_post.updated': CommunityPostUpdatedPayload;
|
|
962
|
+
'community_post.voted': CommunityPostVotedPayload;
|
|
963
|
+
'customer.created': CustomerCreatedPayload;
|
|
964
|
+
'customer.deleted': CustomerDeletedPayload;
|
|
965
|
+
'customer.updated': CustomerUpdatedPayload;
|
|
966
|
+
'customer_group.created': CustomerGroupCreatedPayload;
|
|
967
|
+
'customer_group.deleted': CustomerGroupDeletedPayload;
|
|
968
|
+
'customer_group.updated': CustomerGroupUpdatedPayload;
|
|
969
|
+
'player.achievement_unlocked': PlayerAchievementUnlockedPayload;
|
|
970
|
+
'player.level_up': PlayerLevelUpPayload;
|
|
971
|
+
'player.quest_completed': PlayerQuestCompletedPayload;
|
|
972
|
+
'player.streak_milestone': PlayerStreakMilestonePayload;
|
|
973
|
+
'player.xp_gained': PlayerXpGainedPayload;
|
|
974
|
+
'social.high_five_sent': SocialHighFiveSentPayload;
|
|
975
|
+
'social.one_up_sent': SocialOneUpSentPayload;
|
|
976
|
+
'survey.submitted': SurveySubmittedPayload;
|
|
977
|
+
'ticket.assigned': TicketAssignedPayload;
|
|
978
|
+
'ticket.closed': TicketClosedPayload;
|
|
979
|
+
'ticket.created': TicketCreatedPayload;
|
|
980
|
+
'ticket.deleted': TicketDeletedPayload;
|
|
981
|
+
'ticket.message_added': TicketMessageAddedPayload;
|
|
982
|
+
'ticket.updated': TicketUpdatedPayload;
|
|
983
|
+
}
|
|
984
|
+
/** A webhook event delivered to your endpoint. */
|
|
985
|
+
interface WebhookEvent<T extends WebhookEventType = WebhookEventType> {
|
|
986
|
+
/** Unique event ID (idempotency key). */
|
|
987
|
+
id: string;
|
|
988
|
+
/** Event type. */
|
|
989
|
+
type: T;
|
|
990
|
+
/** When the event was created (ISO 8601). */
|
|
991
|
+
created_at: string;
|
|
992
|
+
/** Team that owns this event. */
|
|
993
|
+
team_id: string;
|
|
994
|
+
/** Event-specific payload. */
|
|
995
|
+
data: WebhookEventDataMap[T];
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
type WebhookEventData<T extends WebhookEventType> = WebhookEventDataMap[T];
|
|
999
|
+
|
|
1000
|
+
/** A cStar webhook endpoint. */
|
|
1001
|
+
interface Webhook {
|
|
1002
|
+
id: string;
|
|
1003
|
+
object: 'webhook';
|
|
1004
|
+
name: string;
|
|
1005
|
+
url: string;
|
|
1006
|
+
events: WebhookEventType[];
|
|
1007
|
+
isActive: boolean;
|
|
1008
|
+
isRestHooks: boolean;
|
|
1009
|
+
includeFullObjects: boolean;
|
|
1010
|
+
flatPayload: boolean;
|
|
1011
|
+
lastTriggeredAt: string | null;
|
|
1012
|
+
lastSuccessAt: string | null;
|
|
1013
|
+
lastFailureAt: string | null;
|
|
1014
|
+
consecutiveFailures: number;
|
|
1015
|
+
autoDisabledAt: string | null;
|
|
1016
|
+
autoDisableReason: string | null;
|
|
1017
|
+
metadata: Metadata;
|
|
1018
|
+
createdAt: string;
|
|
1019
|
+
updatedAt: string;
|
|
1020
|
+
/** Only returned on creation (POST). */
|
|
1021
|
+
secret?: string;
|
|
1022
|
+
}
|
|
1023
|
+
/** Parameters for listing webhooks. */
|
|
1024
|
+
interface WebhookListParams extends PaginationParams {
|
|
1025
|
+
active?: boolean;
|
|
1026
|
+
}
|
|
1027
|
+
/** Parameters for creating a webhook. */
|
|
1028
|
+
interface WebhookCreateParams {
|
|
1029
|
+
name: string;
|
|
1030
|
+
url: string;
|
|
1031
|
+
events: WebhookEventType[];
|
|
1032
|
+
isRestHooks?: boolean;
|
|
1033
|
+
includeFullObjects?: boolean;
|
|
1034
|
+
flatPayload?: boolean;
|
|
1035
|
+
metadata?: Metadata;
|
|
1036
|
+
}
|
|
1037
|
+
/** Parameters for updating a webhook. */
|
|
1038
|
+
interface WebhookUpdateParams {
|
|
1039
|
+
name?: string;
|
|
1040
|
+
url?: string;
|
|
1041
|
+
events?: WebhookEventType[];
|
|
1042
|
+
isActive?: boolean;
|
|
1043
|
+
includeFullObjects?: boolean;
|
|
1044
|
+
flatPayload?: boolean;
|
|
1045
|
+
metadata?: Record<string, string | null>;
|
|
1046
|
+
}
|
|
1047
|
+
/** Result of testing a webhook delivery. */
|
|
1048
|
+
interface WebhookTestResult {
|
|
1049
|
+
deliveryId: string;
|
|
1050
|
+
event: string;
|
|
1051
|
+
url: string;
|
|
1052
|
+
success: boolean;
|
|
1053
|
+
status: number | null;
|
|
1054
|
+
responseTimeMs: number;
|
|
1055
|
+
error: string | null;
|
|
1056
|
+
}
|
|
1057
|
+
/** Parameters for subscribing (REST Hooks / Zapier protocol). */
|
|
1058
|
+
interface WebhookSubscribeParams {
|
|
1059
|
+
targetUrl: string;
|
|
1060
|
+
event: string;
|
|
1061
|
+
}
|
|
1062
|
+
/** A REST Hooks subscription. */
|
|
1063
|
+
interface WebhookSubscription {
|
|
1064
|
+
id: string;
|
|
1065
|
+
object: 'webhook';
|
|
1066
|
+
[key: string]: unknown;
|
|
1067
|
+
}
|
|
1068
|
+
/** Parameters for registering a CLI listener. */
|
|
1069
|
+
interface WebhookListenerParams {
|
|
1070
|
+
forwardUrl: string;
|
|
1071
|
+
events?: string[];
|
|
1072
|
+
}
|
|
1073
|
+
/** A registered CLI listener. */
|
|
1074
|
+
interface WebhookListener {
|
|
1075
|
+
listenerId: string;
|
|
1076
|
+
secret: string;
|
|
1077
|
+
}
|
|
1078
|
+
/** Parameters for triggering a test webhook event. */
|
|
1079
|
+
interface WebhookTriggerTestParams {
|
|
1080
|
+
event: string;
|
|
1081
|
+
data?: Record<string, unknown>;
|
|
1082
|
+
}
|
|
1083
|
+
/** Result of triggering a test webhook event. */
|
|
1084
|
+
interface WebhookTriggerTestResult {
|
|
1085
|
+
event: string;
|
|
1086
|
+
deliveredTo: number;
|
|
1087
|
+
[key: string]: unknown;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/** Manage webhook endpoints. */
|
|
1091
|
+
declare class WebhooksResource extends BaseResource<Webhook, WebhookListParams, WebhookCreateParams, WebhookUpdateParams> {
|
|
1092
|
+
constructor(client: HttpClient);
|
|
1093
|
+
/** Send a test delivery to a webhook endpoint. */
|
|
1094
|
+
test(webhookId: string, params?: {
|
|
1095
|
+
event?: WebhookEventType;
|
|
1096
|
+
}): Promise<ApiResponse<WebhookTestResult>>;
|
|
1097
|
+
/** Fire a test webhook event to all active webhooks and CLI listeners. */
|
|
1098
|
+
triggerTest(params: WebhookTriggerTestParams, options?: RequestOptions): Promise<ApiResponse<WebhookTriggerTestResult>>;
|
|
1099
|
+
/** Get a sample webhook payload for an event type (used by Zapier). */
|
|
1100
|
+
sample(event: string): Promise<ApiResponse<unknown[]>>;
|
|
1101
|
+
/** Subscribe to an event (REST Hooks / Zapier protocol). */
|
|
1102
|
+
restSubscribe(params: WebhookSubscribeParams, options?: RequestOptions): Promise<ApiResponse<WebhookSubscription>>;
|
|
1103
|
+
/** Unsubscribe from an event (REST Hooks / Zapier protocol). Returns void (204 No Content). */
|
|
1104
|
+
unsubscribe(subscriptionId: string): Promise<void>;
|
|
1105
|
+
/** Register a CLI listener (returns listenerId and signing secret). */
|
|
1106
|
+
listen(params: WebhookListenerParams, options?: RequestOptions): Promise<ApiResponse<WebhookListener>>;
|
|
1107
|
+
/** Deregister a CLI listener. */
|
|
1108
|
+
unlisten(listenerId: string): Promise<ApiResponse<{
|
|
1109
|
+
deleted: true;
|
|
1110
|
+
listenerId: string;
|
|
1111
|
+
}>>;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/** A condition in an automation rule. */
|
|
1115
|
+
interface AutomationCondition {
|
|
1116
|
+
field: string;
|
|
1117
|
+
operator: string;
|
|
1118
|
+
value?: unknown;
|
|
1119
|
+
}
|
|
1120
|
+
/** Condition groups (all must match AND at least one any must match). */
|
|
1121
|
+
interface AutomationConditions {
|
|
1122
|
+
all: AutomationCondition[];
|
|
1123
|
+
any: AutomationCondition[];
|
|
1124
|
+
}
|
|
1125
|
+
/** An action in an automation rule. */
|
|
1126
|
+
interface AutomationAction {
|
|
1127
|
+
type: string;
|
|
1128
|
+
[key: string]: unknown;
|
|
1129
|
+
}
|
|
1130
|
+
/** A cStar automation rule. */
|
|
1131
|
+
interface AutomationRule {
|
|
1132
|
+
id: string;
|
|
1133
|
+
object: 'automation_rule';
|
|
1134
|
+
name: string;
|
|
1135
|
+
description: string;
|
|
1136
|
+
triggerEvent: string;
|
|
1137
|
+
triggerFilter: Record<string, unknown>;
|
|
1138
|
+
conditions: AutomationConditions;
|
|
1139
|
+
actions: AutomationAction[];
|
|
1140
|
+
enabled: boolean;
|
|
1141
|
+
position: number;
|
|
1142
|
+
stopAfter: boolean;
|
|
1143
|
+
maxExecutionsPerTicket: number;
|
|
1144
|
+
cooldownSeconds: number;
|
|
1145
|
+
executionCount: number;
|
|
1146
|
+
lastExecutedAt: string | null;
|
|
1147
|
+
createdBy: string | null;
|
|
1148
|
+
createdAt: string;
|
|
1149
|
+
updatedAt: string;
|
|
1150
|
+
}
|
|
1151
|
+
/** An automation execution log entry. */
|
|
1152
|
+
interface AutomationExecution {
|
|
1153
|
+
id: string;
|
|
1154
|
+
object: 'automation_execution';
|
|
1155
|
+
ruleId: string;
|
|
1156
|
+
ruleName: string | null;
|
|
1157
|
+
triggerEvent: string;
|
|
1158
|
+
resourceType: string;
|
|
1159
|
+
resourceId: string;
|
|
1160
|
+
conditionsMatched: boolean;
|
|
1161
|
+
actionsExecuted: Array<{
|
|
1162
|
+
action: string;
|
|
1163
|
+
success: boolean;
|
|
1164
|
+
error?: string;
|
|
1165
|
+
}>;
|
|
1166
|
+
skippedReason: string | null;
|
|
1167
|
+
dryRun: boolean;
|
|
1168
|
+
executionMs: number;
|
|
1169
|
+
createdAt: string;
|
|
1170
|
+
}
|
|
1171
|
+
/** Parameters for listing automation rules. */
|
|
1172
|
+
interface AutomationListParams extends PaginationParams {
|
|
1173
|
+
enabled?: boolean;
|
|
1174
|
+
triggerEvent?: string;
|
|
1175
|
+
}
|
|
1176
|
+
/** Parameters for creating an automation rule. */
|
|
1177
|
+
interface AutomationCreateParams {
|
|
1178
|
+
name: string;
|
|
1179
|
+
description?: string;
|
|
1180
|
+
triggerEvent: string;
|
|
1181
|
+
triggerFilter?: Record<string, unknown>;
|
|
1182
|
+
conditions?: AutomationConditions;
|
|
1183
|
+
actions?: AutomationAction[];
|
|
1184
|
+
enabled?: boolean;
|
|
1185
|
+
stopAfter?: boolean;
|
|
1186
|
+
maxExecutionsPerTicket?: number;
|
|
1187
|
+
cooldownSeconds?: number;
|
|
1188
|
+
}
|
|
1189
|
+
/** Parameters for updating an automation rule. */
|
|
1190
|
+
interface AutomationUpdateParams {
|
|
1191
|
+
name?: string;
|
|
1192
|
+
description?: string;
|
|
1193
|
+
triggerEvent?: string;
|
|
1194
|
+
triggerFilter?: Record<string, unknown>;
|
|
1195
|
+
conditions?: AutomationConditions;
|
|
1196
|
+
actions?: AutomationAction[];
|
|
1197
|
+
enabled?: boolean;
|
|
1198
|
+
stopAfter?: boolean;
|
|
1199
|
+
maxExecutionsPerTicket?: number;
|
|
1200
|
+
cooldownSeconds?: number;
|
|
1201
|
+
}
|
|
1202
|
+
/** Parameters for listing executions. */
|
|
1203
|
+
interface AutomationExecutionListParams extends PaginationParams {
|
|
1204
|
+
triggerEvent?: string;
|
|
1205
|
+
resourceId?: string;
|
|
1206
|
+
}
|
|
1207
|
+
/** Result of a dry-run test. */
|
|
1208
|
+
interface AutomationTestResult {
|
|
1209
|
+
wouldMatch: boolean;
|
|
1210
|
+
conditionResults: {
|
|
1211
|
+
all: Array<{
|
|
1212
|
+
field: string;
|
|
1213
|
+
operator: string;
|
|
1214
|
+
value: unknown;
|
|
1215
|
+
actual: unknown;
|
|
1216
|
+
passed: boolean;
|
|
1217
|
+
}>;
|
|
1218
|
+
any: Array<{
|
|
1219
|
+
field: string;
|
|
1220
|
+
operator: string;
|
|
1221
|
+
value: unknown;
|
|
1222
|
+
actual: unknown;
|
|
1223
|
+
passed: boolean;
|
|
1224
|
+
}>;
|
|
1225
|
+
};
|
|
1226
|
+
actionsWouldExecute: Array<{
|
|
1227
|
+
action: string;
|
|
1228
|
+
success: boolean;
|
|
1229
|
+
preview?: string;
|
|
1230
|
+
}>;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/** Manage automation rules. */
|
|
1234
|
+
declare class AutomationsResource extends BaseResource<AutomationRule, AutomationListParams, AutomationCreateParams, AutomationUpdateParams> {
|
|
1235
|
+
constructor(client: HttpClient);
|
|
1236
|
+
/** Toggle a rule's enabled state. */
|
|
1237
|
+
toggle(ruleId: string, enabled?: boolean): Promise<ApiResponse<AutomationRule>>;
|
|
1238
|
+
/** Reorder rules by providing an ordered array of IDs. */
|
|
1239
|
+
reorder(orderedIds: string[]): Promise<ApiResponse<AutomationRule[]>>;
|
|
1240
|
+
/** Dry-run a rule against a specific resource (no actions executed). */
|
|
1241
|
+
test(ruleId: string, params: {
|
|
1242
|
+
resourceType: string;
|
|
1243
|
+
resourceId: string;
|
|
1244
|
+
}): Promise<ApiResponse<AutomationTestResult>>;
|
|
1245
|
+
/** Get execution history for a specific rule. */
|
|
1246
|
+
executions(ruleId: string, params?: AutomationExecutionListParams): Promise<ListResponse<AutomationExecution>>;
|
|
1247
|
+
/** Get all execution history for the team. */
|
|
1248
|
+
allExecutions(params?: AutomationExecutionListParams): Promise<ListResponse<AutomationExecution>>;
|
|
1249
|
+
/** Test conditions against sample data (without a rule). */
|
|
1250
|
+
evaluate(params: {
|
|
1251
|
+
conditions: {
|
|
1252
|
+
all: Array<{
|
|
1253
|
+
field: string;
|
|
1254
|
+
operator: string;
|
|
1255
|
+
value?: unknown;
|
|
1256
|
+
}>;
|
|
1257
|
+
any: Array<{
|
|
1258
|
+
field: string;
|
|
1259
|
+
operator: string;
|
|
1260
|
+
value?: unknown;
|
|
1261
|
+
}>;
|
|
1262
|
+
};
|
|
1263
|
+
data: Record<string, unknown>;
|
|
1264
|
+
changes?: Record<string, unknown>;
|
|
1265
|
+
}): Promise<ApiResponse<{
|
|
1266
|
+
matched: boolean;
|
|
1267
|
+
conditionResults: unknown;
|
|
1268
|
+
}>>;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/** A cStar article category. */
|
|
1272
|
+
interface Category {
|
|
1273
|
+
id: string;
|
|
1274
|
+
object: 'category';
|
|
1275
|
+
name: string;
|
|
1276
|
+
slug: string;
|
|
1277
|
+
description: string | null;
|
|
1278
|
+
icon: string | null;
|
|
1279
|
+
color: string | null;
|
|
1280
|
+
sortOrder: number;
|
|
1281
|
+
isPublic: boolean;
|
|
1282
|
+
createdAt: string;
|
|
1283
|
+
updatedAt: string;
|
|
1284
|
+
}
|
|
1285
|
+
/** Parameters for listing categories. */
|
|
1286
|
+
interface CategoryListParams extends PaginationParams {
|
|
1287
|
+
isPublic?: boolean;
|
|
1288
|
+
}
|
|
1289
|
+
/** Parameters for creating a category. */
|
|
1290
|
+
interface CategoryCreateParams {
|
|
1291
|
+
name: string;
|
|
1292
|
+
description?: string;
|
|
1293
|
+
icon?: string;
|
|
1294
|
+
color?: string;
|
|
1295
|
+
sortOrder?: number;
|
|
1296
|
+
isPublic?: boolean;
|
|
1297
|
+
}
|
|
1298
|
+
/** Parameters for updating a category. */
|
|
1299
|
+
interface CategoryUpdateParams {
|
|
1300
|
+
name?: string;
|
|
1301
|
+
description?: string;
|
|
1302
|
+
icon?: string;
|
|
1303
|
+
color?: string;
|
|
1304
|
+
sortOrder?: number;
|
|
1305
|
+
isPublic?: boolean;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
/** Manage article categories. */
|
|
1309
|
+
declare class CategoriesResource extends BaseResource<Category, CategoryListParams, CategoryCreateParams, CategoryUpdateParams> {
|
|
1310
|
+
constructor(client: HttpClient);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
/** Attachment metadata for community posts and comments. */
|
|
1314
|
+
interface CommunityAttachment {
|
|
1315
|
+
filename: string;
|
|
1316
|
+
content_type: string;
|
|
1317
|
+
size_bytes: number;
|
|
1318
|
+
storage_path: string;
|
|
1319
|
+
}
|
|
1320
|
+
/** Custom field definition resolved for a topic. */
|
|
1321
|
+
interface TopicCustomField {
|
|
1322
|
+
id: string;
|
|
1323
|
+
label: string;
|
|
1324
|
+
type: 'text' | 'number' | 'date' | 'select' | 'checkbox' | 'url';
|
|
1325
|
+
required: boolean;
|
|
1326
|
+
options?: Array<{
|
|
1327
|
+
value: string;
|
|
1328
|
+
label: string;
|
|
1329
|
+
}>;
|
|
1330
|
+
defaultValue?: string;
|
|
1331
|
+
}
|
|
1332
|
+
/** A community discussion topic (category/board). */
|
|
1333
|
+
interface CommunityTopic {
|
|
1334
|
+
id: string;
|
|
1335
|
+
name: string;
|
|
1336
|
+
slug: string;
|
|
1337
|
+
description: string | null;
|
|
1338
|
+
icon: string;
|
|
1339
|
+
visibility: 'public' | 'members_only';
|
|
1340
|
+
sortOrder: number;
|
|
1341
|
+
customFields: TopicCustomField[];
|
|
1342
|
+
postCount: number;
|
|
1343
|
+
createdAt: string;
|
|
1344
|
+
}
|
|
1345
|
+
/** Parameters for creating a community topic via the admin SDK. */
|
|
1346
|
+
interface CommunityTopicCreateParams {
|
|
1347
|
+
name: string;
|
|
1348
|
+
slug?: string;
|
|
1349
|
+
description?: string;
|
|
1350
|
+
icon?: string;
|
|
1351
|
+
sortOrder?: number;
|
|
1352
|
+
visibility?: 'public' | 'members_only';
|
|
1353
|
+
requireApproval?: boolean;
|
|
1354
|
+
postGuide?: string;
|
|
1355
|
+
}
|
|
1356
|
+
/** Parameters for updating a community topic. All fields optional. */
|
|
1357
|
+
type CommunityTopicUpdateParams = Partial<CommunityTopicCreateParams>;
|
|
1358
|
+
/** A community discussion post. */
|
|
1359
|
+
interface CommunityPost {
|
|
1360
|
+
id: string;
|
|
1361
|
+
topicId: string;
|
|
1362
|
+
topicName: string;
|
|
1363
|
+
title: string;
|
|
1364
|
+
slug: string;
|
|
1365
|
+
body: string | null;
|
|
1366
|
+
status: 'open' | 'answered' | 'officially_answered' | 'planned' | 'not_planned' | 'completed' | 'under_review';
|
|
1367
|
+
visibility: 'public' | 'members_only';
|
|
1368
|
+
voteCount: number;
|
|
1369
|
+
commentCount: number;
|
|
1370
|
+
isPinned: boolean;
|
|
1371
|
+
isFeatured: boolean;
|
|
1372
|
+
isLocked: boolean;
|
|
1373
|
+
commentsEnabled: boolean;
|
|
1374
|
+
customFields: Record<string, string>;
|
|
1375
|
+
attachments: CommunityAttachment[];
|
|
1376
|
+
authorName: string;
|
|
1377
|
+
lastActivityAt: string;
|
|
1378
|
+
createdAt: string;
|
|
1379
|
+
updatedAt: string;
|
|
1380
|
+
}
|
|
1381
|
+
/** A comment on a community post. */
|
|
1382
|
+
interface CommunityComment {
|
|
1383
|
+
id: string;
|
|
1384
|
+
postId: string;
|
|
1385
|
+
body: string;
|
|
1386
|
+
isOfficial: boolean;
|
|
1387
|
+
voteScore: number;
|
|
1388
|
+
attachments: CommunityAttachment[];
|
|
1389
|
+
authorName: string;
|
|
1390
|
+
parentCommentId: string | null;
|
|
1391
|
+
createdAt: string;
|
|
1392
|
+
}
|
|
1393
|
+
/** Query parameters for listing community posts. */
|
|
1394
|
+
interface CommunityPostListParams {
|
|
1395
|
+
topicId?: string;
|
|
1396
|
+
status?: string;
|
|
1397
|
+
sort?: 'recent' | 'votes' | 'comments';
|
|
1398
|
+
page?: number;
|
|
1399
|
+
pageSize?: number;
|
|
1400
|
+
}
|
|
1401
|
+
/** Parameters for creating a community post. */
|
|
1402
|
+
interface CommunityPostCreateParams {
|
|
1403
|
+
title: string;
|
|
1404
|
+
body?: string;
|
|
1405
|
+
topicId: string;
|
|
1406
|
+
visibility?: 'public' | 'members_only';
|
|
1407
|
+
customFields?: Record<string, string>;
|
|
1408
|
+
attachments?: CommunityAttachment[];
|
|
1409
|
+
}
|
|
1410
|
+
/** Parameters for updating a community post. */
|
|
1411
|
+
interface CommunityPostUpdateParams {
|
|
1412
|
+
title?: string;
|
|
1413
|
+
body?: string;
|
|
1414
|
+
topicId?: string;
|
|
1415
|
+
status?: string;
|
|
1416
|
+
visibility?: string;
|
|
1417
|
+
isPinned?: boolean;
|
|
1418
|
+
isLocked?: boolean;
|
|
1419
|
+
isHidden?: boolean;
|
|
1420
|
+
commentsEnabled?: boolean;
|
|
1421
|
+
customFields?: Record<string, string>;
|
|
1422
|
+
attachments?: CommunityAttachment[];
|
|
1423
|
+
}
|
|
1424
|
+
/** Parameters for creating a comment on a community post. */
|
|
1425
|
+
interface CommunityCommentCreateParams {
|
|
1426
|
+
body: string;
|
|
1427
|
+
parentCommentId?: string;
|
|
1428
|
+
isOfficial?: boolean;
|
|
1429
|
+
attachments?: CommunityAttachment[];
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/** Manage community discussion posts. */
|
|
1433
|
+
declare class CommunityPostsResource extends BaseResource<CommunityPost, CommunityPostListParams, CommunityPostCreateParams, CommunityPostUpdateParams> {
|
|
1434
|
+
constructor(client: HttpClient);
|
|
1435
|
+
/** Toggle vote on a post. Returns new vote state and count. */
|
|
1436
|
+
vote(postId: string): Promise<ApiResponse<{
|
|
1437
|
+
voted: boolean;
|
|
1438
|
+
voteCount: number;
|
|
1439
|
+
}>>;
|
|
1440
|
+
/** Toggle follow on a post. Returns new follow state. */
|
|
1441
|
+
follow(postId: string): Promise<ApiResponse<{
|
|
1442
|
+
following: boolean;
|
|
1443
|
+
}>>;
|
|
1444
|
+
/** List all comments on a post. */
|
|
1445
|
+
listComments(postId: string): Promise<ApiResponse<CommunityComment[]>>;
|
|
1446
|
+
/** Add a comment to a post. */
|
|
1447
|
+
createComment(postId: string, params: CommunityCommentCreateParams): Promise<ApiResponse<CommunityComment>>;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Manage community discussion topics.
|
|
1452
|
+
*
|
|
1453
|
+
* As of 0.13.0 the resource exposes the full CRUD admin surface (closes
|
|
1454
|
+
* F-035): `create`, `update`, `delete` were previously dashboard-only.
|
|
1455
|
+
*
|
|
1456
|
+
* ```ts
|
|
1457
|
+
* const topic = await cstar.community.topics.create({ name: 'General' });
|
|
1458
|
+
* await cstar.community.topics.update(topic.id, { description: '...' });
|
|
1459
|
+
* await cstar.community.topics.del(topic.id);
|
|
1460
|
+
* ```
|
|
1461
|
+
*/
|
|
1462
|
+
declare class CommunityTopicsResource extends BaseResource<CommunityTopic, Record<string, never>, CommunityTopicCreateParams, CommunityTopicUpdateParams> {
|
|
1463
|
+
constructor(client: HttpClient);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/** A team member (agent). */
|
|
1467
|
+
interface Member {
|
|
1468
|
+
id: string;
|
|
1469
|
+
object: 'member';
|
|
1470
|
+
userId: string;
|
|
1471
|
+
name: string;
|
|
1472
|
+
email: string;
|
|
1473
|
+
avatarUrl: string | null;
|
|
1474
|
+
role: string;
|
|
1475
|
+
roleDisplayName: string;
|
|
1476
|
+
permissions: string[];
|
|
1477
|
+
level: number;
|
|
1478
|
+
xp: number;
|
|
1479
|
+
joinedAt: string;
|
|
1480
|
+
}
|
|
1481
|
+
/** Parameters for listing members. */
|
|
1482
|
+
interface MemberListParams extends PaginationParams {
|
|
1483
|
+
role?: string;
|
|
1484
|
+
}
|
|
1485
|
+
/** Parameters for updating a member. */
|
|
1486
|
+
interface MemberUpdateParams {
|
|
1487
|
+
role?: string;
|
|
1488
|
+
}
|
|
1489
|
+
/** A team invite. */
|
|
1490
|
+
interface Invite {
|
|
1491
|
+
id: string;
|
|
1492
|
+
object: 'invite';
|
|
1493
|
+
email: string;
|
|
1494
|
+
role: string;
|
|
1495
|
+
status: string;
|
|
1496
|
+
inviterName: string | null;
|
|
1497
|
+
inviterEmail: string | null;
|
|
1498
|
+
createdAt: string;
|
|
1499
|
+
expiresAt: string;
|
|
1500
|
+
}
|
|
1501
|
+
/** Parameters for listing invites. */
|
|
1502
|
+
interface InviteListParams extends PaginationParams {
|
|
1503
|
+
status?: string;
|
|
1504
|
+
}
|
|
1505
|
+
/** Parameters for creating an invite. */
|
|
1506
|
+
interface InviteCreateParams {
|
|
1507
|
+
email: string;
|
|
1508
|
+
role?: string;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/** Manage team invites as a sub-resource. */
|
|
1512
|
+
declare class InvitesResource {
|
|
1513
|
+
private readonly client;
|
|
1514
|
+
constructor(client: HttpClient);
|
|
1515
|
+
/** List pending invites. */
|
|
1516
|
+
list(params?: InviteListParams): Promise<ListResponse<Invite>>;
|
|
1517
|
+
/** Create and send a new invite. */
|
|
1518
|
+
create(params: InviteCreateParams, options?: RequestOptions): Promise<ApiResponse<Invite>>;
|
|
1519
|
+
/** Revoke a pending invite. */
|
|
1520
|
+
del(inviteId: string): Promise<ApiResponse<DeleteResponse>>;
|
|
1521
|
+
}
|
|
1522
|
+
/** Manage team members. */
|
|
1523
|
+
declare class MembersResource {
|
|
1524
|
+
private readonly client;
|
|
1525
|
+
/** Sub-resource for team invites. */
|
|
1526
|
+
readonly invites: InvitesResource;
|
|
1527
|
+
constructor(client: HttpClient);
|
|
1528
|
+
/** List all team members. */
|
|
1529
|
+
list(params?: MemberListParams): Promise<ListResponse<Member>>;
|
|
1530
|
+
/** Get a single member by membership ID. */
|
|
1531
|
+
get(memberId: string): Promise<ApiResponse<Member>>;
|
|
1532
|
+
/** Update a member's role. */
|
|
1533
|
+
update(memberId: string, params: MemberUpdateParams): Promise<ApiResponse<Member>>;
|
|
1534
|
+
/** Remove a member from the team. */
|
|
1535
|
+
del(memberId: string): Promise<ApiResponse<DeleteResponse>>;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/** Team settings object. */
|
|
1539
|
+
interface TeamSettings {
|
|
1540
|
+
object: 'settings';
|
|
1541
|
+
teamName: string;
|
|
1542
|
+
teamSlug: string;
|
|
1543
|
+
[key: string]: unknown;
|
|
1544
|
+
}
|
|
1545
|
+
/** Parameters for updating team settings. */
|
|
1546
|
+
interface TeamSettingsUpdateParams {
|
|
1547
|
+
[key: string]: unknown;
|
|
1548
|
+
}
|
|
1549
|
+
/** A ticket status configuration. */
|
|
1550
|
+
interface TicketStatus {
|
|
1551
|
+
key: string;
|
|
1552
|
+
object: 'status';
|
|
1553
|
+
label: string;
|
|
1554
|
+
color: string;
|
|
1555
|
+
position: number;
|
|
1556
|
+
isDefault: boolean;
|
|
1557
|
+
isProtected: boolean;
|
|
1558
|
+
}
|
|
1559
|
+
/** Parameters for creating a status. */
|
|
1560
|
+
interface StatusCreateParams {
|
|
1561
|
+
key: string;
|
|
1562
|
+
label: string;
|
|
1563
|
+
color?: string;
|
|
1564
|
+
}
|
|
1565
|
+
/** Parameters for updating a status. */
|
|
1566
|
+
interface StatusUpdateParams {
|
|
1567
|
+
label?: string;
|
|
1568
|
+
color?: string;
|
|
1569
|
+
}
|
|
1570
|
+
/** A quick reply template. */
|
|
1571
|
+
interface QuickReply {
|
|
1572
|
+
id: string;
|
|
1573
|
+
object: 'quick_reply';
|
|
1574
|
+
title: string;
|
|
1575
|
+
body: string;
|
|
1576
|
+
category: string | null;
|
|
1577
|
+
position: number;
|
|
1578
|
+
createdAt: string;
|
|
1579
|
+
updatedAt: string;
|
|
1580
|
+
}
|
|
1581
|
+
/** Parameters for creating a quick reply. */
|
|
1582
|
+
interface QuickReplyCreateParams {
|
|
1583
|
+
title: string;
|
|
1584
|
+
body: string;
|
|
1585
|
+
category?: string;
|
|
1586
|
+
}
|
|
1587
|
+
/** Parameters for updating a quick reply. */
|
|
1588
|
+
interface QuickReplyUpdateParams {
|
|
1589
|
+
title?: string;
|
|
1590
|
+
body?: string;
|
|
1591
|
+
category?: string;
|
|
1592
|
+
}
|
|
1593
|
+
/** Business hours configuration. */
|
|
1594
|
+
interface BusinessHours {
|
|
1595
|
+
object: 'business_hours';
|
|
1596
|
+
enabled: boolean;
|
|
1597
|
+
timezone: string;
|
|
1598
|
+
schedule: Record<string, {
|
|
1599
|
+
enabled: boolean;
|
|
1600
|
+
start: string;
|
|
1601
|
+
end: string;
|
|
1602
|
+
}>;
|
|
1603
|
+
}
|
|
1604
|
+
/** Parameters for updating business hours. */
|
|
1605
|
+
interface BusinessHoursUpdateParams {
|
|
1606
|
+
enabled?: boolean;
|
|
1607
|
+
timezone?: string;
|
|
1608
|
+
schedule?: Record<string, {
|
|
1609
|
+
enabled: boolean;
|
|
1610
|
+
start: string;
|
|
1611
|
+
end: string;
|
|
1612
|
+
}>;
|
|
1613
|
+
}
|
|
1614
|
+
/** Widget configuration. */
|
|
1615
|
+
interface WidgetSettings {
|
|
1616
|
+
object: 'widget_settings';
|
|
1617
|
+
[key: string]: unknown;
|
|
1618
|
+
}
|
|
1619
|
+
/** Parameters for updating widget settings. */
|
|
1620
|
+
interface WidgetSettingsUpdateParams {
|
|
1621
|
+
[key: string]: unknown;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/** Manage ticket status configurations. */
|
|
1625
|
+
declare class StatusesResource {
|
|
1626
|
+
private readonly client;
|
|
1627
|
+
constructor(client: HttpClient);
|
|
1628
|
+
/** List all statuses. */
|
|
1629
|
+
list(): Promise<ApiResponse<TicketStatus[]>>;
|
|
1630
|
+
/** Create a new status. */
|
|
1631
|
+
create(params: StatusCreateParams, options?: RequestOptions): Promise<ApiResponse<TicketStatus>>;
|
|
1632
|
+
/** Update a status. */
|
|
1633
|
+
update(statusKey: string, params: StatusUpdateParams): Promise<ApiResponse<TicketStatus>>;
|
|
1634
|
+
/** Delete a status. */
|
|
1635
|
+
del(statusKey: string): Promise<ApiResponse<DeleteResponse>>;
|
|
1636
|
+
/** Reorder statuses. */
|
|
1637
|
+
reorder(orderedKeys: string[]): Promise<ApiResponse<TicketStatus[]>>;
|
|
1638
|
+
}
|
|
1639
|
+
/** Manage quick reply templates. */
|
|
1640
|
+
declare class QuickRepliesResource {
|
|
1641
|
+
private readonly client;
|
|
1642
|
+
constructor(client: HttpClient);
|
|
1643
|
+
/** List all quick replies. */
|
|
1644
|
+
list(): Promise<ApiResponse<QuickReply[]>>;
|
|
1645
|
+
/** Create a new quick reply. */
|
|
1646
|
+
create(params: QuickReplyCreateParams, options?: RequestOptions): Promise<ApiResponse<QuickReply>>;
|
|
1647
|
+
/** Update a quick reply. */
|
|
1648
|
+
update(replyId: string, params: QuickReplyUpdateParams): Promise<ApiResponse<QuickReply>>;
|
|
1649
|
+
/** Delete a quick reply. */
|
|
1650
|
+
del(replyId: string): Promise<ApiResponse<DeleteResponse>>;
|
|
1651
|
+
/** Reorder quick replies. */
|
|
1652
|
+
reorder(orderedIds: string[]): Promise<ApiResponse<QuickReply[]>>;
|
|
1653
|
+
}
|
|
1654
|
+
/** Manage team settings. */
|
|
1655
|
+
declare class SettingsResource {
|
|
1656
|
+
private readonly client;
|
|
1657
|
+
/** Ticket status configuration. */
|
|
1658
|
+
readonly statuses: StatusesResource;
|
|
1659
|
+
/** Quick reply templates. */
|
|
1660
|
+
readonly quickReplies: QuickRepliesResource;
|
|
1661
|
+
constructor(client: HttpClient);
|
|
1662
|
+
/** Get all team settings. */
|
|
1663
|
+
get(): Promise<ApiResponse<TeamSettings>>;
|
|
1664
|
+
/** Update team settings (bulk). */
|
|
1665
|
+
update(params: TeamSettingsUpdateParams): Promise<ApiResponse<TeamSettings>>;
|
|
1666
|
+
/** Get business hours configuration. */
|
|
1667
|
+
getBusinessHours(): Promise<ApiResponse<BusinessHours>>;
|
|
1668
|
+
/** Update business hours configuration. */
|
|
1669
|
+
updateBusinessHours(params: BusinessHoursUpdateParams): Promise<ApiResponse<BusinessHours>>;
|
|
1670
|
+
/** Get widget settings. */
|
|
1671
|
+
getWidget(): Promise<ApiResponse<WidgetSettings>>;
|
|
1672
|
+
/** Update widget settings. */
|
|
1673
|
+
updateWidget(params: WidgetSettingsUpdateParams): Promise<ApiResponse<WidgetSettings>>;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
/** A notification. */
|
|
1677
|
+
interface Notification {
|
|
1678
|
+
id: string;
|
|
1679
|
+
object: 'notification';
|
|
1680
|
+
type: string;
|
|
1681
|
+
title: string;
|
|
1682
|
+
body: string | null;
|
|
1683
|
+
resourceType: string | null;
|
|
1684
|
+
resourceId: string | null;
|
|
1685
|
+
actorId: string | null;
|
|
1686
|
+
actorName: string | null;
|
|
1687
|
+
read: boolean;
|
|
1688
|
+
readAt: string | null;
|
|
1689
|
+
createdAt: string;
|
|
1690
|
+
}
|
|
1691
|
+
/** Parameters for listing notifications. */
|
|
1692
|
+
interface NotificationListParams extends PaginationParams {
|
|
1693
|
+
unreadOnly?: boolean;
|
|
1694
|
+
}
|
|
1695
|
+
/** Unread count response. */
|
|
1696
|
+
interface UnreadCount {
|
|
1697
|
+
object: 'unread_count';
|
|
1698
|
+
count: number;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
/** Manage notifications. */
|
|
1702
|
+
declare class NotificationsResource {
|
|
1703
|
+
private readonly client;
|
|
1704
|
+
constructor(client: HttpClient);
|
|
1705
|
+
/** List notifications for a user. */
|
|
1706
|
+
list(params: NotificationListParams & {
|
|
1707
|
+
userId: string;
|
|
1708
|
+
}): Promise<ListResponse<Notification>>;
|
|
1709
|
+
/** Get unread notification count for a user. */
|
|
1710
|
+
unreadCount(userId: string): Promise<ApiResponse<UnreadCount>>;
|
|
1711
|
+
/** Mark a single notification as read. */
|
|
1712
|
+
markRead(notificationId: string, userId: string): Promise<ApiResponse<Notification>>;
|
|
1713
|
+
/** Mark all notifications as read. */
|
|
1714
|
+
markAllRead(userId: string): Promise<ApiResponse<{
|
|
1715
|
+
markedRead: number;
|
|
1716
|
+
}>>;
|
|
1717
|
+
/** Delete (dismiss) a notification. For broadcast notifications, pass userId as a query param. */
|
|
1718
|
+
del(notificationId: string, params?: {
|
|
1719
|
+
userId?: string;
|
|
1720
|
+
}): Promise<ApiResponse<DeleteResponse>>;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/** A mention. */
|
|
1724
|
+
interface Mention {
|
|
1725
|
+
id: string;
|
|
1726
|
+
object: 'mention';
|
|
1727
|
+
senderId: string;
|
|
1728
|
+
senderName: string | null;
|
|
1729
|
+
recipientId: string;
|
|
1730
|
+
recipientName: string | null;
|
|
1731
|
+
ticketId: string | null;
|
|
1732
|
+
ticketTitle: string | null;
|
|
1733
|
+
isRead: boolean;
|
|
1734
|
+
createdAt: string;
|
|
1735
|
+
}
|
|
1736
|
+
/** Parameters for listing mentions. */
|
|
1737
|
+
interface MentionListParams extends PaginationParams {
|
|
1738
|
+
isRead?: string;
|
|
1739
|
+
}
|
|
1740
|
+
/** Unread mention count. */
|
|
1741
|
+
interface MentionUnreadCount {
|
|
1742
|
+
unreadCount: number;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/** Manage @mentions. */
|
|
1746
|
+
declare class MentionsResource {
|
|
1747
|
+
private readonly client;
|
|
1748
|
+
constructor(client: HttpClient);
|
|
1749
|
+
/** List mentions for a user. */
|
|
1750
|
+
list(params: MentionListParams & {
|
|
1751
|
+
userId: string;
|
|
1752
|
+
}): Promise<ListResponse<Mention>>;
|
|
1753
|
+
/** Get unread mention count for a user. */
|
|
1754
|
+
unreadCount(userId: string): Promise<ApiResponse<MentionUnreadCount>>;
|
|
1755
|
+
/** Mark a single mention as read. */
|
|
1756
|
+
markRead(mentionId: string): Promise<ApiResponse<{
|
|
1757
|
+
id: string;
|
|
1758
|
+
isRead: true;
|
|
1759
|
+
}>>;
|
|
1760
|
+
/** Mark all mentions as read for a user. */
|
|
1761
|
+
markAllRead(userId: string): Promise<ApiResponse<{
|
|
1762
|
+
markedRead: number;
|
|
1763
|
+
}>>;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
/** A file attachment. */
|
|
1767
|
+
interface Attachment {
|
|
1768
|
+
id: string;
|
|
1769
|
+
object: 'attachment';
|
|
1770
|
+
filename: string;
|
|
1771
|
+
contentType: string;
|
|
1772
|
+
size: number;
|
|
1773
|
+
url: string;
|
|
1774
|
+
ticketId: string | null;
|
|
1775
|
+
uploadedBy: string | null;
|
|
1776
|
+
createdAt: string;
|
|
1777
|
+
}
|
|
1778
|
+
/** Parameters for listing attachments. */
|
|
1779
|
+
interface AttachmentListParams extends PaginationParams {
|
|
1780
|
+
ticketId?: string;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
/** Manage file attachments. */
|
|
1784
|
+
declare class AttachmentsResource {
|
|
1785
|
+
private readonly client;
|
|
1786
|
+
constructor(client: HttpClient);
|
|
1787
|
+
/** List attachments. */
|
|
1788
|
+
list(params?: AttachmentListParams): Promise<ListResponse<Attachment>>;
|
|
1789
|
+
/** Get a single attachment. */
|
|
1790
|
+
get(attachmentId: string): Promise<ApiResponse<Attachment>>;
|
|
1791
|
+
/** Delete an attachment. */
|
|
1792
|
+
del(attachmentId: string): Promise<ApiResponse<DeleteResponse>>;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
/** A custom field definition. */
|
|
1796
|
+
interface CustomField {
|
|
1797
|
+
id: string;
|
|
1798
|
+
object: 'custom_field';
|
|
1799
|
+
name: string;
|
|
1800
|
+
key: string;
|
|
1801
|
+
type: 'text' | 'number' | 'select' | 'multiselect' | 'date' | 'boolean';
|
|
1802
|
+
entityType: 'tickets' | 'customers';
|
|
1803
|
+
description: string | null;
|
|
1804
|
+
required: boolean;
|
|
1805
|
+
options: string[] | null;
|
|
1806
|
+
position: number;
|
|
1807
|
+
createdAt: string;
|
|
1808
|
+
updatedAt: string;
|
|
1809
|
+
}
|
|
1810
|
+
/** Parameters for listing custom fields. */
|
|
1811
|
+
interface CustomFieldListParams extends PaginationParams {
|
|
1812
|
+
entityType?: 'tickets' | 'customers';
|
|
1813
|
+
}
|
|
1814
|
+
/** Parameters for creating a custom field. */
|
|
1815
|
+
interface CustomFieldCreateParams {
|
|
1816
|
+
name: string;
|
|
1817
|
+
key: string;
|
|
1818
|
+
type: 'text' | 'number' | 'select' | 'multiselect' | 'date' | 'boolean';
|
|
1819
|
+
entityType: 'tickets' | 'customers';
|
|
1820
|
+
description?: string;
|
|
1821
|
+
required?: boolean;
|
|
1822
|
+
options?: string[];
|
|
1823
|
+
}
|
|
1824
|
+
/** Parameters for updating a custom field. */
|
|
1825
|
+
interface CustomFieldUpdateParams {
|
|
1826
|
+
name?: string;
|
|
1827
|
+
description?: string;
|
|
1828
|
+
required?: boolean;
|
|
1829
|
+
options?: string[];
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
/** Manage custom field definitions. */
|
|
1833
|
+
declare class CustomFieldsResource {
|
|
1834
|
+
private readonly client;
|
|
1835
|
+
constructor(client: HttpClient);
|
|
1836
|
+
/** List custom fields. */
|
|
1837
|
+
list(params?: CustomFieldListParams): Promise<ListResponse<CustomField>>;
|
|
1838
|
+
/** Get a single custom field. */
|
|
1839
|
+
get(fieldId: string): Promise<ApiResponse<CustomField>>;
|
|
1840
|
+
/** Create a custom field. */
|
|
1841
|
+
create(params: CustomFieldCreateParams, options?: RequestOptions): Promise<ApiResponse<CustomField>>;
|
|
1842
|
+
/** Update a custom field. */
|
|
1843
|
+
update(fieldId: string, params: CustomFieldUpdateParams): Promise<ApiResponse<CustomField>>;
|
|
1844
|
+
/** Delete a custom field. */
|
|
1845
|
+
del(fieldId: string): Promise<ApiResponse<DeleteResponse>>;
|
|
1846
|
+
/** Reorder custom fields within a content type. */
|
|
1847
|
+
reorder(contentType: 'ticket' | 'customer' | 'article', orderedIds: string[]): Promise<ApiResponse<CustomField[]>>;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
/** An SLA rule. */
|
|
1851
|
+
interface SlaRule {
|
|
1852
|
+
id: string;
|
|
1853
|
+
object: 'sla_rule';
|
|
1854
|
+
name: string;
|
|
1855
|
+
description: string | null;
|
|
1856
|
+
priority: string;
|
|
1857
|
+
responseTarget: number;
|
|
1858
|
+
resolutionTarget: number;
|
|
1859
|
+
businessHoursOnly: boolean;
|
|
1860
|
+
enabled: boolean;
|
|
1861
|
+
position: number;
|
|
1862
|
+
createdAt: string;
|
|
1863
|
+
updatedAt: string;
|
|
1864
|
+
}
|
|
1865
|
+
/** Parameters for listing SLA rules. */
|
|
1866
|
+
interface SlaRuleListParams extends PaginationParams {
|
|
1867
|
+
enabled?: boolean;
|
|
1868
|
+
}
|
|
1869
|
+
/** Parameters for creating an SLA rule. */
|
|
1870
|
+
interface SlaRuleCreateParams {
|
|
1871
|
+
name: string;
|
|
1872
|
+
description?: string;
|
|
1873
|
+
priority: string;
|
|
1874
|
+
responseTarget: number;
|
|
1875
|
+
resolutionTarget: number;
|
|
1876
|
+
businessHoursOnly?: boolean;
|
|
1877
|
+
enabled?: boolean;
|
|
1878
|
+
}
|
|
1879
|
+
/** Parameters for updating an SLA rule. */
|
|
1880
|
+
interface SlaRuleUpdateParams {
|
|
1881
|
+
name?: string;
|
|
1882
|
+
description?: string;
|
|
1883
|
+
priority?: string;
|
|
1884
|
+
responseTarget?: number;
|
|
1885
|
+
resolutionTarget?: number;
|
|
1886
|
+
businessHoursOnly?: boolean;
|
|
1887
|
+
enabled?: boolean;
|
|
1888
|
+
}
|
|
1889
|
+
/** Parameters for SLA metrics query. */
|
|
1890
|
+
interface SlaMetricsParams {
|
|
1891
|
+
period?: 'day' | 'week' | 'month' | 'quarter';
|
|
1892
|
+
startDate?: string;
|
|
1893
|
+
endDate?: string;
|
|
1894
|
+
agentId?: string;
|
|
1895
|
+
}
|
|
1896
|
+
/** SLA compliance metrics response. */
|
|
1897
|
+
interface SlaMetrics {
|
|
1898
|
+
object: 'sla_metrics';
|
|
1899
|
+
period: string;
|
|
1900
|
+
[key: string]: unknown;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
/** Manage SLA rules and metrics. */
|
|
1904
|
+
declare class SlaResource {
|
|
1905
|
+
private readonly client;
|
|
1906
|
+
constructor(client: HttpClient);
|
|
1907
|
+
/** List SLA rules. */
|
|
1908
|
+
list(params?: SlaRuleListParams): Promise<ListResponse<SlaRule>>;
|
|
1909
|
+
/** Create an SLA rule. */
|
|
1910
|
+
create(params: SlaRuleCreateParams, options?: RequestOptions): Promise<ApiResponse<SlaRule>>;
|
|
1911
|
+
/** Update an SLA rule. */
|
|
1912
|
+
update(ruleId: string, params: SlaRuleUpdateParams): Promise<ApiResponse<SlaRule>>;
|
|
1913
|
+
/** Delete an SLA rule. */
|
|
1914
|
+
del(ruleId: string): Promise<ApiResponse<DeleteResponse>>;
|
|
1915
|
+
/** Reorder SLA rules by providing an ordered array of IDs. */
|
|
1916
|
+
reorder(orderedIds: string[]): Promise<ApiResponse<SlaRule[]>>;
|
|
1917
|
+
/** Get SLA compliance metrics. */
|
|
1918
|
+
metrics(params?: SlaMetricsParams): Promise<ApiResponse<SlaMetrics>>;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* Analytics response. Shape varies by `type` parameter:
|
|
1923
|
+
* - overview/tickets: tickets, priorities, statusBreakdown, responseTime, resolutionTime
|
|
1924
|
+
* - performance: agents array
|
|
1925
|
+
* - library: totalArticles, publishedArticles, draftArticles
|
|
1926
|
+
*/
|
|
1927
|
+
interface AnalyticsOverview {
|
|
1928
|
+
object: 'analytics';
|
|
1929
|
+
type: string;
|
|
1930
|
+
period: string;
|
|
1931
|
+
/** Present for type=overview and type=tickets */
|
|
1932
|
+
tickets?: {
|
|
1933
|
+
total: number;
|
|
1934
|
+
new: number;
|
|
1935
|
+
closed: number;
|
|
1936
|
+
open: number;
|
|
1937
|
+
};
|
|
1938
|
+
priorities?: Record<string, number>;
|
|
1939
|
+
statusBreakdown?: Record<string, number>;
|
|
1940
|
+
responseTime?: {
|
|
1941
|
+
avgSeconds: number | null;
|
|
1942
|
+
samplesCount: number;
|
|
1943
|
+
};
|
|
1944
|
+
resolutionTime?: {
|
|
1945
|
+
avgSeconds: number | null;
|
|
1946
|
+
samplesCount: number;
|
|
1947
|
+
};
|
|
1948
|
+
/** Present for type=performance */
|
|
1949
|
+
agents?: Array<{
|
|
1950
|
+
agentId: string;
|
|
1951
|
+
ticketsClosed: number;
|
|
1952
|
+
avgResponseSeconds: number | null;
|
|
1953
|
+
goldTier: number;
|
|
1954
|
+
missedSla: number;
|
|
1955
|
+
}>;
|
|
1956
|
+
/** Present for type=library */
|
|
1957
|
+
totalArticles?: number;
|
|
1958
|
+
publishedArticles?: number;
|
|
1959
|
+
draftArticles?: number;
|
|
1960
|
+
[key: string]: unknown;
|
|
1961
|
+
}
|
|
1962
|
+
/** Analytics query parameters. */
|
|
1963
|
+
interface AnalyticsParams {
|
|
1964
|
+
type?: 'overview' | 'tickets' | 'performance' | 'library';
|
|
1965
|
+
period?: 'day' | 'week' | 'month' | 'quarter';
|
|
1966
|
+
agentId?: string;
|
|
1967
|
+
}
|
|
1968
|
+
/** CSAT statistics (from /csat/stats). */
|
|
1969
|
+
interface CsatStats {
|
|
1970
|
+
object: 'csat_stats';
|
|
1971
|
+
period: string;
|
|
1972
|
+
totalSent: number;
|
|
1973
|
+
totalCompleted: number;
|
|
1974
|
+
responseRate: number;
|
|
1975
|
+
averageRating: number | null;
|
|
1976
|
+
distribution: Record<string, number>;
|
|
1977
|
+
positiveRate: number;
|
|
1978
|
+
}
|
|
1979
|
+
/** A CSAT survey (from /csat/surveys). */
|
|
1980
|
+
interface CsatSurvey {
|
|
1981
|
+
id: string;
|
|
1982
|
+
object: 'csat_survey';
|
|
1983
|
+
ticketId: string;
|
|
1984
|
+
customerId: string | null;
|
|
1985
|
+
agentId: string | null;
|
|
1986
|
+
rating: number | null;
|
|
1987
|
+
comment: string | null;
|
|
1988
|
+
sentAt: string | null;
|
|
1989
|
+
completedAt: string | null;
|
|
1990
|
+
expiresAt: string | null;
|
|
1991
|
+
createdAt: string;
|
|
1992
|
+
}
|
|
1993
|
+
/** Parameters for listing CSAT surveys. */
|
|
1994
|
+
interface CsatSurveyListParams extends PaginationParams {
|
|
1995
|
+
completed?: string;
|
|
1996
|
+
agentId?: string;
|
|
1997
|
+
}
|
|
1998
|
+
/** Parameters for creating a CSAT survey. */
|
|
1999
|
+
interface CsatSurveyCreateParams {
|
|
2000
|
+
ticketId: string;
|
|
2001
|
+
customerId?: string;
|
|
2002
|
+
agentId?: string;
|
|
2003
|
+
}
|
|
2004
|
+
/** CSAT settings. */
|
|
2005
|
+
interface CsatSettings {
|
|
2006
|
+
object: 'csat_settings';
|
|
2007
|
+
enabled: boolean;
|
|
2008
|
+
delayMinutes: number;
|
|
2009
|
+
expirationDays: number;
|
|
2010
|
+
}
|
|
2011
|
+
/** Parameters for updating CSAT settings. */
|
|
2012
|
+
interface CsatSettingsUpdateParams {
|
|
2013
|
+
enabled?: boolean;
|
|
2014
|
+
delayMinutes?: number;
|
|
2015
|
+
expirationDays?: number;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
/** Manage CSAT surveys. */
|
|
2019
|
+
declare class CsatSurveysResource {
|
|
2020
|
+
private readonly client;
|
|
2021
|
+
constructor(client: HttpClient);
|
|
2022
|
+
/** List CSAT surveys. */
|
|
2023
|
+
list(params?: CsatSurveyListParams): Promise<ListResponse<CsatSurvey>>;
|
|
2024
|
+
/** Get a single CSAT survey. */
|
|
2025
|
+
get(surveyId: string): Promise<ApiResponse<CsatSurvey>>;
|
|
2026
|
+
/** Create and send a CSAT survey. */
|
|
2027
|
+
create(params: CsatSurveyCreateParams): Promise<ApiResponse<CsatSurvey>>;
|
|
2028
|
+
}
|
|
2029
|
+
/** Access analytics and CSAT data. */
|
|
2030
|
+
declare class AnalyticsResource {
|
|
2031
|
+
private readonly client;
|
|
2032
|
+
/** CSAT surveys sub-resource. */
|
|
2033
|
+
readonly csatSurveys: CsatSurveysResource;
|
|
2034
|
+
constructor(client: HttpClient);
|
|
2035
|
+
/** Get analytics data. Specify type to control the response shape. */
|
|
2036
|
+
get(params?: AnalyticsParams): Promise<ApiResponse<AnalyticsOverview>>;
|
|
2037
|
+
/** Get analytics overview (shortcut for type=overview). */
|
|
2038
|
+
overview(params?: Omit<AnalyticsParams, 'type'>): Promise<ApiResponse<AnalyticsOverview>>;
|
|
2039
|
+
/** Get agent performance stats (shortcut for type=performance). */
|
|
2040
|
+
performance(params?: Omit<AnalyticsParams, 'type'> & {
|
|
2041
|
+
agentId?: string;
|
|
2042
|
+
}): Promise<ApiResponse<AnalyticsOverview>>;
|
|
2043
|
+
/** Get library analytics (shortcut for type=library). */
|
|
2044
|
+
library(params?: Omit<AnalyticsParams, 'type'>): Promise<ApiResponse<AnalyticsOverview>>;
|
|
2045
|
+
/** Get CSAT statistics. */
|
|
2046
|
+
csatStats(params?: {
|
|
2047
|
+
period?: string;
|
|
2048
|
+
agentId?: string;
|
|
2049
|
+
}): Promise<ApiResponse<CsatStats>>;
|
|
2050
|
+
/** Get CSAT settings. */
|
|
2051
|
+
csatSettings(): Promise<ApiResponse<CsatSettings>>;
|
|
2052
|
+
/** Update CSAT settings. */
|
|
2053
|
+
updateCsatSettings(params: CsatSettingsUpdateParams): Promise<ApiResponse<CsatSettings>>;
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
/** Bulk operation result. */
|
|
2057
|
+
interface BulkResult {
|
|
2058
|
+
object: 'bulk_result';
|
|
2059
|
+
action: string;
|
|
2060
|
+
resource: string;
|
|
2061
|
+
total: number;
|
|
2062
|
+
succeeded: number;
|
|
2063
|
+
failed: number;
|
|
2064
|
+
errors: Array<{
|
|
2065
|
+
id: string;
|
|
2066
|
+
error: string;
|
|
2067
|
+
}>;
|
|
2068
|
+
}
|
|
2069
|
+
/** Parameters for a bulk update. */
|
|
2070
|
+
interface BulkUpdateParams {
|
|
2071
|
+
resource: 'tickets' | 'customers' | 'articles';
|
|
2072
|
+
ids: string[];
|
|
2073
|
+
data: Record<string, unknown>;
|
|
2074
|
+
}
|
|
2075
|
+
/** Parameters for a bulk delete. */
|
|
2076
|
+
interface BulkDeleteParams {
|
|
2077
|
+
resource: 'tickets' | 'customers' | 'articles';
|
|
2078
|
+
ids: string[];
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/** Perform bulk operations on resources. */
|
|
2082
|
+
declare class BulkResource {
|
|
2083
|
+
private readonly client;
|
|
2084
|
+
constructor(client: HttpClient);
|
|
2085
|
+
/** Bulk update resources. */
|
|
2086
|
+
update(params: BulkUpdateParams, options?: RequestOptions): Promise<ApiResponse<BulkResult>>;
|
|
2087
|
+
/** Bulk delete resources. */
|
|
2088
|
+
del(params: BulkDeleteParams, options?: RequestOptions): Promise<ApiResponse<BulkResult>>;
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
/** Export request parameters. */
|
|
2092
|
+
interface ExportCreateParams {
|
|
2093
|
+
resources: Array<{
|
|
2094
|
+
type: 'tickets' | 'customers' | 'articles';
|
|
2095
|
+
filters?: Record<string, unknown>;
|
|
2096
|
+
}>;
|
|
2097
|
+
format?: 'json' | 'csv';
|
|
2098
|
+
}
|
|
2099
|
+
/** Export response. */
|
|
2100
|
+
interface ExportResult {
|
|
2101
|
+
object: 'export';
|
|
2102
|
+
format: string;
|
|
2103
|
+
resources: Record<string, unknown[]> | string;
|
|
2104
|
+
totalRows: number;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
/** Import request parameters. */
|
|
2108
|
+
interface ImportCreateParams {
|
|
2109
|
+
resource: 'tickets' | 'customers' | 'articles';
|
|
2110
|
+
records: Record<string, unknown>[];
|
|
2111
|
+
mergeStrategy?: 'skip' | 'overwrite' | 'merge';
|
|
2112
|
+
}
|
|
2113
|
+
/** Import result. */
|
|
2114
|
+
interface ImportResult {
|
|
2115
|
+
object: 'import_result';
|
|
2116
|
+
resource: string;
|
|
2117
|
+
total: number;
|
|
2118
|
+
created: number;
|
|
2119
|
+
updated: number;
|
|
2120
|
+
skipped: number;
|
|
2121
|
+
errors: Array<{
|
|
2122
|
+
index: number;
|
|
2123
|
+
error: string;
|
|
2124
|
+
}>;
|
|
2125
|
+
}
|
|
2126
|
+
/** Import log entry. */
|
|
2127
|
+
interface ImportLog {
|
|
2128
|
+
id: string;
|
|
2129
|
+
object: 'import_log';
|
|
2130
|
+
resource: string;
|
|
2131
|
+
status: string;
|
|
2132
|
+
totalRecords: number;
|
|
2133
|
+
created: number;
|
|
2134
|
+
updated: number;
|
|
2135
|
+
skipped: number;
|
|
2136
|
+
errors: number;
|
|
2137
|
+
createdAt: string;
|
|
2138
|
+
}
|
|
2139
|
+
/** Parameters for listing import logs. */
|
|
2140
|
+
interface ImportLogListParams extends PaginationParams {
|
|
2141
|
+
resource?: string;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
/** Export data from your team. */
|
|
2145
|
+
declare class ExportResource {
|
|
2146
|
+
private readonly client;
|
|
2147
|
+
constructor(client: HttpClient);
|
|
2148
|
+
/** Create an export. Returns exported data synchronously. */
|
|
2149
|
+
create(params: ExportCreateParams, options?: RequestOptions): Promise<ApiResponse<ExportResult>>;
|
|
2150
|
+
}
|
|
2151
|
+
/** Import data into your team. */
|
|
2152
|
+
declare class ImportResource {
|
|
2153
|
+
private readonly client;
|
|
2154
|
+
constructor(client: HttpClient);
|
|
2155
|
+
/** Run an import. Processes records synchronously (max 500). */
|
|
2156
|
+
create(params: ImportCreateParams, options?: RequestOptions): Promise<ApiResponse<ImportResult>>;
|
|
2157
|
+
/** List import history logs. */
|
|
2158
|
+
logs(params?: ImportLogListParams): Promise<ListResponse<ImportLog>>;
|
|
2159
|
+
/** Get a single import log. */
|
|
2160
|
+
getLog(logId: string): Promise<ApiResponse<ImportLog>>;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
/** An audit log entry. */
|
|
2164
|
+
interface AuditLogEntry {
|
|
2165
|
+
id: string;
|
|
2166
|
+
object: 'audit_log_entry';
|
|
2167
|
+
action: string;
|
|
2168
|
+
resourceType: string;
|
|
2169
|
+
resourceId: string | null;
|
|
2170
|
+
actorId: string | null;
|
|
2171
|
+
actorName: string | null;
|
|
2172
|
+
actorType: string;
|
|
2173
|
+
details: Record<string, unknown>;
|
|
2174
|
+
ipAddress: string | null;
|
|
2175
|
+
createdAt: string;
|
|
2176
|
+
}
|
|
2177
|
+
/** Parameters for listing audit log entries. */
|
|
2178
|
+
interface AuditLogListParams extends PaginationParams {
|
|
2179
|
+
action?: string;
|
|
2180
|
+
resourceType?: string;
|
|
2181
|
+
resourceId?: string;
|
|
2182
|
+
actorId?: string;
|
|
2183
|
+
startDate?: string;
|
|
2184
|
+
endDate?: string;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
/** Access the audit log. */
|
|
2188
|
+
declare class AuditLogResource {
|
|
2189
|
+
private readonly client;
|
|
2190
|
+
constructor(client: HttpClient);
|
|
2191
|
+
/** List audit log entries. */
|
|
2192
|
+
list(params?: AuditLogListParams): Promise<ListResponse<AuditLogEntry>>;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/** Search result item. Shape varies by type. */
|
|
2196
|
+
interface SearchResult {
|
|
2197
|
+
type: 'ticket' | 'customer' | 'article';
|
|
2198
|
+
id: string;
|
|
2199
|
+
/** Title (tickets, articles) or name (customers). */
|
|
2200
|
+
title?: string;
|
|
2201
|
+
name?: string;
|
|
2202
|
+
email?: string;
|
|
2203
|
+
status?: string;
|
|
2204
|
+
priority?: string;
|
|
2205
|
+
[key: string]: unknown;
|
|
2206
|
+
}
|
|
2207
|
+
/** Search parameters. */
|
|
2208
|
+
interface SearchParams {
|
|
2209
|
+
query: string;
|
|
2210
|
+
types?: Array<'tickets' | 'customers' | 'articles'>;
|
|
2211
|
+
limit?: number;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
/** Search across tickets, customers, and articles. */
|
|
2215
|
+
declare class SearchResource {
|
|
2216
|
+
private readonly client;
|
|
2217
|
+
constructor(client: HttpClient);
|
|
2218
|
+
/** Perform a cross-resource search. */
|
|
2219
|
+
query(params: SearchParams): Promise<ApiResponse<SearchResult[]>>;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
/** A tag with usage count. */
|
|
2223
|
+
interface Tag {
|
|
2224
|
+
object: 'tag';
|
|
2225
|
+
name: string;
|
|
2226
|
+
count: number;
|
|
2227
|
+
}
|
|
2228
|
+
/** Parameters for listing tags. */
|
|
2229
|
+
interface TagListParams extends PaginationParams {
|
|
2230
|
+
search?: string;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
/** Manage tags. */
|
|
2234
|
+
declare class TagsResource {
|
|
2235
|
+
private readonly client;
|
|
2236
|
+
constructor(client: HttpClient);
|
|
2237
|
+
/** List all tags with usage counts. */
|
|
2238
|
+
list(params?: TagListParams): Promise<ListResponse<Tag>>;
|
|
2239
|
+
/** Create a tag. */
|
|
2240
|
+
create(name: string, options?: RequestOptions): Promise<ApiResponse<Tag>>;
|
|
2241
|
+
/** Delete a tag. */
|
|
2242
|
+
del(name: string): Promise<ApiResponse<DeleteResponse>>;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
/** An activity/timeline event. */
|
|
2246
|
+
interface ActivityEvent {
|
|
2247
|
+
id: string;
|
|
2248
|
+
object: 'activity';
|
|
2249
|
+
type: string;
|
|
2250
|
+
resourceType: string;
|
|
2251
|
+
resourceId: string | null;
|
|
2252
|
+
actorId: string | null;
|
|
2253
|
+
actorName: string | null;
|
|
2254
|
+
description: string;
|
|
2255
|
+
details: Record<string, unknown>;
|
|
2256
|
+
createdAt: string;
|
|
2257
|
+
}
|
|
2258
|
+
/** Parameters for listing activity. */
|
|
2259
|
+
interface ActivityListParams extends PaginationParams {
|
|
2260
|
+
resourceType?: string;
|
|
2261
|
+
resourceId?: string;
|
|
2262
|
+
type?: string;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
/** Access the activity feed. */
|
|
2266
|
+
declare class ActivityResource {
|
|
2267
|
+
private readonly client;
|
|
2268
|
+
constructor(client: HttpClient);
|
|
2269
|
+
/** List recent activity events. */
|
|
2270
|
+
list(params?: ActivityListParams): Promise<ListResponse<ActivityEvent>>;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
/** A customer group/segment. */
|
|
2274
|
+
interface CustomerGroup {
|
|
2275
|
+
id: string;
|
|
2276
|
+
object: 'customer_group';
|
|
2277
|
+
name: string;
|
|
2278
|
+
description: string | null;
|
|
2279
|
+
filters: Record<string, unknown>;
|
|
2280
|
+
customerCount: number;
|
|
2281
|
+
createdAt: string;
|
|
2282
|
+
updatedAt: string;
|
|
2283
|
+
}
|
|
2284
|
+
/** Parameters for listing customer groups. */
|
|
2285
|
+
interface CustomerGroupListParams extends PaginationParams {
|
|
2286
|
+
search?: string;
|
|
2287
|
+
}
|
|
2288
|
+
/** Parameters for creating a customer group. */
|
|
2289
|
+
interface CustomerGroupCreateParams {
|
|
2290
|
+
name: string;
|
|
2291
|
+
description?: string;
|
|
2292
|
+
filters?: Record<string, unknown>;
|
|
2293
|
+
}
|
|
2294
|
+
/** Parameters for updating a customer group. */
|
|
2295
|
+
interface CustomerGroupUpdateParams {
|
|
2296
|
+
name?: string;
|
|
2297
|
+
description?: string;
|
|
2298
|
+
filters?: Record<string, unknown>;
|
|
2299
|
+
}
|
|
2300
|
+
/** Parameters for listing group members. */
|
|
2301
|
+
interface CustomerGroupMemberListParams extends PaginationParams {
|
|
2302
|
+
}
|
|
2303
|
+
/** Parameters for adding members to a group. */
|
|
2304
|
+
interface CustomerGroupAddMembersParams {
|
|
2305
|
+
customerId?: string;
|
|
2306
|
+
customerIds?: string[];
|
|
2307
|
+
}
|
|
2308
|
+
/** Group members list result. */
|
|
2309
|
+
interface CustomerGroupMembersResult {
|
|
2310
|
+
data: Array<{
|
|
2311
|
+
id: string;
|
|
2312
|
+
object: 'customer';
|
|
2313
|
+
name: string | null;
|
|
2314
|
+
email: string | null;
|
|
2315
|
+
sentiment: string;
|
|
2316
|
+
tags: string[];
|
|
2317
|
+
joinedGroupAt: string;
|
|
2318
|
+
}>;
|
|
2319
|
+
pagination: {
|
|
2320
|
+
total: number;
|
|
2321
|
+
page: number;
|
|
2322
|
+
pageSize: number;
|
|
2323
|
+
hasMore: boolean;
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
/** Result of adding members to a group. */
|
|
2327
|
+
interface CustomerGroupAddResult {
|
|
2328
|
+
added: number;
|
|
2329
|
+
total: number;
|
|
2330
|
+
skipped: number;
|
|
2331
|
+
}
|
|
2332
|
+
/** Result of removing a member from a group. */
|
|
2333
|
+
interface CustomerGroupRemoveResult {
|
|
2334
|
+
removed: true;
|
|
2335
|
+
customerId: string;
|
|
2336
|
+
groupId: string;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
/** Manage group memberships as a sub-resource. */
|
|
2340
|
+
declare class CustomerGroupMembersResource {
|
|
2341
|
+
private readonly client;
|
|
2342
|
+
constructor(client: HttpClient);
|
|
2343
|
+
/** List members in a group. */
|
|
2344
|
+
list(groupId: string, params?: CustomerGroupMemberListParams): Promise<ApiResponse<CustomerGroupMembersResult>>;
|
|
2345
|
+
/** Add member(s) to a group. */
|
|
2346
|
+
add(groupId: string, params: CustomerGroupAddMembersParams, options?: RequestOptions): Promise<ApiResponse<CustomerGroupAddResult>>;
|
|
2347
|
+
/** Remove a member from a group. */
|
|
2348
|
+
remove(groupId: string, customerId: string): Promise<ApiResponse<CustomerGroupRemoveResult>>;
|
|
2349
|
+
}
|
|
2350
|
+
/** Manage customer groups/segments. */
|
|
2351
|
+
declare class CustomerGroupsResource extends BaseResource<CustomerGroup, CustomerGroupListParams, CustomerGroupCreateParams, CustomerGroupUpdateParams> {
|
|
2352
|
+
/** Sub-resource for group memberships. */
|
|
2353
|
+
readonly members: CustomerGroupMembersResource;
|
|
2354
|
+
constructor(client: HttpClient);
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
/** Player stats. */
|
|
2358
|
+
interface Player {
|
|
2359
|
+
object: 'player';
|
|
2360
|
+
userId: string;
|
|
2361
|
+
name: string | null;
|
|
2362
|
+
level: number;
|
|
2363
|
+
xp: number;
|
|
2364
|
+
xpToNextLevel: number;
|
|
2365
|
+
totalXp: number;
|
|
2366
|
+
streak: number;
|
|
2367
|
+
ticketsResolved: number;
|
|
2368
|
+
rank: number | null;
|
|
2369
|
+
scores: {
|
|
2370
|
+
daily: number;
|
|
2371
|
+
weekly: number;
|
|
2372
|
+
allTime: number;
|
|
2373
|
+
};
|
|
2374
|
+
[key: string]: unknown;
|
|
2375
|
+
}
|
|
2376
|
+
/** Boss state. */
|
|
2377
|
+
interface Boss {
|
|
2378
|
+
object: 'boss';
|
|
2379
|
+
active: boolean;
|
|
2380
|
+
name: string | null;
|
|
2381
|
+
title: string | null;
|
|
2382
|
+
difficulty: string | null;
|
|
2383
|
+
health: number;
|
|
2384
|
+
maxHealth: number;
|
|
2385
|
+
healthPercent: number;
|
|
2386
|
+
abilities: Record<string, unknown> | null;
|
|
2387
|
+
participants: Array<{
|
|
2388
|
+
userId: string;
|
|
2389
|
+
name: string | null;
|
|
2390
|
+
damage: number;
|
|
2391
|
+
}>;
|
|
2392
|
+
spawnedAt: string | null;
|
|
2393
|
+
}
|
|
2394
|
+
/** Boss damage result. */
|
|
2395
|
+
interface BossDamageResult {
|
|
2396
|
+
object: 'boss_damage';
|
|
2397
|
+
damage: number;
|
|
2398
|
+
bossHealth: number;
|
|
2399
|
+
bossMaxHealth: number;
|
|
2400
|
+
defeated: boolean;
|
|
2401
|
+
[key: string]: unknown;
|
|
2402
|
+
}
|
|
2403
|
+
/** Boss defeat record. */
|
|
2404
|
+
interface BossDefeat {
|
|
2405
|
+
id: string;
|
|
2406
|
+
object: 'boss_defeat';
|
|
2407
|
+
bossName: string;
|
|
2408
|
+
difficulty: string;
|
|
2409
|
+
defeatedAt: string;
|
|
2410
|
+
participants: Array<{
|
|
2411
|
+
userId: string;
|
|
2412
|
+
name: string | null;
|
|
2413
|
+
damage: number;
|
|
2414
|
+
}>;
|
|
2415
|
+
[key: string]: unknown;
|
|
2416
|
+
}
|
|
2417
|
+
/** Parameters for listing boss defeats. */
|
|
2418
|
+
interface BossDefeatListParams extends PaginationParams {
|
|
2419
|
+
}
|
|
2420
|
+
/** Parameters for spawning a boss. */
|
|
2421
|
+
interface BossSpawnParams {
|
|
2422
|
+
difficulty?: 'easy' | 'medium' | 'hard';
|
|
2423
|
+
}
|
|
2424
|
+
/** Parameters for dealing boss damage. */
|
|
2425
|
+
interface BossDamageParams {
|
|
2426
|
+
userId: string;
|
|
2427
|
+
ticketId: string;
|
|
2428
|
+
}
|
|
2429
|
+
/** Leaderboard entry. */
|
|
2430
|
+
interface LeaderboardEntry {
|
|
2431
|
+
object: 'leaderboard_entry';
|
|
2432
|
+
rank: number;
|
|
2433
|
+
userId: string;
|
|
2434
|
+
name: string | null;
|
|
2435
|
+
avatarUrl: string | null;
|
|
2436
|
+
score: number;
|
|
2437
|
+
level: number;
|
|
2438
|
+
}
|
|
2439
|
+
/** Leaderboard parameters. */
|
|
2440
|
+
interface LeaderboardParams extends PaginationParams {
|
|
2441
|
+
period?: 'daily' | 'weekly' | 'allTime';
|
|
2442
|
+
}
|
|
2443
|
+
/** An achievement. */
|
|
2444
|
+
interface Achievement {
|
|
2445
|
+
id: string;
|
|
2446
|
+
object: 'achievement';
|
|
2447
|
+
name: string;
|
|
2448
|
+
description: string | null;
|
|
2449
|
+
category: string | null;
|
|
2450
|
+
icon: string | null;
|
|
2451
|
+
xpReward: number;
|
|
2452
|
+
unlocked: boolean;
|
|
2453
|
+
unlockedAt: string | null;
|
|
2454
|
+
progress?: {
|
|
2455
|
+
current: number;
|
|
2456
|
+
target: number;
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
/** Parameters for listing achievements. */
|
|
2460
|
+
interface AchievementListParams extends PaginationParams {
|
|
2461
|
+
category?: string;
|
|
2462
|
+
}
|
|
2463
|
+
/** A daily quest. */
|
|
2464
|
+
interface Quest {
|
|
2465
|
+
id: string;
|
|
2466
|
+
object: 'quest';
|
|
2467
|
+
title: string;
|
|
2468
|
+
description: string | null;
|
|
2469
|
+
type: string;
|
|
2470
|
+
target: number;
|
|
2471
|
+
current: number;
|
|
2472
|
+
completed: boolean;
|
|
2473
|
+
xpReward: number;
|
|
2474
|
+
completedAt: string | null;
|
|
2475
|
+
}
|
|
2476
|
+
/** A daily puzzle. */
|
|
2477
|
+
interface Puzzle {
|
|
2478
|
+
id: string;
|
|
2479
|
+
object: 'puzzle';
|
|
2480
|
+
type: string;
|
|
2481
|
+
difficulty: string;
|
|
2482
|
+
data: Record<string, unknown>;
|
|
2483
|
+
completed: boolean;
|
|
2484
|
+
xpReward: number;
|
|
2485
|
+
}
|
|
2486
|
+
/** Puzzle completion parameters. */
|
|
2487
|
+
interface PuzzleCompleteParams {
|
|
2488
|
+
userId: string;
|
|
2489
|
+
answer: string;
|
|
2490
|
+
}
|
|
2491
|
+
/** Puzzle completion result. */
|
|
2492
|
+
interface PuzzleCompleteResult {
|
|
2493
|
+
object: 'puzzle_result';
|
|
2494
|
+
correct: boolean;
|
|
2495
|
+
xpAwarded: number;
|
|
2496
|
+
streak: number;
|
|
2497
|
+
}
|
|
2498
|
+
/** Puzzle streak info. */
|
|
2499
|
+
interface PuzzleStreak {
|
|
2500
|
+
object: 'puzzle_streak';
|
|
2501
|
+
userId: string;
|
|
2502
|
+
currentStreak: number;
|
|
2503
|
+
longestStreak: number;
|
|
2504
|
+
totalCompleted: number;
|
|
2505
|
+
}
|
|
2506
|
+
/** A one-up (kudos to a teammate). */
|
|
2507
|
+
interface OneUp {
|
|
2508
|
+
id: string;
|
|
2509
|
+
object: 'one_up';
|
|
2510
|
+
senderId: string;
|
|
2511
|
+
senderName: string | null;
|
|
2512
|
+
recipientId: string;
|
|
2513
|
+
recipientName: string | null;
|
|
2514
|
+
message: string | null;
|
|
2515
|
+
createdAt: string;
|
|
2516
|
+
}
|
|
2517
|
+
/** Parameters for listing one-ups. */
|
|
2518
|
+
interface OneUpListParams extends PaginationParams {
|
|
2519
|
+
userId?: string;
|
|
2520
|
+
}
|
|
2521
|
+
/** Parameters for sending a one-up. */
|
|
2522
|
+
interface OneUpCreateParams {
|
|
2523
|
+
recipientId: string;
|
|
2524
|
+
message?: string;
|
|
2525
|
+
userId: string;
|
|
2526
|
+
}
|
|
2527
|
+
/** Remaining one-ups info. */
|
|
2528
|
+
interface OneUpRemaining {
|
|
2529
|
+
object: 'one_up_remaining';
|
|
2530
|
+
remaining: number;
|
|
2531
|
+
limit: number;
|
|
2532
|
+
resetsAt: string;
|
|
2533
|
+
}
|
|
2534
|
+
/** A high five (kudos between teams). */
|
|
2535
|
+
interface HighFive {
|
|
2536
|
+
id: string;
|
|
2537
|
+
object: 'high_five';
|
|
2538
|
+
senderTeamId: string;
|
|
2539
|
+
senderTeamName: string | null;
|
|
2540
|
+
recipientTeamId: string;
|
|
2541
|
+
recipientTeamName: string | null;
|
|
2542
|
+
senderId: string;
|
|
2543
|
+
senderName: string | null;
|
|
2544
|
+
message: string | null;
|
|
2545
|
+
createdAt: string;
|
|
2546
|
+
}
|
|
2547
|
+
/** Parameters for listing high fives. */
|
|
2548
|
+
interface HighFiveListParams extends PaginationParams {
|
|
2549
|
+
}
|
|
2550
|
+
/** Parameters for sending a high five. */
|
|
2551
|
+
interface HighFiveCreateParams {
|
|
2552
|
+
recipientTeamId: string;
|
|
2553
|
+
message?: string;
|
|
2554
|
+
userId: string;
|
|
2555
|
+
}
|
|
2556
|
+
/** Can-send check result. */
|
|
2557
|
+
interface HighFiveCanSend {
|
|
2558
|
+
object: 'high_five_can_send';
|
|
2559
|
+
canSend: boolean;
|
|
2560
|
+
reason: string | null;
|
|
2561
|
+
}
|
|
2562
|
+
/** An unlocked cosmetic. */
|
|
2563
|
+
interface Cosmetic {
|
|
2564
|
+
id: string;
|
|
2565
|
+
object: 'cosmetic';
|
|
2566
|
+
type: string;
|
|
2567
|
+
name: string;
|
|
2568
|
+
rarity: string | null;
|
|
2569
|
+
unlockedAt: string;
|
|
2570
|
+
}
|
|
2571
|
+
/** Cosmetic preferences. */
|
|
2572
|
+
interface CosmeticPreferences {
|
|
2573
|
+
object: 'cosmetic_preferences';
|
|
2574
|
+
[key: string]: unknown;
|
|
2575
|
+
}
|
|
2576
|
+
/** A game season. */
|
|
2577
|
+
interface Season {
|
|
2578
|
+
id: string;
|
|
2579
|
+
object: 'season';
|
|
2580
|
+
name: string;
|
|
2581
|
+
number: number;
|
|
2582
|
+
startDate: string;
|
|
2583
|
+
endDate: string;
|
|
2584
|
+
active: boolean;
|
|
2585
|
+
daysRemaining: number | null;
|
|
2586
|
+
}
|
|
2587
|
+
/** Season stats for a user. */
|
|
2588
|
+
interface SeasonStats {
|
|
2589
|
+
object: 'season_stats';
|
|
2590
|
+
seasonId: string;
|
|
2591
|
+
userId: string;
|
|
2592
|
+
xp: number;
|
|
2593
|
+
level: number;
|
|
2594
|
+
ticketsResolved: number;
|
|
2595
|
+
[key: string]: unknown;
|
|
2596
|
+
}
|
|
2597
|
+
/** Skill tree data. */
|
|
2598
|
+
interface SkillTree {
|
|
2599
|
+
object: 'skill_tree';
|
|
2600
|
+
skills: Array<{
|
|
2601
|
+
id: string;
|
|
2602
|
+
name: string;
|
|
2603
|
+
description: string;
|
|
2604
|
+
category: string;
|
|
2605
|
+
maxLevel: number;
|
|
2606
|
+
currentLevel: number;
|
|
2607
|
+
bonuses: Record<string, unknown>;
|
|
2608
|
+
}>;
|
|
2609
|
+
availablePoints: number;
|
|
2610
|
+
totalPointsSpent: number;
|
|
2611
|
+
}
|
|
2612
|
+
/** Skill allocation parameters. */
|
|
2613
|
+
interface SkillAllocateParams {
|
|
2614
|
+
skillId: string;
|
|
2615
|
+
userId: string;
|
|
2616
|
+
}
|
|
2617
|
+
/** Skill allocation result. */
|
|
2618
|
+
interface SkillAllocateResult {
|
|
2619
|
+
object: 'skill_allocate';
|
|
2620
|
+
skillId: string;
|
|
2621
|
+
newLevel: number;
|
|
2622
|
+
remainingPoints: number;
|
|
2623
|
+
}
|
|
2624
|
+
/** Game balance configuration (read-only constants from /game/config). */
|
|
2625
|
+
interface GameConfig {
|
|
2626
|
+
object: 'game_config';
|
|
2627
|
+
rewards: Record<string, unknown>;
|
|
2628
|
+
streaks: Record<string, unknown>;
|
|
2629
|
+
combo: Record<string, unknown>;
|
|
2630
|
+
boss: Record<string, unknown>;
|
|
2631
|
+
scoring: Record<string, unknown>;
|
|
2632
|
+
leveling: Record<string, unknown>;
|
|
2633
|
+
social: Record<string, unknown>;
|
|
2634
|
+
}
|
|
2635
|
+
|
|
2636
|
+
declare class BossResource {
|
|
2637
|
+
private readonly client;
|
|
2638
|
+
constructor(client: HttpClient);
|
|
2639
|
+
/** Get current boss state. */
|
|
2640
|
+
current(): Promise<ApiResponse<Boss>>;
|
|
2641
|
+
/** Check if a boss is active (lightweight). */
|
|
2642
|
+
isActive(): Promise<ApiResponse<{
|
|
2643
|
+
active: boolean;
|
|
2644
|
+
}>>;
|
|
2645
|
+
/** Spawn a new boss. */
|
|
2646
|
+
spawn(params?: BossSpawnParams, options?: RequestOptions): Promise<ApiResponse<Boss>>;
|
|
2647
|
+
/** Deal damage to the current boss. */
|
|
2648
|
+
damage(params: BossDamageParams, options?: RequestOptions): Promise<ApiResponse<BossDamageResult>>;
|
|
2649
|
+
/** List boss defeat history. */
|
|
2650
|
+
defeats(params?: BossDefeatListParams): Promise<ListResponse<BossDefeat>>;
|
|
2651
|
+
/** Get a single defeat record. */
|
|
2652
|
+
getDefeat(defeatId: string): Promise<ApiResponse<BossDefeat>>;
|
|
2653
|
+
}
|
|
2654
|
+
declare class AchievementsResource {
|
|
2655
|
+
private readonly client;
|
|
2656
|
+
constructor(client: HttpClient);
|
|
2657
|
+
/** List all achievements with progress. */
|
|
2658
|
+
list(params?: AchievementListParams): Promise<ApiResponse<{
|
|
2659
|
+
object: 'achievement_list';
|
|
2660
|
+
data: Achievement[];
|
|
2661
|
+
summary: {
|
|
2662
|
+
total: number;
|
|
2663
|
+
unlocked: number;
|
|
2664
|
+
totalXpEarned: number;
|
|
2665
|
+
totalGoldEarned: number;
|
|
2666
|
+
byCategory: Record<string, {
|
|
2667
|
+
total: number;
|
|
2668
|
+
unlocked: number;
|
|
2669
|
+
}>;
|
|
2670
|
+
byRarity: Record<string, {
|
|
2671
|
+
total: number;
|
|
2672
|
+
unlocked: number;
|
|
2673
|
+
}>;
|
|
2674
|
+
};
|
|
2675
|
+
}>>;
|
|
2676
|
+
/** List unlocked achievements only. */
|
|
2677
|
+
unlocked(params?: {
|
|
2678
|
+
userId: string;
|
|
2679
|
+
}): Promise<ApiResponse<Achievement[]>>;
|
|
2680
|
+
/** Get a single achievement. */
|
|
2681
|
+
get(achievementId: string, params?: {
|
|
2682
|
+
userId?: string;
|
|
2683
|
+
}): Promise<ApiResponse<Achievement>>;
|
|
2684
|
+
/** Get recently unlocked achievements across the team. */
|
|
2685
|
+
recent(params?: {
|
|
2686
|
+
limit?: number;
|
|
2687
|
+
}): Promise<ApiResponse<{
|
|
2688
|
+
object: 'list';
|
|
2689
|
+
data: Achievement[];
|
|
2690
|
+
}>>;
|
|
2691
|
+
}
|
|
2692
|
+
declare class GameActivityResource {
|
|
2693
|
+
private readonly client;
|
|
2694
|
+
constructor(client: HttpClient);
|
|
2695
|
+
/** Get the team activity feed. */
|
|
2696
|
+
list(params?: {
|
|
2697
|
+
limit?: number;
|
|
2698
|
+
before?: string;
|
|
2699
|
+
}): Promise<ApiResponse<{
|
|
2700
|
+
object: 'list';
|
|
2701
|
+
data: unknown[];
|
|
2702
|
+
cursor: string | null;
|
|
2703
|
+
}>>;
|
|
2704
|
+
/** Get activity for a specific member. */
|
|
2705
|
+
forMember(memberId: string, params?: {
|
|
2706
|
+
limit?: number;
|
|
2707
|
+
}): Promise<ApiResponse<{
|
|
2708
|
+
object: 'list';
|
|
2709
|
+
data: unknown[];
|
|
2710
|
+
}>>;
|
|
2711
|
+
}
|
|
2712
|
+
declare class QuestsResource {
|
|
2713
|
+
private readonly client;
|
|
2714
|
+
constructor(client: HttpClient);
|
|
2715
|
+
/** Get today's quests. */
|
|
2716
|
+
today(params?: {
|
|
2717
|
+
userId?: string;
|
|
2718
|
+
}): Promise<ApiResponse<Quest[]>>;
|
|
2719
|
+
/** Get quest history. */
|
|
2720
|
+
history(params?: {
|
|
2721
|
+
userId?: string;
|
|
2722
|
+
page?: number;
|
|
2723
|
+
pageSize?: number;
|
|
2724
|
+
}): Promise<ApiResponse<unknown>>;
|
|
2725
|
+
}
|
|
2726
|
+
declare class PuzzlesResource {
|
|
2727
|
+
private readonly client;
|
|
2728
|
+
constructor(client: HttpClient);
|
|
2729
|
+
/** Get today's puzzle. */
|
|
2730
|
+
today(params?: {
|
|
2731
|
+
userId?: string;
|
|
2732
|
+
}): Promise<ApiResponse<Puzzle>>;
|
|
2733
|
+
/** Submit a puzzle answer. */
|
|
2734
|
+
complete(params: PuzzleCompleteParams, options?: RequestOptions): Promise<ApiResponse<PuzzleCompleteResult>>;
|
|
2735
|
+
/** Get puzzle streak for a user. */
|
|
2736
|
+
streak(params: {
|
|
2737
|
+
userId: string;
|
|
2738
|
+
}): Promise<ApiResponse<PuzzleStreak>>;
|
|
2739
|
+
/** Get puzzle leaderboard. */
|
|
2740
|
+
leaderboard(params?: {
|
|
2741
|
+
type?: 'scores' | 'streaks';
|
|
2742
|
+
limit?: number;
|
|
2743
|
+
}): Promise<ApiResponse<unknown>>;
|
|
2744
|
+
}
|
|
2745
|
+
declare class OneUpsResource {
|
|
2746
|
+
private readonly client;
|
|
2747
|
+
constructor(client: HttpClient);
|
|
2748
|
+
/** List one-ups. */
|
|
2749
|
+
list(params?: OneUpListParams): Promise<ListResponse<OneUp>>;
|
|
2750
|
+
/** Send a one-up. */
|
|
2751
|
+
send(params: OneUpCreateParams, options?: RequestOptions): Promise<ApiResponse<OneUp>>;
|
|
2752
|
+
/** Check remaining free one-ups today. */
|
|
2753
|
+
remaining(params: {
|
|
2754
|
+
userId: string;
|
|
2755
|
+
}): Promise<ApiResponse<OneUpRemaining>>;
|
|
2756
|
+
}
|
|
2757
|
+
declare class HighFivesResource {
|
|
2758
|
+
private readonly client;
|
|
2759
|
+
constructor(client: HttpClient);
|
|
2760
|
+
/** List high fives. */
|
|
2761
|
+
list(params?: HighFiveListParams): Promise<ListResponse<HighFive>>;
|
|
2762
|
+
/** Send a high five. */
|
|
2763
|
+
send(params: HighFiveCreateParams, options?: RequestOptions): Promise<ApiResponse<HighFive>>;
|
|
2764
|
+
/** Check if you can send a high five to a team. */
|
|
2765
|
+
canSend(recipientTeamId: string, params: {
|
|
2766
|
+
userId: string;
|
|
2767
|
+
}): Promise<ApiResponse<HighFiveCanSend>>;
|
|
2768
|
+
}
|
|
2769
|
+
declare class CosmeticsResource {
|
|
2770
|
+
private readonly client;
|
|
2771
|
+
constructor(client: HttpClient);
|
|
2772
|
+
/** List unlocked cosmetics. */
|
|
2773
|
+
list(params?: {
|
|
2774
|
+
userId?: string;
|
|
2775
|
+
}): Promise<ApiResponse<Cosmetic[]>>;
|
|
2776
|
+
/** Get cosmetic preferences. */
|
|
2777
|
+
getPreferences(params: {
|
|
2778
|
+
userId: string;
|
|
2779
|
+
}): Promise<ApiResponse<CosmeticPreferences>>;
|
|
2780
|
+
/** Update cosmetic preferences. */
|
|
2781
|
+
updatePreferences(params: Record<string, unknown>): Promise<ApiResponse<CosmeticPreferences>>;
|
|
2782
|
+
}
|
|
2783
|
+
declare class SeasonsResource {
|
|
2784
|
+
private readonly client;
|
|
2785
|
+
constructor(client: HttpClient);
|
|
2786
|
+
/** List all seasons. */
|
|
2787
|
+
list(): Promise<ApiResponse<Season[]>>;
|
|
2788
|
+
/** Get the current active season. */
|
|
2789
|
+
current(): Promise<ApiResponse<Season>>;
|
|
2790
|
+
/** Get user stats for a season. */
|
|
2791
|
+
stats(seasonId: string, params: {
|
|
2792
|
+
userId: string;
|
|
2793
|
+
}): Promise<ApiResponse<SeasonStats>>;
|
|
2794
|
+
}
|
|
2795
|
+
declare class SkillsResource {
|
|
2796
|
+
private readonly client;
|
|
2797
|
+
constructor(client: HttpClient);
|
|
2798
|
+
/** Get the skill tree with current allocations. */
|
|
2799
|
+
get(params: {
|
|
2800
|
+
userId: string;
|
|
2801
|
+
}): Promise<ApiResponse<SkillTree>>;
|
|
2802
|
+
/** Allocate a skill point. */
|
|
2803
|
+
allocate(params: SkillAllocateParams, options?: RequestOptions): Promise<ApiResponse<SkillAllocateResult>>;
|
|
2804
|
+
/** Reset all skill allocations. */
|
|
2805
|
+
reset(params: {
|
|
2806
|
+
userId: string;
|
|
2807
|
+
}, options?: RequestOptions): Promise<ApiResponse<SkillTree>>;
|
|
2808
|
+
}
|
|
2809
|
+
/** Access all gamification features. */
|
|
2810
|
+
declare class GameResource {
|
|
2811
|
+
private readonly client;
|
|
2812
|
+
/** Boss battles. */
|
|
2813
|
+
readonly boss: BossResource;
|
|
2814
|
+
/** Achievements. */
|
|
2815
|
+
readonly achievements: AchievementsResource;
|
|
2816
|
+
/** Daily quests. */
|
|
2817
|
+
readonly quests: QuestsResource;
|
|
2818
|
+
/** Daily puzzles. */
|
|
2819
|
+
readonly puzzles: PuzzlesResource;
|
|
2820
|
+
/** One-ups (teammate kudos). */
|
|
2821
|
+
readonly oneUps: OneUpsResource;
|
|
2822
|
+
/** High fives (team-to-team kudos). */
|
|
2823
|
+
readonly highFives: HighFivesResource;
|
|
2824
|
+
/** Cosmetics. */
|
|
2825
|
+
readonly cosmetics: CosmeticsResource;
|
|
2826
|
+
/** Seasons. */
|
|
2827
|
+
readonly seasons: SeasonsResource;
|
|
2828
|
+
/** Skill tree. */
|
|
2829
|
+
readonly skills: SkillsResource;
|
|
2830
|
+
/** Game activity feed. */
|
|
2831
|
+
readonly activity: GameActivityResource;
|
|
2832
|
+
constructor(client: HttpClient);
|
|
2833
|
+
/** Get current player stats. */
|
|
2834
|
+
player(params?: {
|
|
2835
|
+
userId?: string;
|
|
2836
|
+
}): Promise<ApiResponse<Player>>;
|
|
2837
|
+
/** Get a specific player's stats by membership ID. */
|
|
2838
|
+
getPlayer(memberId: string): Promise<ApiResponse<Player>>;
|
|
2839
|
+
/**
|
|
2840
|
+
* Get the team leaderboard. Returns the unwrapped envelope from the
|
|
2841
|
+
* `/game/leaderboard` endpoint (`{entries, totalParticipants, period, ...}`)
|
|
2842
|
+
* — wider than a flat array because the server includes the period and
|
|
2843
|
+
* a participant count alongside the entries.
|
|
2844
|
+
*/
|
|
2845
|
+
leaderboard(params?: LeaderboardParams): Promise<{
|
|
2846
|
+
entries: LeaderboardEntry[];
|
|
2847
|
+
totalParticipants?: number;
|
|
2848
|
+
period?: string;
|
|
2849
|
+
}>;
|
|
2850
|
+
/** Get the current user's leaderboard position. */
|
|
2851
|
+
myRank(params?: {
|
|
2852
|
+
userId?: string;
|
|
2853
|
+
period?: string;
|
|
2854
|
+
}): Promise<ApiResponse<LeaderboardEntry>>;
|
|
2855
|
+
/** Get game balance configuration (read-only constants). */
|
|
2856
|
+
config(): Promise<ApiResponse<GameConfig>>;
|
|
2857
|
+
/**
|
|
2858
|
+
* Subscribe to live boss battle state.
|
|
2859
|
+
* Updates on boss.spawned, boss.damaged, boss.defeated events.
|
|
2860
|
+
*/
|
|
2861
|
+
subscribeBoss(realtime: CStarRealtime): Subscription$1<Boss>;
|
|
2862
|
+
/**
|
|
2863
|
+
* Subscribe to player stats (XP, gold, level, streaks).
|
|
2864
|
+
* Updates on achievement.unlocked, quest.completed, level.up events.
|
|
2865
|
+
*/
|
|
2866
|
+
subscribePlayer(realtime: CStarRealtime, userId?: string): Subscription$1<Player>;
|
|
2867
|
+
/**
|
|
2868
|
+
* Subscribe to the team leaderboard.
|
|
2869
|
+
* Updates when scores change.
|
|
2870
|
+
*/
|
|
2871
|
+
subscribeLeaderboard(realtime: CStarRealtime, params?: LeaderboardParams): Subscription$1<LeaderboardEntry>;
|
|
2872
|
+
/**
|
|
2873
|
+
* Subscribe to team activity feed (achievements, boss defeats, level ups).
|
|
2874
|
+
* Rolling feed of recent game events.
|
|
2875
|
+
*/
|
|
2876
|
+
subscribeActivity(realtime: CStarRealtime): Subscription$1<Record<string, unknown>>;
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
/** AI action types. */
|
|
2880
|
+
type AiAction = 'auto-tag' | 'suggest-reply' | 'summarize' | 'improve';
|
|
2881
|
+
/** Parameters for an AI action. */
|
|
2882
|
+
interface AiActionParams {
|
|
2883
|
+
action: AiAction;
|
|
2884
|
+
ticketId?: string;
|
|
2885
|
+
text?: string;
|
|
2886
|
+
context?: Record<string, unknown>;
|
|
2887
|
+
}
|
|
2888
|
+
/** AI action result. */
|
|
2889
|
+
interface AiActionResult {
|
|
2890
|
+
object: 'ai_result';
|
|
2891
|
+
action: AiAction;
|
|
2892
|
+
result: unknown;
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
/** AI-powered actions (auto-tag, suggest reply, summarize, improve). */
|
|
2896
|
+
declare class AiResource {
|
|
2897
|
+
private readonly client;
|
|
2898
|
+
constructor(client: HttpClient);
|
|
2899
|
+
/** Run an AI action. */
|
|
2900
|
+
run(params: AiActionParams, options?: RequestOptions): Promise<ApiResponse<AiActionResult>>;
|
|
2901
|
+
/** Auto-tag a ticket. */
|
|
2902
|
+
autoTag(ticketId: string): Promise<ApiResponse<AiActionResult>>;
|
|
2903
|
+
/** Suggest a reply for a ticket. */
|
|
2904
|
+
suggestReply(ticketId: string): Promise<ApiResponse<AiActionResult>>;
|
|
2905
|
+
/** Summarize a ticket. */
|
|
2906
|
+
summarize(ticketId: string): Promise<ApiResponse<AiActionResult>>;
|
|
2907
|
+
/** Improve text. */
|
|
2908
|
+
improve(text: string): Promise<ApiResponse<AiActionResult>>;
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
/** A saved view / filter preset. */
|
|
2912
|
+
interface SavedView {
|
|
2913
|
+
id: string;
|
|
2914
|
+
object: 'saved_view';
|
|
2915
|
+
name: string;
|
|
2916
|
+
description: string | null;
|
|
2917
|
+
entityType: 'tickets' | 'customers' | 'articles' | 'community_posts';
|
|
2918
|
+
filters: Record<string, unknown>;
|
|
2919
|
+
sortField: string;
|
|
2920
|
+
sortDirection: 'asc' | 'desc';
|
|
2921
|
+
visibility: 'private' | 'team';
|
|
2922
|
+
createdBy: string | null;
|
|
2923
|
+
createdAt: string;
|
|
2924
|
+
updatedAt: string;
|
|
2925
|
+
}
|
|
2926
|
+
/** Parameters for listing views. */
|
|
2927
|
+
interface ViewListParams extends PaginationParams {
|
|
2928
|
+
entityType?: string;
|
|
2929
|
+
}
|
|
2930
|
+
/** Parameters for creating a view. */
|
|
2931
|
+
interface ViewCreateParams {
|
|
2932
|
+
name: string;
|
|
2933
|
+
description?: string;
|
|
2934
|
+
entityType: 'tickets' | 'customers' | 'articles' | 'community_posts';
|
|
2935
|
+
filters?: Record<string, unknown>;
|
|
2936
|
+
sortField?: string;
|
|
2937
|
+
sortDirection?: 'asc' | 'desc';
|
|
2938
|
+
visibility?: 'private' | 'team';
|
|
2939
|
+
}
|
|
2940
|
+
/** Parameters for updating a view. */
|
|
2941
|
+
interface ViewUpdateParams {
|
|
2942
|
+
name?: string;
|
|
2943
|
+
description?: string;
|
|
2944
|
+
filters?: Record<string, unknown>;
|
|
2945
|
+
sortField?: string;
|
|
2946
|
+
sortDirection?: 'asc' | 'desc';
|
|
2947
|
+
visibility?: 'private' | 'team';
|
|
2948
|
+
}
|
|
2949
|
+
/** Parameters for executing a view. */
|
|
2950
|
+
interface ViewExecuteParams extends PaginationParams {
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
/** Manage saved views (saved filters). */
|
|
2954
|
+
declare class ViewsResource extends BaseResource<SavedView, ViewListParams, ViewCreateParams, ViewUpdateParams> {
|
|
2955
|
+
constructor(client: HttpClient);
|
|
2956
|
+
/** Execute a view — returns the filtered results. The server uses the view's entity_type to determine which table to query. */
|
|
2957
|
+
execute(viewId: string, params?: ViewExecuteParams): Promise<ListResponse<unknown>>;
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
/** Subscription status. */
|
|
2961
|
+
interface Subscription {
|
|
2962
|
+
object: 'subscription';
|
|
2963
|
+
status: string;
|
|
2964
|
+
plan: string | null;
|
|
2965
|
+
currentPeriodStart: string | null;
|
|
2966
|
+
currentPeriodEnd: string | null;
|
|
2967
|
+
cancelAtPeriodEnd: boolean;
|
|
2968
|
+
memberCount: number;
|
|
2969
|
+
[key: string]: unknown;
|
|
2970
|
+
}
|
|
2971
|
+
/** Billing portal result. */
|
|
2972
|
+
interface BillingPortal {
|
|
2973
|
+
object: 'billing_portal';
|
|
2974
|
+
url: string;
|
|
2975
|
+
}
|
|
2976
|
+
/** Parameters for creating a billing portal session. */
|
|
2977
|
+
interface BillingPortalParams {
|
|
2978
|
+
returnUrl?: string;
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
/** Access billing and subscription data. */
|
|
2982
|
+
declare class BillingResource {
|
|
2983
|
+
private readonly client;
|
|
2984
|
+
constructor(client: HttpClient);
|
|
2985
|
+
/** Get current subscription status. */
|
|
2986
|
+
subscription(): Promise<ApiResponse<Subscription>>;
|
|
2987
|
+
/** Create a Stripe billing portal session. */
|
|
2988
|
+
portal(params?: BillingPortalParams): Promise<ApiResponse<BillingPortal>>;
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
interface QueueItem {
|
|
2992
|
+
/** Unique queue item ID. */
|
|
2993
|
+
id: string;
|
|
2994
|
+
/** HTTP method. */
|
|
2995
|
+
method: string;
|
|
2996
|
+
/** API path. */
|
|
2997
|
+
path: string;
|
|
2998
|
+
/** Request body. */
|
|
2999
|
+
body: Record<string, unknown>;
|
|
3000
|
+
/** When the item was queued. */
|
|
3001
|
+
queuedAt: string;
|
|
3002
|
+
}
|
|
3003
|
+
interface QueueResult {
|
|
3004
|
+
id: string;
|
|
3005
|
+
success: boolean;
|
|
3006
|
+
data?: unknown;
|
|
3007
|
+
error?: string;
|
|
3008
|
+
}
|
|
3009
|
+
interface OfflineQueueOptions {
|
|
3010
|
+
/** Storage backend: 'memory' (default) or 'localStorage' for browser persistence. */
|
|
3011
|
+
storage?: 'memory' | 'localStorage';
|
|
3012
|
+
}
|
|
3013
|
+
/**
|
|
3014
|
+
* Offline mutation queue that stores failed requests and replays them when online.
|
|
3015
|
+
*
|
|
3016
|
+
* When `CStarClient` is used with network issues, mutations can be enqueued
|
|
3017
|
+
* instead of failing. The queue persists to localStorage (in browsers) and
|
|
3018
|
+
* auto-flushes when the network comes back.
|
|
3019
|
+
*
|
|
3020
|
+
* ```typescript
|
|
3021
|
+
* const queue = new OfflineQueue(httpClient, { storage: 'localStorage' });
|
|
3022
|
+
* queue.enqueue('POST', '/tickets', { title: 'Bug report' });
|
|
3023
|
+
* // Later, when online:
|
|
3024
|
+
* const results = await queue.flush();
|
|
3025
|
+
* ```
|
|
3026
|
+
*/
|
|
3027
|
+
declare class OfflineQueue {
|
|
3028
|
+
private readonly httpClient;
|
|
3029
|
+
private items;
|
|
3030
|
+
private autoFlushEnabled;
|
|
3031
|
+
private onlineHandler;
|
|
3032
|
+
private readonly useLocalStorage;
|
|
3033
|
+
constructor(httpClient: HttpClient, options?: OfflineQueueOptions);
|
|
3034
|
+
/** Queue a mutation for later execution. Returns a queue item ID. */
|
|
3035
|
+
enqueue(method: string, path: string, body: Record<string, unknown>): string;
|
|
3036
|
+
/**
|
|
3037
|
+
* Process all queued mutations in order. Returns results for each item.
|
|
3038
|
+
* Failed items are re-queued at the front to preserve ordering.
|
|
3039
|
+
* Items enqueued during flush are appended after re-queued failures.
|
|
3040
|
+
*/
|
|
3041
|
+
flush(): Promise<QueueResult[]>;
|
|
3042
|
+
/** Get pending queue items. */
|
|
3043
|
+
get pending(): QueueItem[];
|
|
3044
|
+
/** Number of items in the queue. */
|
|
3045
|
+
get size(): number;
|
|
3046
|
+
/** Clear all pending items. */
|
|
3047
|
+
clear(): void;
|
|
3048
|
+
/**
|
|
3049
|
+
* Enable auto-flush when the browser goes online.
|
|
3050
|
+
* Only works in browser environments with the `online` event.
|
|
3051
|
+
*/
|
|
3052
|
+
enableAutoFlush(): void;
|
|
3053
|
+
/** Disable auto-flush and clean up event listeners. */
|
|
3054
|
+
disableAutoFlush(): void;
|
|
3055
|
+
private saveToStorage;
|
|
3056
|
+
private loadFromStorage;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
/** Error type constants matching the cStar API. */
|
|
3060
|
+
declare const ErrorType: {
|
|
3061
|
+
readonly AUTHENTICATION_ERROR: "authentication_error";
|
|
3062
|
+
readonly PERMISSION_ERROR: "permission_error";
|
|
3063
|
+
readonly INVALID_REQUEST_ERROR: "invalid_request_error";
|
|
3064
|
+
readonly NOT_FOUND_ERROR: "not_found_error";
|
|
3065
|
+
readonly CONFLICT_ERROR: "conflict_error";
|
|
3066
|
+
readonly RATE_LIMIT_ERROR: "rate_limit_error";
|
|
3067
|
+
readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
|
|
3068
|
+
readonly API_ERROR: "api_error";
|
|
3069
|
+
readonly SERVER_ERROR: "server_error";
|
|
3070
|
+
};
|
|
3071
|
+
/** Shape of the error object returned by the cStar API. */
|
|
3072
|
+
interface ApiErrorBody {
|
|
3073
|
+
type: string;
|
|
3074
|
+
code: string;
|
|
3075
|
+
message: string;
|
|
3076
|
+
param?: string;
|
|
3077
|
+
doc_url: string;
|
|
3078
|
+
request_id?: string;
|
|
3079
|
+
feature?: string;
|
|
3080
|
+
enable_url?: string;
|
|
3081
|
+
}
|
|
3082
|
+
/** Base error class for all cStar API errors. */
|
|
3083
|
+
declare class CStarError extends Error {
|
|
3084
|
+
readonly type: string;
|
|
3085
|
+
readonly code: string;
|
|
3086
|
+
readonly param?: string;
|
|
3087
|
+
readonly docUrl: string;
|
|
3088
|
+
readonly requestId?: string;
|
|
3089
|
+
readonly statusCode: number;
|
|
3090
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3091
|
+
}
|
|
3092
|
+
/** Thrown when authentication fails (401). */
|
|
3093
|
+
declare class CStarAuthenticationError extends CStarError {
|
|
3094
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3095
|
+
}
|
|
3096
|
+
/** Thrown when rate limited (429). Includes retry timing. */
|
|
3097
|
+
declare class CStarRateLimitError extends CStarError {
|
|
3098
|
+
readonly retryAfter: number;
|
|
3099
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
|
|
3100
|
+
}
|
|
3101
|
+
/** Thrown when a resource is not found (404). */
|
|
3102
|
+
declare class CStarNotFoundError extends CStarError {
|
|
3103
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3104
|
+
}
|
|
3105
|
+
/** Thrown on invalid request parameters (400/422). */
|
|
3106
|
+
declare class CStarValidationError extends CStarError {
|
|
3107
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3108
|
+
}
|
|
3109
|
+
/** Thrown when authenticated but lacking permission (403). */
|
|
3110
|
+
declare class CStarPermissionError extends CStarError {
|
|
3111
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3112
|
+
}
|
|
3113
|
+
/** Thrown on resource conflicts (409). */
|
|
3114
|
+
declare class CStarConflictError extends CStarError {
|
|
3115
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3116
|
+
}
|
|
3117
|
+
/** Thrown on internal server errors (500+). */
|
|
3118
|
+
declare class CStarServerError extends CStarError {
|
|
3119
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3120
|
+
}
|
|
3121
|
+
/**
|
|
3122
|
+
* Thrown when the call landed on a feature that the team has not enabled
|
|
3123
|
+
* or configured (e.g. Quick Help on a team without an AI agent). Carries
|
|
3124
|
+
* `feature` and `enableUrl` so the caller can route the user to the
|
|
3125
|
+
* dashboard setting that fixes it.
|
|
3126
|
+
*
|
|
3127
|
+
* Closes F-031 — anonymous QuickHelp `.ask()` previously surfaced as an
|
|
3128
|
+
* unactionable 503.
|
|
3129
|
+
*/
|
|
3130
|
+
declare class CStarFeatureDisabledError extends CStarError {
|
|
3131
|
+
readonly feature: string;
|
|
3132
|
+
readonly enableUrl: string;
|
|
3133
|
+
constructor(messageOrStatus: string | number, body?: ApiErrorBody);
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
/** Configuration for the CStarClient. */
|
|
3137
|
+
interface CStarClientConfig {
|
|
3138
|
+
/** Your API key (sk_live_*, sk_test_*, pk_live_*, or pk_test_*). */
|
|
3139
|
+
apiKey: string;
|
|
3140
|
+
/** Your team ID. */
|
|
3141
|
+
teamId: string;
|
|
3142
|
+
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
3143
|
+
baseUrl?: string;
|
|
3144
|
+
/** API version header (defaults to 2026-03-01). */
|
|
3145
|
+
version?: string;
|
|
3146
|
+
/** Max retry attempts for failed requests (defaults to 3). */
|
|
3147
|
+
maxRetries?: number;
|
|
3148
|
+
/** Request timeout in ms (defaults to 30000). */
|
|
3149
|
+
timeout?: number;
|
|
3150
|
+
/** Enable offline queue — queues mutations when network fails, auto-flushes on reconnect. */
|
|
3151
|
+
offline?: boolean | OfflineQueueOptions;
|
|
3152
|
+
}
|
|
3153
|
+
/**
|
|
3154
|
+
* The cStar admin API client. **Server-side only.**
|
|
3155
|
+
*
|
|
3156
|
+
* Requires a secret API key (`sk_live_*` or `sk_test_*`). Never use this in
|
|
3157
|
+
* client-side / browser code — your secret key would be exposed to anyone
|
|
3158
|
+
* viewing your site.
|
|
3159
|
+
*
|
|
3160
|
+
* For client-side integrations, use:
|
|
3161
|
+
* - `@cstar.help/js/chat` — Customer chat widget (publishable key)
|
|
3162
|
+
* - `@cstar.help/js/library` — Public knowledge base (no auth)
|
|
3163
|
+
* - `@cstar.help/js/community` — Public community forum (no auth)
|
|
3164
|
+
*
|
|
3165
|
+
* ```typescript
|
|
3166
|
+
* import { CStarClient } from '@cstar.help/js';
|
|
3167
|
+
*
|
|
3168
|
+
* const cstar = new CStarClient({
|
|
3169
|
+
* apiKey: process.env.CSTAR_SECRET_KEY, // sk_live_... or sk_test_...
|
|
3170
|
+
* teamId: process.env.CSTAR_TEAM_ID,
|
|
3171
|
+
* });
|
|
3172
|
+
*
|
|
3173
|
+
* const { data } = await cstar.tickets.list({ status: 'open' });
|
|
3174
|
+
* ```
|
|
3175
|
+
*/
|
|
3176
|
+
declare class CStarClient {
|
|
3177
|
+
/** Manage support tickets. */
|
|
3178
|
+
readonly tickets: TicketsResource;
|
|
3179
|
+
/** Manage customers. */
|
|
3180
|
+
readonly customers: CustomersResource;
|
|
3181
|
+
/** Manage knowledge base articles. */
|
|
3182
|
+
readonly articles: ArticlesResource;
|
|
3183
|
+
/** Manage webhook endpoints. */
|
|
3184
|
+
readonly webhooks: WebhooksResource;
|
|
3185
|
+
/** Manage automation rules. */
|
|
3186
|
+
readonly automations: AutomationsResource;
|
|
3187
|
+
/** Manage article categories. */
|
|
3188
|
+
readonly categories: CategoriesResource;
|
|
3189
|
+
/** Manage community posts and topics. */
|
|
3190
|
+
readonly community: {
|
|
3191
|
+
readonly posts: CommunityPostsResource;
|
|
3192
|
+
readonly topics: CommunityTopicsResource;
|
|
3193
|
+
};
|
|
3194
|
+
/** Manage team members and invites. */
|
|
3195
|
+
readonly members: MembersResource;
|
|
3196
|
+
/** Manage team settings, statuses, quick replies, business hours, and widget. */
|
|
3197
|
+
readonly settings: SettingsResource;
|
|
3198
|
+
/** Manage notifications. */
|
|
3199
|
+
readonly notifications: NotificationsResource;
|
|
3200
|
+
/** Manage @mentions. */
|
|
3201
|
+
readonly mentions: MentionsResource;
|
|
3202
|
+
/** Manage file attachments. */
|
|
3203
|
+
readonly attachments: AttachmentsResource;
|
|
3204
|
+
/** Manage custom field definitions. */
|
|
3205
|
+
readonly customFields: CustomFieldsResource;
|
|
3206
|
+
/** Manage SLA rules. */
|
|
3207
|
+
readonly sla: SlaResource;
|
|
3208
|
+
/** Access analytics and CSAT data. */
|
|
3209
|
+
readonly analytics: AnalyticsResource;
|
|
3210
|
+
/** Perform bulk operations. */
|
|
3211
|
+
readonly bulk: BulkResource;
|
|
3212
|
+
/** Export data. */
|
|
3213
|
+
readonly export: ExportResource;
|
|
3214
|
+
/** Import data. */
|
|
3215
|
+
readonly import: ImportResource;
|
|
3216
|
+
/** Access the audit log. */
|
|
3217
|
+
readonly auditLog: AuditLogResource;
|
|
3218
|
+
/** Search across resources. */
|
|
3219
|
+
readonly search: SearchResource;
|
|
3220
|
+
/** Manage tags. */
|
|
3221
|
+
readonly tags: TagsResource;
|
|
3222
|
+
/** Access the activity feed. */
|
|
3223
|
+
readonly activity: ActivityResource;
|
|
3224
|
+
/** Manage customer groups/segments. */
|
|
3225
|
+
readonly customerGroups: CustomerGroupsResource;
|
|
3226
|
+
/** Access all gamification features. */
|
|
3227
|
+
readonly game: GameResource;
|
|
3228
|
+
/** AI-powered actions. */
|
|
3229
|
+
readonly ai: AiResource;
|
|
3230
|
+
/** Manage saved views. */
|
|
3231
|
+
readonly views: ViewsResource;
|
|
3232
|
+
/** Access billing and subscription data. */
|
|
3233
|
+
readonly billing: BillingResource;
|
|
3234
|
+
/** Real-time event stream via SSE. */
|
|
3235
|
+
readonly realtime: CStarRealtime;
|
|
3236
|
+
/**
|
|
3237
|
+
* Offline mutation queue. Only available when `offline: true` is passed to the constructor.
|
|
3238
|
+
* Queues failed mutations and replays them when the network returns.
|
|
3239
|
+
*/
|
|
3240
|
+
readonly offlineQueue: OfflineQueue | null;
|
|
3241
|
+
/**
|
|
3242
|
+
* @internal The underlying HTTP client — used by realtime and subscription layers.
|
|
3243
|
+
* Not part of the public API. May change without notice between versions.
|
|
3244
|
+
*/
|
|
3245
|
+
private readonly _httpClient;
|
|
3246
|
+
constructor(config: CStarClientConfig);
|
|
3247
|
+
/** Disconnect the realtime stream and clean up. */
|
|
3248
|
+
destroy(): void;
|
|
3249
|
+
/** Whether this client is using test mode keys (sk_test_* or pk_test_*). */
|
|
3250
|
+
get isTestMode(): boolean;
|
|
3251
|
+
/**
|
|
3252
|
+
* Validate the configured API key and return the team + key metadata it
|
|
3253
|
+
* resolves to. Useful for confirming the key is wired up correctly during
|
|
3254
|
+
* onboarding (and for AI assistants that want a one-call sanity check).
|
|
3255
|
+
*
|
|
3256
|
+
* Closes F-018.
|
|
3257
|
+
*
|
|
3258
|
+
* ```ts
|
|
3259
|
+
* const me = await cstar.whoami();
|
|
3260
|
+
* console.log(me.teamSlug, me.environment); // 'acme', 'test'
|
|
3261
|
+
* ```
|
|
3262
|
+
*/
|
|
3263
|
+
whoami(): Promise<{
|
|
3264
|
+
teamId: string;
|
|
3265
|
+
teamName: string;
|
|
3266
|
+
teamSlug: string;
|
|
3267
|
+
keyId: string;
|
|
3268
|
+
keyType: 'secret' | 'publishable';
|
|
3269
|
+
environment: 'live' | 'test';
|
|
3270
|
+
createdAt: string;
|
|
3271
|
+
subscriptionStatus: string;
|
|
3272
|
+
}>;
|
|
3273
|
+
/**
|
|
3274
|
+
* Side-channel metadata from the most recent HTTP response. Holds the
|
|
3275
|
+
* server `requestId` (for support escalations), `timestamp`, and the
|
|
3276
|
+
* `pagination` info from list endpoints. Reset on every call — read it
|
|
3277
|
+
* immediately after awaiting the call you care about.
|
|
3278
|
+
*
|
|
3279
|
+
* ```ts
|
|
3280
|
+
* const ticket = await cstar.tickets.create({...});
|
|
3281
|
+
* console.error('Created', ticket.id, 'request:', cstar.lastMeta.requestId);
|
|
3282
|
+
* ```
|
|
3283
|
+
*/
|
|
3284
|
+
get lastMeta(): LastMeta;
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
export { type Achievement, type AchievementListParams, type ActivityEvent, type ActivityListParams, type AiAction, type AiActionParams, type AiActionResult, type AnalyticsOverview, type AnalyticsParams, type ApiErrorBody, type ApiResponse, type Article, type ArticleCreateParams, type ArticleListParams, type ArticleUpdateParams, type Attachment, type AttachmentListParams, type AuditLogEntry, type AuditLogListParams, type AutomationAction, type AutomationCondition, type AutomationConditions, type AutomationCreateParams, type AutomationExecution, type AutomationExecutionListParams, type AutomationListParams, type AutomationRule, type AutomationTestResult, type AutomationUpdateParams, type BillingPortal, type BillingPortalParams, type Boss, type BossDamageParams, type BossDamageResult, type BossDefeat, type BossDefeatListParams, type BossSpawnParams, type BulkDeleteParams, type BulkResult, type BulkUpdateParams, type BusinessHours, type BusinessHoursUpdateParams, CStarAuthenticationError, CStarClient, type CStarClientConfig, CStarConflictError, CStarError, CStarFeatureDisabledError, CStarNotFoundError, CStarPermissionError, CStarRateLimitError, CStarRealtime, CStarServerError, CStarValidationError, type Category, type CategoryCreateParams, type CategoryListParams, type CategoryUpdateParams, type CommunityComment, type CommunityCommentCreateParams, type CommunityPost, type CommunityPostCreateParams, type CommunityPostListParams, type CommunityPostUpdateParams, type CommunityTopic, type ConnectionHandler, type Cosmetic, type CosmeticPreferences, type CsatSettings, type CsatSettingsUpdateParams, type CsatStats, type CsatSurvey, type CsatSurveyCreateParams, type CsatSurveyListParams, type CustomField, type CustomFieldCreateParams, type CustomFieldListParams, type CustomFieldUpdateParams, type Customer, type CustomerCreateParams, type CustomerGroup, type CustomerGroupAddMembersParams, type CustomerGroupAddResult, type CustomerGroupCreateParams, type CustomerGroupListParams, type CustomerGroupMemberListParams, type CustomerGroupMembersResult, type CustomerGroupRemoveResult, type CustomerGroupUpdateParams, type CustomerListParams, type CustomerUpdateParams, type DeleteResponse, type ErrorHandler, ErrorType, type EventHandler, type ExportCreateParams, type ExportResult, type GameConfig, type HighFive, type HighFiveCanSend, type HighFiveCreateParams, type HighFiveListParams, type ImportCreateParams, type ImportLog, type ImportLogListParams, type ImportResult, type Invite, type InviteCreateParams, type InviteListParams, type LeaderboardEntry, type LeaderboardParams, type ListResponse, type Member, type MemberListParams, type MemberUpdateParams, type Mention, type MentionListParams, type MentionUnreadCount, type Message, type MessageCreateParams, type Metadata, type Notification, type NotificationListParams, OfflineQueue, type OfflineQueueOptions, type OneUp, type OneUpCreateParams, type OneUpListParams, type OneUpRemaining, type PaginationInfo, type PaginationParams, type Player, type Puzzle, type PuzzleCompleteParams, type PuzzleCompleteResult, type PuzzleStreak, type Quest, type QueueItem, type QueueResult, type QuickReply, type QuickReplyCreateParams, type QuickReplyUpdateParams, type RealtimeEvent, type RealtimeOptions, type RequestOptions, type SavedView, type SearchParams, type SearchResult, type Season, type SeasonStats, type SkillAllocateParams, type SkillAllocateResult, type SkillTree, type SlaMetrics, type SlaMetricsParams, type SlaRule, type SlaRuleCreateParams, type SlaRuleListParams, type SlaRuleUpdateParams, type StatusCreateParams, type StatusUpdateParams, Subscription$1 as Subscription, type Tag, type TagListParams, type TeamSettings, type TeamSettingsUpdateParams, type Ticket, type TicketCreateParams, type TicketCustomerSummary, type TicketListParams, type TicketStatus, type TicketUpdateParams, type TopicCustomField, type UnreadCount, type ViewCreateParams, type ViewExecuteParams, type ViewListParams, type ViewUpdateParams, type Webhook, type WebhookCreateParams, type WebhookEvent, type WebhookEventData, type WebhookEventType, type WebhookListParams, type WebhookListener, type WebhookListenerParams, type WebhookSubscribeParams, type WebhookSubscription, type WebhookTestResult, type WebhookTriggerTestParams, type WebhookTriggerTestResult, type WebhookUpdateParams, type WidgetSettings, type WidgetSettingsUpdateParams };
|