@cstar.help/js 0.16.0 → 0.17.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.
@@ -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,8 @@ declare class ChatClient {
374
319
  private teamId;
375
320
  private customerId;
376
321
  private authMode;
377
- private pollingTimers;
322
+ private sessionGeneration;
323
+ private pollingSubscriptions;
378
324
  private stateListeners;
379
325
  private realtimeManager;
380
326
  private presenceManager;
@@ -384,6 +330,8 @@ declare class ChatClient {
384
330
  readonly tickets: TicketsApi;
385
331
  /** Sub-resource for managing messages. */
386
332
  readonly messages: MessagesApi;
333
+ /** Authenticated downloads of files on this customer's public messages. */
334
+ readonly attachments: AttachmentsApi;
387
335
  /** Sub-resource for community actions (create posts, vote, comment). Uses the same session as chat. */
388
336
  readonly community: ChatCommunityApi;
389
337
  constructor(config: ChatConfig);
@@ -418,6 +366,7 @@ declare class ChatClient {
418
366
  * every request — there is no client-side validation here.
419
367
  */
420
368
  loginWithSession(params: LoginWithSessionParams): Promise<void>;
369
+ private applySession;
421
370
  /**
422
371
  * Subscribe to client state changes (auth mode flips, identify, disconnect).
423
372
  * Fires after the mutation, so listeners reading `getAuthMode()` /
@@ -456,6 +405,10 @@ declare class ChatClient {
456
405
  sendTyping(ticketId: string, isTyping: boolean): Promise<void>;
457
406
  /** Disconnect all subscriptions and clean up. */
458
407
  disconnect(): void;
408
+ private retireSession;
409
+ private assertSession;
410
+ /** @internal Keep a public operation owned across its asynchronous prerequisites. */
411
+ captureSession(): () => void;
459
412
  /**
460
413
  * @internal Make an authenticated request to the widget API.
461
414
  *
@@ -472,6 +425,9 @@ declare class ChatClient {
472
425
  method: string;
473
426
  body?: unknown;
474
427
  query?: Record<string, string | undefined>;
428
+ signal?: AbortSignal;
429
+ cache?: RequestCache;
430
+ readBody?: (response: Response) => Promise<T>;
475
431
  }): Promise<T>;
476
432
  /**
477
433
  * Look up the team UUID from the configured `teamSlug`. Used by
@@ -496,7 +452,7 @@ declare class ChatClient {
496
452
  * `"Missing teamId"` when the chat client was teamSlug-only because the
497
453
  * tickets sub-resource read `getTeamId()` synchronously and bailed.
498
454
  */
499
- ensureTeamId(): Promise<string>;
455
+ ensureTeamId(signal?: AbortSignal): Promise<string>;
500
456
  /** @internal Set team ID from identify response or other source. */
501
457
  setTeamId(teamId: string): void;
502
458
  /** @internal Wait for realtime to be initialized (for testing). */
@@ -553,4 +509,4 @@ declare class MessagesApi {
553
509
  send(ticketId: string, content: string): Promise<Message>;
554
510
  }
555
511
 
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 };
512
+ 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,8 @@ declare class ChatClient {
374
319
  private teamId;
375
320
  private customerId;
376
321
  private authMode;
377
- private pollingTimers;
322
+ private sessionGeneration;
323
+ private pollingSubscriptions;
378
324
  private stateListeners;
379
325
  private realtimeManager;
380
326
  private presenceManager;
@@ -384,6 +330,8 @@ declare class ChatClient {
384
330
  readonly tickets: TicketsApi;
385
331
  /** Sub-resource for managing messages. */
386
332
  readonly messages: MessagesApi;
333
+ /** Authenticated downloads of files on this customer's public messages. */
334
+ readonly attachments: AttachmentsApi;
387
335
  /** Sub-resource for community actions (create posts, vote, comment). Uses the same session as chat. */
388
336
  readonly community: ChatCommunityApi;
389
337
  constructor(config: ChatConfig);
@@ -418,6 +366,7 @@ declare class ChatClient {
418
366
  * every request — there is no client-side validation here.
419
367
  */
420
368
  loginWithSession(params: LoginWithSessionParams): Promise<void>;
369
+ private applySession;
421
370
  /**
422
371
  * Subscribe to client state changes (auth mode flips, identify, disconnect).
423
372
  * Fires after the mutation, so listeners reading `getAuthMode()` /
@@ -456,6 +405,10 @@ declare class ChatClient {
456
405
  sendTyping(ticketId: string, isTyping: boolean): Promise<void>;
457
406
  /** Disconnect all subscriptions and clean up. */
458
407
  disconnect(): void;
408
+ private retireSession;
409
+ private assertSession;
410
+ /** @internal Keep a public operation owned across its asynchronous prerequisites. */
411
+ captureSession(): () => void;
459
412
  /**
460
413
  * @internal Make an authenticated request to the widget API.
461
414
  *
@@ -472,6 +425,9 @@ declare class ChatClient {
472
425
  method: string;
473
426
  body?: unknown;
474
427
  query?: Record<string, string | undefined>;
428
+ signal?: AbortSignal;
429
+ cache?: RequestCache;
430
+ readBody?: (response: Response) => Promise<T>;
475
431
  }): Promise<T>;
476
432
  /**
477
433
  * Look up the team UUID from the configured `teamSlug`. Used by
@@ -496,7 +452,7 @@ declare class ChatClient {
496
452
  * `"Missing teamId"` when the chat client was teamSlug-only because the
497
453
  * tickets sub-resource read `getTeamId()` synchronously and bailed.
498
454
  */
499
- ensureTeamId(): Promise<string>;
455
+ ensureTeamId(signal?: AbortSignal): Promise<string>;
500
456
  /** @internal Set team ID from identify response or other source. */
501
457
  setTeamId(teamId: string): void;
502
458
  /** @internal Wait for realtime to be initialized (for testing). */
@@ -553,4 +509,4 @@ declare class MessagesApi {
553
509
  send(ticketId: string, content: string): Promise<Message>;
554
510
  }
555
511
 
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 };
512
+ 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 };