vc-error-handlers 0.1.8 → 0.1.9

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,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Component, Input, Directive, ViewChild, NgModule, Optional, InjectionToken, ErrorHandler } from '@angular/core';
3
3
  import { Subject, throwError } from 'rxjs';
4
+ import * as i3 from '@angular/router';
5
+ import { NavigationStart, NavigationEnd, NavigationError } from '@angular/router';
4
6
  import * as i1 from '@vcomply/authorizer';
5
7
  import * as i2 from '@angular/common';
6
8
  import { CommonModule } from '@angular/common';
7
- import * as i3 from '@angular/router';
8
- import { NavigationStart, NavigationEnd, NavigationError } from '@angular/router';
9
9
  import { HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
10
10
  import * as Sentry from '@sentry/angular-ivy';
11
11
  import { timeout, tap, catchError } from 'rxjs/operators';
@@ -38,71 +38,6 @@ var ErrorStatusCode;
38
38
  ErrorStatusCode[ErrorStatusCode["JSChunkUnavailable"] = 600] = "JSChunkUnavailable";
39
39
  })(ErrorStatusCode || (ErrorStatusCode = {}));
40
40
 
41
- class GlobalErrorService {
42
- constructor() {
43
- this.globalError$ = new Subject();
44
- this.localError$ = new Subject();
45
- }
46
- handleError(error, request) {
47
- if (this.isUnauthenticated(error) ||
48
- this.isUnauthorizedAccess(error) ||
49
- this.isNetworkUnavailable(error)) {
50
- this.globalError$.next(error);
51
- }
52
- }
53
- isUnauthenticated(error) {
54
- return error.status === ErrorStatusCode.Unauthenticated;
55
- }
56
- isUnauthorizedAccess(error) {
57
- return error.status === ErrorStatusCode.UnauthorizedAccess;
58
- }
59
- isNetworkUnavailable(error) {
60
- return error.status === ErrorStatusCode.NetworkUnavailable;
61
- }
62
- }
63
- GlobalErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
64
- GlobalErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, providedIn: 'root' });
65
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, decorators: [{
66
- type: Injectable,
67
- args: [{
68
- providedIn: 'root',
69
- }]
70
- }] });
71
-
72
- class AuthService {
73
- constructor(authorizer) {
74
- this.authorizer = authorizer;
75
- }
76
- logoutUser() {
77
- this.authorizer.logout();
78
- }
79
- }
80
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, deps: [{ token: i1.AuthorizerService }], target: i0.ɵɵFactoryTarget.Injectable });
81
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, providedIn: "root" });
82
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, decorators: [{
83
- type: Injectable,
84
- args: [{
85
- providedIn: "root",
86
- }]
87
- }], ctorParameters: function () { return [{ type: i1.AuthorizerService }]; } });
88
-
89
- class RouterService {
90
- redirectToLogin() {
91
- window.location.href =
92
- `https://${window.location.host}/` +
93
- 'signin?redirectURL=' +
94
- encodeURIComponent(window.location.href);
95
- }
96
- }
97
- RouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
98
- RouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, providedIn: 'root' });
99
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, decorators: [{
100
- type: Injectable,
101
- args: [{
102
- providedIn: 'root',
103
- }]
104
- }] });
105
-
106
41
  const VCOMPLY_LOGO_URL = 'https://cdn.v-comply.com/logo/prod/v-logo.svg';
107
42
  const API_TIMEOUT_TIME = 1000 * 15;
108
43
  const ERROR_CONFIG = {
@@ -146,6 +81,49 @@ const ERROR_CONFIG = {
146
81
  },
147
82
  };
148
83
 
84
+ const PAGE_LEVEL_API_CONFIG = [
85
+ {
86
+ method: 'POST',
87
+ path: '/compliance_post',
88
+ query: { mode: 'xyz' },
89
+ body: { mode: 'abc' },
90
+ pageCodes: ['compliance:mr', 'risk:mr'],
91
+ },
92
+ {
93
+ method: 'GET',
94
+ path: '/compliance_post',
95
+ query: { mode: 'xyz' },
96
+ body: { mode: 'abc' },
97
+ pageCodes: ['compliance:mr', 'risk:mr'],
98
+ },
99
+ ];
100
+ const COMPONENT_LEVEL_API_CONFIG = [
101
+ {
102
+ method: 'GET',
103
+ path: '/organization/?mode=organisationUsersList',
104
+ query: { type: 'active' },
105
+ body: null,
106
+ },
107
+ {
108
+ method: 'GET',
109
+ path: '/organization/?mode=organisationUsersList',
110
+ query: { type: 'power_users' },
111
+ body: null,
112
+ },
113
+ {
114
+ method: 'GET',
115
+ path: '/organization/?mode=organisationUsersList',
116
+ query: { type: 'light_users' },
117
+ body: null,
118
+ },
119
+ {
120
+ method: 'GET',
121
+ path: '/organization/?mode=organisationUsersList',
122
+ query: { type: 'inactive' },
123
+ body: null,
124
+ },
125
+ ];
126
+
149
127
  class SnackBarService {
150
128
  constructor() {
151
129
  this.snackbarSubject = new Subject();
@@ -175,6 +153,196 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
175
153
  }]
176
154
  }], ctorParameters: function () { return []; } });
177
155
 
156
+ class UtilsService {
157
+ isJsonSubset(parentJson, subsetJson) {
158
+ for (let key in subsetJson) {
159
+ if (!parentJson.hasOwnProperty(key) || parentJson[key] !== subsetJson[key]) {
160
+ return false;
161
+ }
162
+ }
163
+ return true;
164
+ }
165
+ }
166
+ UtilsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
167
+ UtilsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, providedIn: 'root' });
168
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, decorators: [{
169
+ type: Injectable,
170
+ args: [{
171
+ providedIn: 'root',
172
+ }]
173
+ }] });
174
+
175
+ class GlobalErrorService {
176
+ constructor(snackBarService, utilService, router) {
177
+ this.snackBarService = snackBarService;
178
+ this.utilService = utilService;
179
+ this.router = router;
180
+ this.globalError$ = new Subject();
181
+ this.localError$ = new Subject();
182
+ this.pageLevelApiConfig = PAGE_LEVEL_API_CONFIG;
183
+ this.componentLevelApiConfig = COMPONENT_LEVEL_API_CONFIG;
184
+ }
185
+ handleSoftErrors(event) {
186
+ const xData = event.headers.get('X-Data');
187
+ if (xData) {
188
+ const parsedData = JSON.parse(xData);
189
+ const statusCode = parsedData.statusCode;
190
+ const statusMessage = parsedData.message;
191
+ if (statusCode && statusCode !== 0) {
192
+ this.snackBarService.show(statusMessage || 'Error occurred', 'error');
193
+ }
194
+ }
195
+ }
196
+ handleError(error, request) {
197
+ if (this.isUnauthenticated(error) ||
198
+ this.isUnauthorizedAccess(error) ||
199
+ this.isNetworkUnavailable(error)) {
200
+ this.publishGlobalError(error);
201
+ }
202
+ else if (this.isServerError(error)) {
203
+ this.handleServerError(error, request);
204
+ }
205
+ else {
206
+ this.handleSoftErrors(error);
207
+ }
208
+ }
209
+ isServerError(error) {
210
+ const serverErrorCodes = [
211
+ ErrorStatusCode.InternalServerError,
212
+ ErrorStatusCode.ServiceUnavailable,
213
+ ErrorStatusCode.BadGateway,
214
+ ErrorStatusCode.RequestTimeout,
215
+ ];
216
+ return serverErrorCodes.includes(error.status);
217
+ }
218
+ isUnauthenticated(error) {
219
+ return error.status === ErrorStatusCode.Unauthenticated;
220
+ }
221
+ isUnauthorizedAccess(error) {
222
+ return error.status === ErrorStatusCode.UnauthorizedAccess;
223
+ }
224
+ isNetworkUnavailable(error) {
225
+ return error.status === ErrorStatusCode.NetworkUnavailable;
226
+ }
227
+ handleServerError(error, request) {
228
+ if (this.isPageLevelError(error, request)) {
229
+ this.publishGlobalError(error);
230
+ }
231
+ else if (this.isComponentLevelError(error, request)) {
232
+ this.publishLocalError(error, request);
233
+ }
234
+ else {
235
+ this.showServerSnackBarError();
236
+ }
237
+ }
238
+ publishGlobalError(error) {
239
+ this.globalError$.next(error);
240
+ }
241
+ publishLocalError(error, request) {
242
+ this.localError$.next({ error, request });
243
+ }
244
+ showServerSnackBarError() {
245
+ const message = ERROR_CONFIG.SERVER_ERROR.snackBarMessage;
246
+ this.snackBarService.show(message, 'error');
247
+ }
248
+ isPageLevelError(error, request) {
249
+ const { method, path, query, body } = this.parseRequest(request);
250
+ const pageCode = this.getPageCode();
251
+ const isConfigMatched = this.pageLevelApiConfig.some((apiConfig) => {
252
+ if (apiConfig.method !== method)
253
+ return false;
254
+ if (apiConfig.path !== path)
255
+ return false;
256
+ const isQuerySubset = this.utilService.isJsonSubset(apiConfig.query, query);
257
+ if (!isQuerySubset)
258
+ return false;
259
+ const isBodyMatch = this.utilService.isJsonSubset(apiConfig.body, body);
260
+ if (!isBodyMatch)
261
+ return false;
262
+ return apiConfig.pageCodes.includes(pageCode);
263
+ });
264
+ return isConfigMatched;
265
+ }
266
+ isComponentLevelError(error, request) {
267
+ const { method, url: path, params, body } = request;
268
+ const query = {};
269
+ params.keys().forEach((key) => {
270
+ query[key] = params.get(key);
271
+ });
272
+ const isConfigFound = this.componentLevelApiConfig.some((apiConfig) => {
273
+ if (apiConfig.method !== method)
274
+ return false;
275
+ if (!path.includes(apiConfig.path))
276
+ return false;
277
+ const isQuerySubset = this.utilService.isJsonSubset(query, apiConfig.query);
278
+ if (!isQuerySubset)
279
+ return false;
280
+ if (apiConfig.body) {
281
+ const isBodyMatch = this.utilService.isJsonSubset(apiConfig.body, body);
282
+ if (!isBodyMatch)
283
+ return false;
284
+ }
285
+ return true;
286
+ });
287
+ return isConfigFound;
288
+ }
289
+ parseRequest(request) {
290
+ const { method, url: path, params, body } = request;
291
+ const query = {};
292
+ params.keys().forEach((key) => {
293
+ query[key] = params.get(key);
294
+ });
295
+ return { method, path, query, body };
296
+ }
297
+ getPageCode() {
298
+ var _a;
299
+ const currentRoute = this.router.routerState.snapshot.root.firstChild;
300
+ return (_a = currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.data) === null || _a === void 0 ? void 0 : _a.pageCode;
301
+ }
302
+ }
303
+ GlobalErrorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, deps: [{ token: SnackBarService }, { token: UtilsService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
304
+ GlobalErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, providedIn: 'root' });
305
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, decorators: [{
306
+ type: Injectable,
307
+ args: [{
308
+ providedIn: 'root',
309
+ }]
310
+ }], ctorParameters: function () { return [{ type: SnackBarService }, { type: UtilsService }, { type: i3.Router }]; } });
311
+
312
+ class AuthService {
313
+ constructor(authorizer) {
314
+ this.authorizer = authorizer;
315
+ }
316
+ logoutUser() {
317
+ this.authorizer.logout();
318
+ }
319
+ }
320
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, deps: [{ token: i1.AuthorizerService }], target: i0.ɵɵFactoryTarget.Injectable });
321
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, providedIn: "root" });
322
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, decorators: [{
323
+ type: Injectable,
324
+ args: [{
325
+ providedIn: "root",
326
+ }]
327
+ }], ctorParameters: function () { return [{ type: i1.AuthorizerService }]; } });
328
+
329
+ class RouterService {
330
+ redirectToLogin() {
331
+ window.location.href =
332
+ `https://${window.location.host}/` +
333
+ 'signin?redirectURL=' +
334
+ encodeURIComponent(window.location.href);
335
+ }
336
+ }
337
+ RouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
338
+ RouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, providedIn: 'root' });
339
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, decorators: [{
340
+ type: Injectable,
341
+ args: [{
342
+ providedIn: 'root',
343
+ }]
344
+ }] });
345
+
178
346
  class SnackBarComponent {
179
347
  constructor(snackbarService) {
180
348
  this.snackbarService = snackbarService;
@@ -598,6 +766,74 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
598
766
  }]
599
767
  }], ctorParameters: function () { return [{ type: DialogService }]; } });
600
768
 
769
+ class ServerErrorComponent {
770
+ constructor() {
771
+ this.errorConfig = ERROR_CONFIG.SERVER_ERROR;
772
+ this.VcomplyLogo = VCOMPLY_LOGO_URL;
773
+ }
774
+ refreshPage() {
775
+ window.location.reload();
776
+ }
777
+ }
778
+ ServerErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
779
+ ServerErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: ServerErrorComponent, selector: "lib-vc-error-server-error", ngImport: i0, template: `
780
+ <div class="errorPage">
781
+ <div class="errorPage-top">
782
+ <img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
783
+ </div>
784
+ <div class="errorPage-container">
785
+ <div class="errorPage-inner">
786
+ <div class="errorPage-inner-image">
787
+ <img
788
+ [src]="errorConfig.imageUrl"
789
+ alt="Error Image"
790
+ width="246"
791
+ height="178"
792
+ />
793
+ </div>
794
+ <div class="errorPage-inner-right">
795
+ <div class="errorPage-heading">{{ errorConfig.title }}</div>
796
+ <div class="errorPage-text">{{ errorConfig.description }}</div>
797
+ <div class="errorPage-details">{{ errorConfig.details }}</div>
798
+ <button class="errorPage-btn" (click)="refreshPage()">
799
+ {{ errorConfig.buttonText }} <i class="icons">&#xe92b;</i>
800
+ </button>
801
+ </div>
802
+ </div>
803
+ </div>
804
+ </div>
805
+ `, isInline: true, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] });
806
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, decorators: [{
807
+ type: Component,
808
+ args: [{ selector: 'lib-vc-error-server-error', template: `
809
+ <div class="errorPage">
810
+ <div class="errorPage-top">
811
+ <img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
812
+ </div>
813
+ <div class="errorPage-container">
814
+ <div class="errorPage-inner">
815
+ <div class="errorPage-inner-image">
816
+ <img
817
+ [src]="errorConfig.imageUrl"
818
+ alt="Error Image"
819
+ width="246"
820
+ height="178"
821
+ />
822
+ </div>
823
+ <div class="errorPage-inner-right">
824
+ <div class="errorPage-heading">{{ errorConfig.title }}</div>
825
+ <div class="errorPage-text">{{ errorConfig.description }}</div>
826
+ <div class="errorPage-details">{{ errorConfig.details }}</div>
827
+ <button class="errorPage-btn" (click)="refreshPage()">
828
+ {{ errorConfig.buttonText }} <i class="icons">&#xe92b;</i>
829
+ </button>
830
+ </div>
831
+ </div>
832
+ </div>
833
+ </div>
834
+ `, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] }]
835
+ }] });
836
+
601
837
  class VcErrorHandlersComponent {
602
838
  constructor(errorService, snackBarService) {
603
839
  this.errorService = errorService;
@@ -606,6 +842,7 @@ class VcErrorHandlersComponent {
606
842
  this.unauthorized = false;
607
843
  this.sessionExpired = false;
608
844
  this.chunkUnavailable = false;
845
+ this.serverError = false;
609
846
  this.isOnline = navigator.onLine;
610
847
  this.onNetworkOnline = () => {
611
848
  this.isOnline = true;
@@ -642,6 +879,9 @@ class VcErrorHandlersComponent {
642
879
  else if (error.status === ErrorStatusCode.NetworkUnavailable) {
643
880
  this.handleNetworkError();
644
881
  }
882
+ else if (this.errorService.isServerError(error)) {
883
+ this.serverError = true;
884
+ }
645
885
  }
646
886
  subscribeNetworkDetection() {
647
887
  window.addEventListener('online', this.onNetworkOnline);
@@ -669,7 +909,8 @@ VcErrorHandlersComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0
669
909
  <lib-vc-error-chunk-unavailable
670
910
  *ngIf="chunkUnavailable"
671
911
  ></lib-vc-error-chunk-unavailable>
672
- `, isInline: true, components: [{ type: SnackBarComponent, selector: "app-snack-bar" }, { type: SessionExpiredComponent, selector: "lib-vc-error-session-expired" }, { type: UnauthorizedComponent, selector: "lib-vc-error-unauthorized" }, { type: ChunkUnavailableComponent, selector: "lib-vc-error-chunk-unavailable" }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
912
+ <lib-vc-error-server-error *ngIf="serverError"></lib-vc-error-server-error>
913
+ `, isInline: true, components: [{ type: SnackBarComponent, selector: "app-snack-bar" }, { type: SessionExpiredComponent, selector: "lib-vc-error-session-expired" }, { type: UnauthorizedComponent, selector: "lib-vc-error-unauthorized" }, { type: ChunkUnavailableComponent, selector: "lib-vc-error-chunk-unavailable" }, { type: ServerErrorComponent, selector: "lib-vc-error-server-error" }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
673
914
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersComponent, decorators: [{
674
915
  type: Component,
675
916
  args: [{
@@ -683,6 +924,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
683
924
  <lib-vc-error-chunk-unavailable
684
925
  *ngIf="chunkUnavailable"
685
926
  ></lib-vc-error-chunk-unavailable>
927
+ <lib-vc-error-server-error *ngIf="serverError"></lib-vc-error-server-error>
686
928
  `,
687
929
  }]
688
930
  }], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: SnackBarService }]; } });
@@ -766,74 +1008,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
766
1008
  `, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] }]
767
1009
  }], ctorParameters: function () { return [{ type: i3.Router }]; } });
768
1010
 
769
- class ServerErrorComponent {
770
- constructor() {
771
- this.errorConfig = ERROR_CONFIG.SERVER_ERROR;
772
- this.VcomplyLogo = VCOMPLY_LOGO_URL;
773
- }
774
- refreshPage() {
775
- window.location.reload();
776
- }
777
- }
778
- ServerErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
779
- ServerErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: ServerErrorComponent, selector: "lib-vc-error-server-error", ngImport: i0, template: `
780
- <div class="errorPage">
781
- <div class="errorPage-top">
782
- <img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
783
- </div>
784
- <div class="errorPage-container">
785
- <div class="errorPage-inner">
786
- <div class="errorPage-inner-image">
787
- <img
788
- [src]="errorConfig.imageUrl"
789
- alt="Error Image"
790
- width="246"
791
- height="178"
792
- />
793
- </div>
794
- <div class="errorPage-inner-right">
795
- <div class="errorPage-heading">{{ errorConfig.title }}</div>
796
- <div class="errorPage-text">{{ errorConfig.description }}</div>
797
- <div class="errorPage-details">{{ errorConfig.details }}</div>
798
- <button class="errorPage-btn" (click)="refreshPage()">
799
- {{ errorConfig.buttonText }} <i class="icons">&#xe92b;</i>
800
- </button>
801
- </div>
802
- </div>
803
- </div>
804
- </div>
805
- `, isInline: true, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] });
806
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, decorators: [{
807
- type: Component,
808
- args: [{ selector: 'lib-vc-error-server-error', template: `
809
- <div class="errorPage">
810
- <div class="errorPage-top">
811
- <img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
812
- </div>
813
- <div class="errorPage-container">
814
- <div class="errorPage-inner">
815
- <div class="errorPage-inner-image">
816
- <img
817
- [src]="errorConfig.imageUrl"
818
- alt="Error Image"
819
- width="246"
820
- height="178"
821
- />
822
- </div>
823
- <div class="errorPage-inner-right">
824
- <div class="errorPage-heading">{{ errorConfig.title }}</div>
825
- <div class="errorPage-text">{{ errorConfig.description }}</div>
826
- <div class="errorPage-details">{{ errorConfig.details }}</div>
827
- <button class="errorPage-btn" (click)="refreshPage()">
828
- {{ errorConfig.buttonText }} <i class="icons">&#xe92b;</i>
829
- </button>
830
- </div>
831
- </div>
832
- </div>
833
- </div>
834
- `, styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";.errorPage{background:#161b2f;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:9999}.errorPage-top{width:100%;height:3rem;display:flex;align-items:center;padding-left:.75rem}.errorPage-container{background:#f2f2f5;border-radius:.75rem;border:1px solid #e3e3e9;box-shadow:0 4px 8px #1d5dd31a;height:calc(100vh - 3.75rem);display:flex;align-items:center;justify-content:center;padding:0 4rem;margin:0 .75rem;position:relative}.errorPage-inner{display:flex;align-items:center}.errorPage-inner-image{width:16rem}.errorPage-inner-right{margin-left:2rem;width:calc(100% - 18rem)}.errorPage-inner-right .errorPage-heading{-webkit-text-fill-color:#e3e3e9;-webkit-text-stroke-color:#a9aab6;-webkit-text-stroke-width:1px;color:#e3e3e9;font-size:78px;font-weight:bold;line-height:110px;margin-bottom:1.5rem}.errorPage-inner-right .errorPage-text{color:#141724;font-size:19px;font-weight:500;line-height:1.75rem;margin-bottom:.5rem}.errorPage-inner-right .errorPage-details{color:#565a6f;font-size:13px;line-height:20px;margin-bottom:1.75rem}.errorPage-inner-right .errorPage-btn{background:#1e5dd3;border-radius:.25rem;border:none;color:#fff;display:inline-flex;align-items:center;font-size:11px;font-weight:500;line-height:2rem;padding:0 1rem}.errorPage-inner-right .errorPage-btn i{font-size:14px;margin-left:.25rem}.errorPage-copyright{font-size:11px;color:#787a8c;font-weight:500;position:absolute;bottom:8px;right:16px;line-height:16px}\n"] }]
835
- }] });
836
-
837
1011
  class SnackBarModule {
838
1012
  }
839
1013
  SnackBarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SnackBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -900,37 +1074,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
900
1074
  } });
901
1075
 
902
1076
  class HttpReqInterceptor {
903
- constructor(errorService, snackBarService) {
1077
+ constructor(errorService) {
904
1078
  this.errorService = errorService;
905
- this.snackBarService = snackBarService;
906
1079
  }
907
1080
  intercept(req, next) {
908
1081
  return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
909
1082
  if (event instanceof HttpResponse) {
910
- this.handleSoftErrors(event);
1083
+ this.errorService.handleSoftErrors(event);
911
1084
  }
912
1085
  }), catchError((error) => {
913
1086
  this.errorService.handleError(error, req);
914
1087
  return throwError(error);
915
1088
  }));
916
1089
  }
917
- handleSoftErrors(event) {
918
- const xData = event.headers.get('X-Data');
919
- if (xData) {
920
- const parsedData = JSON.parse(xData);
921
- const statusCode = parsedData.statusCode;
922
- const statusMessage = parsedData.message;
923
- if (statusCode && statusCode !== 0) {
924
- this.snackBarService.show(statusMessage || 'Error occurred', 'error');
925
- }
926
- }
927
- }
928
1090
  }
929
- HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }, { token: SnackBarService }], target: i0.ɵɵFactoryTarget.Injectable });
1091
+ HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }], target: i0.ɵɵFactoryTarget.Injectable });
930
1092
  HttpReqInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor });
931
1093
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, decorators: [{
932
1094
  type: Injectable
933
- }], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: SnackBarService }]; } });
1095
+ }], ctorParameters: function () { return [{ type: GlobalErrorService }]; } });
934
1096
 
935
1097
  const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken('forRoot() SentryErrorHandler options');
936
1098
  class VcErrorHandlersModule {