@open-rlb/ng-app 3.1.16 → 3.1.17

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.
@@ -1633,19 +1633,21 @@ class CompanyInterceptor {
1633
1633
  return next.handle(req);
1634
1634
  }
1635
1635
  return this.store.select(state => state[appContextFeatureKey].currentApp).pipe(take(1), map$1((app) => {
1636
- // Get the correct keys from config
1637
- const companyKey = this.config.acl?.interceptorMapping?.companyIdKey ?? 'companyId';
1638
- const productKey = this.config.acl?.interceptorMapping?.productIdKey ?? 'productId';
1639
- const companyId = app?.data?.companyId;
1640
- const productId = app?.data?.productId;
1641
- if (companyId && productId) {
1642
- const params = req.params
1643
- .set(companyKey, companyId)
1644
- .set(productKey, productId);
1645
- return req.clone({ params });
1636
+ const mapping = this.config.acl?.interceptorMapping;
1637
+ // If no mapping is defined, just return the request
1638
+ if (!mapping || !app?.data) {
1639
+ return req;
1646
1640
  }
1647
- // If no companyId and productId presented call as is
1648
- return req;
1641
+ let params = req.params;
1642
+ // DYNAMIC LOOP:
1643
+ // Iterate over all keys defined in the environment config
1644
+ Object.entries(mapping).forEach(([httpParamName, storeDataKey]) => {
1645
+ const value = app.data[storeDataKey];
1646
+ if (value !== undefined && value !== null) {
1647
+ params = params.set(httpParamName, value.toString());
1648
+ }
1649
+ });
1650
+ return req.clone({ params });
1649
1651
  }), switchMap$1(clonedReq => next.handle(clonedReq)));
1650
1652
  }
1651
1653
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: CompanyInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }