@docgenlab.com/chat-widget 0.2.4 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * X-DocGenLab-Key — the publishable key (server resolves to agent)
7
7
  * X-DocGenLab-Visitor-Id — a stable UUID minted in localStorage
8
8
  */
9
- import type { AgentInfo, StreamEvent } from './types';
9
+ import type { AgentInfo, StreamEvent, TicketRef } from './types';
10
10
  export interface ClientOptions {
11
11
  agentKey: string;
12
12
  apiBaseUrl: string;
@@ -27,10 +27,60 @@ export declare class WidgetClient {
27
27
  constructor(opts: ClientOptions);
28
28
  private headers;
29
29
  getAgent(): Promise<AgentInfo>;
30
+ /** List all conversations this visitor has had with this agent.
31
+ * Used by the "All chats" modal to let users browse + jump back
32
+ * to previous threads. Lightweight payload — message bodies are
33
+ * fetched on demand via getConversation when the user opens one. */
34
+ listConversations(): Promise<Array<{
35
+ id: string;
36
+ title: string | null;
37
+ preview: string | null;
38
+ message_count: number;
39
+ created_at: string | null;
40
+ updated_at: string | null;
41
+ }>>;
42
+ /** Load a previous conversation's messages so the widget can show
43
+ * history after a refresh / re-open. The visitor-id header is the
44
+ * authorization — the backend only returns conversations owned by
45
+ * the requesting visitor on this agent. */
46
+ getConversation(conversationId: string): Promise<any>;
47
+ /** Reconstruct the ticket card that SHOULD currently be on the
48
+ * conversation, based on persisted state. Lets the widget restore
49
+ * raise-ticket / "already on it" / created cards after refresh.
50
+ * Returns kind=null when nothing should show. */
51
+ getTicketCardState(conversationId: string): Promise<{
52
+ kind: 'offer' | 'existing' | 'created' | null;
53
+ conversation_id: string | null;
54
+ connector_type?: string | null;
55
+ connector_name?: string | null;
56
+ ticket_id?: string | null;
57
+ external_ticket_number?: string | null;
58
+ external_url?: string | null;
59
+ status?: string | null;
60
+ }>;
30
61
  uploadImage(file: File): Promise<string>;
31
62
  /** Fetch a previously-uploaded image as a blob URL. Caller must
32
63
  * URL.revokeObjectURL() when done to avoid memory leaks. */
33
64
  fetchImage(imagePath: string): Promise<string>;
65
+ /** Raise a support ticket from a conversation. Requires explicit user
66
+ * consent — the widget only calls this after the user clicks the
67
+ * in-chat "Raise a ticket" chip. */
68
+ raiseTicket(conversationId: string, body: {
69
+ consent: boolean;
70
+ end_user_email?: string;
71
+ end_user_phone?: string;
72
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
73
+ /** Escape hatch from the "We're already on it" card — bypasses
74
+ * the duplicate guard so the user can raise a fresh ticket
75
+ * for a different issue even when a recent one is still open. */
76
+ force_new?: boolean;
77
+ }): Promise<TicketRef>;
78
+ /** List all tickets for THIS visitor on THIS agent. Used by the widget
79
+ * to hydrate ticket cards on conversation reload and to power the
80
+ * "Manage tickets" modal. Optionally filtered by conversation. */
81
+ listTickets(conversationId?: string): Promise<TicketRef[]>;
82
+ /** Fetch the latest status of a ticket the user raised. */
83
+ getTicket(ticketId: string, refresh?: boolean): Promise<TicketRef>;
34
84
  /** Fetch a video-source frame attached to a citation chunk.
35
85
  * Same auth pattern as fetchImage. */
36
86
  fetchSourceFrame(sourceId: string, framePath: string): Promise<string>;