vc-error-handlers 0.1.95 → 0.1.97

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.
@@ -6,9 +6,10 @@ import { NavigationStart, NavigationEnd, NavigationError } from '@angular/router
6
6
  import * as i1 from '@vcomply/authorizer';
7
7
  import * as i2 from '@angular/common';
8
8
  import { CommonModule } from '@angular/common';
9
+ import * as i1$1 from '@angular/common/http';
9
10
  import { HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
11
+ import { retry, timeout, tap, catchError } from 'rxjs/operators';
10
12
  import * as Sentry from '@sentry/angular-ivy';
11
- import { timeout, tap, catchError } from 'rxjs/operators';
12
13
 
13
14
  class VcErrorHandlersService {
14
15
  constructor() { }
@@ -189,7 +190,7 @@ const COMPONENT_LEVEL_API_CONFIG = [
189
190
  },
190
191
  {
191
192
  method: 'POST',
192
- path: '/organization_post/?mode=memberDetailsbyIds',
193
+ path: '/organization_post?mode=memberDetailsbyIds',
193
194
  query: null,
194
195
  body: null,
195
196
  },
@@ -213,8 +214,8 @@ const COMPONENT_LEVEL_API_CONFIG = [
213
214
  },
214
215
  {
215
216
  method: 'POST',
216
- path: '/risk?mode=risk/list',
217
- query: { queryPage: 'compliance_workroom' },
217
+ path: 'risk/list',
218
+ query: null,
218
219
  body: null,
219
220
  },
220
221
  {
@@ -271,6 +272,18 @@ const COMPONENT_LEVEL_API_CONFIG = [
271
272
  query: null,
272
273
  body: null,
273
274
  },
275
+ {
276
+ method: 'GET',
277
+ path: '/program/subCategories',
278
+ query: null,
279
+ body: null,
280
+ },
281
+ {
282
+ method: 'POST',
283
+ path: '/Assessment/?mode=assessment/getAssessmentById',
284
+ query: null,
285
+ body: null,
286
+ },
274
287
  ];
275
288
 
276
289
  class SnackBarService {
@@ -413,16 +426,16 @@ class GlobalErrorService {
413
426
  params.keys().forEach((key) => {
414
427
  query[key] = params.get(key);
415
428
  });
416
- console.log('query', query, 'body', body, 'path', path, 'method', method, 'params', params);
417
429
  const isConfigFound = this.componentLevelApiConfig.some((apiConfig) => {
418
430
  if (apiConfig.method !== method)
419
431
  return false;
420
- console.log('apiConfig.path', apiConfig.path, path.includes(apiConfig.path));
421
432
  if (!path.includes(apiConfig.path))
422
433
  return false;
423
- const isQuerySubset = this.utilService.isJsonSubset(query, apiConfig.query);
424
- if (!isQuerySubset)
425
- return false;
434
+ if (apiConfig.query) {
435
+ const isQuerySubset = this.utilService.isJsonSubset(query, apiConfig.query);
436
+ if (!isQuerySubset)
437
+ return false;
438
+ }
426
439
  if (apiConfig.body) {
427
440
  const isBodyMatch = this.utilService.isJsonSubset(apiConfig.body, body);
428
441
  if (!isBodyMatch)
@@ -1273,6 +1286,212 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1273
1286
  }]
1274
1287
  }] });
1275
1288
 
1289
+ // This file can be replaced during build by using the `fileReplacements` array.
1290
+ // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
1291
+ // The list of file replacements can be found in `angular.json`.
1292
+ let domainName = 'devapi.v-comply.com';
1293
+ let apiBaseUrl = 'https://api-uat1.v-comply.com';
1294
+ switch (window.location.host) {
1295
+ case 'dev.v-comply.com':
1296
+ domainName = 'devapi.v-comply.com';
1297
+ apiBaseUrl = 'https://api-uat1.v-comply.com';
1298
+ break;
1299
+ case 'beta.v-comply.com':
1300
+ domainName = 'betaapi.v-comply.com';
1301
+ apiBaseUrl = 'https://api-staging.v-comply.com';
1302
+ break;
1303
+ case 'test.v-comply.com':
1304
+ domainName = 'devapi.v-comply.com';
1305
+ break;
1306
+ case 'eu.v-comply.com':
1307
+ domainName = 'euapi.v-comply.com';
1308
+ break;
1309
+ default:
1310
+ domainName = 'api.v-comply.com';
1311
+ break;
1312
+ }
1313
+ const PORT_EDITOR = 8081;
1314
+ const PORT_CONTENT_SAVE = 8834;
1315
+ let endPoint = 'https://devapi.v-comply.com/';
1316
+ const environment = {
1317
+ production: false,
1318
+ appUrl: 'http://localhost:4200/',
1319
+ apiBaseUrl: 'https://api-uat1.v-comply.com',
1320
+ authEndpoint: `${endPoint}VcomplyAuth/`,
1321
+ orgEndpoint_TL: `${endPoint}organization_pwt/?mode=`,
1322
+ s3Url: '',
1323
+ s3BucketUrl: `${endPoint}globals?mode=bucket`,
1324
+ s3Bucket: '',
1325
+ profile: '/profile_pic/thumb/',
1326
+ assessmentEnpoint: `${endPoint}Assessment/?mode=`,
1327
+ organizationPost: `${endPoint}organization_post/?mode=`,
1328
+ organizationGet: `${endPoint}organization/?mode=`,
1329
+ complianceGet: `${endPoint}compliance/?mode=`,
1330
+ compliancePost: `${endPoint}compliance_post/?mode=`,
1331
+ fileUploadEndPoint: 'https://upload-uat1.v-comply.com/fileupload/?destination=',
1332
+ assuranceGet: `${endPoint}assurance/?mode=`,
1333
+ policyGet: `${endPoint}policy/?mode=`,
1334
+ saveDoc: 'https://dev-node.v-comply.com/saveContent?bypass-token=true&id=',
1335
+ docxUpload: 'https://dev-node.v-comply.com/ImportDocument',
1336
+ fileUpload: 'https://dev-node.v-comply.com/importFiles',
1337
+ policyPost: `${endPoint}policy_post/?mode=`,
1338
+ policyPut: `${endPoint}policy_put/?mode=`,
1339
+ responsibilityPost: `${endPoint}responsibilities_post/?mode=`,
1340
+ linkDoc: 'https://dev-node.v-comply.com' + '/ImportDocument',
1341
+ linkPdf: 'https://dev-node.v-comply.com' + '/extractDocs',
1342
+ assuranceApi: 'https://devapi.v-comply.com/Assurance/',
1343
+ assurance: 'https://devapi.v-comply.com/Assurance/',
1344
+ programEndpoint: 'https://devapi.v-comply.com/program',
1345
+ risk: 'https://devapi.v-comply.com/risk/?mode=',
1346
+ risk_put: 'https://devapi.v-comply.com/risk_put/?mode=',
1347
+ riskPdfPost: 'https://devapi.v-comply.com/risk_pdf_post?mode=',
1348
+ riskPost: 'https://devapi.v-comply.com/risk_post/?mode=',
1349
+ riskGet: 'https://devapi.v-comply.com/risk/?mode=',
1350
+ baseUrl: 'https://devapi.v-comply.com/',
1351
+ grc_get: 'https://devapi.v-comply.com/grc_object/?mode=',
1352
+ leftMenuLogo: 'https://cdn.v-comply.com/logo/prod/v-logo.svg?v=1.0',
1353
+ vLoader: 'https://cdn.v-comply.com/logo/prod/v-icon-loader.svg?v=1.0',
1354
+ };
1355
+ /*
1356
+ * For easier debugging in development mode, you can import the following file
1357
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
1358
+ *
1359
+ * This import should be commented out in production mode because it will have a negative impact
1360
+ * on performance if an error is thrown.
1361
+ */
1362
+ // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
1363
+
1364
+ class FeatureFlagService {
1365
+ constructor(http, authorizer) {
1366
+ this.http = http;
1367
+ this.authorizer = authorizer;
1368
+ this.flagFetchError = false;
1369
+ this.featuresMap = {};
1370
+ this.AWSFlags = {};
1371
+ }
1372
+ fetchFlags() {
1373
+ return this.http.get(environment.baseUrl + 'features').pipe(retry(2));
1374
+ }
1375
+ loadConfig() {
1376
+ if (this.flagSubscription) {
1377
+ this.flagSubscription.unsubscribe();
1378
+ }
1379
+ return new Promise((resolve, reject) => {
1380
+ this.flagSubscription = this.fetchFlags().subscribe({
1381
+ next: (res) => {
1382
+ try {
1383
+ resolve(true);
1384
+ this.flagFetchError = false;
1385
+ this.AWSFlags = res;
1386
+ this.buildFeatureFlags(this.authorizer.getOrganizationId());
1387
+ }
1388
+ catch (error) {
1389
+ reject(error);
1390
+ }
1391
+ },
1392
+ error: (err) => {
1393
+ reject(true);
1394
+ this.flagFetchError = true;
1395
+ console.log('An error occurred while fetching feature flags', err);
1396
+ },
1397
+ });
1398
+ });
1399
+ }
1400
+ buildFeatureFlags(orgId) {
1401
+ orgId = orgId?.toString();
1402
+ const enabledFeatures = {};
1403
+ Object.keys(this.AWSFlags).forEach((flag) => {
1404
+ const flagObj = this.AWSFlags[flag];
1405
+ enabledFeatures[flag] = false;
1406
+ if (flagObj) {
1407
+ if (flagObj?.enabled && !flagObj.hasOwnProperty('enabledOrgIds')) {
1408
+ enabledFeatures[flag] = true;
1409
+ }
1410
+ else if (flagObj?.enabled &&
1411
+ flagObj.hasOwnProperty('enabledOrgIds') &&
1412
+ flagObj?.enabledOrgIds?.length > 0) {
1413
+ if (flagObj?.enabledOrgIds?.includes(orgId)) {
1414
+ enabledFeatures[flag] = true;
1415
+ }
1416
+ else {
1417
+ enabledFeatures[flag] = false;
1418
+ }
1419
+ }
1420
+ else {
1421
+ if (flagObj?.enabled) {
1422
+ enabledFeatures[flag] = true;
1423
+ }
1424
+ else {
1425
+ enabledFeatures[flag] = false;
1426
+ }
1427
+ }
1428
+ }
1429
+ else {
1430
+ enabledFeatures[flag] = true;
1431
+ }
1432
+ });
1433
+ this.featuresMap = enabledFeatures;
1434
+ }
1435
+ isFeatureEnabled(featureFlag) {
1436
+ if (this.featuresMap.hasOwnProperty(featureFlag)) {
1437
+ return this.featuresMap[featureFlag];
1438
+ }
1439
+ else {
1440
+ return true;
1441
+ }
1442
+ }
1443
+ }
1444
+ FeatureFlagService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagService, deps: [{ token: i1$1.HttpClient }, { token: i1.AuthorizerService }], target: i0.ɵɵFactoryTarget.Injectable });
1445
+ FeatureFlagService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagService, providedIn: 'root' });
1446
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagService, decorators: [{
1447
+ type: Injectable,
1448
+ args: [{
1449
+ providedIn: 'root',
1450
+ }]
1451
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: i1.AuthorizerService }]; } });
1452
+
1453
+ class FeatureFlagDirective {
1454
+ constructor(tpl, vcr, featureFlagService) {
1455
+ this.tpl = tpl;
1456
+ this.vcr = vcr;
1457
+ this.featureFlagService = featureFlagService;
1458
+ }
1459
+ ngOnInit() {
1460
+ const isEnabled = this.featureFlagService.isFeatureEnabled(this.featureFlag);
1461
+ if (isEnabled) {
1462
+ this.vcr.createEmbeddedView(this.tpl);
1463
+ }
1464
+ }
1465
+ }
1466
+ FeatureFlagDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: FeatureFlagService }], target: i0.ɵɵFactoryTarget.Directive });
1467
+ FeatureFlagDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.1", type: FeatureFlagDirective, selector: "[featureFlag]", inputs: { featureFlag: "featureFlag" }, ngImport: i0 });
1468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagDirective, decorators: [{
1469
+ type: Directive,
1470
+ args: [{
1471
+ selector: "[featureFlag]"
1472
+ }]
1473
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: FeatureFlagService }]; }, propDecorators: { featureFlag: [{
1474
+ type: Input
1475
+ }] } });
1476
+
1477
+ class FeatureFlagModule {
1478
+ }
1479
+ FeatureFlagModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1480
+ FeatureFlagModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, declarations: [FeatureFlagDirective], imports: [CommonModule], exports: [FeatureFlagDirective] });
1481
+ FeatureFlagModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, imports: [[
1482
+ CommonModule
1483
+ ]] });
1484
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, decorators: [{
1485
+ type: NgModule,
1486
+ args: [{
1487
+ declarations: [FeatureFlagDirective],
1488
+ imports: [
1489
+ CommonModule
1490
+ ],
1491
+ exports: [FeatureFlagDirective]
1492
+ }]
1493
+ }] });
1494
+
1276
1495
  class Configurations {
1277
1496
  constructor() {
1278
1497
  this.sentryConfig = {};
@@ -1323,28 +1542,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1323
1542
  }] }]; } });
1324
1543
 
1325
1544
  class HttpReqInterceptor {
1326
- constructor(errorService) {
1545
+ constructor(errorService, featureFlagService) {
1327
1546
  this.errorService = errorService;
1547
+ this.featureFlagService = featureFlagService;
1328
1548
  }
1329
1549
  intercept(req, next) {
1330
- return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
1331
- if (event instanceof HttpResponse) {
1332
- this.errorService.handleSoftErrors(event);
1333
- }
1334
- }), catchError((error) => {
1335
- this.errorService.handleError(error, req);
1336
- return throwError(error);
1337
- }));
1550
+ if (this.featureFlagService.isFeatureEnabled('ff_error_handling')) {
1551
+ return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
1552
+ if (event instanceof HttpResponse) {
1553
+ this.errorService.handleSoftErrors(event);
1554
+ }
1555
+ }), catchError((error) => {
1556
+ this.errorService.handleError(error, req);
1557
+ return throwError(error);
1558
+ }));
1559
+ }
1560
+ else {
1561
+ return next.handle(req);
1562
+ }
1338
1563
  }
1339
1564
  }
1340
- HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }], target: i0.ɵɵFactoryTarget.Injectable });
1565
+ HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }, { token: FeatureFlagService }], target: i0.ɵɵFactoryTarget.Injectable });
1341
1566
  HttpReqInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor });
1342
1567
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, decorators: [{
1343
1568
  type: Injectable
1344
- }], ctorParameters: function () { return [{ type: GlobalErrorService }]; } });
1569
+ }], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: FeatureFlagService }]; } });
1345
1570
 
1346
1571
  const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken('forRoot() SentryErrorHandler options');
1347
1572
  class VcErrorHandlersModule {
1573
+ constructor(loadConfig) {
1574
+ this.loadConfig = loadConfig;
1575
+ this.loadConfig.loadConfig();
1576
+ }
1348
1577
  static forRoot(environmentConfig) {
1349
1578
  return {
1350
1579
  ngModule: VcErrorHandlersModule,
@@ -1352,7 +1581,7 @@ class VcErrorHandlersModule {
1352
1581
  };
1353
1582
  }
1354
1583
  }
1355
- VcErrorHandlersModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1584
+ VcErrorHandlersModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, deps: [{ token: FeatureFlagService }], target: i0.ɵɵFactoryTarget.NgModule });
1356
1585
  VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, bootstrap: [VcErrorHandlersComponent], declarations: [VcErrorHandlersComponent,
1357
1586
  PageNotFoundComponent,
1358
1587
  UnauthorizedComponent,
@@ -1360,7 +1589,7 @@ VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
1360
1589
  ChunkUnavailableComponent,
1361
1590
  ServerErrorComponent,
1362
1591
  ErrorModalComponent,
1363
- ComponentLevelServerErrorComponent], imports: [CommonModule, DialogModule, SnackBarModule], exports: [VcErrorHandlersComponent,
1592
+ ComponentLevelServerErrorComponent], imports: [CommonModule, DialogModule, SnackBarModule, FeatureFlagModule], exports: [VcErrorHandlersComponent,
1364
1593
  PageNotFoundComponent,
1365
1594
  UnauthorizedComponent,
1366
1595
  SessionExpiredComponent,
@@ -1371,7 +1600,7 @@ VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
1371
1600
  VcErrorHandlersModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, providers: [
1372
1601
  { provide: ErrorHandler, useClass: SentryErrorHandler },
1373
1602
  { provide: HTTP_INTERCEPTORS, useClass: HttpReqInterceptor, multi: true },
1374
- ], imports: [[CommonModule, DialogModule, SnackBarModule]] });
1603
+ ], imports: [[CommonModule, DialogModule, SnackBarModule, FeatureFlagModule]] });
1375
1604
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, decorators: [{
1376
1605
  type: NgModule,
1377
1606
  args: [{
@@ -1385,7 +1614,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1385
1614
  ErrorModalComponent,
1386
1615
  ComponentLevelServerErrorComponent,
1387
1616
  ],
1388
- imports: [CommonModule, DialogModule, SnackBarModule],
1617
+ imports: [CommonModule, DialogModule, SnackBarModule, FeatureFlagModule],
1389
1618
  exports: [
1390
1619
  VcErrorHandlersComponent,
1391
1620
  PageNotFoundComponent,
@@ -1402,7 +1631,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1402
1631
  ],
1403
1632
  bootstrap: [VcErrorHandlersComponent],
1404
1633
  }]
1405
- }] });
1634
+ }], ctorParameters: function () { return [{ type: FeatureFlagService }]; } });
1406
1635
 
1407
1636
  /*
1408
1637
  * Public API Surface of vc-error-handlers