@docgenlab.com/chat-widget 0.2.4 → 0.4.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.
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,48 @@ export declare class WidgetClient {
27
27
  constructor(opts: ClientOptions);
28
28
  private headers;
29
29
  getAgent(): Promise<AgentInfo>;
30
+ /** Load a previous conversation's messages so the widget can show
31
+ * history after a refresh / re-open. The visitor-id header is the
32
+ * authorization — the backend only returns conversations owned by
33
+ * the requesting visitor on this agent. */
34
+ getConversation(conversationId: string): Promise<any>;
35
+ /** Reconstruct the ticket card that SHOULD currently be on the
36
+ * conversation, based on persisted state. Lets the widget restore
37
+ * raise-ticket / "already on it" / created cards after refresh.
38
+ * Returns kind=null when nothing should show. */
39
+ getTicketCardState(conversationId: string): Promise<{
40
+ kind: 'offer' | 'existing' | 'created' | null;
41
+ conversation_id: string | null;
42
+ connector_type?: string | null;
43
+ connector_name?: string | null;
44
+ ticket_id?: string | null;
45
+ external_ticket_number?: string | null;
46
+ external_url?: string | null;
47
+ status?: string | null;
48
+ }>;
30
49
  uploadImage(file: File): Promise<string>;
31
50
  /** Fetch a previously-uploaded image as a blob URL. Caller must
32
51
  * URL.revokeObjectURL() when done to avoid memory leaks. */
33
52
  fetchImage(imagePath: string): Promise<string>;
53
+ /** Raise a support ticket from a conversation. Requires explicit user
54
+ * consent — the widget only calls this after the user clicks the
55
+ * in-chat "Raise a ticket" chip. */
56
+ raiseTicket(conversationId: string, body: {
57
+ consent: boolean;
58
+ end_user_email?: string;
59
+ end_user_phone?: string;
60
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
61
+ /** Escape hatch from the "We're already on it" card — bypasses
62
+ * the duplicate guard so the user can raise a fresh ticket
63
+ * for a different issue even when a recent one is still open. */
64
+ force_new?: boolean;
65
+ }): Promise<TicketRef>;
66
+ /** List all tickets for THIS visitor on THIS agent. Used by the widget
67
+ * to hydrate ticket cards on conversation reload and to power the
68
+ * "Manage tickets" modal. Optionally filtered by conversation. */
69
+ listTickets(conversationId?: string): Promise<TicketRef[]>;
70
+ /** Fetch the latest status of a ticket the user raised. */
71
+ getTicket(ticketId: string, refresh?: boolean): Promise<TicketRef>;
34
72
  /** Fetch a video-source frame attached to a citation chunk.
35
73
  * Same auth pattern as fetchImage. */
36
74
  fetchSourceFrame(sourceId: string, framePath: string): Promise<string>;