@cstar.help/js 0.16.1 → 0.17.2

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.
@@ -1,3 +1,5 @@
1
+ import { C as CommunityCreatePostParams, a as CommunityCreatedPost, b as CommunityUpdatePostParams, c as CommunityUpdateCommentParams, d as CommunityCreatedComment, e as CommunityVoteResult, f as CommunityCreateCommentParams, g as CommunityFollowResult } from '../types-DF7GprCV.cjs';
2
+
1
3
  /** Configuration for the ChatClient. */
2
4
  interface ChatConfig {
3
5
  /** Team slug (e.g., 'acme'). Used to identify the team. */
@@ -142,6 +144,25 @@ interface Message {
142
144
  /** Whether this message was sent by an AI agent. */
143
145
  is_bot?: boolean;
144
146
  }
147
+ /** A confirmed customer's message attachment. Never a Storage path or URL. */
148
+ interface CustomerAttachmentReference {
149
+ readonly ticketId: string;
150
+ readonly messageId: string;
151
+ readonly attachmentIndex: number;
152
+ }
153
+ interface AttachmentDownloadOptions {
154
+ signal?: AbortSignal;
155
+ /** Request download disposition by default; false allows supported preview types. */
156
+ download?: boolean;
157
+ }
158
+ /** Authenticated file bytes. The host owns any object URLs it creates for display. */
159
+ interface DownloadedAttachment {
160
+ blob: Blob;
161
+ filename: string;
162
+ contentType: string;
163
+ /** Actual downloaded byte count, not an unverified metadata size. */
164
+ size: number;
165
+ }
145
166
  /** Parameters for listing tickets. */
146
167
  interface TicketListParams {
147
168
  limit?: number;
@@ -163,87 +184,11 @@ type MessageCallback = (message: Message) => void;
163
184
  /** Callback for typing indicator events. */
164
185
  type TypingCallback = (payload: TypingPayload) => void;
165
186
 
166
- /** Attachment metadata for community posts and comments (images only, max 5MB each). */
167
- interface CommunityAttachment {
168
- filename: string;
169
- content_type: string;
170
- size_bytes: number;
171
- storage_path: string;
172
- }
173
- /** Parameters for creating a post as an identified customer. */
174
- interface CommunityCreatePostParams {
175
- /** Post title. */
176
- title: string;
177
- /** Post body/content (optional). */
178
- body?: string;
179
- /** Topic UUID to post in. */
180
- topicId: string;
181
- /** Custom field values keyed by field definition ID. */
182
- customFields?: Record<string, string>;
183
- /** Image attachments (max 10, images only, 5MB each). */
184
- attachments?: CommunityAttachment[];
185
- }
186
- /** Parameters for updating a post as the original author. */
187
- interface CommunityUpdatePostParams {
188
- /** Updated post title. */
189
- title?: string;
190
- /** Updated post body/content. */
191
- body?: string;
192
- /** Updated custom field values keyed by field definition ID. */
193
- customFields?: Record<string, string>;
194
- }
195
- /** Parameters for updating a comment as the original author. */
196
- interface CommunityUpdateCommentParams {
197
- /** Updated comment body text. */
198
- body: string;
199
- }
200
- /** Parameters for creating a comment as an identified customer. */
201
- interface CommunityCreateCommentParams {
202
- /** Comment body text. */
203
- body: string;
204
- /** Parent comment ID for replies (optional, 1-level nesting). */
205
- parentCommentId?: string | null;
206
- /** Image attachments (max 5, images only, 5MB each). */
207
- attachments?: CommunityAttachment[];
208
- }
209
- /** Response from creating a post. */
210
- interface CommunityCreatedPost {
211
- id: string;
212
- title: string;
213
- slug: string;
214
- body: string;
215
- status: string;
216
- visibility: string;
217
- voteCount: number;
218
- commentCount: number;
219
- customFields: Record<string, string>;
220
- topicName: string;
221
- topicSlug: string;
222
- authorName: string;
223
- authorAvatar: string;
224
- isTeamMember: boolean;
225
- createdAt: string;
226
- }
227
- /** Response from creating a comment. */
228
- interface CommunityCreatedComment {
229
- id: string;
230
- body: string;
231
- isOfficial: boolean;
232
- voteScore: number;
233
- parentCommentId: string | null;
234
- authorName: string;
235
- authorAvatar: string;
236
- isTeamMember: boolean;
237
- createdAt: string;
238
- }
239
- /** Response from toggling a vote. */
240
- interface CommunityVoteResult {
241
- voted: boolean;
242
- voteCount: number;
243
- }
244
- /** Response from toggling a follow. */
245
- interface CommunityFollowResult {
246
- following: boolean;
187
+ /** Customer file access through the authenticated saved-message boundary. */
188
+ declare class AttachmentsApi {
189
+ private readonly chat;
190
+ constructor(chat: ChatClient);
191
+ download(reference: CustomerAttachmentReference, options?: AttachmentDownloadOptions): Promise<DownloadedAttachment>;
247
192
  }
248
193
 
249
194
  /**
@@ -374,7 +319,9 @@ declare class ChatClient {
374
319
  private teamId;
375
320
  private customerId;
376
321
  private authMode;
377
- private pollingTimers;
322
+ private sessionGeneration;
323
+ private pollingSubscriptions;
324
+ private realtimeMessageSubscriptions;
378
325
  private stateListeners;
379
326
  private realtimeManager;
380
327
  private presenceManager;
@@ -384,6 +331,8 @@ declare class ChatClient {
384
331
  readonly tickets: TicketsApi;
385
332
  /** Sub-resource for managing messages. */
386
333
  readonly messages: MessagesApi;
334
+ /** Authenticated downloads of files on this customer's public messages. */
335
+ readonly attachments: AttachmentsApi;
387
336
  /** Sub-resource for community actions (create posts, vote, comment). Uses the same session as chat. */
388
337
  readonly community: ChatCommunityApi;
389
338
  constructor(config: ChatConfig);
@@ -418,6 +367,7 @@ declare class ChatClient {
418
367
  * every request — there is no client-side validation here.
419
368
  */
420
369
  loginWithSession(params: LoginWithSessionParams): Promise<void>;
370
+ private applySession;
421
371
  /**
422
372
  * Subscribe to client state changes (auth mode flips, identify, disconnect).
423
373
  * Fires after the mutation, so listeners reading `getAuthMode()` /
@@ -456,6 +406,10 @@ declare class ChatClient {
456
406
  sendTyping(ticketId: string, isTyping: boolean): Promise<void>;
457
407
  /** Disconnect all subscriptions and clean up. */
458
408
  disconnect(): void;
409
+ private retireSession;
410
+ private assertSession;
411
+ /** @internal Keep a public operation owned across its asynchronous prerequisites. */
412
+ captureSession(): () => void;
459
413
  /**
460
414
  * @internal Make an authenticated request to the widget API.
461
415
  *
@@ -472,6 +426,9 @@ declare class ChatClient {
472
426
  method: string;
473
427
  body?: unknown;
474
428
  query?: Record<string, string | undefined>;
429
+ signal?: AbortSignal;
430
+ cache?: RequestCache;
431
+ readBody?: (response: Response) => Promise<T>;
475
432
  }): Promise<T>;
476
433
  /**
477
434
  * Look up the team UUID from the configured `teamSlug`. Used by
@@ -487,16 +444,11 @@ declare class ChatClient {
487
444
  getTeamId(): string | null;
488
445
  /**
489
446
  * Resolve a team ID, lazily looking it up from `teamSlug` if no team ID
490
- * has been cached yet. Used by `tickets.list` and friends so that a
491
- * caller who constructed `new ChatClient({ teamSlug, publishableKey })`
492
- * doesn't have to manually call `loginWithCredentials` before reading
493
- * public data.
494
- *
495
- * Closes NEW-v3-05 — `TicketsState(chatClient)` previously errored
496
- * `"Missing teamId"` when the chat client was teamSlug-only because the
497
- * tickets sub-resource read `getTeamId()` synchronously and bailed.
447
+ * has been cached yet. Authenticated resources and realtime bootstrap
448
+ * use this after session login so callers do not need to list tickets
449
+ * or set a UUID before opening an existing conversation.
498
450
  */
499
- ensureTeamId(): Promise<string>;
451
+ ensureTeamId(signal?: AbortSignal): Promise<string>;
500
452
  /** @internal Set team ID from identify response or other source. */
501
453
  setTeamId(teamId: string): void;
502
454
  /** @internal Wait for realtime to be initialized (for testing). */
@@ -553,4 +505,4 @@ declare class MessagesApi {
553
505
  send(ticketId: string, content: string): Promise<Message>;
554
506
  }
555
507
 
556
- export { type ChatAuthMode, ChatClient, ChatClientAuthError, ChatClientError, ChatClientNetworkError, ChatClientRateLimitError, ChatClientServerError, type ChatConfig, type ChatStateListener, type IdentifyParams, type IdentifyResult, type LoginWithCredentialsParams, type LoginWithCredentialsResult, type LoginWithSessionParams, type Message, type MessageCallback, type RealtimeTokenResponse, type Ticket, type TicketCreateParams, type TicketListParams, type TicketListResponse, type TypingCallback, type TypingPayload };
508
+ export { type AttachmentDownloadOptions, type ChatAuthMode, ChatClient, ChatClientAuthError, ChatClientError, ChatClientNetworkError, ChatClientRateLimitError, ChatClientServerError, type ChatConfig, type ChatStateListener, type CustomerAttachmentReference, type DownloadedAttachment, type IdentifyParams, type IdentifyResult, type LoginWithCredentialsParams, type LoginWithCredentialsResult, type LoginWithSessionParams, type Message, type MessageCallback, type RealtimeTokenResponse, type Ticket, type TicketCreateParams, type TicketListParams, type TicketListResponse, type TypingCallback, type TypingPayload };
@@ -1,3 +1,5 @@
1
+ import { C as CommunityCreatePostParams, a as CommunityCreatedPost, b as CommunityUpdatePostParams, c as CommunityUpdateCommentParams, d as CommunityCreatedComment, e as CommunityVoteResult, f as CommunityCreateCommentParams, g as CommunityFollowResult } from '../types-DF7GprCV.js';
2
+
1
3
  /** Configuration for the ChatClient. */
2
4
  interface ChatConfig {
3
5
  /** Team slug (e.g., 'acme'). Used to identify the team. */
@@ -142,6 +144,25 @@ interface Message {
142
144
  /** Whether this message was sent by an AI agent. */
143
145
  is_bot?: boolean;
144
146
  }
147
+ /** A confirmed customer's message attachment. Never a Storage path or URL. */
148
+ interface CustomerAttachmentReference {
149
+ readonly ticketId: string;
150
+ readonly messageId: string;
151
+ readonly attachmentIndex: number;
152
+ }
153
+ interface AttachmentDownloadOptions {
154
+ signal?: AbortSignal;
155
+ /** Request download disposition by default; false allows supported preview types. */
156
+ download?: boolean;
157
+ }
158
+ /** Authenticated file bytes. The host owns any object URLs it creates for display. */
159
+ interface DownloadedAttachment {
160
+ blob: Blob;
161
+ filename: string;
162
+ contentType: string;
163
+ /** Actual downloaded byte count, not an unverified metadata size. */
164
+ size: number;
165
+ }
145
166
  /** Parameters for listing tickets. */
146
167
  interface TicketListParams {
147
168
  limit?: number;
@@ -163,87 +184,11 @@ type MessageCallback = (message: Message) => void;
163
184
  /** Callback for typing indicator events. */
164
185
  type TypingCallback = (payload: TypingPayload) => void;
165
186
 
166
- /** Attachment metadata for community posts and comments (images only, max 5MB each). */
167
- interface CommunityAttachment {
168
- filename: string;
169
- content_type: string;
170
- size_bytes: number;
171
- storage_path: string;
172
- }
173
- /** Parameters for creating a post as an identified customer. */
174
- interface CommunityCreatePostParams {
175
- /** Post title. */
176
- title: string;
177
- /** Post body/content (optional). */
178
- body?: string;
179
- /** Topic UUID to post in. */
180
- topicId: string;
181
- /** Custom field values keyed by field definition ID. */
182
- customFields?: Record<string, string>;
183
- /** Image attachments (max 10, images only, 5MB each). */
184
- attachments?: CommunityAttachment[];
185
- }
186
- /** Parameters for updating a post as the original author. */
187
- interface CommunityUpdatePostParams {
188
- /** Updated post title. */
189
- title?: string;
190
- /** Updated post body/content. */
191
- body?: string;
192
- /** Updated custom field values keyed by field definition ID. */
193
- customFields?: Record<string, string>;
194
- }
195
- /** Parameters for updating a comment as the original author. */
196
- interface CommunityUpdateCommentParams {
197
- /** Updated comment body text. */
198
- body: string;
199
- }
200
- /** Parameters for creating a comment as an identified customer. */
201
- interface CommunityCreateCommentParams {
202
- /** Comment body text. */
203
- body: string;
204
- /** Parent comment ID for replies (optional, 1-level nesting). */
205
- parentCommentId?: string | null;
206
- /** Image attachments (max 5, images only, 5MB each). */
207
- attachments?: CommunityAttachment[];
208
- }
209
- /** Response from creating a post. */
210
- interface CommunityCreatedPost {
211
- id: string;
212
- title: string;
213
- slug: string;
214
- body: string;
215
- status: string;
216
- visibility: string;
217
- voteCount: number;
218
- commentCount: number;
219
- customFields: Record<string, string>;
220
- topicName: string;
221
- topicSlug: string;
222
- authorName: string;
223
- authorAvatar: string;
224
- isTeamMember: boolean;
225
- createdAt: string;
226
- }
227
- /** Response from creating a comment. */
228
- interface CommunityCreatedComment {
229
- id: string;
230
- body: string;
231
- isOfficial: boolean;
232
- voteScore: number;
233
- parentCommentId: string | null;
234
- authorName: string;
235
- authorAvatar: string;
236
- isTeamMember: boolean;
237
- createdAt: string;
238
- }
239
- /** Response from toggling a vote. */
240
- interface CommunityVoteResult {
241
- voted: boolean;
242
- voteCount: number;
243
- }
244
- /** Response from toggling a follow. */
245
- interface CommunityFollowResult {
246
- following: boolean;
187
+ /** Customer file access through the authenticated saved-message boundary. */
188
+ declare class AttachmentsApi {
189
+ private readonly chat;
190
+ constructor(chat: ChatClient);
191
+ download(reference: CustomerAttachmentReference, options?: AttachmentDownloadOptions): Promise<DownloadedAttachment>;
247
192
  }
248
193
 
249
194
  /**
@@ -374,7 +319,9 @@ declare class ChatClient {
374
319
  private teamId;
375
320
  private customerId;
376
321
  private authMode;
377
- private pollingTimers;
322
+ private sessionGeneration;
323
+ private pollingSubscriptions;
324
+ private realtimeMessageSubscriptions;
378
325
  private stateListeners;
379
326
  private realtimeManager;
380
327
  private presenceManager;
@@ -384,6 +331,8 @@ declare class ChatClient {
384
331
  readonly tickets: TicketsApi;
385
332
  /** Sub-resource for managing messages. */
386
333
  readonly messages: MessagesApi;
334
+ /** Authenticated downloads of files on this customer's public messages. */
335
+ readonly attachments: AttachmentsApi;
387
336
  /** Sub-resource for community actions (create posts, vote, comment). Uses the same session as chat. */
388
337
  readonly community: ChatCommunityApi;
389
338
  constructor(config: ChatConfig);
@@ -418,6 +367,7 @@ declare class ChatClient {
418
367
  * every request — there is no client-side validation here.
419
368
  */
420
369
  loginWithSession(params: LoginWithSessionParams): Promise<void>;
370
+ private applySession;
421
371
  /**
422
372
  * Subscribe to client state changes (auth mode flips, identify, disconnect).
423
373
  * Fires after the mutation, so listeners reading `getAuthMode()` /
@@ -456,6 +406,10 @@ declare class ChatClient {
456
406
  sendTyping(ticketId: string, isTyping: boolean): Promise<void>;
457
407
  /** Disconnect all subscriptions and clean up. */
458
408
  disconnect(): void;
409
+ private retireSession;
410
+ private assertSession;
411
+ /** @internal Keep a public operation owned across its asynchronous prerequisites. */
412
+ captureSession(): () => void;
459
413
  /**
460
414
  * @internal Make an authenticated request to the widget API.
461
415
  *
@@ -472,6 +426,9 @@ declare class ChatClient {
472
426
  method: string;
473
427
  body?: unknown;
474
428
  query?: Record<string, string | undefined>;
429
+ signal?: AbortSignal;
430
+ cache?: RequestCache;
431
+ readBody?: (response: Response) => Promise<T>;
475
432
  }): Promise<T>;
476
433
  /**
477
434
  * Look up the team UUID from the configured `teamSlug`. Used by
@@ -487,16 +444,11 @@ declare class ChatClient {
487
444
  getTeamId(): string | null;
488
445
  /**
489
446
  * Resolve a team ID, lazily looking it up from `teamSlug` if no team ID
490
- * has been cached yet. Used by `tickets.list` and friends so that a
491
- * caller who constructed `new ChatClient({ teamSlug, publishableKey })`
492
- * doesn't have to manually call `loginWithCredentials` before reading
493
- * public data.
494
- *
495
- * Closes NEW-v3-05 — `TicketsState(chatClient)` previously errored
496
- * `"Missing teamId"` when the chat client was teamSlug-only because the
497
- * tickets sub-resource read `getTeamId()` synchronously and bailed.
447
+ * has been cached yet. Authenticated resources and realtime bootstrap
448
+ * use this after session login so callers do not need to list tickets
449
+ * or set a UUID before opening an existing conversation.
498
450
  */
499
- ensureTeamId(): Promise<string>;
451
+ ensureTeamId(signal?: AbortSignal): Promise<string>;
500
452
  /** @internal Set team ID from identify response or other source. */
501
453
  setTeamId(teamId: string): void;
502
454
  /** @internal Wait for realtime to be initialized (for testing). */
@@ -553,4 +505,4 @@ declare class MessagesApi {
553
505
  send(ticketId: string, content: string): Promise<Message>;
554
506
  }
555
507
 
556
- export { type ChatAuthMode, ChatClient, ChatClientAuthError, ChatClientError, ChatClientNetworkError, ChatClientRateLimitError, ChatClientServerError, type ChatConfig, type ChatStateListener, type IdentifyParams, type IdentifyResult, type LoginWithCredentialsParams, type LoginWithCredentialsResult, type LoginWithSessionParams, type Message, type MessageCallback, type RealtimeTokenResponse, type Ticket, type TicketCreateParams, type TicketListParams, type TicketListResponse, type TypingCallback, type TypingPayload };
508
+ export { type AttachmentDownloadOptions, type ChatAuthMode, ChatClient, ChatClientAuthError, ChatClientError, ChatClientNetworkError, ChatClientRateLimitError, ChatClientServerError, type ChatConfig, type ChatStateListener, type CustomerAttachmentReference, type DownloadedAttachment, type IdentifyParams, type IdentifyResult, type LoginWithCredentialsParams, type LoginWithCredentialsResult, type LoginWithSessionParams, type Message, type MessageCallback, type RealtimeTokenResponse, type Ticket, type TicketCreateParams, type TicketListParams, type TicketListResponse, type TypingCallback, type TypingPayload };