@abp/ng.core 5.3.1 → 6.0.0-rc.1

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.
Files changed (32) hide show
  1. package/esm2020/lib/directives/form-submit.directive.mjs +1 -1
  2. package/esm2020/lib/directives/permission.directive.mjs +15 -3
  3. package/esm2020/lib/interceptors/api.interceptor.mjs +3 -2
  4. package/esm2020/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.mjs +3 -5
  5. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/api-exploring/abp-api-definition.service.mjs +2 -2
  6. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service.mjs +3 -5
  7. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/models.mjs +1 -1
  8. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/object-extending/models.mjs +1 -2
  9. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/multi-tenancy/models.mjs +1 -1
  10. package/esm2020/lib/proxy/volo/abp/http/modeling/models.mjs +1 -2
  11. package/esm2020/lib/proxy/volo/abp/localization/models.mjs +1 -1
  12. package/esm2020/lib/proxy/volo/abp/models.mjs +1 -1
  13. package/esm2020/lib/services/config-state.service.mjs +17 -1
  14. package/esm2020/lib/services/environment.service.mjs +14 -1
  15. package/esm2020/lib/services/multi-tenancy.service.mjs +3 -3
  16. package/esm2020/lib/services/rest.service.mjs +6 -2
  17. package/fesm2015/abp-ng.core.mjs +53 -12
  18. package/fesm2015/abp-ng.core.mjs.map +1 -1
  19. package/fesm2020/abp-ng.core.mjs +53 -16
  20. package/fesm2020/abp-ng.core.mjs.map +1 -1
  21. package/lib/directives/permission.directive.d.ts +6 -3
  22. package/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.d.ts +2 -2
  23. package/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service.d.ts +2 -2
  24. package/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/models.d.ts +10 -4
  25. package/lib/proxy/volo/abp/http/modeling/models.d.ts +10 -0
  26. package/lib/services/config-state.service.d.ts +20 -5
  27. package/lib/services/environment.service.d.ts +2 -0
  28. package/lib/services/rest.service.d.ts +1 -0
  29. package/lib/strategies/auth-flow.strategy.d.ts +14 -4
  30. package/lib/utils/auth-utils.d.ts +7 -2
  31. package/lib/utils/initial-utils.d.ts +7 -2
  32. package/package.json +2 -2
@@ -4,7 +4,7 @@ import * as i1$1 from '@angular/router';
4
4
  import { PRIMARY_OUTLET, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, ActivatedRoute, Router, RouterModule } from '@angular/router';
5
5
  import * as i5 from '@angular/common';
6
6
  import { registerLocaleData, DOCUMENT, DatePipe, DATE_PIPE_DEFAULT_TIMEZONE, CommonModule } from '@angular/common';
7
- import { BehaviorSubject, Subject, throwError, combineLatest, from, Subscription, fromEvent, of, timer, pipe, Observable, concat, ReplaySubject } from 'rxjs';
7
+ import { BehaviorSubject, Subject, throwError, combineLatest, from, Subscription, fromEvent, ReplaySubject, of, timer, pipe, Observable, concat } from 'rxjs';
8
8
  import { map, distinctUntilChanged, filter, catchError, switchMap, take, mapTo, debounceTime, takeUntil, tap, finalize, retryWhen, delay, shareReplay } from 'rxjs/operators';
9
9
  import * as i1 from '@angular/common/http';
10
10
  import { HttpParams, HttpHeaders, HttpClient, HttpClientModule, HttpClientXsrfModule, HTTP_INTERCEPTORS } from '@angular/common/http';
@@ -264,6 +264,12 @@ class InternalStore {
264
264
  }
265
265
 
266
266
  const mapToApiUrl = (key) => (apis) => (apis[key] || apis.default).url || apis.default.url;
267
+ const mapToIssuer = (issuer) => {
268
+ if (!issuer) {
269
+ return issuer;
270
+ }
271
+ return issuer.endsWith('/') ? issuer : issuer + '/';
272
+ };
267
273
  class EnvironmentService {
268
274
  constructor() {
269
275
  this.store = new InternalStore({});
@@ -286,6 +292,13 @@ class EnvironmentService {
286
292
  setState(environment) {
287
293
  this.store.set(environment);
288
294
  }
295
+ getIssuer() {
296
+ const issuer = this.store.state.oAuthConfig.issuer;
297
+ return mapToIssuer(issuer);
298
+ }
299
+ getIssuer$() {
300
+ return this.store.sliceState(state => state.oAuthConfig.issuer).pipe(map(mapToIssuer));
301
+ }
289
302
  }
290
303
  EnvironmentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: EnvironmentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
291
304
  EnvironmentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: EnvironmentService, providedIn: 'root' });
@@ -339,8 +352,9 @@ class RestService {
339
352
  api = api || this.getApiFromStore(config.apiName);
340
353
  const { method, params, ...options } = request;
341
354
  const { observe = "body" /* Body */, skipHandleError } = config;
355
+ const url = this.removeDuplicateSlashes(api + request.url);
342
356
  return this.http
343
- .request(method, api + request.url, {
357
+ .request(method, url, {
344
358
  observe,
345
359
  ...(params && {
346
360
  params: this.getParams(params, config.httpParamEncoder),
@@ -363,6 +377,9 @@ class RestService {
363
377
  ? new HttpParams({ encoder, fromObject: filteredParams })
364
378
  : new HttpParams({ fromObject: filteredParams });
365
379
  }
380
+ removeDuplicateSlashes(url) {
381
+ return url.replace(/([^:]\/)\/+/g, '$1');
382
+ }
366
383
  }
367
384
  RestService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: RestService, deps: [{ token: CORE_OPTIONS }, { token: i1.HttpClient }, { token: EnvironmentService }, { token: HttpErrorReporterService }], target: i0.ɵɵFactoryTarget.Injectable });
368
385
  RestService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: RestService, providedIn: 'root' });
@@ -380,9 +397,7 @@ class AbpApplicationConfigurationService {
380
397
  constructor(restService) {
381
398
  this.restService = restService;
382
399
  this.apiName = 'abp';
383
- }
384
- get() {
385
- return this.restService.request({
400
+ this.get = () => this.restService.request({
386
401
  method: 'GET',
387
402
  url: '/api/abp/application-configuration',
388
403
  }, { apiName: this.apiName });
@@ -498,6 +513,22 @@ class ConfigStateService {
498
513
  }, {});
499
514
  }));
500
515
  }
516
+ getGlobalFeatures() {
517
+ return this.store.state.globalFeatures;
518
+ }
519
+ getGlobalFeatures$() {
520
+ return this.store.sliceState(state => state.globalFeatures);
521
+ }
522
+ isGlobalFeatureEnabled(key, globalFeatures) {
523
+ const features = globalFeatures.enabledFeatures || [];
524
+ return features.some(f => key === f);
525
+ }
526
+ getGlobalFeatureIsEnabled(key) {
527
+ return this.isGlobalFeatureEnabled(key, this.store.state.globalFeatures);
528
+ }
529
+ getGlobalFeatureIsEnabled$(key) {
530
+ return this.store.sliceState(state => this.isGlobalFeatureEnabled(key, state.globalFeatures));
531
+ }
501
532
  }
502
533
  ConfigStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ConfigStateService, deps: [{ token: AbpApplicationConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
503
534
  ConfigStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ConfigStateService, providedIn: 'root' });
@@ -1907,6 +1938,8 @@ class PermissionDirective {
1907
1938
  this.permissionService = permissionService;
1908
1939
  this.cdRef = cdRef;
1909
1940
  this.runChangeDetection = true;
1941
+ this.cdrSubject = new ReplaySubject();
1942
+ this.rendered = false;
1910
1943
  }
1911
1944
  check() {
1912
1945
  if (this.subscription) {
@@ -1920,7 +1953,12 @@ class PermissionDirective {
1920
1953
  if (isGranted)
1921
1954
  this.vcRef.createEmbeddedView(this.templateRef);
1922
1955
  if (this.runChangeDetection) {
1923
- this.cdRef.detectChanges();
1956
+ if (!this.rendered) {
1957
+ this.cdrSubject.next();
1958
+ }
1959
+ else {
1960
+ this.cdRef.detectChanges();
1961
+ }
1924
1962
  }
1925
1963
  else {
1926
1964
  this.cdRef.markForCheck();
@@ -1934,6 +1972,10 @@ class PermissionDirective {
1934
1972
  ngOnChanges() {
1935
1973
  this.check();
1936
1974
  }
1975
+ ngAfterViewInit() {
1976
+ this.cdrSubject.pipe(take(1)).subscribe(() => this.cdRef.detectChanges());
1977
+ this.rendered = true;
1978
+ }
1937
1979
  }
1938
1980
  PermissionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: PermissionDirective, deps: [{ token: i0.TemplateRef, optional: true }, { token: i0.ViewContainerRef }, { token: PermissionService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1939
1981
  PermissionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: PermissionDirective, selector: "[abpPermission]", inputs: { condition: ["abpPermission", "condition"], runChangeDetection: ["abpPermissionRunChangeDetection", "runChangeDetection"] }, usesOnChanges: true, ngImport: i0 });
@@ -2285,6 +2327,7 @@ class ApiInterceptor {
2285
2327
  if (!existingHeaders?.has(this.tenantKey) && tenant?.id) {
2286
2328
  headers[this.tenantKey] = tenant.id;
2287
2329
  }
2330
+ headers['X-Requested-With'] = 'XMLHttpRequest';
2288
2331
  return headers;
2289
2332
  }
2290
2333
  }
@@ -2751,15 +2794,13 @@ class AbpTenantService {
2751
2794
  constructor(restService) {
2752
2795
  this.restService = restService;
2753
2796
  this.apiName = 'abp';
2754
- this.findTenantById = (id, headers) => this.restService.request({
2797
+ this.findTenantById = (id) => this.restService.request({
2755
2798
  method: 'GET',
2756
2799
  url: `/api/abp/multi-tenancy/tenants/by-id/${id}`,
2757
- headers,
2758
2800
  }, { apiName: this.apiName });
2759
- this.findTenantByName = (name, headers) => this.restService.request({
2801
+ this.findTenantByName = (name) => this.restService.request({
2760
2802
  method: 'GET',
2761
2803
  url: `/api/abp/multi-tenancy/tenants/by-name/${name}`,
2762
- headers,
2763
2804
  }, { apiName: this.apiName });
2764
2805
  }
2765
2806
  }
@@ -2789,12 +2830,12 @@ class MultiTenancyService {
2789
2830
  }
2790
2831
  setTenantByName(tenantName) {
2791
2832
  return this.tenantService
2792
- .findTenantByName(tenantName, { [this.tenantKey]: '' })
2833
+ .findTenantByName(tenantName)
2793
2834
  .pipe(switchMap(this.setTenantToState));
2794
2835
  }
2795
2836
  setTenantById(tenantId) {
2796
2837
  return this.tenantService
2797
- .findTenantById(tenantId, { [this.tenantKey]: '' })
2838
+ .findTenantById(tenantId)
2798
2839
  .pipe(switchMap(this.setTenantToState));
2799
2840
  }
2800
2841
  }
@@ -3922,14 +3963,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImpor
3922
3963
  }]
3923
3964
  }], ctorParameters: function () { return [{ type: RestService }]; } });
3924
3965
 
3925
- /* eslint-disable @typescript-eslint/ban-types */
3926
-
3927
3966
  var index = /*#__PURE__*/Object.freeze({
3928
3967
  __proto__: null
3929
3968
  });
3930
3969
 
3931
- /* eslint-disable @typescript-eslint/ban-types */
3932
-
3933
3970
  class ContainerStrategy {
3934
3971
  constructor(containerRef) {
3935
3972
  this.containerRef = containerRef;