@acorex/connectivity 20.6.0-next.7 → 20.6.0-next.9

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.
package/api/index.d.ts CHANGED
@@ -9,6 +9,7 @@ import { AXPApplicationLoader, AXPApplication, AXPFeatureLoader, AXPFeature, AXP
9
9
  import * as i3 from '@acorex/connectivity/utils';
10
10
  import * as i1 from '@acorex/platform/runtime';
11
11
  import { Observable } from 'rxjs';
12
+ import { AXPUserAvatarProvider, AXPUserAvatarData } from '@acorex/platform/layout/components';
12
13
  import * as _acorex_modules_report_management from '@acorex/modules/report-management';
13
14
  import { AXPReportCategoryProvider, AXPReportCategory, AXPReportDefinitionProvider, AXPReportDefinition } from '@acorex/modules/report-management';
14
15
 
@@ -209,6 +210,12 @@ declare class AXMOidcTenantLoader implements AXPTenantLoader {
209
210
  static ɵprov: i0.ɵɵInjectableDeclaration<AXMOidcTenantLoader>;
210
211
  }
211
212
 
213
+ declare class AXCApiUserAvatarProvider implements AXPUserAvatarProvider {
214
+ private userService;
215
+ private sessionService;
216
+ provide(userId: string): Promise<AXPUserAvatarData>;
217
+ }
218
+
212
219
  declare class APIGoogleStrategy extends AXPAuthStrategy {
213
220
  private aXMAuthConfigs;
214
221
  private oauthService;
@@ -423,5 +430,5 @@ declare const AXC_REPORT_DEFINITION_API_PROVIDER: {
423
430
  multi: boolean;
424
431
  };
425
432
 
426
- export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
433
+ export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCApiUserAvatarProvider, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
427
434
  export type { AXCReportCategoryApiItem, AXCReportCategoryApiResponse, AXCReportDefinitionApiItem, AXCReportDefinitionApiResponse, AXCReportLayoutDefinition, AXCReportParameter, AXCReportParameterGroup, AXPExecuteReportDto, AXPOAuthExternalCredentials, AXPUserPassCredentials, ApplicationConfiguration, Auth, Culture, IAuthenticationDataModel, Language, Localization, NameValue, Resource };
@@ -8,11 +8,14 @@ import { kebabCase } from 'lodash-es';
8
8
  import { firstValueFrom, catchError, of, map, BehaviorSubject, tap, filter, take, switchMap, delay } from 'rxjs';
9
9
  import * as i2 from '@acorex/platform/auth';
10
10
  import { AXPAuthStrategy, AXPSessionService, JwtUtil, TimeUtil, PkceUtil, AXPAuthModule, AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER } from '@acorex/platform/auth';
11
+ import { AXP_USER_AVATAR_PROVIDER } from '@acorex/platform/layout/components';
11
12
  import { STRATEGY_CONFIG_TOKEN } from '@acorex/platform/layout/widgets';
12
13
  import * as i1$1 from 'angular-oauth2-oidc';
13
14
  import { OAuthService, OAuthModule } from 'angular-oauth2-oidc';
14
15
  import { AXM_AUTH_CONFIG_TOKEN } from '@acorex/modules/auth';
15
16
  import { Router } from '@angular/router';
17
+ import { AXMUsersEntityService } from '@acorex/modules/security-management';
18
+ import { AXPDataGenerator } from '@acorex/platform/core';
16
19
  import { AXCUtilsModule, AXCExternalAuthorizationService } from '@acorex/connectivity/utils';
17
20
  import { AXPRuntimeModule, provideCommandSetups } from '@acorex/platform/runtime';
18
21
  import { AXP_REPORT_CATEGORY_PROVIDER, AXP_REPORT_DEFINITION_PROVIDER } from '@acorex/modules/report-management';
@@ -789,6 +792,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
789
792
  type: Injectable
790
793
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
791
794
 
795
+ class AXCApiUserAvatarProvider {
796
+ constructor() {
797
+ this.userService = inject(AXMUsersEntityService);
798
+ this.sessionService = inject(AXPSessionService);
799
+ }
800
+ async provide(userId) {
801
+ // Check if requesting current user info
802
+ const currentUser = this.sessionService.user;
803
+ const isCurrentUser = currentUser?.id === userId;
804
+ if (isCurrentUser && currentUser) {
805
+ // Use session service user data for current user
806
+ const [firstName, lastName] = (currentUser.name || '').split(' ') || ['', ''];
807
+ return {
808
+ id: currentUser.id,
809
+ username: currentUser.name || '',
810
+ firstName: firstName || '',
811
+ lastName: lastName || '',
812
+ status: 'online',
813
+ avatarUrl: currentUser.avatar || `https://avatar.iran.liara.run/public/${AXPDataGenerator.pick([35, 22, 16, 6, 31])}`,
814
+ };
815
+ }
816
+ // Use entity service for other users
817
+ const user = await this.userService.getOne(userId);
818
+ if (!user) {
819
+ throw new Error(`User not found for ${userId}`);
820
+ }
821
+ const [firstName, lastName] = user.displayName.split(' ') || ['', ''];
822
+ return {
823
+ id: user.id,
824
+ username: user.username,
825
+ firstName: firstName || '',
826
+ lastName: lastName || '',
827
+ status: 'online',
828
+ avatarUrl: `https://avatar.iran.liara.run/public/${AXPDataGenerator.pick([35, 22, 16, 6, 31])}`,
829
+ };
830
+ }
831
+ }
832
+
792
833
  //#endregion
793
834
  //#region ---- Helper Functions ----
794
835
  // /**
@@ -1215,7 +1256,11 @@ class AXCApiModule {
1215
1256
  selectValueStrategy: 'valueField',
1216
1257
  lookupValueStrategy: 'valueField',
1217
1258
  },
1218
- }
1259
+ },
1260
+ {
1261
+ provide: AXP_USER_AVATAR_PROVIDER,
1262
+ useClass: AXCApiUserAvatarProvider,
1263
+ },
1219
1264
  ], imports: [OAuthModule.forRoot(),
1220
1265
  AXPAuthModule.forRoot({
1221
1266
  strategies: [AXCAPIOidcStrategy],
@@ -1265,7 +1310,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
1265
1310
  selectValueStrategy: 'valueField',
1266
1311
  lookupValueStrategy: 'valueField',
1267
1312
  },
1268
- }
1313
+ },
1314
+ {
1315
+ provide: AXP_USER_AVATAR_PROVIDER,
1316
+ useClass: AXCApiUserAvatarProvider,
1317
+ },
1269
1318
  ],
1270
1319
  }]
1271
1320
  }] });
@@ -1545,5 +1594,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
1545
1594
  * Generated bundle index. Do not edit.
1546
1595
  */
1547
1596
 
1548
- export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
1597
+ export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCApiUserAvatarProvider, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
1549
1598
  //# sourceMappingURL=acorex-connectivity-api.mjs.map