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() { }
@@ -1287,6 +1288,213 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1287
1288
  }]
1288
1289
  }] });
1289
1290
 
1291
+ // This file can be replaced during build by using the `fileReplacements` array.
1292
+ // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
1293
+ // The list of file replacements can be found in `angular.json`.
1294
+ let domainName = 'devapi.v-comply.com';
1295
+ let apiBaseUrl = 'https://api-uat1.v-comply.com';
1296
+ switch (window.location.host) {
1297
+ case 'dev.v-comply.com':
1298
+ domainName = 'devapi.v-comply.com';
1299
+ apiBaseUrl = 'https://api-uat1.v-comply.com';
1300
+ break;
1301
+ case 'beta.v-comply.com':
1302
+ domainName = 'betaapi.v-comply.com';
1303
+ apiBaseUrl = 'https://api-staging.v-comply.com';
1304
+ break;
1305
+ case 'test.v-comply.com':
1306
+ domainName = 'devapi.v-comply.com';
1307
+ break;
1308
+ case 'eu.v-comply.com':
1309
+ domainName = 'euapi.v-comply.com';
1310
+ break;
1311
+ default:
1312
+ domainName = 'api.v-comply.com';
1313
+ break;
1314
+ }
1315
+ const PORT_EDITOR = 8081;
1316
+ const PORT_CONTENT_SAVE = 8834;
1317
+ let endPoint = 'https://devapi.v-comply.com/';
1318
+ const environment = {
1319
+ production: false,
1320
+ appUrl: 'http://localhost:4200/',
1321
+ apiBaseUrl: 'https://api-uat1.v-comply.com',
1322
+ authEndpoint: `${endPoint}VcomplyAuth/`,
1323
+ orgEndpoint_TL: `${endPoint}organization_pwt/?mode=`,
1324
+ s3Url: '',
1325
+ s3BucketUrl: `${endPoint}globals?mode=bucket`,
1326
+ s3Bucket: '',
1327
+ profile: '/profile_pic/thumb/',
1328
+ assessmentEnpoint: `${endPoint}Assessment/?mode=`,
1329
+ organizationPost: `${endPoint}organization_post/?mode=`,
1330
+ organizationGet: `${endPoint}organization/?mode=`,
1331
+ complianceGet: `${endPoint}compliance/?mode=`,
1332
+ compliancePost: `${endPoint}compliance_post/?mode=`,
1333
+ fileUploadEndPoint: 'https://upload-uat1.v-comply.com/fileupload/?destination=',
1334
+ assuranceGet: `${endPoint}assurance/?mode=`,
1335
+ policyGet: `${endPoint}policy/?mode=`,
1336
+ saveDoc: 'https://dev-node.v-comply.com/saveContent?bypass-token=true&id=',
1337
+ docxUpload: 'https://dev-node.v-comply.com/ImportDocument',
1338
+ fileUpload: 'https://dev-node.v-comply.com/importFiles',
1339
+ policyPost: `${endPoint}policy_post/?mode=`,
1340
+ policyPut: `${endPoint}policy_put/?mode=`,
1341
+ responsibilityPost: `${endPoint}responsibilities_post/?mode=`,
1342
+ linkDoc: 'https://dev-node.v-comply.com' + '/ImportDocument',
1343
+ linkPdf: 'https://dev-node.v-comply.com' + '/extractDocs',
1344
+ assuranceApi: 'https://devapi.v-comply.com/Assurance/',
1345
+ assurance: 'https://devapi.v-comply.com/Assurance/',
1346
+ programEndpoint: 'https://devapi.v-comply.com/program',
1347
+ risk: 'https://devapi.v-comply.com/risk/?mode=',
1348
+ risk_put: 'https://devapi.v-comply.com/risk_put/?mode=',
1349
+ riskPdfPost: 'https://devapi.v-comply.com/risk_pdf_post?mode=',
1350
+ riskPost: 'https://devapi.v-comply.com/risk_post/?mode=',
1351
+ riskGet: 'https://devapi.v-comply.com/risk/?mode=',
1352
+ baseUrl: 'https://devapi.v-comply.com/',
1353
+ grc_get: 'https://devapi.v-comply.com/grc_object/?mode=',
1354
+ leftMenuLogo: 'https://cdn.v-comply.com/logo/prod/v-logo.svg?v=1.0',
1355
+ vLoader: 'https://cdn.v-comply.com/logo/prod/v-icon-loader.svg?v=1.0',
1356
+ };
1357
+ /*
1358
+ * For easier debugging in development mode, you can import the following file
1359
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
1360
+ *
1361
+ * This import should be commented out in production mode because it will have a negative impact
1362
+ * on performance if an error is thrown.
1363
+ */
1364
+ // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
1365
+
1366
+ class FeatureFlagService {
1367
+ constructor(http, authorizer) {
1368
+ this.http = http;
1369
+ this.authorizer = authorizer;
1370
+ this.flagFetchError = false;
1371
+ this.featuresMap = {};
1372
+ this.AWSFlags = {};
1373
+ }
1374
+ fetchFlags() {
1375
+ return this.http.get(environment.baseUrl + 'features').pipe(retry(2));
1376
+ }
1377
+ loadConfig() {
1378
+ if (this.flagSubscription) {
1379
+ this.flagSubscription.unsubscribe();
1380
+ }
1381
+ return new Promise((resolve, reject) => {
1382
+ this.flagSubscription = this.fetchFlags().subscribe({
1383
+ next: (res) => {
1384
+ try {
1385
+ resolve(true);
1386
+ this.flagFetchError = false;
1387
+ this.AWSFlags = res;
1388
+ this.buildFeatureFlags(this.authorizer.getOrganizationId());
1389
+ }
1390
+ catch (error) {
1391
+ reject(error);
1392
+ }
1393
+ },
1394
+ error: (err) => {
1395
+ reject(true);
1396
+ this.flagFetchError = true;
1397
+ console.log('An error occurred while fetching feature flags', err);
1398
+ },
1399
+ });
1400
+ });
1401
+ }
1402
+ buildFeatureFlags(orgId) {
1403
+ orgId = orgId === null || orgId === void 0 ? void 0 : orgId.toString();
1404
+ const enabledFeatures = {};
1405
+ Object.keys(this.AWSFlags).forEach((flag) => {
1406
+ var _a, _b;
1407
+ const flagObj = this.AWSFlags[flag];
1408
+ enabledFeatures[flag] = false;
1409
+ if (flagObj) {
1410
+ if ((flagObj === null || flagObj === void 0 ? void 0 : flagObj.enabled) && !flagObj.hasOwnProperty('enabledOrgIds')) {
1411
+ enabledFeatures[flag] = true;
1412
+ }
1413
+ else if ((flagObj === null || flagObj === void 0 ? void 0 : flagObj.enabled) &&
1414
+ flagObj.hasOwnProperty('enabledOrgIds') &&
1415
+ ((_a = flagObj === null || flagObj === void 0 ? void 0 : flagObj.enabledOrgIds) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1416
+ if ((_b = flagObj === null || flagObj === void 0 ? void 0 : flagObj.enabledOrgIds) === null || _b === void 0 ? void 0 : _b.includes(orgId)) {
1417
+ enabledFeatures[flag] = true;
1418
+ }
1419
+ else {
1420
+ enabledFeatures[flag] = false;
1421
+ }
1422
+ }
1423
+ else {
1424
+ if (flagObj === null || flagObj === void 0 ? void 0 : flagObj.enabled) {
1425
+ enabledFeatures[flag] = true;
1426
+ }
1427
+ else {
1428
+ enabledFeatures[flag] = false;
1429
+ }
1430
+ }
1431
+ }
1432
+ else {
1433
+ enabledFeatures[flag] = true;
1434
+ }
1435
+ });
1436
+ this.featuresMap = enabledFeatures;
1437
+ }
1438
+ isFeatureEnabled(featureFlag) {
1439
+ if (this.featuresMap.hasOwnProperty(featureFlag)) {
1440
+ return this.featuresMap[featureFlag];
1441
+ }
1442
+ else {
1443
+ return true;
1444
+ }
1445
+ }
1446
+ }
1447
+ 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 });
1448
+ FeatureFlagService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagService, providedIn: 'root' });
1449
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagService, decorators: [{
1450
+ type: Injectable,
1451
+ args: [{
1452
+ providedIn: 'root',
1453
+ }]
1454
+ }], ctorParameters: function () { return [{ type: i1$1.HttpClient }, { type: i1.AuthorizerService }]; } });
1455
+
1456
+ class FeatureFlagDirective {
1457
+ constructor(tpl, vcr, featureFlagService) {
1458
+ this.tpl = tpl;
1459
+ this.vcr = vcr;
1460
+ this.featureFlagService = featureFlagService;
1461
+ }
1462
+ ngOnInit() {
1463
+ const isEnabled = this.featureFlagService.isFeatureEnabled(this.featureFlag);
1464
+ if (isEnabled) {
1465
+ this.vcr.createEmbeddedView(this.tpl);
1466
+ }
1467
+ }
1468
+ }
1469
+ 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 });
1470
+ FeatureFlagDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.1", type: FeatureFlagDirective, selector: "[featureFlag]", inputs: { featureFlag: "featureFlag" }, ngImport: i0 });
1471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagDirective, decorators: [{
1472
+ type: Directive,
1473
+ args: [{
1474
+ selector: "[featureFlag]"
1475
+ }]
1476
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: FeatureFlagService }]; }, propDecorators: { featureFlag: [{
1477
+ type: Input
1478
+ }] } });
1479
+
1480
+ class FeatureFlagModule {
1481
+ }
1482
+ FeatureFlagModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1483
+ FeatureFlagModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, declarations: [FeatureFlagDirective], imports: [CommonModule], exports: [FeatureFlagDirective] });
1484
+ FeatureFlagModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, imports: [[
1485
+ CommonModule
1486
+ ]] });
1487
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: FeatureFlagModule, decorators: [{
1488
+ type: NgModule,
1489
+ args: [{
1490
+ declarations: [FeatureFlagDirective],
1491
+ imports: [
1492
+ CommonModule
1493
+ ],
1494
+ exports: [FeatureFlagDirective]
1495
+ }]
1496
+ }] });
1497
+
1290
1498
  class Configurations {
1291
1499
  constructor() {
1292
1500
  this.sentryConfig = {};
@@ -1339,28 +1547,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1339
1547
  } });
1340
1548
 
1341
1549
  class HttpReqInterceptor {
1342
- constructor(errorService) {
1550
+ constructor(errorService, featureFlagService) {
1343
1551
  this.errorService = errorService;
1552
+ this.featureFlagService = featureFlagService;
1344
1553
  }
1345
1554
  intercept(req, next) {
1346
- return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
1347
- if (event instanceof HttpResponse) {
1348
- this.errorService.handleSoftErrors(event);
1349
- }
1350
- }), catchError((error) => {
1351
- this.errorService.handleError(error, req);
1352
- return throwError(error);
1353
- }));
1555
+ if (this.featureFlagService.isFeatureEnabled('ff_error_handling')) {
1556
+ return next.handle(req).pipe(timeout(API_TIMEOUT_TIME), tap((event) => {
1557
+ if (event instanceof HttpResponse) {
1558
+ this.errorService.handleSoftErrors(event);
1559
+ }
1560
+ }), catchError((error) => {
1561
+ this.errorService.handleError(error, req);
1562
+ return throwError(error);
1563
+ }));
1564
+ }
1565
+ else {
1566
+ return next.handle(req);
1567
+ }
1354
1568
  }
1355
1569
  }
1356
- HttpReqInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, deps: [{ token: GlobalErrorService }], target: i0.ɵɵFactoryTarget.Injectable });
1570
+ 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 });
1357
1571
  HttpReqInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor });
1358
1572
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: HttpReqInterceptor, decorators: [{
1359
1573
  type: Injectable
1360
- }], ctorParameters: function () { return [{ type: GlobalErrorService }]; } });
1574
+ }], ctorParameters: function () { return [{ type: GlobalErrorService }, { type: FeatureFlagService }]; } });
1361
1575
 
1362
1576
  const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken('forRoot() SentryErrorHandler options');
1363
1577
  class VcErrorHandlersModule {
1578
+ constructor(loadConfig) {
1579
+ this.loadConfig = loadConfig;
1580
+ this.loadConfig.loadConfig();
1581
+ }
1364
1582
  static forRoot(environmentConfig) {
1365
1583
  return {
1366
1584
  ngModule: VcErrorHandlersModule,
@@ -1368,7 +1586,7 @@ class VcErrorHandlersModule {
1368
1586
  };
1369
1587
  }
1370
1588
  }
1371
- VcErrorHandlersModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1589
+ VcErrorHandlersModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, deps: [{ token: FeatureFlagService }], target: i0.ɵɵFactoryTarget.NgModule });
1372
1590
  VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, bootstrap: [VcErrorHandlersComponent], declarations: [VcErrorHandlersComponent,
1373
1591
  PageNotFoundComponent,
1374
1592
  UnauthorizedComponent,
@@ -1376,7 +1594,7 @@ VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
1376
1594
  ChunkUnavailableComponent,
1377
1595
  ServerErrorComponent,
1378
1596
  ErrorModalComponent,
1379
- ComponentLevelServerErrorComponent], imports: [CommonModule, DialogModule, SnackBarModule], exports: [VcErrorHandlersComponent,
1597
+ ComponentLevelServerErrorComponent], imports: [CommonModule, DialogModule, SnackBarModule, FeatureFlagModule], exports: [VcErrorHandlersComponent,
1380
1598
  PageNotFoundComponent,
1381
1599
  UnauthorizedComponent,
1382
1600
  SessionExpiredComponent,
@@ -1387,7 +1605,7 @@ VcErrorHandlersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
1387
1605
  VcErrorHandlersModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, providers: [
1388
1606
  { provide: ErrorHandler, useClass: SentryErrorHandler },
1389
1607
  { provide: HTTP_INTERCEPTORS, useClass: HttpReqInterceptor, multi: true },
1390
- ], imports: [[CommonModule, DialogModule, SnackBarModule]] });
1608
+ ], imports: [[CommonModule, DialogModule, SnackBarModule, FeatureFlagModule]] });
1391
1609
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: VcErrorHandlersModule, decorators: [{
1392
1610
  type: NgModule,
1393
1611
  args: [{
@@ -1401,7 +1619,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1401
1619
  ErrorModalComponent,
1402
1620
  ComponentLevelServerErrorComponent,
1403
1621
  ],
1404
- imports: [CommonModule, DialogModule, SnackBarModule],
1622
+ imports: [CommonModule, DialogModule, SnackBarModule, FeatureFlagModule],
1405
1623
  exports: [
1406
1624
  VcErrorHandlersComponent,
1407
1625
  PageNotFoundComponent,
@@ -1418,7 +1636,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1418
1636
  ],
1419
1637
  bootstrap: [VcErrorHandlersComponent],
1420
1638
  }]
1421
- }] });
1639
+ }], ctorParameters: function () { return [{ type: FeatureFlagService }]; } });
1422
1640
 
1423
1641
  /*
1424
1642
  * Public API Surface of vc-error-handlers
@@ -1429,3 +1647,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
1429
1647
  */
1430
1648
 
1431
1649
  export { AuthService, ChunkUnavailableComponent, ComponentLevelServerErrorComponent, ErrorModalComponent, FOR_ROOT_SENTRY_OPTIONS_TOKEN, GlobalErrorService, HttpReqInterceptor, PageNotFoundComponent, RouterService, ServerErrorComponent, SessionExpiredComponent, UnauthorizedComponent, VcErrorHandlersComponent, VcErrorHandlersModule, VcErrorHandlersService };
1650
+ //# sourceMappingURL=vc-error-handlers.mjs.map