@hivegpt/hiveai-angular 0.0.157 → 0.0.160

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('@angular/platform-browser'), require('rxjs'), require('rxjs/operators'), require('rxjs/webSocket'), require('@angular/common'), require('@angular/forms'), require('@angular/material/icon'), require('@angular/material/sidenav')) :
3
- typeof define === 'function' && define.amd ? define('@hivegpt/hiveai-angular', ['exports', '@angular/common/http', '@angular/core', '@angular/platform-browser', 'rxjs', 'rxjs/operators', 'rxjs/webSocket', '@angular/common', '@angular/forms', '@angular/material/icon', '@angular/material/sidenav'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hivegpt = global.hivegpt || {}, global.hivegpt['hiveai-angular'] = {}), global.ng.common.http, global.ng.core, global.ng.platformBrowser, global.rxjs, global.rxjs.operators, global.rxjs.webSocket, global.ng.common, global.ng.forms, global.ng.material.icon, global.ng.material.sidenav));
5
- }(this, (function (exports, http, i0, platformBrowser, rxjs, operators, webSocket, common, forms, icon, sidenav) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('@angular/platform-browser'), require('rxjs'), require('rxjs/operators'), require('ngx-socket-io'), require('@angular/common'), require('@angular/forms'), require('@angular/material/icon'), require('@angular/material/sidenav')) :
3
+ typeof define === 'function' && define.amd ? define('@hivegpt/hiveai-angular', ['exports', '@angular/common/http', '@angular/core', '@angular/platform-browser', 'rxjs', 'rxjs/operators', 'ngx-socket-io', '@angular/common', '@angular/forms', '@angular/material/icon', '@angular/material/sidenav'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hivegpt = global.hivegpt || {}, global.hivegpt['hiveai-angular'] = {}), global.ng.common.http, global.ng.core, global.ng.platformBrowser, global.rxjs, global.rxjs.operators, global.ngxSocketIo, global.ng.common, global.ng.forms, global.ng.material.icon, global.ng.material.sidenav));
5
+ }(this, (function (exports, http, i0, platformBrowser, rxjs, operators, ngxSocketIo, common, forms, icon, sidenav) { 'use strict';
6
6
 
7
7
  /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -521,6 +521,7 @@
521
521
  var ConversationService = /** @class */ (function () {
522
522
  function ConversationService() {
523
523
  this.storageKey = 'conversationKey';
524
+ this.userSepecificNotification = new rxjs.Subject();
524
525
  }
525
526
  ConversationService.prototype.generateKey = function () {
526
527
  var timestamp = Math.floor(new Date().getTime() / 1000).toString(16);
@@ -543,6 +544,13 @@
543
544
  this.ensureKeyExists(storageKey, key);
544
545
  return localStorage.getItem(storageKey);
545
546
  };
547
+ ConversationService.prototype.sendValidatedUserData = function (message) {
548
+ //console.log('lgging messages', message, new Date());\
549
+ this.userSepecificNotification.next(message);
550
+ };
551
+ ConversationService.prototype.getUserSpecificNotification = function () {
552
+ return this.userSepecificNotification.asObservable();
553
+ };
546
554
  return ConversationService;
547
555
  }());
548
556
  ConversationService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ConversationService_Factory() { return new ConversationService(); }, token: ConversationService, providedIn: "root" });
@@ -553,45 +561,89 @@
553
561
  ];
554
562
  ConversationService.ctorParameters = function () { return []; };
555
563
 
564
+ var NotificationSocket = /** @class */ (function (_super) {
565
+ __extends(NotificationSocket, _super);
566
+ function NotificationSocket() {
567
+ return _super.call(this, socketConfig) || this;
568
+ }
569
+ return NotificationSocket;
570
+ }(ngxSocketIo.Socket));
571
+ NotificationSocket.ɵprov = i0.ɵɵdefineInjectable({ factory: function NotificationSocket_Factory() { return new NotificationSocket(); }, token: NotificationSocket, providedIn: "root" });
572
+ NotificationSocket.decorators = [
573
+ { type: i0.Injectable, args: [{
574
+ providedIn: 'root' // This ensures the service is available across the application
575
+ },] }
576
+ ];
577
+ NotificationSocket.ctorParameters = function () { return []; };
578
+ var socketConfig = {
579
+ url: prod_environment.SocketUrl,
580
+ options: {
581
+ transports: ['websocket', 'polling'],
582
+ reconnection: true,
583
+ autoConnect: true,
584
+ upgrade: true,
585
+ reconnectionDelay: 1000,
586
+ reconnectionDelayMax: 5000,
587
+ reconnectionAttempts: Infinity
588
+ }
589
+ };
590
+
556
591
  var SocketService = /** @class */ (function () {
557
- function SocketService() {
558
- this.connect();
592
+ function SocketService(conversationService, notificationSocket) {
593
+ this.conversationService = conversationService;
594
+ this.notificationSocket = notificationSocket;
595
+ this.isCommonSocketInitialized = false;
596
+ this.isUserSpecificSocketInitialized = false;
597
+ this.isUserSpecificEventReleased = true;
598
+ this.messageQueue = [];
599
+ this.releaseInterval = 1000;
600
+ this.intervalSetup = false;
601
+ this.startReleasingMessages();
559
602
  }
560
- SocketService.prototype.connect = function () {
561
- var _this = this;
562
- var url = prod_environment;
563
- this.socket$ = webSocket.webSocket(url.SocketUrl);
564
- this.socket$.subscribe(function (message) { return _this.onMessage(message); }, function (err) { return console.error('WebSocket error', err); }, function () { return console.warn('WebSocket closed'); });
603
+ SocketService.prototype.isSocketInitialized = function (isCommon) {
604
+ return isCommon
605
+ ? this.isCommonSocketInitialized
606
+ : this.isUserSpecificSocketInitialized &&
607
+ !this.isUserSpecificEventReleased;
565
608
  };
566
- SocketService.prototype.onMessage = function (message) {
567
- console.log('Received message:', message);
568
- // Handle incoming messages
609
+ SocketService.prototype.disconnectSocketConnection = function () {
610
+ this.notificationSocket.disconnect();
569
611
  };
570
- SocketService.prototype.sendMessage = function (message) {
571
- this.socket$.next(message);
572
- };
573
- SocketService.prototype.close = function () {
574
- this.socket$.complete();
612
+ SocketService.prototype.registerUserSpecificHiveSocket = function (botId, conversation_id) {
613
+ var _this = this;
614
+ this.notificationSocket.emit('joinData', {
615
+ groupId: "Hive_AI_Notifs_" + botId + "_" + conversation_id,
616
+ });
617
+ this.notificationSocket
618
+ .fromEvent('commonNotification')
619
+ .subscribe(function (res) {
620
+ _this.conversationService.sendValidatedUserData(res);
621
+ });
575
622
  };
576
- SocketService.prototype.onEvent = function (eventName) {
623
+ SocketService.prototype.startReleasingMessages = function () {
577
624
  var _this = this;
578
- return new rxjs.Observable(function (observer) {
579
- _this.socket$.subscribe(function (message) {
580
- if (message.event === eventName) {
581
- observer.next(message.data);
625
+ if (!this.intervalSetup) {
626
+ setInterval(function () {
627
+ if (_this.messageQueue.length > 0) {
628
+ var message = _this.messageQueue.shift(); // Remove the first message from the queue
629
+ // this.campaignService.sendValidatedUserData(message);
582
630
  }
583
- });
584
- });
631
+ }, this.releaseInterval);
632
+ this.intervalSetup = true; // Prevents multiple intervals
633
+ }
585
634
  };
586
635
  return SocketService;
587
636
  }());
588
- SocketService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(); }, token: SocketService, providedIn: "root" });
637
+ SocketService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(i0.ɵɵinject(ConversationService), i0.ɵɵinject(NotificationSocket)); }, token: SocketService, providedIn: "root" });
589
638
  SocketService.decorators = [
590
639
  { type: i0.Injectable, args: [{
591
640
  providedIn: 'root'
592
641
  },] }
593
642
  ];
594
- SocketService.ctorParameters = function () { return []; };
643
+ SocketService.ctorParameters = function () { return [
644
+ { type: ConversationService },
645
+ { type: NotificationSocket }
646
+ ]; };
595
647
 
596
648
  var ChatDrawerComponent = /** @class */ (function () {
597
649
  function ChatDrawerComponent(cdr, http, sanitizer, elementRef, renderer, socketService, conversation
@@ -726,22 +778,27 @@
726
778
  this.fetchAgents();
727
779
  this.cdr.markForCheck();
728
780
  this.initializeSocketAndListen();
781
+ setTimeout(function () {
782
+ _this.listenSockets();
783
+ }, 200);
729
784
  };
730
- ChatDrawerComponent.prototype.initializeSocketAndListen = function () {
785
+ ChatDrawerComponent.prototype.initializeSocket = function () {
786
+ this.socketService.registerUserSpecificHiveSocket(this.botId, this.conversationKey);
787
+ };
788
+ ChatDrawerComponent.prototype.listenSockets = function () {
731
789
  var _this = this;
732
- this.eventSubscription = this.socketService.onEvent('webresult').subscribe(function (data) {
733
- console.log('Event received webresult:', data);
734
- _this.handleEvent(data, 'webresult');
735
- });
736
- this.eventSubscription = this.socketService.onEvent('answer').subscribe(function (data) {
737
- console.log('Event received answer:', data);
738
- _this.handleEvent(data, 'answer');
739
- });
740
- this.eventSubscription = this.socketService.onEvent('graph').subscribe(function (data) {
741
- console.log('Event received graph:', data);
742
- _this.handleEvent(data, 'graph');
790
+ this.eventSubscription = this.conversation
791
+ .getUserSpecificNotification()
792
+ .subscribe(function (res) {
793
+ console.log("Socket Data");
794
+ console.log(res);
795
+ }, function (err) {
796
+ _this.eventSubscription.unsubscribe();
797
+ console.error('Error in fetching data from socket');
743
798
  });
744
799
  };
800
+ ChatDrawerComponent.prototype.initializeSocketAndListen = function () {
801
+ };
745
802
  ChatDrawerComponent.prototype.handleEvent = function (data, type) {
746
803
  switch (type) {
747
804
  case 'webresult':
@@ -758,7 +815,7 @@
758
815
  if (this.eventSubscription) {
759
816
  this.eventSubscription.unsubscribe();
760
817
  }
761
- this.socketService.close();
818
+ //this.socketService.close();
762
819
  };
763
820
  ChatDrawerComponent.prototype.changeTemperature = function (newTemperature) {
764
821
  if (this.loading)
@@ -1882,8 +1939,9 @@
1882
1939
  exports.HiveGptModule = HiveGptModule;
1883
1940
  exports.ɵa = SocketService;
1884
1941
  exports.ɵb = ConversationService;
1885
- exports.ɵc = VideoPlayerComponent;
1886
- exports.ɵd = SafeHtmlPipe;
1942
+ exports.ɵc = NotificationSocket;
1943
+ exports.ɵd = VideoPlayerComponent;
1944
+ exports.ɵe = SafeHtmlPipe;
1887
1945
 
1888
1946
  Object.defineProperty(exports, '__esModule', { value: true });
1889
1947