taxtank-core 0.23.4 → 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
 
@@ -4479,9 +4479,13 @@
4479
4479
  if (items === void 0) { items = []; }
4480
4480
  return new this.collectionConstructor(items);
4481
4481
  };
4482
- CollectionDictionary.prototype.length = function () {
4483
- return this.keys.length;
4484
- };
4482
+ Object.defineProperty(CollectionDictionary.prototype, "length", {
4483
+ get: function () {
4484
+ return this.keys.length;
4485
+ },
4486
+ enumerable: false,
4487
+ configurable: true
4488
+ });
4485
4489
  /**
4486
4490
  * @Todo find a better solution to get list of the sorted keys
4487
4491
  * Get array of the "keys" by provided order
@@ -5410,6 +5414,17 @@
5410
5414
  return BankAccountCollection;
5411
5415
  }(Collection));
5412
5416
 
5417
+ /**
5418
+ * any event happened in the app, which needs to be handled somehow (distributed to other part of the app)
5419
+ */
5420
+ var AppEvent = /** @class */ (function () {
5421
+ function AppEvent(type, payload) {
5422
+ this.type = type;
5423
+ this.payload = payload;
5424
+ }
5425
+ return AppEvent;
5426
+ }());
5427
+
5413
5428
  /**
5414
5429
  * BankConnection means user account at specific bank (usually each user has only one at the same bank)
5415
5430
  * service handles BankConnection management
@@ -5445,6 +5460,7 @@
5445
5460
  _this.cacheSubject.next(cloneDeep__default["default"](_this.cache));
5446
5461
  }
5447
5462
  }
5463
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BANK_CONNECTION_ADDED, null));
5448
5464
  return classTransformer.plainToClass(BankConnection, connection);
5449
5465
  }));
5450
5466
  };
@@ -5640,11 +5656,11 @@
5640
5656
  /**
5641
5657
  * Interceptor which adds user's basiq token to any http request to basiq api
5642
5658
  */
5643
- var BasiqInterceptor = /** @class */ (function () {
5644
- function BasiqInterceptor(basiqTokenService) {
5659
+ var BasiqTokenInterceptor = /** @class */ (function () {
5660
+ function BasiqTokenInterceptor(basiqTokenService) {
5645
5661
  this.basiqTokenService = basiqTokenService;
5646
5662
  }
5647
- BasiqInterceptor.prototype.intercept = function (request, next) {
5663
+ BasiqTokenInterceptor.prototype.intercept = function (request, next) {
5648
5664
  var _this = this;
5649
5665
  // skip non-basiq requests
5650
5666
  if (!request.url.includes(BasiqService.basiqApiUrl)) {
@@ -5654,21 +5670,264 @@
5654
5670
  return next.handle(_this.addToken(request, token));
5655
5671
  }));
5656
5672
  };
5657
- BasiqInterceptor.prototype.addToken = function (request, token) {
5673
+ BasiqTokenInterceptor.prototype.addToken = function (request, token) {
5658
5674
  return request.clone({
5659
5675
  setHeaders: {
5660
5676
  Authorization: 'Bearer ' + token.value
5661
5677
  }
5662
5678
  });
5663
5679
  };
5664
- return BasiqInterceptor;
5680
+ return BasiqTokenInterceptor;
5665
5681
  }());
5666
- 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 });
5667
- BasiqInterceptor.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqInterceptor });
5668
- 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: [{
5669
5685
  type: i0.Injectable
5670
5686
  }], ctorParameters: function () { return [{ type: BasiqTokenService }]; } });
5671
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
+
5672
5931
  var InterceptorsModule = /** @class */ (function () {
5673
5932
  function InterceptorsModule() {
5674
5933
  }
@@ -5705,7 +5964,12 @@
5705
5964
  },
5706
5965
  {
5707
5966
  provide: i1.HTTP_INTERCEPTORS,
5708
- useClass: BasiqInterceptor,
5967
+ useClass: BasiqTokenInterceptor,
5968
+ multi: true
5969
+ },
5970
+ {
5971
+ provide: i1.HTTP_INTERCEPTORS,
5972
+ useClass: BasiqClientIdInterceptor,
5709
5973
  multi: true
5710
5974
  }
5711
5975
  ] });
@@ -5741,7 +6005,12 @@
5741
6005
  },
5742
6006
  {
5743
6007
  provide: i1.HTTP_INTERCEPTORS,
5744
- useClass: BasiqInterceptor,
6008
+ useClass: BasiqTokenInterceptor,
6009
+ multi: true
6010
+ },
6011
+ {
6012
+ provide: i1.HTTP_INTERCEPTORS,
6013
+ useClass: BasiqClientIdInterceptor,
5745
6014
  multi: true
5746
6015
  }
5747
6016
  ]
@@ -9030,17 +9299,6 @@
9030
9299
  classTransformer.Type(function () { return User; })
9031
9300
  ], EmployeeInvite.prototype, "employee", void 0);
9032
9301
 
9033
- /**
9034
- * any event happened in the app, which needs to be handled somehow (distributed to other part of the app)
9035
- */
9036
- var AppEvent = /** @class */ (function () {
9037
- function AppEvent(type, payload) {
9038
- this.type = type;
9039
- this.payload = payload;
9040
- }
9041
- return AppEvent;
9042
- }());
9043
-
9044
9302
  exports.ExportFormatEnum = void 0;
9045
9303
  (function (ExportFormatEnum) {
9046
9304
  ExportFormatEnum["PDF"] = "PDF";
@@ -11373,7 +11631,7 @@
11373
11631
  }]
11374
11632
  }] });
11375
11633
 
11376
- var MessagesEnum$1;
11634
+ var MessagesEnum;
11377
11635
  (function (MessagesEnum) {
11378
11636
  MessagesEnum["VEHICLE_CREATED"] = "Vehicle created successfully";
11379
11637
  MessagesEnum["VEHICLE_UPDATED"] = "Vehicle updated successfully";
@@ -11384,7 +11642,7 @@
11384
11642
  MessagesEnum["VEHICLE_LOGBOOK_CREATED"] = "Vehicle logbook created successfully";
11385
11643
  MessagesEnum["VEHICLE_LOGBOOK_UPDATED"] = "Vehicle logbook updated successfully";
11386
11644
  MessagesEnum["VEHICLE_LOGBOOK_DELETED"] = "Vehicle logbook deleted successfully";
11387
- })(MessagesEnum$1 || (MessagesEnum$1 = {}));
11645
+ })(MessagesEnum || (MessagesEnum = {}));
11388
11646
 
11389
11647
  var VehicleClaimService = /** @class */ (function (_super) {
11390
11648
  __extends(VehicleClaimService, _super);
@@ -11392,9 +11650,9 @@
11392
11650
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11393
11651
  _this.modelClass = VehicleClaim;
11394
11652
  _this.url = 'vehicle-claims';
11395
- _this.messageCreated = MessagesEnum$1.VEHICLE_CLAIM_CREATED;
11396
- _this.messageUpdated = MessagesEnum$1.VEHICLE_CLAIM_UPDATED;
11397
- _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;
11398
11656
  return _this;
11399
11657
  }
11400
11658
  return VehicleClaimService;
@@ -11421,13 +11679,6 @@
11421
11679
  return list;
11422
11680
  }
11423
11681
 
11424
- var MessagesEnum;
11425
- (function (MessagesEnum) {
11426
- MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
11427
- MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
11428
- MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
11429
- })(MessagesEnum || (MessagesEnum = {}));
11430
-
11431
11682
  /**
11432
11683
  * Service for transactions business logic
11433
11684
  */
@@ -11565,7 +11816,6 @@
11565
11816
  _this.updateCache();
11566
11817
  }
11567
11818
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
11568
- _this.toastService.success(MessagesEnum.CREATED_MESSAGE);
11569
11819
  return addedTransactions;
11570
11820
  }));
11571
11821
  };
@@ -11603,7 +11853,6 @@
11603
11853
  _this.addBatch(childTransactionsToAdd).subscribe();
11604
11854
  }
11605
11855
  }
11606
- _this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
11607
11856
  replace(_this.cache, updatedTransaction);
11608
11857
  _this.updateCache();
11609
11858
  return updatedTransaction;
@@ -11652,7 +11901,6 @@
11652
11901
  return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
11653
11902
  });
11654
11903
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_DELETED, model));
11655
- _this.toastService.success(MessagesEnum.DELETED_MESSAGE);
11656
11904
  _this.updateCache();
11657
11905
  _this.transactionDeleted.emit(model);
11658
11906
  }));
@@ -12368,54 +12616,6 @@
12368
12616
  }]
12369
12617
  }] });
12370
12618
 
12371
- /**
12372
- * server sent events service
12373
- * https://symfony.com/doc/current/mercure.html
12374
- */
12375
- var SseService = /** @class */ (function () {
12376
- function SseService(zone, jwtService, environment) {
12377
- this.zone = zone;
12378
- this.jwtService = jwtService;
12379
- this.environment = environment;
12380
- }
12381
- /**
12382
- * list to url for server events
12383
- */
12384
- SseService.prototype.on = function (topic) {
12385
- var _this = this;
12386
- var url = new URL(this.environment.mercureUrl);
12387
- url.searchParams.append('topic', this.environment.apiV2 + "/users/" + this.jwtService.decodeToken().username + "/" + topic);
12388
- // tslint:disable-next-line:typedef
12389
- return new rxjs.Observable(function (observer) {
12390
- var es = new eventsource_min_js.EventSourcePolyfill(url, {
12391
- headers: {
12392
- Authorization: 'Bearer ' + _this.jwtService.getToken(),
12393
- }
12394
- });
12395
- es.onmessage = function (event) {
12396
- _this.zone.run(function () { return observer.next(event); });
12397
- };
12398
- })
12399
- .pipe(operators.map(function (messageEvent) {
12400
- return JSON.parse(messageEvent.data);
12401
- }));
12402
- };
12403
- return SseService;
12404
- }());
12405
- 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 });
12406
- SseService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, providedIn: 'root' });
12407
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SseService, decorators: [{
12408
- type: i0.Injectable,
12409
- args: [{
12410
- providedIn: 'root'
12411
- }]
12412
- }], ctorParameters: function () {
12413
- return [{ type: i0__namespace.NgZone }, { type: JwtService }, { type: undefined, decorators: [{
12414
- type: i0.Inject,
12415
- args: ['environment']
12416
- }] }];
12417
- } });
12418
-
12419
12619
  /**
12420
12620
  * Service for work with chats
12421
12621
  */
@@ -15043,161 +15243,6 @@
15043
15243
  }] }];
15044
15244
  } });
15045
15245
 
15046
- /**
15047
- * Service to work with user
15048
- */
15049
- var UserService = /** @class */ (function () {
15050
- function UserService(http, jwtService, eventDispatcherService, sseService, environment) {
15051
- this.http = http;
15052
- this.jwtService = jwtService;
15053
- this.eventDispatcherService = eventDispatcherService;
15054
- this.sseService = sseService;
15055
- this.environment = environment;
15056
- this.cacheSubject = new rxjs.ReplaySubject(1);
15057
- this.listenEvents();
15058
- }
15059
- UserService.prototype.listenEvents = function () {
15060
- this.listenServiceSubscriptionUpdated();
15061
- };
15062
- UserService.prototype.get = function () {
15063
- var _this = this;
15064
- if (!this.cache) {
15065
- this.fetch().subscribe(function () { }, function (error) {
15066
- // force logout user (clear localStorage) when get current user return error
15067
- if (error.status === 500) {
15068
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.CURRENT_USER_GET_FAILED, null));
15069
- }
15070
- });
15071
- }
15072
- return this.cacheSubject.asObservable();
15073
- };
15074
- /**
15075
- * Get current user
15076
- */
15077
- UserService.prototype.fetch = function () {
15078
- var _this = this;
15079
- return this.http.get(this.environment.apiV2 + "/users/current")
15080
- .pipe(operators.map(function (userBase) {
15081
- var user = classTransformer.plainToClass(User, userBase);
15082
- localStorage.setItem('userId', user.id.toString());
15083
- // @TODO remove
15084
- localStorage.setItem('financialYear', user.financialYear.toString());
15085
- _this.cache = user;
15086
- _this.cacheSubject.next(_this.cache);
15087
- return user;
15088
- }));
15089
- };
15090
- /**
15091
- * Register new user
15092
- */
15093
- UserService.prototype.register = function (data) {
15094
- return this.http.post(this.environment.apiV2 + "/users/registration", data);
15095
- };
15096
- /**
15097
- * Update user
15098
- */
15099
- UserService.prototype.update = function (user) {
15100
- var _this = this;
15101
- return this.http.put(this.environment.apiV2 + "/users/" + user.id, user)
15102
- .pipe(operators.map(function (userBase) {
15103
- _this.cache = classTransformer.plainToClass(User, userBase);
15104
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.USER_UPDATED, null));
15105
- _this.cacheSubject.next(_this.cache);
15106
- }));
15107
- };
15108
- /**
15109
- * Change user password
15110
- */
15111
- UserService.prototype.changePassword = function (currentPassword, newPassword) {
15112
- return this.http.put(this.environment.apiV2 + "/users/password/change", { currentPassword: currentPassword, newPassword: newPassword });
15113
- };
15114
- /**
15115
- * Recovery user password
15116
- */
15117
- UserService.prototype.recoveryPassword = function (email) {
15118
- return this.http.put(this.environment.apiV2 + "/users/password/recovery", { email: email });
15119
- };
15120
- /**
15121
- * Reset user password
15122
- */
15123
- UserService.prototype.resetPassword = function (newPassword, resetToken) {
15124
- return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
15125
- };
15126
- UserService.prototype.resendConfirmationEmail = function (email) {
15127
- return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
15128
- };
15129
- /**
15130
- * Confirm registered user
15131
- */
15132
- UserService.prototype.confirm = function (verificationCode) {
15133
- return this.http.post(this.environment.apiV2 + "/users/confirmation", { verificationCode: verificationCode });
15134
- };
15135
- /**
15136
- * Search existing user
15137
- */
15138
- UserService.prototype.search = function (email) {
15139
- return this.http.get(this.environment.apiV2 + "/users/search?email=" + email)
15140
- .pipe(operators.map(function (userBase) {
15141
- return classTransformer.plainToClass(User, userBase);
15142
- }));
15143
- };
15144
- /**
15145
- * Finish onboarding process
15146
- */
15147
- UserService.prototype.finishOnboarding = function (user) {
15148
- var _this = this;
15149
- return this.http.put(this.environment.apiV2 + "/users/status", user)
15150
- .pipe(operators.map(function () {
15151
- _this.cache = user;
15152
- _this.cacheSubject.next(_this.cache);
15153
- }));
15154
- };
15155
- /**
15156
- * Update user photo
15157
- */
15158
- UserService.prototype.updatePhoto = function (photo) {
15159
- var _this = this;
15160
- return this.http.post(this.environment.apiV2 + "/users/photo?_method=PUT", photo)
15161
- .pipe(operators.map(function (photoUrl) {
15162
- _this.cache = classTransformer.plainToClass(User, Object.assign(_this.cache, { photo: photoUrl }));
15163
- _this.cacheSubject.next(_this.cache);
15164
- }));
15165
- };
15166
- UserService.prototype.switchFinancialYear = function (year) {
15167
- return this.http.get(this.environment.apiV2 + "/financial-year/switch", { params: new i1.HttpParams({ fromString: "financialYear=" + year }) }).pipe(operators.map(function () {
15168
- localStorage.setItem('financialYear', year.toString());
15169
- window.location.reload();
15170
- }));
15171
- };
15172
- /**
15173
- * clear service cache
15174
- */
15175
- UserService.prototype.resetCache = function () {
15176
- this.fetch().subscribe();
15177
- };
15178
- /**
15179
- * Update cache when user's service subscription is updated
15180
- */
15181
- UserService.prototype.listenServiceSubscriptionUpdated = function () {
15182
- var _this = this;
15183
- this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
15184
- };
15185
- return UserService;
15186
- }());
15187
- 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 });
15188
- UserService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, providedIn: 'root' });
15189
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, decorators: [{
15190
- type: i0.Injectable,
15191
- args: [{
15192
- providedIn: 'root'
15193
- }]
15194
- }], ctorParameters: function () {
15195
- return [{ type: i1__namespace.HttpClient }, { type: JwtService }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
15196
- type: i0.Inject,
15197
- args: ['environment']
15198
- }] }];
15199
- } });
15200
-
15201
15246
  var UserEventSettingService = /** @class */ (function (_super) {
15202
15247
  __extends(UserEventSettingService, _super);
15203
15248
  function UserEventSettingService() {
@@ -15275,9 +15320,9 @@
15275
15320
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
15276
15321
  _this.url = 'vehicles';
15277
15322
  _this.modelClass = Vehicle;
15278
- _this.messageCreated = MessagesEnum$1.VEHICLE_CREATED;
15279
- _this.messageUpdated = MessagesEnum$1.VEHICLE_UPDATED;
15280
- _this.messageDeleted = MessagesEnum$1.VEHICLE_DELETED;
15323
+ _this.messageCreated = MessagesEnum.VEHICLE_CREATED;
15324
+ _this.messageUpdated = MessagesEnum.VEHICLE_UPDATED;
15325
+ _this.messageDeleted = MessagesEnum.VEHICLE_DELETED;
15281
15326
  return _this;
15282
15327
  }
15283
15328
  VehicleService.prototype.listenEvents = function () {
@@ -15353,7 +15398,7 @@
15353
15398
  .pipe(operators.map(function (vehicleLogbookBase) {
15354
15399
  var newVehicleLogbook = classTransformer.plainToClass(VehicleLogbook, vehicleLogbookBase);
15355
15400
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_CREATED, { logbook: newVehicleLogbook, vehicleId: vehicleId }));
15356
- _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_CREATED);
15401
+ _this.toastService.success(MessagesEnum.VEHICLE_LOGBOOK_CREATED);
15357
15402
  return newVehicleLogbook;
15358
15403
  }));
15359
15404
  };
@@ -15362,7 +15407,7 @@
15362
15407
  return this.http.put(this.environment.apiV2 + "/vehicles/" + vehicleId + "/logbooks/" + logbook.id, logbook).pipe(operators.map(function (vehicleLogbookBase) {
15363
15408
  var updatedVehicleLogbook = classTransformer.plainToClass(VehicleLogbook, vehicleLogbookBase);
15364
15409
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_UPDATED, { logbook: updatedVehicleLogbook, vehicleId: vehicleId }));
15365
- _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_UPDATED);
15410
+ _this.toastService.success(MessagesEnum.VEHICLE_LOGBOOK_UPDATED);
15366
15411
  return classTransformer.plainToClass(VehicleLogbook, updatedVehicleLogbook);
15367
15412
  }));
15368
15413
  };
@@ -15371,7 +15416,7 @@
15371
15416
  return this.http.delete(this.environment.apiV2 + "/vehicles/" + vehicleId + "/logbooks/" + logbook.id)
15372
15417
  .pipe(operators.map(function () {
15373
15418
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_DELETED, { logbook: logbook, vehicleId: vehicleId }));
15374
- _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_DELETED);
15419
+ _this.toastService.success(MessagesEnum.VEHICLE_LOGBOOK_DELETED);
15375
15420
  }));
15376
15421
  };
15377
15422
  return VehicleLogbookService;