@epam/ai-dial-overlay 0.31.0-rc.9 → 0.31.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/README.md CHANGED
@@ -67,6 +67,15 @@ const run = async () => {
67
67
  overlayConversationId: 'some-conversation-id',
68
68
  // optional, if DIAL should redirect to sign in the same browser window
69
69
  signInInSameWindow: false,
70
+ // optional, auto-sign in options
71
+ signInOptions: {
72
+ // optional, If the DIAL should automatically sign in without user interaction (provided there is an active provider session)
73
+ autoSignIn: true,
74
+ //provider which will be used for the sign in
75
+ signInProvider: 'provider_name',
76
+ //optional, should be true if provider page couldn't be open in iframe and hostDomain and DIAL have different providers or application id within one provider
77
+ signInInNewWindow: true,
78
+ },
70
79
  });
71
80
 
72
81
  // overlay loaded application and ready to send and receive information from the application
package/index.esm.js CHANGED
@@ -276,6 +276,15 @@ class ChatOverlay {
276
276
  return this.send(OverlayRequests.getConversations);
277
277
  });
278
278
  }
279
+ /**
280
+ * Get all selected conversations
281
+ * @returns {OverlayConversation[]} all selected conversations visible in chat
282
+ */
283
+ getSelectedConversations() {
284
+ return __awaiter(this, void 0, void 0, function* () {
285
+ return this.send(OverlayRequests.getSelectedConversations);
286
+ });
287
+ }
279
288
  /**
280
289
  * Select conversation
281
290
  * @param {string} id - id of conversation to select
@@ -289,19 +298,97 @@ class ChatOverlay {
289
298
  return this.send(OverlayRequests.selectConversation, request);
290
299
  });
291
300
  }
301
+ /**
302
+ * Delete conversation
303
+ * @param {string} id - id of conversation to delete
304
+ */
305
+ deleteConversation(id) {
306
+ return __awaiter(this, void 0, void 0, function* () {
307
+ const request = {
308
+ id,
309
+ };
310
+ return this.send(OverlayRequests.deleteConversation, request);
311
+ });
312
+ }
313
+ /**
314
+ * Rename conversation
315
+ * @param {string} id - id of conversation to rename
316
+ * @param {string} newName - new name of conversation
317
+ * @returns Returns renamed conversation info
318
+ */
319
+ renameConversation(id, newName) {
320
+ return __awaiter(this, void 0, void 0, function* () {
321
+ const request = {
322
+ id,
323
+ newName,
324
+ };
325
+ return this.send(OverlayRequests.renameConversation, request);
326
+ });
327
+ }
328
+ /**
329
+ * Create playback conversation
330
+ * @param {string} id - id of conversation from create playback
331
+ * @returns Returns newly created playback conversation info
332
+ */
333
+ createPlaybackConversation(id) {
334
+ return __awaiter(this, void 0, void 0, function* () {
335
+ const request = {
336
+ id,
337
+ };
338
+ return this.send(OverlayRequests.createPlaybackConversation, request);
339
+ });
340
+ }
341
+ /**
342
+ * Export conversation
343
+ * @param {string} id - id of conversation to export
344
+ * @returns Returns exported conversation object
345
+ */
346
+ exportConversation(id) {
347
+ return __awaiter(this, void 0, void 0, function* () {
348
+ const request = {
349
+ id,
350
+ };
351
+ return this.send(OverlayRequests.exportConversation, request);
352
+ });
353
+ }
354
+ /**
355
+ * Import conversation
356
+ * @param {LatestExportConversationsFormat} importedConversation - conversation object to import
357
+ * @returns Returns imported conversation info
358
+ */
359
+ importConversation(importedConversation) {
360
+ return __awaiter(this, void 0, void 0, function* () {
361
+ const request = {
362
+ importConversation: importedConversation,
363
+ };
364
+ return this.send(OverlayRequests.importConversation, request);
365
+ });
366
+ }
292
367
  /**
293
368
  * Create conversation
294
369
  * @param {string} parentPath - path to create conversation in. If not defined or null conversation will be created in user Root
295
370
  * @returns Returns created conversation info
296
371
  */
297
- createConversation(parentPath) {
372
+ createConversation(parentPath, local) {
298
373
  return __awaiter(this, void 0, void 0, function* () {
299
374
  const request = {
300
375
  parentPath,
376
+ local,
301
377
  };
302
378
  return this.send(OverlayRequests.createConversation, request);
303
379
  });
304
380
  }
381
+ /**
382
+ * Create local conversation which will be not visible before first assistant message
383
+ *
384
+ * Note: after first assistant message local conversation will be saved in `newConversationsFolderId` option path, or in user Root if it's not defined or null
385
+ * @returns Returns created local conversation info
386
+ */
387
+ createLocalConversation() {
388
+ return __awaiter(this, void 0, void 0, function* () {
389
+ return this.send(OverlayRequests.createLocalConversation);
390
+ });
391
+ }
305
392
  /**
306
393
  * Send message into the first selected conversation
307
394
  * @param content {string} text of message that should be sent to the chat
@@ -574,44 +661,44 @@ class ChatOverlayManager {
574
661
  }
575
662
  /**
576
663
  * Destroys overlay with specified id and removes from this.overlays
577
- * @param id {string} id of overlay that should be deleted
664
+ * @param overlayId {string} id of overlay that should be deleted
578
665
  */
579
- removeOverlay(id) {
580
- const { overlay, container, toggleButton } = this.getOverlay(id);
666
+ removeOverlay(overlayId) {
667
+ const { overlay, container, toggleButton } = this.getOverlay(overlayId);
581
668
  overlay.destroy();
582
- this.overlays = this.overlays.filter(({ options }) => options.id !== id);
669
+ this.overlays = this.overlays.filter(({ options }) => options.id !== overlayId);
583
670
  document.body.removeChild(container);
584
671
  document.body.removeChild(toggleButton);
585
672
  }
586
- openFullscreen(id) {
587
- const { overlay } = this.getOverlay(id);
673
+ openFullscreen(overlayId) {
674
+ const { overlay } = this.getOverlay(overlayId);
588
675
  overlay.openFullscreen();
589
676
  }
590
677
  /**
591
678
  * Shows overlay with specified id
592
- * @param id {string} id of overlay that should be shown
679
+ * @param overlayId {string} id of overlay that should be shown
593
680
  */
594
- showOverlay(id) {
595
- const overlay = this.getOverlay(id);
681
+ showOverlay(overlayId) {
682
+ const overlay = this.getOverlay(overlayId);
596
683
  overlay.isHidden = false;
597
684
  overlay.container.style.transform = 'scale(1) translate(0, 0)';
598
685
  }
599
686
  /**
600
687
  * Hides overlay with specified id
601
- * @param id {string} id of overlay that should be hidden
688
+ * @param overlayId {string} id of overlay that should be hidden
602
689
  */
603
- hideOverlay(id) {
604
- const overlay = this.getOverlay(id);
690
+ hideOverlay(overlayId) {
691
+ const overlay = this.getOverlay(overlayId);
605
692
  overlay.isHidden = true;
606
693
  overlay.container.style.transform = `scale(1) ${overlay.position.transform}`;
607
694
  }
608
695
  /**
609
696
  * Checks the current viewport and updates position, styles if needed
610
- * @param id {string} id of overlay that should be updated
697
+ * @param overlayId {string} id of overlay that should be updated
611
698
  */
612
- updateOverlay(id) {
699
+ updateOverlay(overlayId) {
613
700
  var _a;
614
- const { container, options, isHidden } = this.getOverlay(id);
701
+ const { container, options, isHidden } = this.getOverlay(overlayId);
615
702
  const mobileHeight = `${window.innerHeight}px`;
616
703
  const isMobileView = this.isMobileView();
617
704
  const position = getPosition()[(_a = options.position) !== null && _a !== void 0 ? _a : 'right-bottom'];
@@ -634,60 +721,102 @@ class ChatOverlayManager {
634
721
  : options.height || defaultOverlayPlacementOptions.height,
635
722
  });
636
723
  }
637
- setSystemPrompt(id, systemPrompt) {
638
- const { overlay } = this.getOverlay(id);
724
+ setSystemPrompt(overlayId, systemPrompt) {
725
+ const { overlay } = this.getOverlay(overlayId);
639
726
  return overlay.setSystemPrompt(systemPrompt);
640
727
  }
641
- getMessages(id) {
728
+ getMessages(overlayId) {
642
729
  return __awaiter(this, void 0, void 0, function* () {
643
- const { overlay } = this.getOverlay(id);
730
+ const { overlay } = this.getOverlay(overlayId);
644
731
  return overlay.getMessages();
645
732
  });
646
733
  }
647
- sendMessage(id, content) {
734
+ sendMessage(overlayId, content) {
648
735
  return __awaiter(this, void 0, void 0, function* () {
649
- const { overlay } = this.getOverlay(id);
736
+ const { overlay } = this.getOverlay(overlayId);
650
737
  return overlay.sendMessage(content);
651
738
  });
652
739
  }
653
- getConversations(id) {
740
+ getConversations(overlayId) {
654
741
  return __awaiter(this, void 0, void 0, function* () {
655
- const { overlay } = this.getOverlay(id);
742
+ const { overlay } = this.getOverlay(overlayId);
656
743
  return overlay.getConversations();
657
744
  });
658
745
  }
659
- createConversation(id, parentPath) {
746
+ getSelectedConversations(overlayId) {
660
747
  return __awaiter(this, void 0, void 0, function* () {
661
- const { overlay } = this.getOverlay(id);
748
+ const { overlay } = this.getOverlay(overlayId);
749
+ return overlay.getSelectedConversations();
750
+ });
751
+ }
752
+ createConversation(overlayId, parentPath) {
753
+ return __awaiter(this, void 0, void 0, function* () {
754
+ const { overlay } = this.getOverlay(overlayId);
662
755
  return overlay.createConversation(parentPath);
663
756
  });
664
757
  }
665
- selectConversation(id, conversationId) {
758
+ createLocalConversation(overlayId) {
666
759
  return __awaiter(this, void 0, void 0, function* () {
667
- const { overlay } = this.getOverlay(id);
760
+ const { overlay } = this.getOverlay(overlayId);
761
+ return overlay.createLocalConversation();
762
+ });
763
+ }
764
+ selectConversation(overlayId, conversationId) {
765
+ return __awaiter(this, void 0, void 0, function* () {
766
+ const { overlay } = this.getOverlay(overlayId);
668
767
  return overlay.selectConversation(conversationId);
669
768
  });
670
769
  }
671
- setOverlayOptions(id, options) {
770
+ renameConversation(overlayId, conversationId, newName) {
771
+ return __awaiter(this, void 0, void 0, function* () {
772
+ const { overlay } = this.getOverlay(overlayId);
773
+ return overlay.renameConversation(conversationId, newName);
774
+ });
775
+ }
776
+ setOverlayOptions(overlayId, options) {
672
777
  return __awaiter(this, void 0, void 0, function* () {
673
- const { overlay } = this.getOverlay(id);
778
+ const { overlay } = this.getOverlay(overlayId);
674
779
  return overlay.setOverlayOptions(options);
675
780
  });
676
781
  }
677
- subscribe(id, eventType, callback) {
678
- const { overlay } = this.getOverlay(id);
782
+ deleteConversation(overlayId, conversationId) {
783
+ return __awaiter(this, void 0, void 0, function* () {
784
+ const { overlay } = this.getOverlay(overlayId);
785
+ return overlay.deleteConversation(conversationId);
786
+ });
787
+ }
788
+ createPlaybackConversation(overlayId, conversationId) {
789
+ return __awaiter(this, void 0, void 0, function* () {
790
+ const { overlay } = this.getOverlay(overlayId);
791
+ return overlay.createPlaybackConversation(conversationId);
792
+ });
793
+ }
794
+ exportConversation(overlayId, conversationId) {
795
+ return __awaiter(this, void 0, void 0, function* () {
796
+ const { overlay } = this.getOverlay(overlayId);
797
+ return overlay.exportConversation(conversationId);
798
+ });
799
+ }
800
+ importConversation(overlayId, importedConversation) {
801
+ return __awaiter(this, void 0, void 0, function* () {
802
+ const { overlay } = this.getOverlay(overlayId);
803
+ return overlay.importConversation(importedConversation);
804
+ });
805
+ }
806
+ subscribe(overlayId, eventType, callback) {
807
+ const { overlay } = this.getOverlay(overlayId);
679
808
  return overlay.subscribe(eventType, callback);
680
809
  }
681
810
  /**
682
811
  * Get reference to overlay from this.overlay with specified id
683
812
  * Throws exception if there is no such overlay with specified id
684
- * @param id {string} id of overlay that should be returned
813
+ * @param overlayId {string} id of overlay that should be returned
685
814
  * @returns {Overlay} reference to overlay with specified id
686
815
  */
687
- getOverlay(id) {
688
- const overlay = this.overlays.find(({ options }) => options.id === id);
816
+ getOverlay(overlayId) {
817
+ const overlay = this.overlays.find(({ options }) => options.id === overlayId);
689
818
  if (!overlay)
690
- throw new Error(`There is no overlay with ${id}`);
819
+ throw new Error(`There is no overlay with ${overlayId}`);
691
820
  return overlay;
692
821
  }
693
822
  /**
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@epam/ai-dial-overlay",
3
3
  "description": "Package for opening dial in overlay",
4
4
  "homepage": "https://epam-rail.com",
5
- "version": "0.31.0-rc.9",
5
+ "version": "0.31.1",
6
6
  "dependencies": {
7
- "@epam/ai-dial-shared": "0.31.0-rc.9"
7
+ "@epam/ai-dial-shared": "0.31.1"
8
8
  },
9
9
  "type": "module",
10
10
  "bugs": {
@@ -1,4 +1,4 @@
1
- import { ChatOverlayOptions, CreateConversationResponse, DeferredRequest, GetConversationsResponse, GetMessagesResponse, OverlayRequest, OverlayRequests, SelectConversationResponse, SendMessageResponse, SetSystemPromptResponse, Styles, Task } from '@epam/ai-dial-shared';
1
+ import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, CreatePlaybackConversationResponse, DeferredRequest, ExportConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, ImportConversationResponse, LatestExportConversationsFormat, OverlayRequest, OverlayRequests, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetSystemPromptResponse, Styles, Task } from '@epam/ai-dial-shared';
2
2
  interface Subscription {
3
3
  eventType: string;
4
4
  callback: (payload: unknown) => void;
@@ -94,18 +94,60 @@ export declare class ChatOverlay {
94
94
  * @returns {OverlayConversation[]} all conversations visible in chat
95
95
  */
96
96
  getConversations(): Promise<GetConversationsResponse>;
97
+ /**
98
+ * Get all selected conversations
99
+ * @returns {OverlayConversation[]} all selected conversations visible in chat
100
+ */
101
+ getSelectedConversations(): Promise<GetSelectedConversationsResponse>;
97
102
  /**
98
103
  * Select conversation
99
104
  * @param {string} id - id of conversation to select
100
105
  * @returns Returns selected conversation info
101
106
  */
102
107
  selectConversation(id: string): Promise<SelectConversationResponse>;
108
+ /**
109
+ * Delete conversation
110
+ * @param {string} id - id of conversation to delete
111
+ */
112
+ deleteConversation(id: string): Promise<void>;
113
+ /**
114
+ * Rename conversation
115
+ * @param {string} id - id of conversation to rename
116
+ * @param {string} newName - new name of conversation
117
+ * @returns Returns renamed conversation info
118
+ */
119
+ renameConversation(id: string, newName: string): Promise<RenameConversationResponse>;
120
+ /**
121
+ * Create playback conversation
122
+ * @param {string} id - id of conversation from create playback
123
+ * @returns Returns newly created playback conversation info
124
+ */
125
+ createPlaybackConversation(id: string): Promise<CreatePlaybackConversationResponse>;
126
+ /**
127
+ * Export conversation
128
+ * @param {string} id - id of conversation to export
129
+ * @returns Returns exported conversation object
130
+ */
131
+ exportConversation(id: string): Promise<ExportConversationResponse>;
132
+ /**
133
+ * Import conversation
134
+ * @param {LatestExportConversationsFormat} importedConversation - conversation object to import
135
+ * @returns Returns imported conversation info
136
+ */
137
+ importConversation(importedConversation: LatestExportConversationsFormat): Promise<ImportConversationResponse>;
103
138
  /**
104
139
  * Create conversation
105
140
  * @param {string} parentPath - path to create conversation in. If not defined or null conversation will be created in user Root
106
141
  * @returns Returns created conversation info
107
142
  */
108
- createConversation(parentPath?: string | null): Promise<CreateConversationResponse>;
143
+ createConversation(parentPath?: string | null, local?: boolean | null): Promise<CreateConversationResponse>;
144
+ /**
145
+ * Create local conversation which will be not visible before first assistant message
146
+ *
147
+ * Note: after first assistant message local conversation will be saved in `newConversationsFolderId` option path, or in user Root if it's not defined or null
148
+ * @returns Returns created local conversation info
149
+ */
150
+ createLocalConversation(): Promise<CreateLocalConversationResponse>;
109
151
  /**
110
152
  * Send message into the first selected conversation
111
153
  * @param content {string} text of message that should be sent to the chat
@@ -1,5 +1,5 @@
1
1
  import { ChatOverlay } from './ChatOverlay';
2
- import { ChatOverlayOptions } from '@epam/ai-dial-shared';
2
+ import { ChatOverlayOptions, LatestExportConversationsFormat } from '@epam/ai-dial-shared';
3
3
  export type OverlayPosition = 'left-bottom' | 'left-top' | 'right-bottom' | 'right-top';
4
4
  export interface Position {
5
5
  top: string;
@@ -64,40 +64,47 @@ export declare class ChatOverlayManager {
64
64
  createCloseButton(): HTMLButtonElement;
65
65
  /**
66
66
  * Destroys overlay with specified id and removes from this.overlays
67
- * @param id {string} id of overlay that should be deleted
67
+ * @param overlayId {string} id of overlay that should be deleted
68
68
  */
69
- removeOverlay(id: string): void;
70
- openFullscreen(id: string): void;
69
+ removeOverlay(overlayId: string): void;
70
+ openFullscreen(overlayId: string): void;
71
71
  /**
72
72
  * Shows overlay with specified id
73
- * @param id {string} id of overlay that should be shown
73
+ * @param overlayId {string} id of overlay that should be shown
74
74
  */
75
- showOverlay(id: string): void;
75
+ showOverlay(overlayId: string): void;
76
76
  /**
77
77
  * Hides overlay with specified id
78
- * @param id {string} id of overlay that should be hidden
78
+ * @param overlayId {string} id of overlay that should be hidden
79
79
  */
80
- hideOverlay(id: string): void;
80
+ hideOverlay(overlayId: string): void;
81
81
  /**
82
82
  * Checks the current viewport and updates position, styles if needed
83
- * @param id {string} id of overlay that should be updated
83
+ * @param overlayId {string} id of overlay that should be updated
84
84
  */
85
- updateOverlay(id: string): void;
86
- setSystemPrompt(id: string, systemPrompt: string): Promise<void>;
87
- getMessages(id: string): Promise<import("@epam/ai-dial-shared").GetMessagesResponse>;
88
- sendMessage(id: string, content: string): Promise<void>;
89
- getConversations(id: string): Promise<import("@epam/ai-dial-shared").GetConversationsResponse>;
90
- createConversation(id: string, parentPath?: string | null): Promise<import("@epam/ai-dial-shared").CreateConversationResponse>;
91
- selectConversation(id: string, conversationId: string): Promise<import("@epam/ai-dial-shared").SelectConversationResponse>;
92
- setOverlayOptions(id: string, options: ChatOverlayOptions): Promise<void>;
93
- subscribe(id: string, eventType: string, callback: (payload?: unknown) => void): () => void;
85
+ updateOverlay(overlayId: string): void;
86
+ setSystemPrompt(overlayId: string, systemPrompt: string): Promise<void>;
87
+ getMessages(overlayId: string): Promise<import("@epam/ai-dial-shared").GetMessagesResponse>;
88
+ sendMessage(overlayId: string, content: string): Promise<void>;
89
+ getConversations(overlayId: string): Promise<import("@epam/ai-dial-shared").GetConversationsResponse>;
90
+ getSelectedConversations(overlayId: string): Promise<import("@epam/ai-dial-shared").GetSelectedConversationsResponse>;
91
+ createConversation(overlayId: string, parentPath?: string | null): Promise<import("@epam/ai-dial-shared").CreateConversationResponse>;
92
+ createLocalConversation(overlayId: string): Promise<import("@epam/ai-dial-shared").CreateLocalConversationResponse>;
93
+ selectConversation(overlayId: string, conversationId: string): Promise<import("@epam/ai-dial-shared").SelectConversationResponse>;
94
+ renameConversation(overlayId: string, conversationId: string, newName: string): Promise<import("@epam/ai-dial-shared").RenameConversationResponse>;
95
+ setOverlayOptions(overlayId: string, options: ChatOverlayOptions): Promise<void>;
96
+ deleteConversation(overlayId: string, conversationId: string): Promise<void>;
97
+ createPlaybackConversation(overlayId: string, conversationId: string): Promise<import("@epam/ai-dial-shared").CreatePlaybackConversationResponse>;
98
+ exportConversation(overlayId: string, conversationId: string): Promise<import("@epam/ai-dial-shared").ExportConversationResponse>;
99
+ importConversation(overlayId: string, importedConversation: LatestExportConversationsFormat): Promise<import("@epam/ai-dial-shared").ImportConversationResponse>;
100
+ subscribe(overlayId: string, eventType: string, callback: (payload?: unknown) => void): () => void;
94
101
  /**
95
102
  * Get reference to overlay from this.overlay with specified id
96
103
  * Throws exception if there is no such overlay with specified id
97
- * @param id {string} id of overlay that should be returned
104
+ * @param overlayId {string} id of overlay that should be returned
98
105
  * @returns {Overlay} reference to overlay with specified id
99
106
  */
100
- protected getOverlay(id: string): Overlay;
107
+ protected getOverlay(overlayId: string): Overlay;
101
108
  /**
102
109
  * Checks that window has mobile view
103
110
  * @returns {boolean} Returns true if window has mobile view