@senior-gestao-empresarial/angular-components 5.1.0 → 6.0.0

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.
Files changed (34) hide show
  1. package/bundles/senior-gestao-empresarial-angular-components.umd.js +118 -148
  2. package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
  3. package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +2 -2
  4. package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
  5. package/components/lookups/erp-lookups.d.ts +1 -0
  6. package/components/nps/index.d.ts +1 -0
  7. package/components/nps/nps.service.d.ts +4 -35
  8. package/components/nps/protocols/index.d.ts +3 -0
  9. package/components/nps/protocols/tenant-full-dto.d.ts +3 -0
  10. package/components/nps/protocols/token-senior-x.d.ts +14 -0
  11. package/components/nps/protocols/tracksale-request.d.ts +18 -0
  12. package/components/websocket/websocket.service.d.ts +42 -17
  13. package/esm2015/components/lookups/erp-lookups.js +14 -19
  14. package/esm2015/components/nps/index.js +1 -1
  15. package/esm2015/components/nps/nps.service.js +12 -9
  16. package/esm2015/components/nps/protocols/index.js +1 -0
  17. package/esm2015/components/nps/protocols/tenant-full-dto.js +1 -0
  18. package/esm2015/components/nps/protocols/token-senior-x.js +1 -0
  19. package/esm2015/components/nps/protocols/tracksale-request.js +1 -0
  20. package/esm2015/components/websocket/websocket.service.js +51 -58
  21. package/esm5/components/lookups/erp-lookups.js +15 -19
  22. package/esm5/components/nps/index.js +1 -1
  23. package/esm5/components/nps/nps.service.js +32 -23
  24. package/esm5/components/nps/protocols/index.js +1 -0
  25. package/esm5/components/nps/protocols/tenant-full-dto.js +1 -0
  26. package/esm5/components/nps/protocols/token-senior-x.js +1 -0
  27. package/esm5/components/nps/protocols/tracksale-request.js +1 -0
  28. package/esm5/components/websocket/websocket.service.js +72 -107
  29. package/fesm2015/senior-gestao-empresarial-angular-components.js +74 -83
  30. package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
  31. package/fesm5/senior-gestao-empresarial-angular-components.js +115 -145
  32. package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
  33. package/package.json +1 -1
  34. package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/breadcrumb'), require('@angular/router'), require('rxjs'), require('rxjs/operators'), require('moment'), require('@seniorsistemas/angular-components'), require('@angular/common/http'), require('primeng/api'), require('@ngx-translate/core'), require('@seniorsistemas/platform-components'), require('@seniorsistemas/senior-platform-data'), require('@angular/forms'), require('js-cookie'), require('@stomp/stompjs'), require('sockjs-client')) :
3
- typeof define === 'function' && define.amd ? define('@senior-gestao-empresarial/angular-components', ['exports', '@angular/core', '@angular/common', 'primeng/breadcrumb', '@angular/router', 'rxjs', 'rxjs/operators', 'moment', '@seniorsistemas/angular-components', '@angular/common/http', 'primeng/api', '@ngx-translate/core', '@seniorsistemas/platform-components', '@seniorsistemas/senior-platform-data', '@angular/forms', 'js-cookie', '@stomp/stompjs', 'sockjs-client'], factory) :
4
- (global = global || self, factory((global['senior-gestao-empresarial'] = global['senior-gestao-empresarial'] || {}, global['senior-gestao-empresarial']['angular-components'] = {}), global.ng.core, global.ng.common, global.breadcrumb, global.ng.router, global.rxjs, global.rxjs.operators, global.moment_, global.angularComponents, global.ng.common.http, global.api, global.core$1, global.platformComponents, global.seniorPlatformData, global.ng.forms, global.jsCookie, global.stompjs, global.SockJS));
5
- }(this, (function (exports, core, common, breadcrumb, router, rxjs, operators, moment_, angularComponents, http, api, core$1, platformComponents, seniorPlatformData, forms, jsCookie, stompjs, SockJS) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/breadcrumb'), require('@angular/router'), require('rxjs'), require('rxjs/operators'), require('moment'), require('@seniorsistemas/angular-components'), require('@angular/common/http'), require('primeng/api'), require('@ngx-translate/core'), require('@seniorsistemas/platform-components'), require('@seniorsistemas/senior-platform-data'), require('@angular/forms'), require('@stomp/stompjs'), require('js-cookie'), require('sockjs-client')) :
3
+ typeof define === 'function' && define.amd ? define('@senior-gestao-empresarial/angular-components', ['exports', '@angular/core', '@angular/common', 'primeng/breadcrumb', '@angular/router', 'rxjs', 'rxjs/operators', 'moment', '@seniorsistemas/angular-components', '@angular/common/http', 'primeng/api', '@ngx-translate/core', '@seniorsistemas/platform-components', '@seniorsistemas/senior-platform-data', '@angular/forms', '@stomp/stompjs', 'js-cookie', 'sockjs-client'], factory) :
4
+ (global = global || self, factory((global['senior-gestao-empresarial'] = global['senior-gestao-empresarial'] || {}, global['senior-gestao-empresarial']['angular-components'] = {}), global.ng.core, global.ng.common, global.breadcrumb, global.ng.router, global.rxjs, global.rxjs.operators, global.moment_, global.angularComponents, global.ng.common.http, global.api, global.core$1, global.platformComponents, global.seniorPlatformData, global.ng.forms, global.stompjs, global.jsCookie, global.SockJS));
5
+ }(this, (function (exports, core, common, breadcrumb, router, rxjs, operators, moment_, angularComponents, http, api, core$1, platformComponents, seniorPlatformData, forms, stompjs, jsCookie, SockJS) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -629,15 +629,7 @@
629
629
  }, this.entity, options.domain || this.domain, options.service || this.service)
630
630
  .pipe(operators.takeUntil(this.ngUnsubscribe))
631
631
  .pipe(operators.map(function (list) {
632
- return list.contents.map(function (item) { return (__assign(__assign({}, item), { label: lookupDisplayFields
633
- .map(function (field) {
634
- if (field.indexOf(".") > 0)
635
- return _this.getProp(item, field, prefix);
636
- return item[field] !== undefined && item[field] !== null
637
- ? item[field]
638
- : _this.translate.instant(prefix + ".empty_label");
639
- })
640
- .join(" - ") })); });
632
+ return list.contents.map(function (item) { return (__assign(__assign({}, item), { label: _this.getItemLabel(item, prefix, lookupDisplayFields) })); });
641
633
  }))
642
634
  .subscribe(function (data) {
643
635
  _this.lookupSuggestionsObservable.next(data);
@@ -706,21 +698,25 @@
706
698
  .list({ page: page, sort: sort, filterQuery: filterQuery, displayFields: displayFields }, this.entity, options.domain || this.domain, options.service || this.service)
707
699
  .pipe(operators.takeUntil(this.ngUnsubscribe))
708
700
  .pipe(operators.map(function (list) { return ({
709
- gridData: list.contents.map(function (item) { return (__assign(__assign({}, item), { label: lookupDisplayFields
710
- .map(function (field) {
711
- if (field.indexOf(".") > 0)
712
- return _this.getProp(item, field, prefix);
713
- return item[field] !== undefined && item[field] !== null
714
- ? item[field]
715
- : _this.translate.instant(prefix + ".empty_label");
716
- })
717
- .join(" - ") })); }),
701
+ gridData: list.contents.map(function (item) { return (__assign(__assign({}, item), { label: _this.getItemLabel(item, prefix, lookupDisplayFields) })); }),
718
702
  totalRecords: list.totalElements
719
703
  }); }))
720
704
  .subscribe(function (data) {
721
705
  _this.lookupSearchObservable.next(data);
722
706
  });
723
707
  };
708
+ ErpLookups.prototype.getItemLabel = function (item, prefix, lookupDisplayFields) {
709
+ var _this = this;
710
+ return lookupDisplayFields
711
+ .map(function (field) {
712
+ if (field.indexOf(".") > 0)
713
+ return _this.getProp(item, field, prefix);
714
+ return item[field] !== undefined && item[field] !== null
715
+ ? item[field]
716
+ : _this.translate.instant(prefix + ".empty_label");
717
+ })
718
+ .join(" - ");
719
+ };
724
720
  ErpLookups.ctorParameters = function () { return [
725
721
  { type: ErpLookupsService },
726
722
  { type: core$1.TranslateService },
@@ -6676,38 +6672,47 @@
6676
6672
  return UtilsModule;
6677
6673
  }());
6678
6674
 
6675
+ // https://widget.tracksale.co/
6679
6676
  var NpsService = /** @class */ (function () {
6680
6677
  function NpsService() {
6681
6678
  }
6682
- Object.defineProperty(NpsService.prototype, "cookieInformation", {
6683
- get: function () {
6684
- return JSON.parse(jsCookie.get("com.senior.pau.userdata") || "{}");
6685
- },
6686
- enumerable: true,
6687
- configurable: true
6688
- });
6679
+ NpsService.prototype.getUserInformation = function () {
6680
+ return __awaiter(this, void 0, void 0, function () {
6681
+ return __generator(this, function (_a) {
6682
+ switch (_a.label) {
6683
+ case 0: return [4 /*yield*/, seniorPlatformData.user.getToken()];
6684
+ case 1: return [2 /*return*/, _a.sent()];
6685
+ }
6686
+ });
6687
+ });
6688
+ };
6689
6689
  /**
6690
6690
  * Executa o serviço de NPS utilizando os dados do usuário atual, no caso sobreescrevendos os campos name, email, identification,
6691
6691
  * tags.tenant e tags.email fornecidos no request original. Esses serão sobreescritos com os valores retornados pelo cookie
6692
- * com.senior.pau.userdata. *
6692
+ * com.senior.pau.userdata.
6693
+ *
6693
6694
  * @param tracksaleRequest request que será enviado ao serviço de nps
6694
6695
  */
6695
6696
  NpsService.prototype.currentUserInitNPS = function (tracksaleRequest) {
6696
6697
  return __awaiter(this, void 0, void 0, function () {
6697
- var _a, tenantName, email, fullname, id, copyTracksaleRequest;
6698
+ var _a, tenantName, email, fullName, copyTracksaleRequest;
6698
6699
  return __generator(this, function (_b) {
6699
- _a = this.cookieInformation, tenantName = _a.tenantName, email = _a.email, fullname = _a.fullname, id = _a.id;
6700
- copyTracksaleRequest = __assign({}, tracksaleRequest);
6701
- copyTracksaleRequest.tags =
6702
- (tracksaleRequest.tags && __assign({}, tracksaleRequest.tags)) ||
6703
- {};
6704
- copyTracksaleRequest.name = fullname;
6705
- copyTracksaleRequest.email = email;
6706
- copyTracksaleRequest.identification = id;
6707
- copyTracksaleRequest.tags.tenant = tenantName;
6708
- copyTracksaleRequest.tags.email = email;
6709
- this.initNPS(copyTracksaleRequest);
6710
- return [2 /*return*/];
6700
+ switch (_b.label) {
6701
+ case 0: return [4 /*yield*/, this.getUserInformation()];
6702
+ case 1:
6703
+ _a = _b.sent(), tenantName = _a.tenantName, email = _a.email, fullName = _a.fullName;
6704
+ copyTracksaleRequest = __assign({}, tracksaleRequest);
6705
+ copyTracksaleRequest.tags =
6706
+ (tracksaleRequest.tags && __assign({}, tracksaleRequest.tags)) ||
6707
+ {};
6708
+ copyTracksaleRequest.name = fullName;
6709
+ copyTracksaleRequest.email = email;
6710
+ copyTracksaleRequest.identification = email;
6711
+ copyTracksaleRequest.tags.tenant = tenantName;
6712
+ copyTracksaleRequest.tags.email = email;
6713
+ this.initNPS(copyTracksaleRequest);
6714
+ return [2 /*return*/];
6715
+ }
6711
6716
  });
6712
6717
  });
6713
6718
  };
@@ -6753,14 +6758,23 @@
6753
6758
 
6754
6759
  var WebsocketService = /** @class */ (function () {
6755
6760
  function WebsocketService() {
6761
+ /** @private */
6756
6762
  this.focused = true;
6763
+ /** @private */
6757
6764
  this.wasConnected = false;
6765
+ /** @private */
6758
6766
  this.connected = false;
6767
+ /** @private */
6759
6768
  this.isConnecting = false;
6769
+ /** @private */
6760
6770
  this.primitiveManagers = new Map();
6771
+ /** @private */
6761
6772
  this.connect$ = new rxjs.Subject();
6773
+ /** @private */
6762
6774
  this.disconnect$ = new rxjs.Subject();
6775
+ /** @private */
6763
6776
  this.reconnect$ = new rxjs.Subject();
6777
+ /** @private */
6764
6778
  this.error$ = new rxjs.Subject();
6765
6779
  window.onfocus = this.onFocus;
6766
6780
  window.onblur = this.onBlur;
@@ -6802,18 +6816,19 @@
6802
6816
  return this.error$.asObservable();
6803
6817
  };
6804
6818
  /**
6805
- * Observable responsável por emitir uma notificação quando um evento é publicado.
6806
6819
  * @typeParam `<T>` Tipo do objeto que o retorno do `observable` vai devolver.
6807
- * @param domain Dominio da primitiva.
6808
- * @param service Service da primitiva.
6809
- * @param primitive Primitiva que será "observada" pelo client.
6810
- * @param identifierPath Caminho até a propriedade considerada o identificador do registro.
6811
- * @return Um `observable` que emite notificações toda vez que o respectivo evento é publicado no sistema.
6820
+ * @param {Object} options Objeto de configuração do evento.
6821
+ * @param {string} options.domain Domínio da primitiva.
6822
+ * @param {string} options.service Serviço da primitiva.
6823
+ * @param {string} options.primitive Primitiva que será "observada".
6824
+ * @return Um Observable<T> que emite notificações toda vez que o respectivo evento é publicado.
6812
6825
  */
6813
- WebsocketService.prototype.onEvent = function (domain, service, primitive, identifierPath) {
6826
+ WebsocketService.prototype.onEvent = function (options) {
6814
6827
  var _this = this;
6815
- if (this.primitiveManagers.has(primitive)) {
6816
- return this.primitiveManagers.get(primitive).subject.asObservable();
6828
+ var domain = options.domain, service = options.service, primitive = options.primitive;
6829
+ var key = this.getPrimitiveManagerKey(domain, service, primitive);
6830
+ if (this.primitiveManagers.has(key)) {
6831
+ return this.primitiveManagers.get(key).subject.asObservable();
6817
6832
  }
6818
6833
  var primitiveManager = {
6819
6834
  domain: domain,
@@ -6821,13 +6836,11 @@
6821
6836
  primitive: primitive,
6822
6837
  stompSubscriptions: [],
6823
6838
  subject: new rxjs.Subject(),
6824
- identifierPath: identifierPath,
6825
- publishedEvents: [],
6826
6839
  };
6827
- this.primitiveManagers.set(primitive, primitiveManager);
6840
+ this.primitiveManagers.set(key, primitiveManager);
6828
6841
  if (this.isConnected()) {
6829
6842
  this.createStompSubscriptions(primitiveManager);
6830
- return primitiveManager.subject.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitive); }));
6843
+ return primitiveManager.subject.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
6831
6844
  }
6832
6845
  else {
6833
6846
  if (!this.isConnecting) {
@@ -6836,53 +6849,10 @@
6836
6849
  this.connect$.pipe(operators.first()).subscribe(function () {
6837
6850
  _this.createStompSubscriptions(primitiveManager);
6838
6851
  });
6839
- return primitiveManager.subject.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitive); }));
6840
- }
6841
- };
6842
- /**
6843
- * Retorna todos os eventos ouvidos pela primitiva com os respectivos identificadores.
6844
- * @typeParam `<T>` Tipo do evento retornado pela primitiva.
6845
- * @param primitive Primitiva que será "observada" pelo client.
6846
- * @param identifiers Array com os identificadores interessados.
6847
- * @return Array contendo o último evento recebido de cada identificador fornecido.
6848
- */
6849
- WebsocketService.prototype.getPublishedEvents = function (primitive, identifiers) {
6850
- var e_1, _a;
6851
- var _this = this;
6852
- var publishedEvents = [];
6853
- var primitiveManager = this.primitiveManagers.get(primitive);
6854
- var _loop_1 = function (identifier) {
6855
- var event_1 = primitiveManager.publishedEvents.find(function (x) { return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier; });
6856
- if (event_1) {
6857
- publishedEvents.push(event_1);
6858
- }
6859
- };
6860
- try {
6861
- for (var identifiers_1 = __values(identifiers), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
6862
- var identifier = identifiers_1_1.value;
6863
- _loop_1(identifier);
6864
- }
6865
- }
6866
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6867
- finally {
6868
- try {
6869
- if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1.return)) _a.call(identifiers_1);
6870
- }
6871
- finally { if (e_1) throw e_1.error; }
6872
- }
6873
- return publishedEvents;
6874
- };
6875
- WebsocketService.prototype.addPublishedEvent = function (primitiveManager, event) {
6876
- var _this = this;
6877
- var identifier = this.getIdentifierFromEvent(primitiveManager.identifierPath, event);
6878
- var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) { return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier; });
6879
- if (eventIndex !== -1) {
6880
- primitiveManager.publishedEvents[eventIndex] = __assign(__assign({}, primitiveManager.publishedEvents[eventIndex]), event);
6881
- }
6882
- else {
6883
- primitiveManager.publishedEvents.push(event);
6852
+ return primitiveManager.subject.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
6884
6853
  }
6885
6854
  };
6855
+ /** @private */
6886
6856
  WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
6887
6857
  var withTokenUrl = this.getSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
6888
6858
  var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
@@ -6890,25 +6860,7 @@
6890
6860
  var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
6891
6861
  primitiveManager.stompSubscriptions = [stompSubscriptionWithToken, stompSubscriptionWithoutToken];
6892
6862
  };
6893
- WebsocketService.prototype.getIdentifierFromEvent = function (identifierPath, event) {
6894
- var e_2, _a;
6895
- var properties = identifierPath.split(".");
6896
- var identifier = event;
6897
- try {
6898
- for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
6899
- var property = properties_1_1.value;
6900
- identifier = identifier[property];
6901
- }
6902
- }
6903
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
6904
- finally {
6905
- try {
6906
- if (properties_1_1 && !properties_1_1.done && (_a = properties_1.return)) _a.call(properties_1);
6907
- }
6908
- finally { if (e_2) throw e_2.error; }
6909
- }
6910
- return identifier;
6911
- };
6863
+ /** @private */
6912
6864
  WebsocketService.prototype.connect = function () {
6913
6865
  var _this = this;
6914
6866
  this.createStompClient();
@@ -6931,14 +6883,16 @@
6931
6883
  _this.reconnect();
6932
6884
  });
6933
6885
  };
6886
+ /** @private */
6934
6887
  WebsocketService.prototype.onFocus = function () {
6935
6888
  this.focused = true;
6936
6889
  };
6890
+ /** @private */
6937
6891
  WebsocketService.prototype.onBlur = function () {
6938
6892
  this.focused = false;
6939
6893
  };
6940
6894
  WebsocketService.prototype.disconnect = function () {
6941
- var e_3, _a, e_4, _b, e_5, _c;
6895
+ var e_1, _a, e_2, _b, e_3, _c;
6942
6896
  var observersCount = this.getObserversCount();
6943
6897
  if (observersCount > 0)
6944
6898
  return;
@@ -6946,26 +6900,26 @@
6946
6900
  for (var _d = __values(this.primitiveManagers.values()), _e = _d.next(); !_e.done; _e = _d.next()) {
6947
6901
  var primitiveManager = _e.value;
6948
6902
  try {
6949
- for (var _f = (e_4 = void 0, __values(primitiveManager.stompSubscriptions)), _g = _f.next(); !_g.done; _g = _f.next()) {
6903
+ for (var _f = (e_2 = void 0, __values(primitiveManager.stompSubscriptions)), _g = _f.next(); !_g.done; _g = _f.next()) {
6950
6904
  var stompSubscription = _g.value;
6951
6905
  stompSubscription.unsubscribe();
6952
6906
  }
6953
6907
  }
6954
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
6908
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
6955
6909
  finally {
6956
6910
  try {
6957
6911
  if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
6958
6912
  }
6959
- finally { if (e_4) throw e_4.error; }
6913
+ finally { if (e_2) throw e_2.error; }
6960
6914
  }
6961
6915
  }
6962
6916
  }
6963
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
6917
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
6964
6918
  finally {
6965
6919
  try {
6966
6920
  if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
6967
6921
  }
6968
- finally { if (e_3) throw e_3.error; }
6922
+ finally { if (e_1) throw e_1.error; }
6969
6923
  }
6970
6924
  try {
6971
6925
  for (var _h = __values(this.primitiveManagers.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
@@ -6973,12 +6927,12 @@
6973
6927
  primitiveManager.subject.complete();
6974
6928
  }
6975
6929
  }
6976
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
6930
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
6977
6931
  finally {
6978
6932
  try {
6979
6933
  if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
6980
6934
  }
6981
- finally { if (e_5) throw e_5.error; }
6935
+ finally { if (e_3) throw e_3.error; }
6982
6936
  }
6983
6937
  this.primitiveManagers.clear();
6984
6938
  this._stompClient.disconnect();
@@ -6988,35 +6942,40 @@
6988
6942
  this.wasConnected = false;
6989
6943
  this.disconnect$.next();
6990
6944
  };
6945
+ /** @private */
6991
6946
  WebsocketService.prototype.isConnected = function () {
6992
6947
  return this.connected;
6993
6948
  };
6949
+ /** @private */
6994
6950
  WebsocketService.prototype.setConnected = function (connected) {
6995
6951
  this.connected = connected;
6996
6952
  };
6953
+ /** @private */
6997
6954
  WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
6998
6955
  var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
6999
6956
  var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
7000
6957
  return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
7001
6958
  };
6959
+ /** @private */
7002
6960
  WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
7003
6961
  var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
7004
6962
  return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
7005
6963
  };
6964
+ /** @private */
7006
6965
  WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
7007
- var _this = this;
7008
6966
  return this._stompClient.subscribe(destination, function (message) {
7009
6967
  var event = JSON.parse(message.body || "{}");
7010
- _this.addPublishedEvent(primitiveManager, event);
7011
6968
  primitiveManager.subject.next(event);
7012
6969
  });
7013
6970
  };
6971
+ /** @private */
7014
6972
  WebsocketService.prototype.createStompClient = function () {
7015
6973
  var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
7016
6974
  this._stompClient = stompjs.Stomp.over(ws);
7017
6975
  // this._stompClient.debug = (str) => console.log(new Date().toISOString(), str);
7018
6976
  this._stompClient.debug = function () { }; // Para remover os logs.
7019
6977
  };
6978
+ /** @private */
7020
6979
  WebsocketService.prototype.reconnect = function () {
7021
6980
  var _this = this;
7022
6981
  if (this.connected)
@@ -7032,37 +6991,39 @@
7032
6991
  }
7033
6992
  }, WebsocketService_1.RECONNECT_TIMER);
7034
6993
  };
6994
+ /** @private */
7035
6995
  WebsocketService.prototype.reconnectPrimitives = function () {
7036
- var e_6, _a, e_7, _b;
6996
+ var e_4, _a, e_5, _b;
7037
6997
  try {
7038
6998
  for (var _c = __values(this.primitiveManagers.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
7039
6999
  var primitiveManager = _d.value;
7040
7000
  try {
7041
- for (var _e = (e_7 = void 0, __values(primitiveManager.stompSubscriptions)), _f = _e.next(); !_f.done; _f = _e.next()) {
7001
+ for (var _e = (e_5 = void 0, __values(primitiveManager.stompSubscriptions)), _f = _e.next(); !_f.done; _f = _e.next()) {
7042
7002
  var stompSubscription = _f.value;
7043
7003
  stompSubscription.unsubscribe();
7044
7004
  }
7045
7005
  }
7046
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
7006
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
7047
7007
  finally {
7048
7008
  try {
7049
7009
  if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
7050
7010
  }
7051
- finally { if (e_7) throw e_7.error; }
7011
+ finally { if (e_5) throw e_5.error; }
7052
7012
  }
7053
7013
  this.createStompSubscriptions(primitiveManager);
7054
7014
  }
7055
7015
  }
7056
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
7016
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
7057
7017
  finally {
7058
7018
  try {
7059
7019
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
7060
7020
  }
7061
- finally { if (e_6) throw e_6.error; }
7021
+ finally { if (e_4) throw e_4.error; }
7062
7022
  }
7063
7023
  };
7024
+ /** @private */
7064
7025
  WebsocketService.prototype.getObserversCount = function () {
7065
- var e_8, _a;
7026
+ var e_6, _a;
7066
7027
  var observersCount = 0;
7067
7028
  try {
7068
7029
  for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -7070,21 +7031,19 @@
7070
7031
  observersCount += primitiveManager.subject.observers.length;
7071
7032
  }
7072
7033
  }
7073
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
7034
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
7074
7035
  finally {
7075
7036
  try {
7076
7037
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
7077
7038
  }
7078
- finally { if (e_8) throw e_8.error; }
7039
+ finally { if (e_6) throw e_6.error; }
7079
7040
  }
7080
7041
  return observersCount;
7081
7042
  };
7082
- WebsocketService.prototype.disconnectPrimitiveOnFinalize = function (primitive) {
7083
- var e_9, _a;
7084
- var primitiveManager = this.primitiveManagers.get(primitive);
7085
- if (!primitiveManager)
7086
- return;
7087
- // @IMPORTANT: Replace .observers.length with .observed in rxjs 7.0+
7043
+ /** @private */
7044
+ WebsocketService.prototype.disconnectPrimitiveOnFinalize = function (primitiveManager) {
7045
+ var e_7, _a;
7046
+ // @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
7088
7047
  var hasObservers = !(primitiveManager.subject.observers.length === 1);
7089
7048
  if (hasObservers)
7090
7049
  return;
@@ -7094,22 +7053,33 @@
7094
7053
  stompSubscription.unsubscribe();
7095
7054
  }
7096
7055
  }
7097
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
7056
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
7098
7057
  finally {
7099
7058
  try {
7100
7059
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
7101
7060
  }
7102
- finally { if (e_9) throw e_9.error; }
7061
+ finally { if (e_7) throw e_7.error; }
7103
7062
  }
7104
- this.primitiveManagers.delete(primitive);
7063
+ var key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
7064
+ this.primitiveManagers.delete(key);
7105
7065
  this.disconnect();
7106
7066
  };
7067
+ /** @private */
7068
+ WebsocketService.prototype.getPrimitiveManagerKey = function (domain, service, primitive) {
7069
+ return domain + "/" + service + "/" + primitive;
7070
+ };
7107
7071
  var WebsocketService_1;
7072
+ /** @private */
7108
7073
  WebsocketService.RECONNECT_TIMER = 3000;
7074
+ /** @private */
7109
7075
  WebsocketService.CONNECTION_TIMEOUT = 15000;
7076
+ /** @private */
7110
7077
  WebsocketService.BASE_URL_COOKIE = "com.senior.base.url";
7078
+ /** @private */
7111
7079
  WebsocketService.TOKEN_COOKIE = "com.senior.token";
7080
+ /** @private */
7112
7081
  WebsocketService.TOKEN = JSON.parse(jsCookie.get(WebsocketService_1.TOKEN_COOKIE) || "{}");
7082
+ /** @private */
7113
7083
  WebsocketService.WEBSOCKET_URL = jsCookie.get(WebsocketService_1.BASE_URL_COOKIE) + "/websocket/";
7114
7084
  WebsocketService.ɵprov = core.ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
7115
7085
  WebsocketService = WebsocketService_1 = __decorate([