taxtank-core 0.23.6 → 0.23.7-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.
@@ -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('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/last'), require('moment'), require('moment-range'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('lodash/compact'), require('@angular/forms'), require('lodash/fromPairs'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
- typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/last', 'moment', 'moment-range', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'lodash/compact', '@angular/forms', 'lodash/fromPairs', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'html2pdf.js', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.last, global.moment, global.momentRange, global.flatten, global.hasIn, global.first, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.compact, global.ng.forms, global.fromPairs, global._, global.eventsource_min_js, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, moment, momentRange, flatten, hasIn, first, uniqBy, concat, throwError, cloneDeep$1, compact, forms, fromPairs, _, eventsource_min_js, i1$2, clone, html2pdf, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/last'), require('moment'), require('moment-range'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('event-source-polyfill/src/eventsource.min.js'), require('lodash/compact'), require('@angular/forms'), require('lodash/fromPairs'), require('lodash'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
+ typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/last', 'moment', 'moment-range', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'event-source-polyfill/src/eventsource.min.js', 'lodash/compact', '@angular/forms', 'lodash/fromPairs', 'lodash', '@angular/router', 'lodash/clone', 'html2pdf.js', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.last, global.moment, global.momentRange, global.flatten, global.hasIn, global.first, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.eventsource_min_js, global.compact, global.ng.forms, global.fromPairs, global._, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
+ })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, moment, momentRange, flatten, hasIn, first, uniqBy, concat, throwError, cloneDeep$1, eventsource_min_js, compact, forms, fromPairs, _, i1$2, clone, html2pdf, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -5656,11 +5656,11 @@
5656
5656
  /**
5657
5657
  * Interceptor which adds user's basiq token to any http request to basiq api
5658
5658
  */
5659
- var BasiqInterceptor = /** @class */ (function () {
5660
- function BasiqInterceptor(basiqTokenService) {
5659
+ var BasiqTokenInterceptor = /** @class */ (function () {
5660
+ function BasiqTokenInterceptor(basiqTokenService) {
5661
5661
  this.basiqTokenService = basiqTokenService;
5662
5662
  }
5663
- BasiqInterceptor.prototype.intercept = function (request, next) {
5663
+ BasiqTokenInterceptor.prototype.intercept = function (request, next) {
5664
5664
  var _this = this;
5665
5665
  // skip non-basiq requests
5666
5666
  if (!request.url.includes(BasiqService.basiqApiUrl)) {
@@ -5670,21 +5670,264 @@
5670
5670
  return next.handle(_this.addToken(request, token));
5671
5671
  }));
5672
5672
  };
5673
- BasiqInterceptor.prototype.addToken = function (request, token) {
5673
+ BasiqTokenInterceptor.prototype.addToken = function (request, token) {
5674
5674
  return request.clone({
5675
5675
  setHeaders: {
5676
5676
  Authorization: 'Bearer ' + token.value
5677
5677
  }
5678
5678
  });
5679
5679
  };
5680
- return BasiqInterceptor;
5680
+ return BasiqTokenInterceptor;
5681
5681
  }());
5682
- BasiqInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqInterceptor, deps: [{ token: BasiqTokenService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
5683
- BasiqInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqInterceptor });
5684
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqInterceptor, decorators: [{
5682
+ BasiqTokenInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor, deps: [{ token: BasiqTokenService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
5683
+ BasiqTokenInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor });
5684
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqTokenInterceptor, decorators: [{
5685
5685
  type: i0.Injectable
5686
5686
  }], ctorParameters: function () { return [{ type: BasiqTokenService }]; } });
5687
5687
 
5688
+ /**
5689
+ * server sent events service
5690
+ * https://symfony.com/doc/current/mercure.html
5691
+ */
5692
+ var SseService = /** @class */ (function () {
5693
+ function SseService(zone, jwtService, environment) {
5694
+ this.zone = zone;
5695
+ this.jwtService = jwtService;
5696
+ this.environment = environment;
5697
+ }
5698
+ /**
5699
+ * list to url for server events
5700
+ */
5701
+ SseService.prototype.on = function (topic) {
5702
+ var _this = this;
5703
+ var url = new URL(this.environment.mercureUrl);
5704
+ url.searchParams.append('topic', this.environment.apiV2 + "/users/" + this.jwtService.decodeToken().username + "/" + topic);
5705
+ // tslint:disable-next-line:typedef
5706
+ return new rxjs.Observable(function (observer) {
5707
+ var es = new eventsource_min_js.EventSourcePolyfill(url, {
5708
+ headers: {
5709
+ Authorization: 'Bearer ' + _this.jwtService.getToken(),
5710
+ }
5711
+ });
5712
+ es.onmessage = function (event) {
5713
+ _this.zone.run(function () { return observer.next(event); });
5714
+ };
5715
+ })
5716
+ .pipe(operators.map(function (messageEvent) {
5717
+ return JSON.parse(messageEvent.data);
5718
+ }));
5719
+ };
5720
+ return SseService;
5721
+ }());
5722
+ SseService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, deps: [{ token: i0__namespace.NgZone }, { token: JwtService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
5723
+ SseService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, providedIn: 'root' });
5724
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, decorators: [{
5725
+ type: i0.Injectable,
5726
+ args: [{
5727
+ providedIn: 'root'
5728
+ }]
5729
+ }], ctorParameters: function () {
5730
+ return [{ type: i0__namespace.NgZone }, { type: JwtService }, { type: undefined, decorators: [{
5731
+ type: i0.Inject,
5732
+ args: ['environment']
5733
+ }] }];
5734
+ } });
5735
+
5736
+ /**
5737
+ * Service to work with user
5738
+ */
5739
+ var UserService = /** @class */ (function () {
5740
+ function UserService(http, jwtService, eventDispatcherService, sseService, environment) {
5741
+ this.http = http;
5742
+ this.jwtService = jwtService;
5743
+ this.eventDispatcherService = eventDispatcherService;
5744
+ this.sseService = sseService;
5745
+ this.environment = environment;
5746
+ this.cacheSubject = new rxjs.ReplaySubject(1);
5747
+ this.listenEvents();
5748
+ }
5749
+ UserService.prototype.listenEvents = function () {
5750
+ this.listenServiceSubscriptionUpdated();
5751
+ };
5752
+ UserService.prototype.get = function () {
5753
+ var _this = this;
5754
+ if (!this.cache) {
5755
+ this.fetch().subscribe(function () { }, function (error) {
5756
+ // force logout user (clear localStorage) when get current user return error
5757
+ if (error.status === 500) {
5758
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
5759
+ }
5760
+ });
5761
+ }
5762
+ return this.cacheSubject.asObservable();
5763
+ };
5764
+ /**
5765
+ * Get current user
5766
+ */
5767
+ UserService.prototype.fetch = function () {
5768
+ var _this = this;
5769
+ return this.http.get(this.environment.apiV2 + "/users/current")
5770
+ .pipe(operators.map(function (userBase) {
5771
+ var user = classTransformer.plainToClass(User, userBase);
5772
+ localStorage.setItem('userId', user.id.toString());
5773
+ // @TODO remove
5774
+ localStorage.setItem('financialYear', user.financialYear.toString());
5775
+ _this.cache = user;
5776
+ _this.cacheSubject.next(_this.cache);
5777
+ return user;
5778
+ }));
5779
+ };
5780
+ /**
5781
+ * Register new user
5782
+ */
5783
+ UserService.prototype.register = function (data) {
5784
+ return this.http.post(this.environment.apiV2 + "/users/registration", data);
5785
+ };
5786
+ /**
5787
+ * Update user
5788
+ */
5789
+ UserService.prototype.update = function (user) {
5790
+ var _this = this;
5791
+ return this.http.put(this.environment.apiV2 + "/users/" + user.id, user)
5792
+ .pipe(operators.map(function (userBase) {
5793
+ _this.cache = classTransformer.plainToClass(User, userBase);
5794
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.USER_UPDATED, null));
5795
+ _this.cacheSubject.next(_this.cache);
5796
+ }));
5797
+ };
5798
+ /**
5799
+ * Change user password
5800
+ */
5801
+ UserService.prototype.changePassword = function (currentPassword, newPassword) {
5802
+ return this.http.put(this.environment.apiV2 + "/users/password/change", { currentPassword: currentPassword, newPassword: newPassword });
5803
+ };
5804
+ /**
5805
+ * Recovery user password
5806
+ */
5807
+ UserService.prototype.recoveryPassword = function (email) {
5808
+ return this.http.put(this.environment.apiV2 + "/users/password/recovery", { email: email });
5809
+ };
5810
+ /**
5811
+ * Reset user password
5812
+ */
5813
+ UserService.prototype.resetPassword = function (newPassword, resetToken) {
5814
+ return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
5815
+ };
5816
+ UserService.prototype.resendConfirmationEmail = function (email) {
5817
+ return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
5818
+ };
5819
+ /**
5820
+ * Confirm registered user
5821
+ */
5822
+ UserService.prototype.confirm = function (verificationCode) {
5823
+ return this.http.post(this.environment.apiV2 + "/users/confirmation", { verificationCode: verificationCode });
5824
+ };
5825
+ /**
5826
+ * Search existing user
5827
+ */
5828
+ UserService.prototype.search = function (email) {
5829
+ return this.http.get(this.environment.apiV2 + "/users/search?email=" + email)
5830
+ .pipe(operators.map(function (userBase) {
5831
+ return classTransformer.plainToClass(User, userBase);
5832
+ }));
5833
+ };
5834
+ /**
5835
+ * Finish onboarding process
5836
+ */
5837
+ UserService.prototype.finishOnboarding = function (user) {
5838
+ var _this = this;
5839
+ return this.http.put(this.environment.apiV2 + "/users/status", user)
5840
+ .pipe(operators.map(function () {
5841
+ _this.cache = user;
5842
+ _this.cacheSubject.next(_this.cache);
5843
+ }));
5844
+ };
5845
+ /**
5846
+ * Update user photo
5847
+ */
5848
+ UserService.prototype.updatePhoto = function (photo) {
5849
+ var _this = this;
5850
+ return this.http.post(this.environment.apiV2 + "/users/photo?_method=PUT", photo)
5851
+ .pipe(operators.map(function (photoUrl) {
5852
+ _this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { photo: photoUrl }));
5853
+ _this.cacheSubject.next(_this.cache);
5854
+ }));
5855
+ };
5856
+ UserService.prototype.switchFinancialYear = function (year) {
5857
+ return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
5858
+ localStorage.setItem('financialYear', year.toString());
5859
+ window.location.reload();
5860
+ }));
5861
+ };
5862
+ /**
5863
+ * clear service cache
5864
+ */
5865
+ UserService.prototype.resetCache = function () {
5866
+ this.fetch().subscribe();
5867
+ };
5868
+ /**
5869
+ * Create basiq (if not exist yet) to provide access to basiq api
5870
+ */
5871
+ UserService.prototype.createBasiq = function () {
5872
+ var _this = this;
5873
+ return this.http.post(this.environment.apiV2 + "/basiq/user", {})
5874
+ .pipe(operators.map(function (basiqId) {
5875
+ _this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { basiqId: basiqId }));
5876
+ _this.cacheSubject.next(_this.cache);
5877
+ return basiqId;
5878
+ }));
5879
+ };
5880
+ /**
5881
+ * Update cache when user's service subscription is updated
5882
+ */
5883
+ UserService.prototype.listenServiceSubscriptionUpdated = function () {
5884
+ var _this = this;
5885
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
5886
+ };
5887
+ return UserService;
5888
+ }());
5889
+ UserService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
5890
+ UserService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, providedIn: 'root' });
5891
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, decorators: [{
5892
+ type: i0.Injectable,
5893
+ args: [{
5894
+ providedIn: 'root'
5895
+ }]
5896
+ }], ctorParameters: function () {
5897
+ return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
5898
+ type: i0.Inject,
5899
+ args: ['environment']
5900
+ }] }];
5901
+ } });
5902
+
5903
+ /**
5904
+ * Interceptor which check if client's basiq id exist and request it if not
5905
+ */
5906
+ var BasiqClientIdInterceptor = /** @class */ (function () {
5907
+ function BasiqClientIdInterceptor(userService) {
5908
+ this.userService = userService;
5909
+ }
5910
+ BasiqClientIdInterceptor.prototype.intercept = function (request, next) {
5911
+ var _this = this;
5912
+ // Check if 'client id' URL segment contains null instead of id
5913
+ if (!request.url.startsWith(BasiqService.basiqApiUrl + "/users/null")) {
5914
+ return next.handle(request);
5915
+ }
5916
+ return this.userService.createBasiq().pipe(operators.mergeMap(function (basiqClientId) { return next.handle(_this.addId(request, basiqClientId)); }));
5917
+ };
5918
+ BasiqClientIdInterceptor.prototype.addId = function (request, basiqClientId) {
5919
+ return request.clone({
5920
+ url: request.url.replace('null', basiqClientId)
5921
+ });
5922
+ };
5923
+ return BasiqClientIdInterceptor;
5924
+ }());
5925
+ BasiqClientIdInterceptor.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor, deps: [{ token: UserService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
5926
+ BasiqClientIdInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor });
5927
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqClientIdInterceptor, decorators: [{
5928
+ type: i0.Injectable
5929
+ }], ctorParameters: function () { return [{ type: UserService }]; } });
5930
+
5688
5931
  var InterceptorsModule = /** @class */ (function () {
5689
5932
  function InterceptorsModule() {
5690
5933
  }
@@ -5721,7 +5964,12 @@
5721
5964
  },
5722
5965
  {
5723
5966
  provide: i1.HTTP_INTERCEPTORS,
5724
- useClass: BasiqInterceptor,
5967
+ useClass: BasiqTokenInterceptor,
5968
+ multi: true
5969
+ },
5970
+ {
5971
+ provide: i1.HTTP_INTERCEPTORS,
5972
+ useClass: BasiqClientIdInterceptor,
5725
5973
  multi: true
5726
5974
  }
5727
5975
  ] });
@@ -5757,7 +6005,12 @@
5757
6005
  },
5758
6006
  {
5759
6007
  provide: i1.HTTP_INTERCEPTORS,
5760
- useClass: BasiqInterceptor,
6008
+ useClass: BasiqTokenInterceptor,
6009
+ multi: true
6010
+ },
6011
+ {
6012
+ provide: i1.HTTP_INTERCEPTORS,
6013
+ useClass: BasiqClientIdInterceptor,
5761
6014
  multi: true
5762
6015
  }
5763
6016
  ]
@@ -11378,7 +11631,7 @@
11378
11631
  }]
11379
11632
  }] });
11380
11633
 
11381
- var MessagesEnum$1;
11634
+ var MessagesEnum;
11382
11635
  (function (MessagesEnum) {
11383
11636
  MessagesEnum["VEHICLE_CREATED"] = "Vehicle created successfully";
11384
11637
  MessagesEnum["VEHICLE_UPDATED"] = "Vehicle updated successfully";
@@ -11389,7 +11642,7 @@
11389
11642
  MessagesEnum["VEHICLE_LOGBOOK_CREATED"] = "Vehicle logbook created successfully";
11390
11643
  MessagesEnum["VEHICLE_LOGBOOK_UPDATED"] = "Vehicle logbook updated successfully";
11391
11644
  MessagesEnum["VEHICLE_LOGBOOK_DELETED"] = "Vehicle logbook deleted successfully";
11392
- })(MessagesEnum$1 || (MessagesEnum$1 = {}));
11645
+ })(MessagesEnum || (MessagesEnum = {}));
11393
11646
 
11394
11647
  var VehicleClaimService = /** @class */ (function (_super) {
11395
11648
  __extends(VehicleClaimService, _super);
@@ -11397,9 +11650,9 @@
11397
11650
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11398
11651
  _this.modelClass = VehicleClaim;
11399
11652
  _this.url = 'vehicle-claims';
11400
- _this.messageCreated = MessagesEnum$1.VEHICLE_CLAIM_CREATED;
11401
- _this.messageUpdated = MessagesEnum$1.VEHICLE_CLAIM_UPDATED;
11402
- _this.messageDeleted = MessagesEnum$1.VEHICLE_CLAIM_DELETED;
11653
+ _this.messageCreated = MessagesEnum.VEHICLE_CLAIM_CREATED;
11654
+ _this.messageUpdated = MessagesEnum.VEHICLE_CLAIM_UPDATED;
11655
+ _this.messageDeleted = MessagesEnum.VEHICLE_CLAIM_DELETED;
11403
11656
  return _this;
11404
11657
  }
11405
11658
  return VehicleClaimService;
@@ -11426,13 +11679,6 @@
11426
11679
  return list;
11427
11680
  }
11428
11681
 
11429
- var MessagesEnum;
11430
- (function (MessagesEnum) {
11431
- MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
11432
- MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
11433
- MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
11434
- })(MessagesEnum || (MessagesEnum = {}));
11435
-
11436
11682
  /**
11437
11683
  * Service for transactions business logic
11438
11684
  */
@@ -11570,7 +11816,6 @@
11570
11816
  _this.updateCache();
11571
11817
  }
11572
11818
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
11573
- _this.toastService.success(MessagesEnum.CREATED_MESSAGE);
11574
11819
  return addedTransactions;
11575
11820
  }));
11576
11821
  };
@@ -11608,7 +11853,6 @@
11608
11853
  _this.addBatch(childTransactionsToAdd).subscribe();
11609
11854
  }
11610
11855
  }
11611
- _this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
11612
11856
  replace(_this.cache, updatedTransaction);
11613
11857
  _this.updateCache();
11614
11858
  return updatedTransaction;
@@ -11657,7 +11901,6 @@
11657
11901
  return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
11658
11902
  });
11659
11903
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_DELETED, model));
11660
- _this.toastService.success(MessagesEnum.DELETED_MESSAGE);
11661
11904
  _this.updateCache();
11662
11905
  _this.transactionDeleted.emit(model);
11663
11906
  }));
@@ -12373,54 +12616,6 @@
12373
12616
  }]
12374
12617
  }] });
12375
12618
 
12376
- /**
12377
- * server sent events service
12378
- * https://symfony.com/doc/current/mercure.html
12379
- */
12380
- var SseService = /** @class */ (function () {
12381
- function SseService(zone, jwtService, environment) {
12382
- this.zone = zone;
12383
- this.jwtService = jwtService;
12384
- this.environment = environment;
12385
- }
12386
- /**
12387
- * list to url for server events
12388
- */
12389
- SseService.prototype.on = function (topic) {
12390
- var _this = this;
12391
- var url = new URL(this.environment.mercureUrl);
12392
- url.searchParams.append('topic', this.environment.apiV2 + "/users/" + this.jwtService.decodeToken().username + "/" + topic);
12393
- // tslint:disable-next-line:typedef
12394
- return new rxjs.Observable(function (observer) {
12395
- var es = new eventsource_min_js.EventSourcePolyfill(url, {
12396
- headers: {
12397
- Authorization: 'Bearer ' + _this.jwtService.getToken(),
12398
- }
12399
- });
12400
- es.onmessage = function (event) {
12401
- _this.zone.run(function () { return observer.next(event); });
12402
- };
12403
- })
12404
- .pipe(operators.map(function (messageEvent) {
12405
- return JSON.parse(messageEvent.data);
12406
- }));
12407
- };
12408
- return SseService;
12409
- }());
12410
- SseService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, deps: [{ token: i0__namespace.NgZone }, { token: JwtService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12411
- SseService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, providedIn: 'root' });
12412
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, decorators: [{
12413
- type: i0.Injectable,
12414
- args: [{
12415
- providedIn: 'root'
12416
- }]
12417
- }], ctorParameters: function () {
12418
- return [{ type: i0__namespace.NgZone }, { type: JwtService }, { type: undefined, decorators: [{
12419
- type: i0.Inject,
12420
- args: ['environment']
12421
- }] }];
12422
- } });
12423
-
12424
12619
  /**
12425
12620
  * Service for work with chats
12426
12621
  */
@@ -15048,161 +15243,6 @@
15048
15243
  }] }];
15049
15244
  } });
15050
15245
 
15051
- /**
15052
- * Service to work with user
15053
- */
15054
- var UserService = /** @class */ (function () {
15055
- function UserService(http, jwtService, eventDispatcherService, sseService, environment) {
15056
- this.http = http;
15057
- this.jwtService = jwtService;
15058
- this.eventDispatcherService = eventDispatcherService;
15059
- this.sseService = sseService;
15060
- this.environment = environment;
15061
- this.cacheSubject = new rxjs.ReplaySubject(1);
15062
- this.listenEvents();
15063
- }
15064
- UserService.prototype.listenEvents = function () {
15065
- this.listenServiceSubscriptionUpdated();
15066
- };
15067
- UserService.prototype.get = function () {
15068
- var _this = this;
15069
- if (!this.cache) {
15070
- this.fetch().subscribe(function () { }, function (error) {
15071
- // force logout user (clear localStorage) when get current user return error
15072
- if (error.status === 500) {
15073
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
15074
- }
15075
- });
15076
- }
15077
- return this.cacheSubject.asObservable();
15078
- };
15079
- /**
15080
- * Get current user
15081
- */
15082
- UserService.prototype.fetch = function () {
15083
- var _this = this;
15084
- return this.http.get(this.environment.apiV2 + "/users/current")
15085
- .pipe(operators.map(function (userBase) {
15086
- var user = classTransformer.plainToClass(User, userBase);
15087
- localStorage.setItem('userId', user.id.toString());
15088
- // @TODO remove
15089
- localStorage.setItem('financialYear', user.financialYear.toString());
15090
- _this.cache = user;
15091
- _this.cacheSubject.next(_this.cache);
15092
- return user;
15093
- }));
15094
- };
15095
- /**
15096
- * Register new user
15097
- */
15098
- UserService.prototype.register = function (data) {
15099
- return this.http.post(this.environment.apiV2 + "/users/registration", data);
15100
- };
15101
- /**
15102
- * Update user
15103
- */
15104
- UserService.prototype.update = function (user) {
15105
- var _this = this;
15106
- return this.http.put(this.environment.apiV2 + "/users/" + user.id, user)
15107
- .pipe(operators.map(function (userBase) {
15108
- _this.cache = classTransformer.plainToClass(User, userBase);
15109
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.USER_UPDATED, null));
15110
- _this.cacheSubject.next(_this.cache);
15111
- }));
15112
- };
15113
- /**
15114
- * Change user password
15115
- */
15116
- UserService.prototype.changePassword = function (currentPassword, newPassword) {
15117
- return this.http.put(this.environment.apiV2 + "/users/password/change", { currentPassword: currentPassword, newPassword: newPassword });
15118
- };
15119
- /**
15120
- * Recovery user password
15121
- */
15122
- UserService.prototype.recoveryPassword = function (email) {
15123
- return this.http.put(this.environment.apiV2 + "/users/password/recovery", { email: email });
15124
- };
15125
- /**
15126
- * Reset user password
15127
- */
15128
- UserService.prototype.resetPassword = function (newPassword, resetToken) {
15129
- return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
15130
- };
15131
- UserService.prototype.resendConfirmationEmail = function (email) {
15132
- return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
15133
- };
15134
- /**
15135
- * Confirm registered user
15136
- */
15137
- UserService.prototype.confirm = function (verificationCode) {
15138
- return this.http.post(this.environment.apiV2 + "/users/confirmation", { verificationCode: verificationCode });
15139
- };
15140
- /**
15141
- * Search existing user
15142
- */
15143
- UserService.prototype.search = function (email) {
15144
- return this.http.get(this.environment.apiV2 + "/users/search?email=" + email)
15145
- .pipe(operators.map(function (userBase) {
15146
- return classTransformer.plainToClass(User, userBase);
15147
- }));
15148
- };
15149
- /**
15150
- * Finish onboarding process
15151
- */
15152
- UserService.prototype.finishOnboarding = function (user) {
15153
- var _this = this;
15154
- return this.http.put(this.environment.apiV2 + "/users/status", user)
15155
- .pipe(operators.map(function () {
15156
- _this.cache = user;
15157
- _this.cacheSubject.next(_this.cache);
15158
- }));
15159
- };
15160
- /**
15161
- * Update user photo
15162
- */
15163
- UserService.prototype.updatePhoto = function (photo) {
15164
- var _this = this;
15165
- return this.http.post(this.environment.apiV2 + "/users/photo?_method=PUT", photo)
15166
- .pipe(operators.map(function (photoUrl) {
15167
- _this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { photo: photoUrl }));
15168
- _this.cacheSubject.next(_this.cache);
15169
- }));
15170
- };
15171
- UserService.prototype.switchFinancialYear = function (year) {
15172
- return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
15173
- localStorage.setItem('financialYear', year.toString());
15174
- window.location.reload();
15175
- }));
15176
- };
15177
- /**
15178
- * clear service cache
15179
- */
15180
- UserService.prototype.resetCache = function () {
15181
- this.fetch().subscribe();
15182
- };
15183
- /**
15184
- * Update cache when user's service subscription is updated
15185
- */
15186
- UserService.prototype.listenServiceSubscriptionUpdated = function () {
15187
- var _this = this;
15188
- this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
15189
- };
15190
- return UserService;
15191
- }());
15192
- UserService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
15193
- UserService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, providedIn: 'root' });
15194
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, decorators: [{
15195
- type: i0.Injectable,
15196
- args: [{
15197
- providedIn: 'root'
15198
- }]
15199
- }], ctorParameters: function () {
15200
- return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
15201
- type: i0.Inject,
15202
- args: ['environment']
15203
- }] }];
15204
- } });
15205
-
15206
15246
  var UserEventSettingService = /** @class */ (function (_super) {
15207
15247
  __extends(UserEventSettingService, _super);
15208
15248
  function UserEventSettingService() {
@@ -15280,9 +15320,9 @@
15280
15320
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
15281
15321
  _this.url = 'vehicles';
15282
15322
  _this.modelClass = Vehicle;
15283
- _this.messageCreated = MessagesEnum$1.VEHICLE_CREATED;
15284
- _this.messageUpdated = MessagesEnum$1.VEHICLE_UPDATED;
15285
- _this.messageDeleted = MessagesEnum$1.VEHICLE_DELETED;
15323
+ _this.messageCreated = MessagesEnum.VEHICLE_CREATED;
15324
+ _this.messageUpdated = MessagesEnum.VEHICLE_UPDATED;
15325
+ _this.messageDeleted = MessagesEnum.VEHICLE_DELETED;
15286
15326
  return _this;
15287
15327
  }
15288
15328
  VehicleService.prototype.listenEvents = function () {
@@ -15358,7 +15398,7 @@
15358
15398
  .pipe(operators.map(function (vehicleLogbookBase) {
15359
15399
  var newVehicleLogbook = classTransformer.plainToClass(VehicleLogbook, vehicleLogbookBase);
15360
15400
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_CREATED, { logbook: newVehicleLogbook, vehicleId: vehicleId }));
15361
- _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_CREATED);
15401
+ _this.toastService.success(MessagesEnum.VEHICLE_LOGBOOK_CREATED);
15362
15402
  return newVehicleLogbook;
15363
15403
  }));
15364
15404
  };
@@ -15367,7 +15407,7 @@
15367
15407
  return this.http.put(this.environment.apiV2 + "/vehicles/" + vehicleId + "/logbooks/" + logbook.id, logbook).pipe(operators.map(function (vehicleLogbookBase) {
15368
15408
  var updatedVehicleLogbook = classTransformer.plainToClass(VehicleLogbook, vehicleLogbookBase);
15369
15409
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_UPDATED, { logbook: updatedVehicleLogbook, vehicleId: vehicleId }));
15370
- _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_UPDATED);
15410
+ _this.toastService.success(MessagesEnum.VEHICLE_LOGBOOK_UPDATED);
15371
15411
  return classTransformer.plainToClass(VehicleLogbook, updatedVehicleLogbook);
15372
15412
  }));
15373
15413
  };
@@ -15376,7 +15416,7 @@
15376
15416
  return this.http.delete(this.environment.apiV2 + "/vehicles/" + vehicleId + "/logbooks/" + logbook.id)
15377
15417
  .pipe(operators.map(function () {
15378
15418
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_DELETED, { logbook: logbook, vehicleId: vehicleId }));
15379
- _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_DELETED);
15419
+ _this.toastService.success(MessagesEnum.VEHICLE_LOGBOOK_DELETED);
15380
15420
  }));
15381
15421
  };
15382
15422
  return VehicleLogbookService;