@bangdb/web-sdk 1.0.10 → 1.0.12

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/README.md CHANGED
@@ -27,13 +27,13 @@ bun add @bangdb/web-sdk
27
27
 
28
28
  <script type="text/javascript">
29
29
  window.BangdbChatWidget.init({
30
- title: "Chat with AI",
31
30
  config: {
32
31
  apikey: "your-api-key",
33
32
  backendURL: "https://your-bangdb-instance.com:18080",
34
33
  resourceURL: "https://your-resource-service.com:18082",
35
34
  userid: "user-123",
36
35
  indexName: "my-index",
36
+ org: "your-org-id"
37
37
  },
38
38
  });
39
39
  </script>
@@ -55,13 +55,13 @@ export function Chat() {
55
55
  mountedRef.current = true;
56
56
 
57
57
  new ChatWidget({
58
- title: "Chat with AI",
59
58
  config: {
60
59
  apikey: "your-api-key",
61
60
  backendURL: "https://your-bangdb-instance.com:18080",
62
61
  resourceURL: "https://your-resource-service.com:18082",
63
62
  userid: "user-123",
64
63
  indexName: "my-index",
64
+ org: "your-org-id"
65
65
  },
66
66
  });
67
67
 
@@ -108,13 +108,13 @@ export function Chat() {
108
108
  mountedRef.current = true;
109
109
 
110
110
  new ChatWidget({
111
- title: "Chat with AI",
112
111
  config: {
113
112
  apikey: "your-api-key",
114
113
  backendURL: "https://your-bangdb-instance.com:18080",
115
114
  resourceURL: "https://your-resource-service.com:18082",
116
115
  userid: "user-123",
117
116
  indexName: "my-index",
117
+ org: "your-org-id"
118
118
  },
119
119
  });
120
120
 
@@ -171,13 +171,13 @@ export class ChatWidgetComponent implements AfterViewInit, OnDestroy {
171
171
  const { ChatWidget } = await import("@bangdb/web-sdk");
172
172
 
173
173
  this.widget = new ChatWidget({
174
- title: "Chat with AI",
175
174
  config: {
176
175
  apikey: "your-api-key",
177
176
  backendURL: "https://your-bangdb-instance.com:18080",
178
177
  resourceURL: "https://your-resource-service.com:18082",
179
178
  userid: "user-123",
180
179
  indexName: "my-index",
180
+ org: "your-org-id"
181
181
  },
182
182
  });
183
183
  }
@@ -209,12 +209,12 @@ export class AppComponent {}
209
209
 
210
210
  ### `ChatWidgetOptions`
211
211
 
212
- | Option | Type | Required | Description |
213
- |---------------|---------------|----------|--------------------------------------|
214
- | `config` | `ApiConfig` | ✅ | API connection settings |
215
- | `title` | `string` | ❌ | Chat header title |
216
- | `logo` | `string` | ❌ | URL to logo image shown in the header |
217
- | `colorTokens` | `ColorTokens` | ❌ | Override default theme colors |
212
+ | Option | Type | Required | Description |
213
+ |------------------|---------------|----------|---------------------------------------|
214
+ | `config` | `ApiConfig` | ✅ | API connection settings |
215
+ | `enableIndexing` | `boolean` | ❌ | Enables file indexing feature |
216
+ | `logo` | `string` | ❌ | URL to logo image shown in the header |
217
+ | `colorTokens` | `ColorTokens` | ❌ | Override default theme colors |
218
218
 
219
219
  ### `ApiConfig`
220
220
 
@@ -223,7 +223,8 @@ export class AppComponent {}
223
223
  | `apikey` | `string` | ✅ | BangDB API key |
224
224
  | `backendURL` | `string` | ✅ | BangDB backend service URL |
225
225
  | `resourceURL` | `string` | ✅ | BangDB resource service URL (for files/images) |
226
- | `userid` | `string` | ✅ | BangDB user account ID |
226
+ | `userid` | `string` | ✅ | BangDB user ID |
227
+ | `org` | `string` | ✅ | BangDB account ID |
227
228
  | `indexName` | `string` | ✅ | Vector index to query against |
228
229
 
229
230
  ---
package/dist/index.d.mts CHANGED
@@ -1,3 +1,18 @@
1
+ type FileStatus = "pending" | "downloading" | "uploading" | "embedding" | "done" | "error" | "warning";
2
+
3
+ interface FileState {
4
+ id: string;
5
+ name: string;
6
+ type: string;
7
+ sizeBytes?: number;
8
+ status: FileStatus;
9
+ metadata?: Record<string, any>;
10
+ error?: string | null;
11
+ errorSeverity?: "error" | "warning" | "success";
12
+ bucket_name?: string;
13
+ file?: File;
14
+ }
15
+
1
16
  type ColorTokens = {
2
17
  background: string;
3
18
  foreground: string;
@@ -24,11 +39,12 @@ type ApiConfig = {
24
39
  resourceURL: string;
25
40
  backendURL: string;
26
41
  userid: string;
42
+ org: string;
27
43
  indexName: string;
28
44
  };
29
45
  interface ChatWidgetOptions {
30
46
  colorTokens?: ColorTokens;
31
- title?: string;
47
+ enableIndexing?: boolean;
32
48
  config: ApiConfig;
33
49
  logo?: string;
34
50
  tools?: {
@@ -51,27 +67,56 @@ declare class ChatWidget {
51
67
  private chatUIEl;
52
68
  private chatAreaEl;
53
69
  private renderedMessageIds;
54
- private chatTitle;
55
70
  private logoUrl;
71
+ private closeAnimationTimeout;
72
+ private activePanelView;
73
+ private lastMode;
74
+ private sessionListRenderRequest;
75
+ private pendingFileBlobs;
76
+ private enableIndexing;
56
77
  constructor(options: ChatWidgetOptions);
57
78
  private mount;
58
79
  init(): Promise<void>;
80
+ private fetchSessionsFromApi;
81
+ private fetchSessionChatsFromApi;
82
+ private getClampedBubblePosition;
83
+ private getDefaultBubblePosition;
84
+ private resetRenderedMessages;
59
85
  private handleChatDataChange;
60
86
  private handleModeChange;
87
+ private renderPanelView;
88
+ private renderActiveSession;
89
+ private renderChatView;
90
+ private renderSessionList;
91
+ private syncPanelHeader;
92
+ private openSession;
93
+ private createNewSession;
94
+ private getSessionTitle;
95
+ private getActiveSessionTitle;
61
96
  /** Repositions the chat panel above/below/left/right based on where the bubble is on screen */
62
97
  private updatePanelPosition;
63
98
  createChatBubble(): HTMLElement;
64
99
  createChatUI(): HTMLElement;
100
+ sessionListLoadingView(): HTMLElement;
101
+ sessionListView(): HTMLElement;
65
102
  chatArea(): HTMLElement;
66
103
  loadingIndicator(): HTMLElement;
67
- userRequestMessage(query: string): HTMLElement;
104
+ private formatFileSize;
105
+ private getFileIconMarkup;
106
+ private getFileStatusText;
107
+ private isFileBusy;
108
+ private readonly allowedUploadFileTypes;
109
+ private getUploadAcceptValue;
110
+ private isAllowedUploadFile;
111
+ private createFileCard;
112
+ userRequestMessage(query?: string, files?: FileState[], logSid?: string): HTMLElement;
68
113
  aiResponseMessage(response: any): HTMLElement;
69
114
  private renderSourceTags;
70
115
  private renderTables;
71
116
  private renderImages;
117
+ private openFileUploadModal;
72
118
  chatQueryForm(): HTMLElement;
73
119
  sendQuery(): Promise<void>;
74
- downloadChat(): void;
75
120
  }
76
121
 
77
122
  declare function init(options: ChatWidgetOptions): ChatWidget;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,18 @@
1
+ type FileStatus = "pending" | "downloading" | "uploading" | "embedding" | "done" | "error" | "warning";
2
+
3
+ interface FileState {
4
+ id: string;
5
+ name: string;
6
+ type: string;
7
+ sizeBytes?: number;
8
+ status: FileStatus;
9
+ metadata?: Record<string, any>;
10
+ error?: string | null;
11
+ errorSeverity?: "error" | "warning" | "success";
12
+ bucket_name?: string;
13
+ file?: File;
14
+ }
15
+
1
16
  type ColorTokens = {
2
17
  background: string;
3
18
  foreground: string;
@@ -24,11 +39,12 @@ type ApiConfig = {
24
39
  resourceURL: string;
25
40
  backendURL: string;
26
41
  userid: string;
42
+ org: string;
27
43
  indexName: string;
28
44
  };
29
45
  interface ChatWidgetOptions {
30
46
  colorTokens?: ColorTokens;
31
- title?: string;
47
+ enableIndexing?: boolean;
32
48
  config: ApiConfig;
33
49
  logo?: string;
34
50
  tools?: {
@@ -51,27 +67,56 @@ declare class ChatWidget {
51
67
  private chatUIEl;
52
68
  private chatAreaEl;
53
69
  private renderedMessageIds;
54
- private chatTitle;
55
70
  private logoUrl;
71
+ private closeAnimationTimeout;
72
+ private activePanelView;
73
+ private lastMode;
74
+ private sessionListRenderRequest;
75
+ private pendingFileBlobs;
76
+ private enableIndexing;
56
77
  constructor(options: ChatWidgetOptions);
57
78
  private mount;
58
79
  init(): Promise<void>;
80
+ private fetchSessionsFromApi;
81
+ private fetchSessionChatsFromApi;
82
+ private getClampedBubblePosition;
83
+ private getDefaultBubblePosition;
84
+ private resetRenderedMessages;
59
85
  private handleChatDataChange;
60
86
  private handleModeChange;
87
+ private renderPanelView;
88
+ private renderActiveSession;
89
+ private renderChatView;
90
+ private renderSessionList;
91
+ private syncPanelHeader;
92
+ private openSession;
93
+ private createNewSession;
94
+ private getSessionTitle;
95
+ private getActiveSessionTitle;
61
96
  /** Repositions the chat panel above/below/left/right based on where the bubble is on screen */
62
97
  private updatePanelPosition;
63
98
  createChatBubble(): HTMLElement;
64
99
  createChatUI(): HTMLElement;
100
+ sessionListLoadingView(): HTMLElement;
101
+ sessionListView(): HTMLElement;
65
102
  chatArea(): HTMLElement;
66
103
  loadingIndicator(): HTMLElement;
67
- userRequestMessage(query: string): HTMLElement;
104
+ private formatFileSize;
105
+ private getFileIconMarkup;
106
+ private getFileStatusText;
107
+ private isFileBusy;
108
+ private readonly allowedUploadFileTypes;
109
+ private getUploadAcceptValue;
110
+ private isAllowedUploadFile;
111
+ private createFileCard;
112
+ userRequestMessage(query?: string, files?: FileState[], logSid?: string): HTMLElement;
68
113
  aiResponseMessage(response: any): HTMLElement;
69
114
  private renderSourceTags;
70
115
  private renderTables;
71
116
  private renderImages;
117
+ private openFileUploadModal;
72
118
  chatQueryForm(): HTMLElement;
73
119
  sendQuery(): Promise<void>;
74
- downloadChat(): void;
75
120
  }
76
121
 
77
122
  declare function init(options: ChatWidgetOptions): ChatWidget;