@acorex/connectivity 20.3.0-next.2 → 20.3.0-next.20

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.
@@ -8,12 +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 { STRATEGY_CONFIG_TOKEN } from '@acorex/platform/widgets';
11
+ import { STRATEGY_CONFIG_TOKEN } from '@acorex/platform/layout/widgets';
12
12
  import * as i1$1 from 'angular-oauth2-oidc';
13
13
  import { OAuthService, OAuthModule } from 'angular-oauth2-oidc';
14
14
  import { AXM_AUTH_CONFIG_TOKEN } from '@acorex/modules/auth';
15
15
  import { Router } from '@angular/router';
16
16
  import { AXCUtilsModule, AXCExternalAuthorizationService } from '@acorex/connectivity/utils';
17
+ import { AXPRuntimeModule, provideCommandSetups } from '@acorex/platform/runtime';
18
+ import { AXP_REPORT_CATEGORY_PROVIDER, AXP_REPORT_DEFINITION_PROVIDER } from '@acorex/modules/report-management';
17
19
 
18
20
  class AXCApiEntityStorageService {
19
21
  constructor(http) {
@@ -22,6 +24,9 @@ class AXCApiEntityStorageService {
22
24
  this.filterService = inject(AXPFilterOperatorMiddlewareService);
23
25
  this.entityResolver = inject(AXPEntityResolver);
24
26
  this.mainUrl = this.configs.baseUrl;
27
+ // API routing constants
28
+ this.API_VERSION = 'v1';
29
+ this.DEFAULT_AREA = 'global';
25
30
  }
26
31
  get dbName() {
27
32
  return 'ACoreXPlatform';
@@ -37,6 +42,7 @@ class AXCApiEntityStorageService {
37
42
  module: moduleKebab,
38
43
  entity: entityKebab,
39
44
  area: areaKebab,
45
+ version: this.API_VERSION,
40
46
  };
41
47
  }
42
48
  else {
@@ -46,7 +52,8 @@ class AXCApiEntityStorageService {
46
52
  return {
47
53
  module: moduleKebab,
48
54
  entity: entityKebab,
49
- area: null,
55
+ area: this.DEFAULT_AREA,
56
+ version: this.API_VERSION,
50
57
  };
51
58
  }
52
59
  }
@@ -59,22 +66,22 @@ class AXCApiEntityStorageService {
59
66
  }
60
67
  async getOne(entityName, id) {
61
68
  const routeElement = await this.getConfigEntity(entityName);
62
- const url = `${this.mainUrl}/${routeElement.area ? routeElement.area + '/' : ''}${routeElement.module}/${routeElement.entity}${id ? '/' + id : ''}`;
69
+ const url = `${this.mainUrl}/${routeElement.version}/${routeElement.area}/${routeElement.module}/${routeElement.entity}${id ? '/' + id : ''}`;
63
70
  return firstValueFrom(this.http.get(url));
64
71
  }
65
72
  async updateOne(entityName, id, keyValue) {
66
73
  const routeElement = await this.getConfigEntity(entityName);
67
- const url = `${this.mainUrl}/${routeElement.area ? routeElement.area + '/' : ''}${routeElement.module}/${routeElement.entity}${id ? '/' + id : ''}`;
74
+ const url = `${this.mainUrl}/${routeElement.version}/${routeElement.area}/${routeElement.module}/${routeElement.entity}${id ? '/' + id : ''}`;
68
75
  return firstValueFrom(this.http.put(url, keyValue));
69
76
  }
70
77
  async deleteOne(entityName, id) {
71
78
  const routeElement = await this.getConfigEntity(entityName);
72
- const url = `${this.mainUrl}/${routeElement.area ? routeElement.area + '/' : ''}${routeElement.module}/${routeElement.entity}/${id}`;
79
+ const url = `${this.mainUrl}/${routeElement.version}/${routeElement.area}/${routeElement.module}/${routeElement.entity}/${id}`;
73
80
  firstValueFrom(this.http.delete(url));
74
81
  }
75
82
  async insertOne(entityName, entityItem) {
76
83
  const routeElement = await this.getConfigEntity(entityName);
77
- const url = `${this.mainUrl}/${routeElement.area ? routeElement.area + '/' : ''}${routeElement.module}/${routeElement.entity}`;
84
+ const url = `${this.mainUrl}/${routeElement.version}/${routeElement.area}/${routeElement.module}/${routeElement.entity}`;
78
85
  return firstValueFrom(this.http.post(url, entityItem));
79
86
  }
80
87
  async getAll(entityName) {
@@ -124,17 +131,17 @@ class AXCApiEntityStorageService {
124
131
  if (queryString) {
125
132
  httpParams = httpParams.set('$query', queryString);
126
133
  }
127
- return firstValueFrom(this.http.get(`${this.mainUrl}/${routeElement.area ? routeElement.area + '/' : ''}${routeElement.module}/${routeElement.entity}`, { params: httpParams })).then((response) => {
134
+ return firstValueFrom(this.http.get(`${this.mainUrl}/${routeElement.version}/${routeElement.area}/${routeElement.module}/${routeElement.entity}`, { params: httpParams })).then((response) => {
128
135
  return {
129
136
  total: response.totalCount,
130
137
  items: response.items,
131
138
  };
132
139
  });
133
140
  }
134
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCApiEntityStorageService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
135
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCApiEntityStorageService }); }
141
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCApiEntityStorageService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
142
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCApiEntityStorageService }); }
136
143
  }
137
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCApiEntityStorageService, decorators: [{
144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCApiEntityStorageService, decorators: [{
138
145
  type: Injectable
139
146
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
140
147
 
@@ -278,10 +285,10 @@ class AXCFileStorageApiService extends AXPFileStorageService {
278
285
  // Silently fail in fallback mode
279
286
  }
280
287
  }
281
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCFileStorageApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
282
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCFileStorageApiService }); }
288
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCFileStorageApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
289
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCFileStorageApiService }); }
283
290
  }
284
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCFileStorageApiService, decorators: [{
291
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCFileStorageApiService, decorators: [{
285
292
  type: Injectable
286
293
  }] });
287
294
 
@@ -326,10 +333,10 @@ class AXMOidcApplicationLoader {
326
333
  // features: item.features || [],
327
334
  };
328
335
  }
329
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcApplicationLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
330
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcApplicationLoader }); }
336
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcApplicationLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
337
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcApplicationLoader }); }
331
338
  }
332
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcApplicationLoader, decorators: [{
339
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcApplicationLoader, decorators: [{
333
340
  type: Injectable
334
341
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
335
342
 
@@ -369,10 +376,10 @@ class AXMConfigurationService {
369
376
  switchMap(() => of(this.applicationConfig)));
370
377
  }
371
378
  }
372
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
373
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMConfigurationService, providedIn: 'root' }); }
379
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
380
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMConfigurationService, providedIn: 'root' }); }
374
381
  }
375
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMConfigurationService, decorators: [{
382
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMConfigurationService, decorators: [{
376
383
  type: Injectable,
377
384
  args: [{
378
385
  providedIn: 'root',
@@ -621,6 +628,8 @@ class AXCAPIOidcStrategy extends AXPAuthStrategy {
621
628
  .join('&');
622
629
  const authorizeUrl = `${authorizeEndpoint}?${queryParams}`;
623
630
  window.location.href = authorizeUrl;
631
+ // Prevent further execution by waiting on a never-resolving Promise after redirect
632
+ await new Promise(() => { });
624
633
  }
625
634
  }
626
635
  catch (error) {
@@ -631,7 +640,8 @@ class AXCAPIOidcStrategy extends AXPAuthStrategy {
631
640
  localStorage.removeItem('pkce_code_verifier');
632
641
  localStorage.removeItem('oauth_provider');
633
642
  console.log(this.openidConfigurationInfo?.info?.discoveryDocument);
634
- const logoutUrl = `${this.aXMAuthConfigs?.baseUrl}/connect/logout`;
643
+ // Use configured logoutUrl or derive from baseUrl
644
+ const logoutUrl = this.aXMAuthConfigs.logoutUrl || `connect/logout`;
635
645
  window.location.href = logoutUrl;
636
646
  }
637
647
  async refreshToken(context) {
@@ -715,10 +725,10 @@ class AXCAPIOidcStrategy extends AXPAuthStrategy {
715
725
  get name() {
716
726
  return 'oidc';
717
727
  }
718
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCAPIOidcStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
719
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCAPIOidcStrategy }); }
728
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCAPIOidcStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
729
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCAPIOidcStrategy }); }
720
730
  }
721
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCAPIOidcStrategy, decorators: [{
731
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCAPIOidcStrategy, decorators: [{
722
732
  type: Injectable
723
733
  }] });
724
734
 
@@ -743,10 +753,10 @@ class AXMOidcPermissionLoader {
743
753
  const truePolicies = Object.keys(policies).filter((key) => policies[key] === true);
744
754
  return truePolicies;
745
755
  }
746
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcPermissionLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
747
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcPermissionLoader }); }
756
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcPermissionLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
757
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcPermissionLoader }); }
748
758
  }
749
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcPermissionLoader, decorators: [{
759
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcPermissionLoader, decorators: [{
750
760
  type: Injectable
751
761
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
752
762
 
@@ -772,17 +782,328 @@ class AXMOidcTenantLoader {
772
782
  // Add other fields and defaults as needed, and handle the logo if applicable
773
783
  };
774
784
  }
775
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcTenantLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
776
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcTenantLoader }); }
785
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcTenantLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
786
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcTenantLoader }); }
777
787
  }
778
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXMOidcTenantLoader, decorators: [{
788
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXMOidcTenantLoader, decorators: [{
779
789
  type: Injectable
780
790
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
781
791
 
792
+ //#endregion
793
+ //#region ---- Helper Functions ----
794
+ // /**
795
+ // * Converts a widget string to AXPWidgetsList key
796
+ // */
797
+ // function convertWidgetStringToAXPWidgetsListKey(
798
+ // widgetString: string,
799
+ // )
800
+ // :
801
+ // | keyof typeof AXPWidgetsList.Editors
802
+ // | keyof typeof AXPWidgetsList.Layouts
803
+ // | keyof typeof AXPWidgetsList.Actions
804
+ // | keyof typeof AXPWidgetsList.Advanced
805
+ // | keyof typeof AXPWidgetsList.Templates
806
+ // | keyof typeof AXPWidgetsList.Entity
807
+ // | keyof typeof AXPWidgetsList.Theme
808
+ // {
809
+ // console.log('Converting widget string:', widgetString);
810
+ // // Check if the string is in format "AXPWidgetsList.Category.Key"
811
+ // if (widgetString.startsWith('AXPWidgetsList.')) {
812
+ // // Extract the key from "AXPWidgetsList.Editors.DateTimeBox" -> "DateTimeBox"
813
+ // const parts = widgetString.split('.');
814
+ // if (parts.length >= 3) {
815
+ // const key = parts[parts.length - 1]; // Get the last part (key)
816
+ // console.log('Extracted key from AXPWidgetsList format:', key);
817
+ // return key as any;
818
+ // }
819
+ // }
820
+ // // Search through all AXPWidgetsList categories to find matching widget
821
+ // for (const category of Object.values(AXPWidgetsList)) {
822
+ // if (typeof category === 'object') {
823
+ // for (const [key, value] of Object.entries(category)) {
824
+ // if (value === widgetString) {
825
+ // console.log('Found matching widget:', key, 'for value:', value);
826
+ // return key as any; // Return the AXPWidgetsList key (e.g., "DateTimeBox")
827
+ // }
828
+ // }
829
+ // }
830
+ // }
831
+ // console.log('Widget not found in AXPWidgetsList, returning original string:', widgetString);
832
+ // // If not found in AXPWidgetsList, return the original string as fallback
833
+ // return widgetString as any;
834
+ // }
835
+ //#endregion
836
+ //#region ---- Shared Data Service ----
837
+ class AXCReportManagementDataService {
838
+ constructor() {
839
+ this.http = inject(HttpClient);
840
+ this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
841
+ this.baseUrl = this.configs.baseUrl;
842
+ // Shared cache for all categories data
843
+ this.allCategoriesData = [];
844
+ this.dataLoaded = false;
845
+ }
846
+ async getAllCategoriesData() {
847
+ if (!this.dataLoaded) {
848
+ await this.loadAllCategories();
849
+ }
850
+ return this.allCategoriesData;
851
+ }
852
+ async loadAllCategories() {
853
+ const url = `${this.baseUrl}/v1/global/report-management/category`;
854
+ const params = { Skip: 0, Take: 1000 };
855
+ const response = await firstValueFrom(this.http.get(url, { params }));
856
+ this.allCategoriesData = response.items;
857
+ this.dataLoaded = true;
858
+ }
859
+ clearCache() {
860
+ this.allCategoriesData = [];
861
+ this.dataLoaded = false;
862
+ }
863
+ async executeReport(reportId, parameters = {}) {
864
+ const url = `{this.dataService['baseUrl']}/api/v1/global/Report-Management/report/Execute`;
865
+ const body = {
866
+ reportId,
867
+ parameters,
868
+ };
869
+ const response = await firstValueFrom(this.http.post(url, body));
870
+ return response;
871
+ }
872
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportManagementDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
873
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportManagementDataService }); }
874
+ }
875
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportManagementDataService, decorators: [{
876
+ type: Injectable
877
+ }] });
878
+ //#endregion
879
+ //#region ---- API Providers ----
880
+ class AXCReportCategoryApiProvider {
881
+ constructor() {
882
+ this.dataService = inject(AXCReportManagementDataService);
883
+ // Cache to store processed categories
884
+ this.categoriesCache = new Map();
885
+ }
886
+ async getList(parentId) {
887
+ // Check cache first
888
+ if (this.categoriesCache.has(parentId)) {
889
+ return this.categoriesCache.get(parentId);
890
+ }
891
+ try {
892
+ // Get data from shared service
893
+ const allCategoriesData = await this.dataService.getAllCategoriesData();
894
+ // Filter categories based on parentId
895
+ let filteredItems;
896
+ if (!parentId) {
897
+ // Root categories (no parent)
898
+ filteredItems = allCategoriesData.filter((item) => !item.reportCategoryParentId);
899
+ }
900
+ else {
901
+ // Child categories
902
+ filteredItems = allCategoriesData.filter((item) => item.reportCategoryParentId === parentId);
903
+ }
904
+ const categories = filteredItems.map((item) => this.mapApiCategoryToReportCategory(item));
905
+ // Cache the result
906
+ this.categoriesCache.set(parentId, categories);
907
+ return categories;
908
+ }
909
+ catch (error) {
910
+ console.error('Error fetching report categories:', error);
911
+ return [];
912
+ }
913
+ }
914
+ async getById(id) {
915
+ try {
916
+ // Get data from shared service
917
+ const allCategoriesData = await this.dataService.getAllCategoriesData();
918
+ const apiItem = allCategoriesData.find((item) => item.id === id);
919
+ if (!apiItem) {
920
+ return undefined;
921
+ }
922
+ return this.mapApiCategoryToReportCategory(apiItem);
923
+ }
924
+ catch (error) {
925
+ console.error('Error fetching report category by ID:', error);
926
+ return undefined;
927
+ }
928
+ }
929
+ mapApiCategoryToReportCategory(apiItem) {
930
+ return {
931
+ id: apiItem.id,
932
+ title: apiItem.title,
933
+ description: apiItem.description || undefined,
934
+ parentId: apiItem.reportCategoryParentId || undefined,
935
+ hasChild: apiItem.folderCount > 0, // folderItems = folders
936
+ hasReport: apiItem.itemCount > 0, // reportDefinitionItems = files
937
+ };
938
+ }
939
+ // Method to clear cache when needed
940
+ clearCache() {
941
+ this.categoriesCache.clear();
942
+ this.dataService.clearCache();
943
+ }
944
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportCategoryApiProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
945
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportCategoryApiProvider }); }
946
+ }
947
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportCategoryApiProvider, decorators: [{
948
+ type: Injectable
949
+ }] });
950
+ class AXCReportDefinitionApiProvider {
951
+ constructor() {
952
+ this.dataService = inject(AXCReportManagementDataService);
953
+ this.http = inject(HttpClient);
954
+ // Cache to store report definitions by category to avoid unnecessary API calls
955
+ this.reportDefinitionsCache = new Map();
956
+ }
957
+ async getList(categoryId) {
958
+ // Check cache first
959
+ if (this.reportDefinitionsCache.has(categoryId)) {
960
+ return this.reportDefinitionsCache.get(categoryId);
961
+ }
962
+ try {
963
+ // Get data from shared service
964
+ const allCategoriesData = await this.dataService.getAllCategoriesData();
965
+ // Find the specific category and extract its report definitions
966
+ const categoryItem = allCategoriesData.find((item) => item.id === categoryId);
967
+ if (!categoryItem) {
968
+ // Cache empty result to avoid repeated API calls
969
+ this.reportDefinitionsCache.set(categoryId, []);
970
+ return [];
971
+ }
972
+ const reportDefinitions = categoryItem.reportDefinitionItems.map((item) => this.mapApiReportDefinitionItemToReportDefinition(item));
973
+ // Cache the result
974
+ this.reportDefinitionsCache.set(categoryId, reportDefinitions);
975
+ return reportDefinitions;
976
+ }
977
+ catch (error) {
978
+ console.error('Error fetching report definitions:', error);
979
+ // Cache empty result to avoid repeated failed API calls
980
+ this.reportDefinitionsCache.set(categoryId, []);
981
+ return [];
982
+ }
983
+ }
984
+ async getById(id) {
985
+ try {
986
+ console.log('AXCReportDefinitionApiProvider.getById called with ID:', id);
987
+ // Make API call to get full report definition with layouts
988
+ const url = `${this.dataService['baseUrl']}/v1/global/report-management/report/${id}`;
989
+ console.log('Making API call to:', url);
990
+ const response = await firstValueFrom(this.http.get(url));
991
+ return this.mapApiReportDefinitionToReportDefinition(response);
992
+ }
993
+ catch (error) {
994
+ console.error('Error fetching report definition by ID:', error);
995
+ return undefined;
996
+ }
997
+ }
998
+ mapApiReportDefinitionItemToReportDefinition(apiItem) {
999
+ return {
1000
+ id: apiItem.id,
1001
+ title: apiItem.title,
1002
+ description: apiItem.description || undefined,
1003
+ categoryIds: apiItem.categoryIds,
1004
+ parameterGroups: [], // These would need to be fetched separately if needed
1005
+ layouts: [], // These would need to be fetched separately if needed
1006
+ defaultLayoutId: '', // This would need to be set based on the first layout
1007
+ };
1008
+ }
1009
+ mapApiReportDefinitionToReportDefinition(apiResponse) {
1010
+ let res = {
1011
+ id: apiResponse.id,
1012
+ title: apiResponse.title,
1013
+ description: apiResponse.description || undefined,
1014
+ categoryIds: apiResponse.categoryIds,
1015
+ parameterGroups: apiResponse.parameterGroups.map((group) => ({
1016
+ name: group.name,
1017
+ title: group.title,
1018
+ parameters: group.parameters.map((param) => ({
1019
+ path: param.path,
1020
+ title: param.title,
1021
+ widget: {
1022
+ type: param.widget.type,
1023
+ options: param.widget.options || {},
1024
+ valueTransforms: param.widget.valueTransforms || {},
1025
+ },
1026
+ })),
1027
+ })),
1028
+ layouts: apiResponse.layouts.map((layout) => ({
1029
+ id: layout.id,
1030
+ title: layout.title,
1031
+ layout: layout.layout,
1032
+ dataSource: layout.dataSource,
1033
+ export: layout.export,
1034
+ isDefault: layout.isDefault || false,
1035
+ })),
1036
+ defaultLayoutId: apiResponse.defaultLayoutId,
1037
+ };
1038
+ return res;
1039
+ }
1040
+ async executeReport(reportId, parameters = {}) {
1041
+ return await this.dataService.executeReport(reportId, parameters);
1042
+ }
1043
+ // Method to clear cache when needed
1044
+ clearCache() {
1045
+ this.reportDefinitionsCache.clear();
1046
+ this.dataService.clearCache();
1047
+ }
1048
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportDefinitionApiProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1049
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportDefinitionApiProvider }); }
1050
+ }
1051
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportDefinitionApiProvider, decorators: [{
1052
+ type: Injectable
1053
+ }] });
1054
+ //#endregion
1055
+ //#region ---- Provider Exports ----
1056
+ const AXC_REPORT_CATEGORY_API_PROVIDER = {
1057
+ provide: AXP_REPORT_CATEGORY_PROVIDER,
1058
+ useClass: AXCReportCategoryApiProvider,
1059
+ multi: true,
1060
+ };
1061
+ const AXC_REPORT_DEFINITION_API_PROVIDER = {
1062
+ provide: AXP_REPORT_DEFINITION_PROVIDER,
1063
+ useClass: AXCReportDefinitionApiProvider,
1064
+ multi: true,
1065
+ };
1066
+
1067
+ class AXCReportManagementApiModule {
1068
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportManagementApiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1069
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: AXCReportManagementApiModule, imports: [AXPRuntimeModule] }); }
1070
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportManagementApiModule, providers: [
1071
+ AXCReportManagementDataService,
1072
+ AXC_REPORT_CATEGORY_API_PROVIDER,
1073
+ AXC_REPORT_DEFINITION_API_PROVIDER,
1074
+ provideCommandSetups([
1075
+ {
1076
+ key: 'ReportManagement.Report:Execute',
1077
+ command: () => import('./acorex-connectivity-api-execute.command-BLf56xbu.mjs').then((c) => c.AXCReportExecuteCommand),
1078
+ },
1079
+ ]),
1080
+ ], imports: [AXPRuntimeModule] }); }
1081
+ }
1082
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCReportManagementApiModule, decorators: [{
1083
+ type: NgModule,
1084
+ args: [{
1085
+ imports: [AXPRuntimeModule],
1086
+ exports: [],
1087
+ declarations: [],
1088
+ providers: [
1089
+ AXCReportManagementDataService,
1090
+ AXC_REPORT_CATEGORY_API_PROVIDER,
1091
+ AXC_REPORT_DEFINITION_API_PROVIDER,
1092
+ provideCommandSetups([
1093
+ {
1094
+ key: 'ReportManagement.Report:Execute',
1095
+ command: () => import('./acorex-connectivity-api-execute.command-BLf56xbu.mjs').then((c) => c.AXCReportExecuteCommand),
1096
+ },
1097
+ ]),
1098
+ ],
1099
+ }]
1100
+ }] });
1101
+
782
1102
  class AXCApiModule {
783
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCApiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
784
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.8", ngImport: i0, type: AXCApiModule, imports: [i1$1.OAuthModule, i2.AXPAuthModule, AXCUtilsModule] }); }
785
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCApiModule, providers: [
1103
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCApiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1104
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: AXCApiModule, imports: [i1$1.OAuthModule, i2.AXPAuthModule, AXCUtilsModule,
1105
+ AXCReportManagementApiModule] }); }
1106
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCApiModule, providers: [
786
1107
  {
787
1108
  provide: AXPEntityStorageService,
788
1109
  useClass: AXCApiEntityStorageService,
@@ -813,14 +1134,15 @@ class AXCApiModule {
813
1134
  selectValueStrategy: 'valueField',
814
1135
  lookupValueStrategy: 'valueField',
815
1136
  },
816
- },
1137
+ }
817
1138
  ], imports: [OAuthModule.forRoot(),
818
1139
  AXPAuthModule.forRoot({
819
1140
  strategies: [AXCAPIOidcStrategy],
820
1141
  }),
821
- AXCUtilsModule] }); }
1142
+ AXCUtilsModule,
1143
+ AXCReportManagementApiModule] }); }
822
1144
  }
823
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXCApiModule, decorators: [{
1145
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXCApiModule, decorators: [{
824
1146
  type: NgModule,
825
1147
  args: [{
826
1148
  imports: [
@@ -829,6 +1151,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImpor
829
1151
  strategies: [AXCAPIOidcStrategy],
830
1152
  }),
831
1153
  AXCUtilsModule,
1154
+ AXCReportManagementApiModule,
832
1155
  ],
833
1156
  providers: [
834
1157
  {
@@ -861,7 +1184,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImpor
861
1184
  selectValueStrategy: 'valueField',
862
1185
  lookupValueStrategy: 'valueField',
863
1186
  },
864
- },
1187
+ }
865
1188
  ],
866
1189
  }]
867
1190
  }] });
@@ -1130,10 +1453,10 @@ class APIGoogleStrategy extends AXPAuthStrategy {
1130
1453
  console.error('Authentication error:', error);
1131
1454
  throw error;
1132
1455
  }
1133
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: APIGoogleStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1134
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: APIGoogleStrategy }); }
1456
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: APIGoogleStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1457
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: APIGoogleStrategy }); }
1135
1458
  }
1136
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: APIGoogleStrategy, decorators: [{
1459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: APIGoogleStrategy, decorators: [{
1137
1460
  type: Injectable
1138
1461
  }], ctorParameters: () => [] });
1139
1462
 
@@ -1141,5 +1464,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImpor
1141
1464
  * Generated bundle index. Do not edit.
1142
1465
  */
1143
1466
 
1144
- export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
1467
+ export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCReportManagementApiModule, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
1145
1468
  //# sourceMappingURL=acorex-connectivity-api.mjs.map