@abp/ng.core 6.0.1 → 7.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 (30) hide show
  1. package/esm2020/lib/core.module.mjs +3 -1
  2. package/esm2020/lib/providers/include-localization-resources.provider.mjs +6 -0
  3. package/esm2020/lib/proxy/pages/abp/multi-tenancy/abp-tenant.service.mjs +1 -1
  4. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/api-exploring/abp-api-definition.service.mjs +1 -1
  5. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service.mjs +3 -2
  6. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-localization.service.mjs +24 -0
  7. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/index.mjs +2 -1
  8. package/esm2020/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/models.mjs +1 -1
  9. package/esm2020/lib/proxy/volo/abp/http/modeling/models.mjs +1 -1
  10. package/esm2020/lib/services/config-state.service.mjs +37 -7
  11. package/esm2020/lib/services/localization.service.mjs +35 -6
  12. package/esm2020/lib/tokens/include-localization-resources.token.mjs +3 -0
  13. package/esm2020/lib/tokens/index.mjs +2 -1
  14. package/fesm2015/abp-ng.core.mjs +99 -12
  15. package/fesm2015/abp-ng.core.mjs.map +1 -1
  16. package/fesm2020/abp-ng.core.mjs +97 -12
  17. package/fesm2020/abp-ng.core.mjs.map +1 -1
  18. package/lib/providers/include-localization-resources.provider.d.ts +2 -0
  19. package/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service.d.ts +2 -2
  20. package/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-localization.service.d.ts +11 -0
  21. package/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/index.d.ts +1 -0
  22. package/lib/proxy/volo/abp/asp-net-core/mvc/application-configurations/models.d.ts +16 -1
  23. package/lib/proxy/volo/abp/http/modeling/models.d.ts +8 -0
  24. package/lib/services/config-state.service.d.ts +29 -7
  25. package/lib/strategies/auth-flow.strategy.d.ts +22 -6
  26. package/lib/tokens/include-localization-resources.token.d.ts +2 -0
  27. package/lib/tokens/index.d.ts +1 -0
  28. package/lib/utils/auth-utils.d.ts +11 -3
  29. package/lib/utils/initial-utils.d.ts +11 -3
  30. package/package.json +2 -2
@@ -5,7 +5,7 @@ import { PRIMARY_OUTLET, NavigationCancel, NavigationEnd, NavigationError, Navig
5
5
  import * as i5 from '@angular/common';
6
6
  import { registerLocaleData, DOCUMENT, DatePipe, DATE_PIPE_DEFAULT_TIMEZONE, CommonModule } from '@angular/common';
7
7
  import { BehaviorSubject, Subject, throwError, combineLatest, from, Subscription, fromEvent, ReplaySubject, of, timer, pipe, Observable, concat } from 'rxjs';
8
- import { map, distinctUntilChanged, filter, catchError, switchMap, take, mapTo, debounceTime, takeUntil, tap, finalize, retryWhen, delay, shareReplay } from 'rxjs/operators';
8
+ import { map, distinctUntilChanged, filter, catchError, switchMap, take, tap, debounceTime, mapTo, takeUntil, 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';
11
11
  import compare from 'just-compare';
@@ -400,9 +400,10 @@ class AbpApplicationConfigurationService {
400
400
  constructor(restService) {
401
401
  this.restService = restService;
402
402
  this.apiName = 'abp';
403
- this.get = () => this.restService.request({
403
+ this.get = (options) => this.restService.request({
404
404
  method: 'GET',
405
405
  url: '/api/abp/application-configuration',
406
+ params: { includeLocalizationResources: options.includeLocalizationResources },
406
407
  }, { apiName: this.apiName });
407
408
  }
408
409
  }
@@ -415,9 +416,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImpor
415
416
  }]
416
417
  }], ctorParameters: function () { return [{ type: RestService }]; } });
417
418
 
419
+ class AbpApplicationLocalizationService {
420
+ constructor(restService) {
421
+ this.restService = restService;
422
+ this.apiName = 'abp';
423
+ this.get = (input) => this.restService.request({
424
+ method: 'GET',
425
+ url: '/api/abp/application-localization',
426
+ params: { cultureName: input.cultureName, onlyDynamics: input.onlyDynamics },
427
+ }, { apiName: this.apiName });
428
+ }
429
+ }
430
+ AbpApplicationLocalizationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AbpApplicationLocalizationService, deps: [{ token: RestService }], target: i0.ɵɵFactoryTarget.Injectable });
431
+ AbpApplicationLocalizationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AbpApplicationLocalizationService, providedIn: 'root' });
432
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: AbpApplicationLocalizationService, decorators: [{
433
+ type: Injectable,
434
+ args: [{
435
+ providedIn: 'root',
436
+ }]
437
+ }], ctorParameters: function () { return [{ type: RestService }]; } });
438
+
439
+ const INCUDE_LOCALIZATION_RESOURCES_TOKEN = new InjectionToken('INCUDE_LOCALIZATION_RESOURCES_TOKEN');
440
+
418
441
  class ConfigStateService {
419
- constructor(abpConfigService) {
442
+ constructor(abpConfigService, abpApplicationLocalizationService, includeLocalizationResources) {
420
443
  this.abpConfigService = abpConfigService;
444
+ this.abpApplicationLocalizationService = abpApplicationLocalizationService;
445
+ this.includeLocalizationResources = includeLocalizationResources;
421
446
  this.store = new InternalStore({});
422
447
  this.updateSubject = new Subject();
423
448
  this.initUpdateStream();
@@ -427,13 +452,35 @@ class ConfigStateService {
427
452
  }
428
453
  initUpdateStream() {
429
454
  this.updateSubject
430
- .pipe(switchMap(() => this.abpConfigService.get()))
455
+ .pipe(switchMap(() => this.abpConfigService.get({
456
+ includeLocalizationResources: this.includeLocalizationResources,
457
+ })))
458
+ .pipe(switchMap(appState => this.getLocalizationAndCombineWithAppState(appState)))
431
459
  .subscribe(res => this.store.set(res));
432
460
  }
461
+ getLocalizationAndCombineWithAppState(appState) {
462
+ return this.getlocalizationResource(appState.localization.currentCulture.cultureName).pipe(map(result => ({ ...appState, localization: { ...appState.localization, ...result } })));
463
+ }
464
+ getlocalizationResource(cultureName) {
465
+ return this.abpApplicationLocalizationService.get({
466
+ cultureName: cultureName,
467
+ onlyDynamics: false,
468
+ });
469
+ }
433
470
  refreshAppState() {
434
471
  this.updateSubject.next();
435
472
  return this.createOnUpdateStream(state => state).pipe(take(1));
436
473
  }
474
+ refreshLocalization(lang) {
475
+ if (this.includeLocalizationResources) {
476
+ return this.refreshAppState().pipe(map(() => null));
477
+ }
478
+ else {
479
+ return this.getlocalizationResource(lang)
480
+ .pipe(tap(result => this.store.patch({ localization: { ...this.store.state.localization, ...result } })))
481
+ .pipe(map(() => null));
482
+ }
483
+ }
437
484
  getOne$(key) {
438
485
  return this.store.sliceState(state => state[key]);
439
486
  }
@@ -533,14 +580,17 @@ class ConfigStateService {
533
580
  return this.store.sliceState(state => this.isGlobalFeatureEnabled(key, state.globalFeatures));
534
581
  }
535
582
  }
536
- ConfigStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ConfigStateService, deps: [{ token: AbpApplicationConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
583
+ ConfigStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ConfigStateService, deps: [{ token: AbpApplicationConfigurationService }, { token: AbpApplicationLocalizationService }, { token: INCUDE_LOCALIZATION_RESOURCES_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
537
584
  ConfigStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ConfigStateService, providedIn: 'root' });
538
585
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: ConfigStateService, decorators: [{
539
586
  type: Injectable,
540
587
  args: [{
541
588
  providedIn: 'root',
542
589
  }]
543
- }], ctorParameters: function () { return [{ type: AbpApplicationConfigurationService }]; } });
590
+ }], ctorParameters: function () { return [{ type: AbpApplicationConfigurationService }, { type: AbpApplicationLocalizationService }, { type: undefined, decorators: [{
591
+ type: Inject,
592
+ args: [INCUDE_LOCALIZATION_RESOURCES_TOKEN]
593
+ }] }]; } });
544
594
  function splitKeys(keys) {
545
595
  if (typeof keys === 'string') {
546
596
  keys = keys.split('.');
@@ -651,11 +701,16 @@ class LocalizationService {
651
701
  }
652
702
  initLocalizationValues() {
653
703
  localizations$.subscribe(val => this.addLocalization(val));
654
- const remoteLocalizations$ = this.configState.getDeep$('localization.values');
704
+ const legacyResources$ = this.configState.getDeep$('localization.values');
705
+ const remoteLocalizations$ = this.configState.getDeep$('localization.resources');
655
706
  const currentLanguage$ = this.sessionState.getLanguage$();
656
707
  const uiLocalizations$ = combineLatest([currentLanguage$, this.uiLocalizations$]).pipe(map(([currentLang, localizations]) => localizations.get(currentLang)));
657
- combineLatest([remoteLocalizations$, uiLocalizations$])
658
- .pipe(map(([remote, local]) => {
708
+ combineLatest([legacyResources$, remoteLocalizations$, uiLocalizations$])
709
+ .pipe(map(([legacy, resource, local]) => {
710
+ if (!resource) {
711
+ return;
712
+ }
713
+ const remote = combineLegacyandNewResources(legacy || {}, resource);
659
714
  if (remote) {
660
715
  if (!local) {
661
716
  local = new Map();
@@ -690,7 +745,7 @@ class LocalizationService {
690
745
  listenToSetLanguage() {
691
746
  this.sessionState
692
747
  .onLanguageChange$()
693
- .pipe(filter(lang => this.configState.getDeep('localization.currentCulture.cultureName') !== lang), switchMap(lang => this.configState.refreshAppState().pipe(mapTo(lang))), switchMap(lang => from(this.registerLocale(lang).then(() => lang))))
748
+ .pipe(filter(lang => this.configState.getDeep('localization.currentCulture.cultureName') !== lang), switchMap(lang => this.configState.refreshLocalization(lang).pipe(map(() => lang))), switchMap(lang => from(this.registerLocale(lang).then(() => lang))))
694
749
  .subscribe(lang => this._languageChange$.next(lang));
695
750
  }
696
751
  registerLocale(locale) {
@@ -793,7 +848,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImpor
793
848
  type: Optional
794
849
  }, {
795
850
  type: SkipSelf
796
- }] }, { type: ConfigStateService }]; } });
851
+ }] }, { type: ConfigStateService }]; } });
852
+ function recursivelyMergeBaseResources(baseResourceName, source) {
853
+ const item = source[baseResourceName];
854
+ if (item.baseResources.length === 0) {
855
+ return item;
856
+ }
857
+ return item.baseResources.reduce((acc, baseResource) => {
858
+ const baseItem = recursivelyMergeBaseResources(baseResource, source);
859
+ const texts = { ...baseItem.texts, ...item.texts };
860
+ return { ...acc, texts };
861
+ }, item);
862
+ }
863
+ function mergeResourcesWithBaseResource(resource) {
864
+ const entities = Object.keys(resource).map(key => {
865
+ const newValue = recursivelyMergeBaseResources(key, resource);
866
+ return [key, newValue];
867
+ });
868
+ return entities.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
869
+ }
870
+ function combineLegacyandNewResources(legacy, resource) {
871
+ const mergedResource = mergeResourcesWithBaseResource(resource);
872
+ return Object.entries(mergedResource).reduce((acc, [key, value]) => {
873
+ return { ...acc, [key]: value.texts };
874
+ }, legacy);
875
+ }
797
876
 
798
877
  function findRoute(routesService, path) {
799
878
  const node = routesService.find(route => route.path === path);
@@ -3545,6 +3624,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImpor
3545
3624
  type: Optional
3546
3625
  }] }]; } });
3547
3626
 
3627
+ const IncludeLocalizationResourcesProvider = {
3628
+ provide: INCUDE_LOCALIZATION_RESOURCES_TOKEN,
3629
+ useValue: false,
3630
+ };
3631
+
3548
3632
  function storageFactory() {
3549
3633
  return oAuthStorage;
3550
3634
  }
@@ -3768,6 +3852,7 @@ class CoreModule {
3768
3852
  useValue: localizationContributor(options.localizations),
3769
3853
  deps: [LocalizationService],
3770
3854
  },
3855
+ IncludeLocalizationResourcesProvider
3771
3856
  ],
3772
3857
  };
3773
3858
  }
@@ -4407,5 +4492,5 @@ const AbpValidators = {
4407
4492
  * Generated bundle index. Do not edit.
4408
4493
  */
4409
4494
 
4410
- export { APP_INIT_ERROR_HANDLERS, AbpApiDefinitionService, AbpApplicationConfigurationService, AbpTenantService, AbpValidators, AbstractNavTreeService, AbstractNgModelComponent, AbstractTreeService, ApiInterceptor, AuditedEntityDto, AuditedEntityWithUserDto, AuthGuard, AuthService, AutofocusDirective, BaseCoreModule, BaseTreeNode, CONTAINER_STRATEGY, CONTENT_SECURITY_STRATEGY, CONTENT_STRATEGY, CONTEXT_STRATEGY, COOKIE_LANGUAGE_KEY, CORE_OPTIONS, CROSS_ORIGIN_STRATEGY, ClearContainerStrategy, ComponentContextStrategy, ComponentProjectionStrategy, ConfigStateService, ContainerStrategy, ContentProjectionService, ContentSecurityStrategy, ContentStrategy, ContextStrategy, CoreModule, CreationAuditedEntityDto, CreationAuditedEntityWithUserDto, CrossOriginStrategy, DOM_STRATEGY, DomInsertionService, DomStrategy, DynamicLayoutComponent, EntityDto, EnvironmentService, ExtensibleAuditedEntityDto, ExtensibleAuditedEntityWithUserDto, ExtensibleCreationAuditedEntityDto, ExtensibleCreationAuditedEntityWithUserDto, ExtensibleEntityDto, ExtensibleFullAuditedEntityDto, ExtensibleFullAuditedEntityWithUserDto, ExtensibleObject, ForDirective, FormSubmitDirective, FullAuditedEntityDto, FullAuditedEntityWithUserDto, HttpErrorReporterService, HttpWaitService, INJECTOR_PIPE_DATA_TOKEN, InitDirective, InputEventDebounceDirective, InsertIntoContainerStrategy, InternalStore, LIST_QUERY_DEBOUNCE_TIME, LOADER_DELAY, LOADING_STRATEGY, LOCALIZATIONS, LazyLoadService, LazyModuleFactory, LimitedResultRequestDto, ListResultDto, ListService, LoadingStrategy, LocalizationModule, LocalizationPipe, LocalizationService, LooseContentSecurityStrategy, MultiTenancyService, NAVIGATE_TO_MANAGE_PROFILE, NavigationEvent, NoContentSecurityStrategy, NoContextStrategy, NoCrossOriginStrategy, index as ObjectExtending, PROJECTION_STRATEGY, PagedAndSortedResultRequestDto, PagedResultDto, PagedResultRequestDto, PermissionDirective, PermissionGuard, PermissionService, ProjectionStrategy, ReplaceableComponentsService, ReplaceableRouteContainerComponent, ReplaceableTemplateDirective, ResourceWaitService, RestService, RootComponentProjectionStrategy, RootCoreModule, RouterEvents, RouterOutletComponent, RouterWaitService, RoutesService, ScriptContentStrategy, ScriptLoadingStrategy, SessionStateService, ShortDatePipe, ShortDateTimePipe, ShortTimePipe, SortPipe, StopPropagationDirective, StyleContentStrategy, StyleLoadingStrategy, SubscriptionService, TENANT_KEY, TemplateContextStrategy, TemplateProjectionStrategy, TimeoutLimitedOAuthService, ToInjectorPipe, TrackByService, WebHttpUrlEncodingCodec, checkAccessToken, coreOptionsFactory, createLocalizationPipeKeyGenerator, createLocalizer, createLocalizerWithFallback, createMapFromList, createTokenParser, createTreeFromList, createTreeNodeFilterCreator, deepMerge, differentLocales, downloadBlob, escapeHtmlChars, exists, featuresFactory, findRoute, fromLazyLoad, generateHash, generatePassword, getInitialData, getLocaleDirection, getPathName, getRemoteEnv, getRoutePath, getShortDateFormat, getShortDateShortTimeFormat, getShortTimeFormat, interpolate, isArray, isNode, isNullOrEmpty, isNullOrUndefined, isNumber, isObject, isObjectAndNotArray, isObjectAndNotArrayNotNode, isUndefinedOrEmptyString, localeInitializer, localizationContributor, localizations$, mapEnumToOptions, noop, parseTenantFromUrl, pipeToLogin, pushValueTo, reloadRoute, removeRememberMe, setRememberMe, setTokenResponseToStorage, storageFactory, trackBy, trackByDeep, uuid, validateCreditCard, validateMinAge, validateRange, validateRequired, validateStringLength, validateUrl };
4495
+ export { APP_INIT_ERROR_HANDLERS, AbpApiDefinitionService, AbpApplicationConfigurationService, AbpApplicationLocalizationService, AbpTenantService, AbpValidators, AbstractNavTreeService, AbstractNgModelComponent, AbstractTreeService, ApiInterceptor, AuditedEntityDto, AuditedEntityWithUserDto, AuthGuard, AuthService, AutofocusDirective, BaseCoreModule, BaseTreeNode, CONTAINER_STRATEGY, CONTENT_SECURITY_STRATEGY, CONTENT_STRATEGY, CONTEXT_STRATEGY, COOKIE_LANGUAGE_KEY, CORE_OPTIONS, CROSS_ORIGIN_STRATEGY, ClearContainerStrategy, ComponentContextStrategy, ComponentProjectionStrategy, ConfigStateService, ContainerStrategy, ContentProjectionService, ContentSecurityStrategy, ContentStrategy, ContextStrategy, CoreModule, CreationAuditedEntityDto, CreationAuditedEntityWithUserDto, CrossOriginStrategy, DOM_STRATEGY, DomInsertionService, DomStrategy, DynamicLayoutComponent, EntityDto, EnvironmentService, ExtensibleAuditedEntityDto, ExtensibleAuditedEntityWithUserDto, ExtensibleCreationAuditedEntityDto, ExtensibleCreationAuditedEntityWithUserDto, ExtensibleEntityDto, ExtensibleFullAuditedEntityDto, ExtensibleFullAuditedEntityWithUserDto, ExtensibleObject, ForDirective, FormSubmitDirective, FullAuditedEntityDto, FullAuditedEntityWithUserDto, HttpErrorReporterService, HttpWaitService, INCUDE_LOCALIZATION_RESOURCES_TOKEN, INJECTOR_PIPE_DATA_TOKEN, InitDirective, InputEventDebounceDirective, InsertIntoContainerStrategy, InternalStore, LIST_QUERY_DEBOUNCE_TIME, LOADER_DELAY, LOADING_STRATEGY, LOCALIZATIONS, LazyLoadService, LazyModuleFactory, LimitedResultRequestDto, ListResultDto, ListService, LoadingStrategy, LocalizationModule, LocalizationPipe, LocalizationService, LooseContentSecurityStrategy, MultiTenancyService, NAVIGATE_TO_MANAGE_PROFILE, NavigationEvent, NoContentSecurityStrategy, NoContextStrategy, NoCrossOriginStrategy, index as ObjectExtending, PROJECTION_STRATEGY, PagedAndSortedResultRequestDto, PagedResultDto, PagedResultRequestDto, PermissionDirective, PermissionGuard, PermissionService, ProjectionStrategy, ReplaceableComponentsService, ReplaceableRouteContainerComponent, ReplaceableTemplateDirective, ResourceWaitService, RestService, RootComponentProjectionStrategy, RootCoreModule, RouterEvents, RouterOutletComponent, RouterWaitService, RoutesService, ScriptContentStrategy, ScriptLoadingStrategy, SessionStateService, ShortDatePipe, ShortDateTimePipe, ShortTimePipe, SortPipe, StopPropagationDirective, StyleContentStrategy, StyleLoadingStrategy, SubscriptionService, TENANT_KEY, TemplateContextStrategy, TemplateProjectionStrategy, TimeoutLimitedOAuthService, ToInjectorPipe, TrackByService, WebHttpUrlEncodingCodec, checkAccessToken, coreOptionsFactory, createLocalizationPipeKeyGenerator, createLocalizer, createLocalizerWithFallback, createMapFromList, createTokenParser, createTreeFromList, createTreeNodeFilterCreator, deepMerge, differentLocales, downloadBlob, escapeHtmlChars, exists, featuresFactory, findRoute, fromLazyLoad, generateHash, generatePassword, getInitialData, getLocaleDirection, getPathName, getRemoteEnv, getRoutePath, getShortDateFormat, getShortDateShortTimeFormat, getShortTimeFormat, interpolate, isArray, isNode, isNullOrEmpty, isNullOrUndefined, isNumber, isObject, isObjectAndNotArray, isObjectAndNotArrayNotNode, isUndefinedOrEmptyString, localeInitializer, localizationContributor, localizations$, mapEnumToOptions, noop, parseTenantFromUrl, pipeToLogin, pushValueTo, reloadRoute, removeRememberMe, setRememberMe, setTokenResponseToStorage, storageFactory, trackBy, trackByDeep, uuid, validateCreditCard, validateMinAge, validateRange, validateRequired, validateStringLength, validateUrl };
4411
4496
  //# sourceMappingURL=abp-ng.core.mjs.map