vc-error-handlers 0.1.96 → 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() { }
@@ -1285,6 +1286,212 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1285
1286
  }]
1286
1287
  }] });
1287
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
+
1288
1495
  class Configurations {
1289
1496
  constructor() {
1290
1497
  this.sentryConfig = {};
@@ -1335,28 +1542,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1335
1542
  }] }]; } });
1336
1543
 
1337
1544
  class HttpReqInterceptor {
1338
- constructor(errorService) {
1545
+ constructor(errorService, featureFlagService) {
1339
1546
  this.errorService = errorService;
1547
+ this.featureFlagService = featureFlagService;
1340
1548
  }
1341
1549
  intercept(req, next) {
1342
- return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
1343
- if (event instanceof HttpResponse) {
1344
- this.errorService.handleSoftErrors(event);
1345
- }
1346
- }), catchError((error) => {
1347
- this.errorService.handleError(error, req);
1348
- return throwError(error);
1349
- }));
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
+ }
1350
1563
  }
1351
1564
  }
1352
- 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 });
1353
1566
  HttpReqInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor });
1354
1567
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, decorators: [{
1355
1568
  type: Injectable
1356
- }], ctorParameters: function () { return [{ type: GlobalErrorService }]; } });
1569
+ }], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: FeatureFlagService }]; } });
1357
1570
 
1358
1571
  const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken('forRoot() SentryErrorHandler options');
1359
1572
  class VcErrorHandlersModule {
1573
+ constructor(loadConfig) {
1574
+ this.loadConfig = loadConfig;
1575
+ this.loadConfig.loadConfig();
1576
+ }
1360
1577
  static forRoot(environmentConfig) {
1361
1578
  return {
1362
1579
  ngModule: VcErrorHandlersModule,
@@ -1364,7 +1581,7 @@ class VcErrorHandlersModule {
1364
1581
  };
1365
1582
  }
1366
1583
  }
1367
- 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 });
1368
1585
  VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, bootstrap: [VcErrorHandlersComponent], declarations: [VcErrorHandlersComponent,
1369
1586
  PageNotFoundComponent,
1370
1587
  UnauthorizedComponent,
@@ -1372,7 +1589,7 @@ VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
1372
1589
  ChunkUnavailableComponent,
1373
1590
  ServerErrorComponent,
1374
1591
  ErrorModalComponent,
1375
- ComponentLevelServerErrorComponent], imports: [CommonModule, DialogModule, SnackBarModule], exports: [VcErrorHandlersComponent,
1592
+ ComponentLevelServerErrorComponent], imports: [CommonModule, DialogModule, SnackBarModule, FeatureFlagModule], exports: [VcErrorHandlersComponent,
1376
1593
  PageNotFoundComponent,
1377
1594
  UnauthorizedComponent,
1378
1595
  SessionExpiredComponent,
@@ -1383,7 +1600,7 @@ VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
1383
1600
  VcErrorHandlersModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, providers: [
1384
1601
  { provide: ErrorHandler, useClass: SentryErrorHandler },
1385
1602
  { provide: HTTP_INTERCEPTORS, useClass: HttpReqInterceptor, multi: true },
1386
- ], imports: [[CommonModule, DialogModule, SnackBarModule]] });
1603
+ ], imports: [[CommonModule, DialogModule, SnackBarModule, FeatureFlagModule]] });
1387
1604
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, decorators: [{
1388
1605
  type: NgModule,
1389
1606
  args: [{
@@ -1397,7 +1614,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1397
1614
  ErrorModalComponent,
1398
1615
  ComponentLevelServerErrorComponent,
1399
1616
  ],
1400
- imports: [CommonModule, DialogModule, SnackBarModule],
1617
+ imports: [CommonModule, DialogModule, SnackBarModule, FeatureFlagModule],
1401
1618
  exports: [
1402
1619
  VcErrorHandlersComponent,
1403
1620
  PageNotFoundComponent,
@@ -1414,7 +1631,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1414
1631
  ],
1415
1632
  bootstrap: [VcErrorHandlersComponent],
1416
1633
  }]
1417
- }] });
1634
+ }], ctorParameters: function () { return [{ type: FeatureFlagService }]; } });
1418
1635
 
1419
1636
  /*
1420
1637
  * Public API Surface of vc-error-handlers
@@ -1425,3 +1642,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1425
1642
  */
1426
1643
 
1427
1644
  export { AuthService, ChunkUnavailableComponent, ComponentLevelServerErrorComponent, ErrorModalComponent, FOR_ROOT_SENTRY_OPTIONS_TOKEN, GlobalErrorService, HttpReqInterceptor, PageNotFoundComponent, RouterService, ServerErrorComponent, SessionExpiredComponent, UnauthorizedComponent, VcErrorHandlersComponent, VcErrorHandlersModule, VcErrorHandlersService };
1645
+ //# sourceMappingURL=vc-error-handlers.mjs.map