vc-error-handlers 0.1.8 → 0.1.91

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,115 @@ 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
+ method: 'GET',
127
+ path: '/Global-Dashboard/ManageDashboards',
128
+ query: null,
129
+ body: null,
130
+ },
131
+ {
132
+ method: 'GET',
133
+ path: '/Global-Dashboard/MyDashboard',
134
+ query: null,
135
+ body: null,
136
+ },
137
+ {
138
+ method: 'GET',
139
+ path: '/grc_object/?mode=grcObject/getGRCTypeList',
140
+ query: null,
141
+ body: null,
142
+ },
143
+ {
144
+ method: 'GET',
145
+ path: '/compliance/?mode=responsibilityCenterTree',
146
+ query: null,
147
+ body: null,
148
+ },
149
+ {
150
+ method: 'GET',
151
+ path: '/organization/?mode=rcholidaylist',
152
+ query: null,
153
+ body: null,
154
+ },
155
+ {
156
+ method: 'GET',
157
+ path: '/organization/?mode=roles/getRoles',
158
+ query: null,
159
+ body: null,
160
+ },
161
+ {
162
+ method: 'GET',
163
+ path: '/organization/?mode=groupsList',
164
+ query: null,
165
+ body: null,
166
+ },
167
+ {
168
+ method: 'GET',
169
+ path: '/compliance_post/?mode=rcProfile',
170
+ query: null,
171
+ body: null,
172
+ },
173
+ {
174
+ method: 'GET',
175
+ path: '/organization_post/?mode=userProfile',
176
+ query: null,
177
+ body: null,
178
+ },
179
+ {
180
+ method: 'GET',
181
+ path: '/organization/?mode=roles/roleById',
182
+ query: null,
183
+ body: null,
184
+ },
185
+ {
186
+ method: 'GET',
187
+ path: '/organization/?mode=groupDetails',
188
+ query: null,
189
+ body: null,
190
+ }
191
+ ];
192
+
149
193
  class SnackBarService {
150
194
  constructor() {
151
195
  this.snackbarSubject = new Subject();
@@ -175,6 +219,196 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
175
219
  }]
176
220
  }], ctorParameters: function () { return []; } });
177
221
 
222
+ class UtilsService {
223
+ isJsonSubset(parentJson, subsetJson) {
224
+ for (let key in subsetJson) {
225
+ if (!parentJson.hasOwnProperty(key) || parentJson[key] !== subsetJson[key]) {
226
+ return false;
227
+ }
228
+ }
229
+ return true;
230
+ }
231
+ }
232
+ UtilsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
233
+ UtilsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, providedIn: 'root' });
234
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: UtilsService, decorators: [{
235
+ type: Injectable,
236
+ args: [{
237
+ providedIn: 'root',
238
+ }]
239
+ }] });
240
+
241
+ class GlobalErrorService {
242
+ constructor(snackBarService, utilService, router) {
243
+ this.snackBarService = snackBarService;
244
+ this.utilService = utilService;
245
+ this.router = router;
246
+ this.globalError$ = new Subject();
247
+ this.localError$ = new Subject();
248
+ this.pageLevelApiConfig = PAGE_LEVEL_API_CONFIG;
249
+ this.componentLevelApiConfig = COMPONENT_LEVEL_API_CONFIG;
250
+ }
251
+ handleSoftErrors(event) {
252
+ const xData = event.headers.get('X-Data');
253
+ if (xData) {
254
+ const parsedData = JSON.parse(xData);
255
+ const statusCode = parsedData.statusCode;
256
+ const statusMessage = parsedData.message;
257
+ if (statusCode && statusCode !== 0) {
258
+ this.snackBarService.show(statusMessage || 'Error occurred', 'error');
259
+ }
260
+ }
261
+ }
262
+ handleError(error, request) {
263
+ if (this.isUnauthenticated(error) ||
264
+ this.isUnauthorizedAccess(error) ||
265
+ this.isNetworkUnavailable(error)) {
266
+ this.publishGlobalError(error);
267
+ }
268
+ else if (this.isServerError(error)) {
269
+ this.handleServerError(error, request);
270
+ }
271
+ else {
272
+ this.handleSoftErrors(error);
273
+ }
274
+ }
275
+ isServerError(error) {
276
+ const serverErrorCodes = [
277
+ ErrorStatusCode.InternalServerError,
278
+ ErrorStatusCode.ServiceUnavailable,
279
+ ErrorStatusCode.BadGateway,
280
+ ErrorStatusCode.RequestTimeout,
281
+ ];
282
+ return serverErrorCodes.includes(error.status);
283
+ }
284
+ isUnauthenticated(error) {
285
+ return error.status === ErrorStatusCode.Unauthenticated;
286
+ }
287
+ isUnauthorizedAccess(error) {
288
+ return error.status === ErrorStatusCode.UnauthorizedAccess;
289
+ }
290
+ isNetworkUnavailable(error) {
291
+ return error.status === ErrorStatusCode.NetworkUnavailable;
292
+ }
293
+ handleServerError(error, request) {
294
+ if (this.isPageLevelError(error, request)) {
295
+ this.publishGlobalError(error);
296
+ }
297
+ else if (this.isComponentLevelError(error, request)) {
298
+ this.publishLocalError(error, request);
299
+ }
300
+ else {
301
+ this.showServerSnackBarError();
302
+ }
303
+ }
304
+ publishGlobalError(error) {
305
+ this.globalError$.next(error);
306
+ }
307
+ publishLocalError(error, request) {
308
+ this.localError$.next({ error, request });
309
+ }
310
+ showServerSnackBarError() {
311
+ const message = ERROR_CONFIG.SERVER_ERROR.snackBarMessage;
312
+ this.snackBarService.show(message, 'error');
313
+ }
314
+ isPageLevelError(error, request) {
315
+ const { method, path, query, body } = this.parseRequest(request);
316
+ const pageCode = this.getPageCode();
317
+ const isConfigMatched = this.pageLevelApiConfig.some((apiConfig) => {
318
+ if (apiConfig.method !== method)
319
+ return false;
320
+ if (apiConfig.path !== path)
321
+ return false;
322
+ const isQuerySubset = this.utilService.isJsonSubset(apiConfig.query, query);
323
+ if (!isQuerySubset)
324
+ return false;
325
+ const isBodyMatch = this.utilService.isJsonSubset(apiConfig.body, body);
326
+ if (!isBodyMatch)
327
+ return false;
328
+ return apiConfig.pageCodes.includes(pageCode);
329
+ });
330
+ return isConfigMatched;
331
+ }
332
+ isComponentLevelError(error, request) {
333
+ const { method, url: path, params, body } = request;
334
+ const query = {};
335
+ params.keys().forEach((key) => {
336
+ query[key] = params.get(key);
337
+ });
338
+ const isConfigFound = this.componentLevelApiConfig.some((apiConfig) => {
339
+ if (apiConfig.method !== method)
340
+ return false;
341
+ if (!path.includes(apiConfig.path))
342
+ return false;
343
+ const isQuerySubset = this.utilService.isJsonSubset(query, apiConfig.query);
344
+ if (!isQuerySubset)
345
+ return false;
346
+ if (apiConfig.body) {
347
+ const isBodyMatch = this.utilService.isJsonSubset(apiConfig.body, body);
348
+ if (!isBodyMatch)
349
+ return false;
350
+ }
351
+ return true;
352
+ });
353
+ return isConfigFound;
354
+ }
355
+ parseRequest(request) {
356
+ const { method, url: path, params, body } = request;
357
+ const query = {};
358
+ params.keys().forEach((key) => {
359
+ query[key] = params.get(key);
360
+ });
361
+ return { method, path, query, body };
362
+ }
363
+ getPageCode() {
364
+ var _a;
365
+ const currentRoute = this.router.routerState.snapshot.root.firstChild;
366
+ return (_a = currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.data) === null || _a === void 0 ? void 0 : _a.pageCode;
367
+ }
368
+ }
369
+ 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 });
370
+ GlobalErrorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, providedIn: 'root' });
371
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: GlobalErrorService, decorators: [{
372
+ type: Injectable,
373
+ args: [{
374
+ providedIn: 'root',
375
+ }]
376
+ }], ctorParameters: function () { return [{ type: SnackBarService }, { type: UtilsService }, { type: i3.Router }]; } });
377
+
378
+ class AuthService {
379
+ constructor(authorizer) {
380
+ this.authorizer = authorizer;
381
+ }
382
+ logoutUser() {
383
+ this.authorizer.logout();
384
+ }
385
+ }
386
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, deps: [{ token: i1.AuthorizerService }], target: i0.ɵɵFactoryTarget.Injectable });
387
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, providedIn: "root" });
388
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: AuthService, decorators: [{
389
+ type: Injectable,
390
+ args: [{
391
+ providedIn: "root",
392
+ }]
393
+ }], ctorParameters: function () { return [{ type: i1.AuthorizerService }]; } });
394
+
395
+ class RouterService {
396
+ redirectToLogin() {
397
+ window.location.href =
398
+ `https://${window.location.host}/` +
399
+ 'signin?redirectURL=' +
400
+ encodeURIComponent(window.location.href);
401
+ }
402
+ }
403
+ RouterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
404
+ RouterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, providedIn: 'root' });
405
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: RouterService, decorators: [{
406
+ type: Injectable,
407
+ args: [{
408
+ providedIn: 'root',
409
+ }]
410
+ }] });
411
+
178
412
  class SnackBarComponent {
179
413
  constructor(snackbarService) {
180
414
  this.snackbarService = snackbarService;
@@ -598,6 +832,74 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
598
832
  }]
599
833
  }], ctorParameters: function () { return [{ type: DialogService }]; } });
600
834
 
835
+ class ServerErrorComponent {
836
+ constructor() {
837
+ this.errorConfig = ERROR_CONFIG.SERVER_ERROR;
838
+ this.VcomplyLogo = VCOMPLY_LOGO_URL;
839
+ }
840
+ refreshPage() {
841
+ window.location.reload();
842
+ }
843
+ }
844
+ ServerErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
845
+ ServerErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: ServerErrorComponent, selector: "lib-vc-error-server-error", ngImport: i0, template: `
846
+ <div class="errorPage">
847
+ <div class="errorPage-top">
848
+ <img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
849
+ </div>
850
+ <div class="errorPage-container">
851
+ <div class="errorPage-inner">
852
+ <div class="errorPage-inner-image">
853
+ <img
854
+ [src]="errorConfig.imageUrl"
855
+ alt="Error Image"
856
+ width="246"
857
+ height="178"
858
+ />
859
+ </div>
860
+ <div class="errorPage-inner-right">
861
+ <div class="errorPage-heading">{{ errorConfig.title }}</div>
862
+ <div class="errorPage-text">{{ errorConfig.description }}</div>
863
+ <div class="errorPage-details">{{ errorConfig.details }}</div>
864
+ <button class="errorPage-btn" (click)="refreshPage()">
865
+ {{ errorConfig.buttonText }} <i class="icons">&#xe92b;</i>
866
+ </button>
867
+ </div>
868
+ </div>
869
+ </div>
870
+ </div>
871
+ `, 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"] });
872
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: ServerErrorComponent, decorators: [{
873
+ type: Component,
874
+ args: [{ selector: 'lib-vc-error-server-error', template: `
875
+ <div class="errorPage">
876
+ <div class="errorPage-top">
877
+ <img [src]="VcomplyLogo" alt="VComply" width="24" height="24" />
878
+ </div>
879
+ <div class="errorPage-container">
880
+ <div class="errorPage-inner">
881
+ <div class="errorPage-inner-image">
882
+ <img
883
+ [src]="errorConfig.imageUrl"
884
+ alt="Error Image"
885
+ width="246"
886
+ height="178"
887
+ />
888
+ </div>
889
+ <div class="errorPage-inner-right">
890
+ <div class="errorPage-heading">{{ errorConfig.title }}</div>
891
+ <div class="errorPage-text">{{ errorConfig.description }}</div>
892
+ <div class="errorPage-details">{{ errorConfig.details }}</div>
893
+ <button class="errorPage-btn" (click)="refreshPage()">
894
+ {{ errorConfig.buttonText }} <i class="icons">&#xe92b;</i>
895
+ </button>
896
+ </div>
897
+ </div>
898
+ </div>
899
+ </div>
900
+ `, 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"] }]
901
+ }] });
902
+
601
903
  class VcErrorHandlersComponent {
602
904
  constructor(errorService, snackBarService) {
603
905
  this.errorService = errorService;
@@ -606,6 +908,7 @@ class VcErrorHandlersComponent {
606
908
  this.unauthorized = false;
607
909
  this.sessionExpired = false;
608
910
  this.chunkUnavailable = false;
911
+ this.serverError = false;
609
912
  this.isOnline = navigator.onLine;
610
913
  this.onNetworkOnline = () => {
611
914
  this.isOnline = true;
@@ -642,6 +945,9 @@ class VcErrorHandlersComponent {
642
945
  else if (error.status === ErrorStatusCode.NetworkUnavailable) {
643
946
  this.handleNetworkError();
644
947
  }
948
+ else if (this.errorService.isServerError(error)) {
949
+ this.serverError = true;
950
+ }
645
951
  }
646
952
  subscribeNetworkDetection() {
647
953
  window.addEventListener('online', this.onNetworkOnline);
@@ -669,7 +975,8 @@ VcErrorHandlersComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0
669
975
  <lib-vc-error-chunk-unavailable
670
976
  *ngIf="chunkUnavailable"
671
977
  ></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"] }] });
978
+ <lib-vc-error-server-error *ngIf="serverError"></lib-vc-error-server-error>
979
+ `, 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
980
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersComponent, decorators: [{
674
981
  type: Component,
675
982
  args: [{
@@ -683,6 +990,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
683
990
  <lib-vc-error-chunk-unavailable
684
991
  *ngIf="chunkUnavailable"
685
992
  ></lib-vc-error-chunk-unavailable>
993
+ <lib-vc-error-server-error *ngIf="serverError"></lib-vc-error-server-error>
686
994
  `,
687
995
  }]
688
996
  }], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: SnackBarService }]; } });
@@ -766,74 +1074,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
766
1074
  `, 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
1075
  }], ctorParameters: function () { return [{ type: i3.Router }]; } });
768
1076
 
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
1077
  class SnackBarModule {
838
1078
  }
839
1079
  SnackBarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SnackBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -900,37 +1140,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
900
1140
  } });
901
1141
 
902
1142
  class HttpReqInterceptor {
903
- constructor(errorService, snackBarService) {
1143
+ constructor(errorService) {
904
1144
  this.errorService = errorService;
905
- this.snackBarService = snackBarService;
906
1145
  }
907
1146
  intercept(req, next) {
908
1147
  return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
909
1148
  if (event instanceof HttpResponse) {
910
- this.handleSoftErrors(event);
1149
+ this.errorService.handleSoftErrors(event);
911
1150
  }
912
1151
  }), catchError((error) => {
913
1152
  this.errorService.handleError(error, req);
914
1153
  return throwError(error);
915
1154
  }));
916
1155
  }
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
1156
  }
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 });
1157
+ HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }], target: i0.ɵɵFactoryTarget.Injectable });
930
1158
  HttpReqInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor });
931
1159
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, decorators: [{
932
1160
  type: Injectable
933
- }], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: SnackBarService }]; } });
1161
+ }], ctorParameters: function () { return [{ type: GlobalErrorService }]; } });
934
1162
 
935
1163
  const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken('forRoot() SentryErrorHandler options');
936
1164
  class VcErrorHandlersModule {