@eloquentai/chat-sdk 0.34.4 → 0.35.0-dev.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.
@@ -0,0 +1,16 @@
1
+ import { EloquentAiApiClient } from './eloquent-ai-api-client';
2
+ import { AttachmentFile, AttachmentMimeType, AttachmentSelection, Message, MessageAttachment } from '../types/message';
3
+ export declare class AttachmentUploadError extends Error {
4
+ name: string;
5
+ }
6
+ export declare function toAttachmentUploadError(error: unknown, fileName: string): unknown;
7
+ export declare function selectAttachmentFiles(selectedFiles: AttachmentFile[], files: File[]): AttachmentSelection;
8
+ export declare function restoreAttachmentFiles(sentFiles: AttachmentFile[], currentFiles: AttachmentFile[]): AttachmentFile[];
9
+ export declare function getAttachmentSendError(error: unknown, sentFiles: AttachmentFile[]): string | null;
10
+ export declare function attachPreviewDisplayUrls(attachments: MessageAttachment[], attachmentFiles: AttachmentFile[]): MessageAttachment[];
11
+ export declare function signStoredAttachments(apiClient: Pick<EloquentAiApiClient, "getAttachmentUrls">, conversationId: string, messages: Message[]): Promise<Message[]>;
12
+ export declare function hasStoredAttachments(message: Message): boolean;
13
+ export declare function getAttachmentDisplayUrl(attachment: MessageAttachment): string | undefined;
14
+ export declare function revokeAttachmentDisplayUrls(messages: Message[]): void;
15
+ export declare function isImageAttachment(mimeType: AttachmentMimeType): boolean;
16
+ export declare function isStoredAttachmentUrl(url: string): boolean;
@@ -1,3 +1,4 @@
1
+ import { MessageAttachment, AttachmentUrls } from '../types/message';
1
2
  import { HttpClientConfig } from './http';
2
3
  export interface ConversationApiResponse {
3
4
  chat_id: string;
@@ -69,6 +70,8 @@ export interface BootResponse {
69
70
  clean_chat_button?: boolean | null;
70
71
  /** Auto-hide delay for the proactive message, in milliseconds. Always wins over the proactiveMessageHideDelay prop. */
71
72
  proactive_message_hide_delay?: number | null;
73
+ /** Let users attach images and PDFs to their messages. Always wins over the hasAttachments prop. */
74
+ attachments_enabled?: boolean | null;
72
75
  };
73
76
  }
74
77
  export declare class EloquentAiApiClient {
@@ -103,12 +106,19 @@ export declare class EloquentAiApiClient {
103
106
  }): Promise<CreateConversationApiResponse>;
104
107
  replyToConversation(options: {
105
108
  text: string;
109
+ attachments?: MessageAttachment[];
106
110
  conversationId: string;
107
111
  userId: string;
108
112
  deviceId: string;
109
113
  userName?: string;
110
114
  userData?: Record<string, string | number | boolean>;
111
115
  }): Promise<ConversationApiResponse>;
116
+ uploadAttachment(options: {
117
+ conversationId: string;
118
+ file: File;
119
+ onProgress: (progress: number) => void;
120
+ }): Promise<MessageAttachment>;
121
+ getAttachmentUrls(conversationId: string, urls: string[]): Promise<AttachmentUrls>;
112
122
  identifyUser(options: {
113
123
  conversationId: string;
114
124
  userId: string;
@@ -13,17 +13,19 @@ export interface HttpClientConfig {
13
13
  }
14
14
  export declare class HttpClient {
15
15
  private baseURL;
16
- private headers;
16
+ private appId;
17
17
  private region;
18
18
  private chatToken;
19
19
  constructor(config: HttpClientConfig);
20
20
  setRegion(region: string): void;
21
21
  setChatToken(token: string | null): void;
22
22
  getChatToken(): string | null;
23
+ private getAuthHeaders;
23
24
  private request;
24
25
  get<T>(url: string): Promise<T>;
25
26
  post<T, D>(url: string, data: D): Promise<T>;
26
27
  put<T, D>(url: string, data: D): Promise<T>;
28
+ upload(url: string, body: FormData, onProgress: (progress: number) => void): Promise<unknown>;
27
29
  /**
28
30
  * External GET request without default headers or credentials
29
31
  * Used for cross-origin requests that don't need authentication