@acorex/platform 20.0.25 → 20.1.0

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 (96) hide show
  1. package/auth/index.d.ts +29 -12
  2. package/common/index.d.ts +266 -41
  3. package/core/index.d.ts +3 -302
  4. package/fesm2022/acorex-platform-auth.mjs +202 -124
  5. package/fesm2022/acorex-platform-auth.mjs.map +1 -1
  6. package/fesm2022/acorex-platform-common.mjs +121 -104
  7. package/fesm2022/acorex-platform-common.mjs.map +1 -1
  8. package/fesm2022/acorex-platform-core.mjs +53 -43
  9. package/fesm2022/acorex-platform-core.mjs.map +1 -1
  10. package/fesm2022/acorex-platform-domain.mjs +16 -16
  11. package/fesm2022/acorex-platform-domain.mjs.map +1 -1
  12. package/fesm2022/acorex-platform-layout-builder.mjs +103 -79
  13. package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
  14. package/fesm2022/acorex-platform-layout-components.mjs +171 -171
  15. package/fesm2022/acorex-platform-layout-components.mjs.map +1 -1
  16. package/fesm2022/acorex-platform-layout-designer.mjs +156 -156
  17. package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
  18. package/fesm2022/acorex-platform-layout-entity.mjs +261 -261
  19. package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
  20. package/fesm2022/acorex-platform-layout-views.mjs +74 -74
  21. package/fesm2022/acorex-platform-layout-views.mjs.map +1 -1
  22. package/fesm2022/acorex-platform-native.mjs +7 -7
  23. package/fesm2022/acorex-platform-native.mjs.map +1 -1
  24. package/fesm2022/acorex-platform-runtime.mjs +42 -42
  25. package/fesm2022/acorex-platform-runtime.mjs.map +1 -1
  26. package/fesm2022/{acorex-platform-themes-default-create-entity-view.component-B1cyUyXJ.mjs → acorex-platform-themes-default-create-entity-view.component-CzHp6G3a.mjs} +6 -6
  27. package/fesm2022/{acorex-platform-themes-default-create-entity-view.component-B1cyUyXJ.mjs.map → acorex-platform-themes-default-create-entity-view.component-CzHp6G3a.mjs.map} +1 -1
  28. package/fesm2022/{acorex-platform-themes-default-entity-master-create-view.component-BNdAQn4R.mjs → acorex-platform-themes-default-entity-master-create-view.component-nzWNHDO7.mjs} +15 -15
  29. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-nzWNHDO7.mjs.map +1 -0
  30. package/fesm2022/{acorex-platform-themes-default-entity-master-list-view.component-CElBGzRM.mjs → acorex-platform-themes-default-entity-master-list-view.component-DJdedfa_.mjs} +54 -54
  31. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-DJdedfa_.mjs.map +1 -0
  32. package/fesm2022/{acorex-platform-themes-default-entity-master-modify-view.component-QQ4bFuiN.mjs → acorex-platform-themes-default-entity-master-modify-view.component-Cn-0fTWn.mjs} +15 -15
  33. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-Cn-0fTWn.mjs.map +1 -0
  34. package/fesm2022/{acorex-platform-themes-default-entity-master-single-view.component-CEfSqV8l.mjs → acorex-platform-themes-default-entity-master-single-view.component-B8XrO58H.mjs} +22 -22
  35. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-B8XrO58H.mjs.map +1 -0
  36. package/fesm2022/{acorex-platform-themes-default-error-401.component-CA41DcvL.mjs → acorex-platform-themes-default-error-401.component-Ycd9latx.mjs} +5 -5
  37. package/fesm2022/{acorex-platform-themes-default-error-401.component-CA41DcvL.mjs.map → acorex-platform-themes-default-error-401.component-Ycd9latx.mjs.map} +1 -1
  38. package/fesm2022/{acorex-platform-themes-default-error-404.component-DHMnI_Ew.mjs → acorex-platform-themes-default-error-404.component-DHbzH27Q.mjs} +5 -5
  39. package/fesm2022/{acorex-platform-themes-default-error-404.component-DHMnI_Ew.mjs.map → acorex-platform-themes-default-error-404.component-DHbzH27Q.mjs.map} +1 -1
  40. package/fesm2022/{acorex-platform-themes-default-error-offline.component-BmPuSWfS.mjs → acorex-platform-themes-default-error-offline.component-BSdZOCbW.mjs} +5 -5
  41. package/fesm2022/{acorex-platform-themes-default-error-offline.component-BmPuSWfS.mjs.map → acorex-platform-themes-default-error-offline.component-BSdZOCbW.mjs.map} +1 -1
  42. package/fesm2022/acorex-platform-themes-default.mjs +68 -61
  43. package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
  44. package/fesm2022/{acorex-platform-themes-shared-color-chooser-view.component-CUtKW-cD.mjs → acorex-platform-themes-shared-color-chooser-view.component-ChOhTEqX.mjs} +8 -8
  45. package/fesm2022/acorex-platform-themes-shared-color-chooser-view.component-ChOhTEqX.mjs.map +1 -0
  46. package/fesm2022/{acorex-platform-themes-shared-icon-chooser-view.component-Dc3LQQOa.mjs → acorex-platform-themes-shared-icon-chooser-view.component-SXfawqIa.mjs} +6 -6
  47. package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-SXfawqIa.mjs.map +1 -0
  48. package/fesm2022/acorex-platform-themes-shared-settings.provider-CXiRmniv.mjs.map +1 -1
  49. package/fesm2022/acorex-platform-themes-shared.mjs +61 -61
  50. package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -1
  51. package/fesm2022/{acorex-platform-widgets-button-widget-designer.component-dBuOCox2.mjs → acorex-platform-widgets-button-widget-designer.component-BfWr5Wz8.mjs} +10 -10
  52. package/fesm2022/acorex-platform-widgets-button-widget-designer.component-BfWr5Wz8.mjs.map +1 -0
  53. package/fesm2022/{acorex-platform-widgets-checkbox-widget-column.component-DAGnRXR6.mjs → acorex-platform-widgets-checkbox-widget-column.component-C7mpTEda.mjs} +4 -4
  54. package/fesm2022/{acorex-platform-widgets-checkbox-widget-column.component-DAGnRXR6.mjs.map → acorex-platform-widgets-checkbox-widget-column.component-C7mpTEda.mjs.map} +1 -1
  55. package/fesm2022/{acorex-platform-widgets-checkbox-widget-designer.component-BSGnyPBn.mjs → acorex-platform-widgets-checkbox-widget-designer.component-Dj3Go0tj.mjs} +10 -10
  56. package/fesm2022/acorex-platform-widgets-checkbox-widget-designer.component-Dj3Go0tj.mjs.map +1 -0
  57. package/fesm2022/{acorex-platform-widgets-checkbox-widget-view.component-C5V7UVN5.mjs → acorex-platform-widgets-checkbox-widget-view.component-Y12esByc.mjs} +10 -10
  58. package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-Y12esByc.mjs.map +1 -0
  59. package/fesm2022/{acorex-platform-widgets-color-box-widget-designer.component-BB3ylFBu.mjs → acorex-platform-widgets-color-box-widget-designer.component-CihtTd0F.mjs} +12 -12
  60. package/fesm2022/acorex-platform-widgets-color-box-widget-designer.component-CihtTd0F.mjs.map +1 -0
  61. package/fesm2022/{acorex-platform-widgets-file-list-popup.component-B58wkY7i.mjs → acorex-platform-widgets-file-list-popup.component-CEPrED5e.mjs} +15 -15
  62. package/fesm2022/acorex-platform-widgets-file-list-popup.component-CEPrED5e.mjs.map +1 -0
  63. package/fesm2022/{acorex-platform-widgets-file-rename-popup.component-BKkGU_y0.mjs → acorex-platform-widgets-file-rename-popup.component-DCVTwkGL.mjs} +15 -15
  64. package/fesm2022/acorex-platform-widgets-file-rename-popup.component-DCVTwkGL.mjs.map +1 -0
  65. package/fesm2022/{acorex-platform-widgets-page-widget-designer.component-DFyDAEzN.mjs → acorex-platform-widgets-page-widget-designer.component-D_970YBz.mjs} +11 -11
  66. package/fesm2022/acorex-platform-widgets-page-widget-designer.component-D_970YBz.mjs.map +1 -0
  67. package/fesm2022/{acorex-platform-widgets-rich-text-popup.component-C1QnFtzt.mjs → acorex-platform-widgets-rich-text-popup.component-ti6XgNeD.mjs} +4 -4
  68. package/fesm2022/{acorex-platform-widgets-rich-text-popup.component-C1QnFtzt.mjs.map → acorex-platform-widgets-rich-text-popup.component-ti6XgNeD.mjs.map} +1 -1
  69. package/fesm2022/{acorex-platform-widgets-tabular-data-edit-popup.component--QOiFzPo.mjs → acorex-platform-widgets-tabular-data-edit-popup.component-C-OZ-B7h.mjs} +11 -11
  70. package/fesm2022/acorex-platform-widgets-tabular-data-edit-popup.component-C-OZ-B7h.mjs.map +1 -0
  71. package/fesm2022/{acorex-platform-widgets-tabular-data-view-popup.component-D-uJJ-tH.mjs → acorex-platform-widgets-tabular-data-view-popup.component-CvPn4SJx.mjs} +6 -6
  72. package/fesm2022/acorex-platform-widgets-tabular-data-view-popup.component-CvPn4SJx.mjs.map +1 -0
  73. package/fesm2022/{acorex-platform-widgets-text-block-widget-designer.component-7C66MAeP.mjs → acorex-platform-widgets-text-block-widget-designer.component-C_iu3jCG.mjs} +6 -6
  74. package/fesm2022/acorex-platform-widgets-text-block-widget-designer.component-C_iu3jCG.mjs.map +1 -0
  75. package/fesm2022/acorex-platform-widgets.mjs +1194 -1194
  76. package/fesm2022/acorex-platform-widgets.mjs.map +1 -1
  77. package/fesm2022/acorex-platform-workflow.mjs +25 -25
  78. package/fesm2022/acorex-platform-workflow.mjs.map +1 -1
  79. package/layout/builder/index.d.ts +1 -0
  80. package/package.json +1 -1
  81. package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-BNdAQn4R.mjs.map +0 -1
  82. package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-CElBGzRM.mjs.map +0 -1
  83. package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-QQ4bFuiN.mjs.map +0 -1
  84. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-CEfSqV8l.mjs.map +0 -1
  85. package/fesm2022/acorex-platform-themes-shared-color-chooser-view.component-CUtKW-cD.mjs.map +0 -1
  86. package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-Dc3LQQOa.mjs.map +0 -1
  87. package/fesm2022/acorex-platform-widgets-button-widget-designer.component-dBuOCox2.mjs.map +0 -1
  88. package/fesm2022/acorex-platform-widgets-checkbox-widget-designer.component-BSGnyPBn.mjs.map +0 -1
  89. package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-C5V7UVN5.mjs.map +0 -1
  90. package/fesm2022/acorex-platform-widgets-color-box-widget-designer.component-BB3ylFBu.mjs.map +0 -1
  91. package/fesm2022/acorex-platform-widgets-file-list-popup.component-B58wkY7i.mjs.map +0 -1
  92. package/fesm2022/acorex-platform-widgets-file-rename-popup.component-BKkGU_y0.mjs.map +0 -1
  93. package/fesm2022/acorex-platform-widgets-page-widget-designer.component-DFyDAEzN.mjs.map +0 -1
  94. package/fesm2022/acorex-platform-widgets-tabular-data-edit-popup.component--QOiFzPo.mjs.map +0 -1
  95. package/fesm2022/acorex-platform-widgets-tabular-data-view-popup.component-D-uJJ-tH.mjs.map +0 -1
  96. package/fesm2022/acorex-platform-widgets-text-block-widget-designer.component-7C66MAeP.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injector, Injectable, signal, inject, Input, Directive, provideAppInitializer, Optional, Inject, NgModule } from '@angular/core';
3
- import { of, map, BehaviorSubject, shareReplay, defaultIfEmpty, firstValueFrom, first } from 'rxjs';
4
- import { AXPBroadcastEventService, AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER } from '@acorex/platform/core';
5
- import { merge, isEmpty } from 'lodash-es';
3
+ import { of, map, BehaviorSubject, shareReplay, defaultIfEmpty, switchMap, filter, firstValueFrom, first } from 'rxjs';
4
+ import { AXPBroadcastEventService } from '@acorex/platform/core';
5
+ import { isEmpty } from 'lodash-es';
6
6
 
7
7
  const AXP_APPLICATION_LOADER = new InjectionToken('AXP_APPLICATION_LOADER', {
8
8
  providedIn: 'root',
@@ -21,6 +21,14 @@ class AXPApplicationDefaultLoader {
21
21
  editionName: 'Standard',
22
22
  features: [],
23
23
  },
24
+ {
25
+ id: '2',
26
+ name: 'default-app',
27
+ title: 'Default Application',
28
+ version: '1.0.0',
29
+ editionName: 'Standard',
30
+ features: [],
31
+ },
24
32
  ]);
25
33
  }
26
34
  }
@@ -60,10 +68,10 @@ class AXPAuthStrategyRegistryService {
60
68
  get(strategyKey) {
61
69
  return this.strategies.get(strategyKey);
62
70
  }
63
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPAuthStrategyRegistryService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
64
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPAuthStrategyRegistryService, providedIn: 'root' }); }
71
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthStrategyRegistryService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
72
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthStrategyRegistryService, providedIn: 'root' }); }
65
73
  }
66
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPAuthStrategyRegistryService, decorators: [{
74
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthStrategyRegistryService, decorators: [{
67
75
  type: Injectable,
68
76
  args: [{
69
77
  providedIn: 'root'
@@ -86,7 +94,7 @@ class AXPFeatureDirective {
86
94
  constructor(templateRef, viewContainer) {
87
95
  this.templateRef = templateRef;
88
96
  this.viewContainer = viewContainer;
89
- this.hasView = signal(false);
97
+ this.hasView = signal(false, ...(ngDevMode ? [{ debugName: "hasView" }] : []));
90
98
  this.sessionService = inject(AXPSessionService);
91
99
  }
92
100
  set feature(featureKeys) {
@@ -120,10 +128,10 @@ class AXPFeatureDirective {
120
128
  ngOnDestroy() {
121
129
  this.subscription?.unsubscribe();
122
130
  }
123
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPFeatureDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
124
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.7", type: AXPFeatureDirective, isStandalone: false, selector: "[feature]", inputs: { feature: "feature", featureElse: "featureElse" }, ngImport: i0 }); }
131
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPFeatureDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
132
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.3", type: AXPFeatureDirective, isStandalone: false, selector: "[feature]", inputs: { feature: "feature", featureElse: "featureElse" }, ngImport: i0 }); }
125
133
  }
126
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPFeatureDirective, decorators: [{
134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPFeatureDirective, decorators: [{
127
135
  type: Directive,
128
136
  args: [{
129
137
  selector: '[feature]',
@@ -216,6 +224,9 @@ class AXPSessionService {
216
224
  this.applicationLoader = inject(AXP_APPLICATION_LOADER);
217
225
  this.status = new BehaviorSubject(AXPSessionStatus.Unauthenticated);
218
226
  this.status$ = this.status.asObservable().pipe(shareReplay(1));
227
+ // Add loading state to prevent premature redirects
228
+ this.isLoading = new BehaviorSubject(true);
229
+ this.isLoading$ = this.isLoading.asObservable().pipe(shareReplay(1));
219
230
  this.currentUserSubject = new BehaviorSubject(null);
220
231
  this.user$ = this.currentUserSubject.asObservable().pipe(shareReplay(1));
221
232
  this.currentTenantSubject = new BehaviorSubject(null);
@@ -226,7 +237,17 @@ class AXPSessionService {
226
237
  this.permissions$ = this.permissionsSubject.asObservable().pipe(shareReplay(1), defaultIfEmpty([]));
227
238
  this.featuresSubject = new BehaviorSubject([]);
228
239
  this.features$ = this.featuresSubject.asObservable().pipe(shareReplay(1), defaultIfEmpty([]));
229
- this.isAuthenticated$ = this.status$.pipe(map((status) => status === AXPSessionStatus.Authenticated || status === AXPSessionStatus.Authorized), shareReplay(1));
240
+ this.isAuthenticated$ = this.status$.pipe(map((status) => {
241
+ const isAuth = status === AXPSessionStatus.Authenticated || status === AXPSessionStatus.Authorized;
242
+ return isAuth;
243
+ }), shareReplay(1));
244
+ // Add a new observable that considers loading state
245
+ this.isAuthenticatedWithLoading$ = this.isLoading$.pipe(switchMap((loading) => {
246
+ if (loading) {
247
+ return this.isLoading$.pipe(filter((isLoading) => !isLoading), switchMap(() => this.isAuthenticated$));
248
+ }
249
+ return this.isAuthenticated$;
250
+ }), shareReplay(1));
230
251
  this.isAuthorized$ = this.status$.pipe(map((status) => status === AXPSessionStatus.Authorized), shareReplay(1));
231
252
  }
232
253
  static { this.SESSION_KEY = 'AXP_SESSION'; }
@@ -264,108 +285,138 @@ class AXPSessionService {
264
285
  return this.featuresSubject.value ?? [];
265
286
  }
266
287
  async restoreSession() {
267
- const sessionData = this.getSessionData();
268
- if (sessionData) {
269
- if (sessionData.user) {
270
- this.currentUserSubject.next(sessionData.user);
271
- this.status.next(AXPSessionStatus.Authenticated);
288
+ this.isLoading.next(true);
289
+ try {
290
+ const sessionData = this.getSessionData();
291
+ if (sessionData) {
292
+ if (sessionData.user) {
293
+ this.currentUserSubject.next(sessionData.user);
294
+ this.status.next(AXPSessionStatus.Authenticated);
295
+ await this.loadPermissions();
296
+ await this.loadFeatures();
297
+ await this.signInComplete();
298
+ }
272
299
  }
273
- // if (sessionData.tenant) {
274
- // this.setTenant(sessionData.tenant);
275
- // }
276
- // if (sessionData.application) {
277
- // this.setApplication(sessionData.application);
278
- // }
279
- await this.loadPermissions();
280
- await this.loadFeatures();
281
- await this.signInComplete();
282
- }
283
- else {
300
+ else {
301
+ this.status.next(AXPSessionStatus.Unauthorized);
302
+ }
303
+ }
304
+ catch (error) {
284
305
  this.status.next(AXPSessionStatus.Unauthorized);
285
306
  }
307
+ finally {
308
+ this.isLoading.next(false);
309
+ }
286
310
  }
287
311
  async signin(credentials) {
288
- //
289
- this.clearSession();
290
- //
291
- const strategy = this.authStrategyRegistry.get(credentials.strategy);
292
- if (!strategy) {
293
- throw new Error(`Authentication strategy '${credentials.strategy}' is not supported`);
294
- }
295
- const result = await strategy.signin(credentials);
296
- if (result.succeed) {
297
- this.currentUserSubject.next(result.data.user);
298
- this.setSession({
299
- accessToken: result.data.accessToken,
300
- refreshToken: result.data.refreshToken,
301
- strategy: credentials.strategy,
302
- user: result.data.user,
303
- application: result.data?.application,
304
- tenant: result.data?.tenant,
305
- expiresIn: result.data?.expiresIn,
306
- idToken: result.data?.idToken ?? null,
307
- });
308
- this.status.next(AXPSessionStatus.Authenticated);
309
- if (this.application && this.tenant)
310
- await this.signInComplete();
312
+ this.isLoading.next(true);
313
+ try {
314
+ //
315
+ this.clearSession();
316
+ //
317
+ const strategy = this.authStrategyRegistry.get(credentials.strategy);
318
+ if (!strategy) {
319
+ throw new Error(`Authentication strategy '${credentials.strategy}' is not supported`);
320
+ }
321
+ const result = await strategy.signin(credentials);
322
+ if (result.succeed) {
323
+ this.currentUserSubject.next(result.data.user);
324
+ this.setSession({
325
+ accessToken: result.data.accessToken,
326
+ refreshToken: result.data.refreshToken,
327
+ strategy: credentials.strategy,
328
+ user: result.data.user,
329
+ application: result.data?.application,
330
+ tenant: result.data?.tenant,
331
+ expiresIn: result.data?.expiresIn,
332
+ idToken: result.data?.idToken ?? null,
333
+ });
334
+ this.status.next(AXPSessionStatus.Authenticated);
335
+ // Load permissions and features
336
+ await this.loadPermissions();
337
+ await this.loadFeatures();
338
+ // If we have both tenant and application, complete the sign-in
339
+ if (this.application && this.tenant) {
340
+ await this.signInComplete();
341
+ }
342
+ }
343
+ else {
344
+ this.status.next(AXPSessionStatus.Unauthenticated);
345
+ throw new Error(`Invalid Username or Password`);
346
+ }
311
347
  }
312
- else {
348
+ catch (error) {
349
+ console.error('Signin error:', error);
313
350
  this.status.next(AXPSessionStatus.Unauthenticated);
314
- throw new Error(`Invalid Username or Password`);
351
+ throw error;
352
+ }
353
+ finally {
354
+ this.isLoading.next(false);
355
+ console.log('Signin process completed');
315
356
  }
316
357
  }
317
358
  async signout() {
318
- const sessionData = this.getSessionData();
319
- if (sessionData?.strategy) {
320
- const strategy = this.authStrategyRegistry.get(sessionData?.strategy);
321
- if (strategy) {
322
- await strategy.signout();
359
+ console.log('Signing out...');
360
+ this.isLoading.next(true);
361
+ try {
362
+ const sessionData = this.getSessionData();
363
+ if (sessionData?.strategy) {
364
+ const strategy = this.authStrategyRegistry.get(sessionData?.strategy);
365
+ if (strategy) {
366
+ try {
367
+ await strategy.signout();
368
+ }
369
+ catch (error) {
370
+ }
371
+ }
323
372
  }
373
+ //
374
+ const userId = this.user?.id;
375
+ this.clearSession();
376
+ this.status.next(AXPSessionStatus.SignedOut);
377
+ this.eventService.publish(AXPSessionStatus.SignedOut, { id: userId });
378
+ }
379
+ finally {
380
+ this.isLoading.next(false);
324
381
  }
325
- //
326
- const userId = this.user?.id;
327
- this.clearSession();
328
- this.status.next(AXPSessionStatus.SignedOut);
329
- this.eventService.publish(AXPSessionStatus.SignedOut, { id: userId });
330
382
  }
331
383
  async refreshToken() {
384
+ console.log('Refreshing token...');
332
385
  return new Promise(async (resolve, reject) => {
333
386
  const sessionData = this.getSessionData();
334
387
  if (!sessionData || !sessionData?.refreshToken) {
388
+ console.log('No session data or refresh token found');
389
+ reject(new Error('No refresh token available'));
335
390
  return;
336
391
  }
337
392
  const strategy = this.authStrategyRegistry.get(sessionData.strategy);
338
393
  if (!strategy) {
339
- reject();
340
- throw new Error(`Authentication strategy '${sessionData.strategy}' is not found`);
394
+ console.error('Authentication strategy not found:', sessionData.strategy);
395
+ reject(new Error(`Authentication strategy '${sessionData.strategy}' is not found`));
396
+ return;
341
397
  }
342
- const result = await strategy.refreshToken(this.getContext());
343
- if (result.succeed) {
344
- this.setSession(result.data);
345
- resolve(result.data?.accessToken);
398
+ try {
399
+ const result = await strategy.refreshToken(this.getContext());
400
+ if (result.succeed) {
401
+ console.log('Token refresh successful');
402
+ this.setSession(result.data);
403
+ resolve(result.data?.accessToken);
404
+ }
405
+ else {
406
+ console.error('Token refresh failed');
407
+ this.clearSession();
408
+ this.status.next(AXPSessionStatus.Expired);
409
+ reject(new Error('Token refresh failed'));
410
+ }
346
411
  }
347
- else {
412
+ catch (error) {
413
+ console.error('Error during token refresh:', error);
348
414
  this.clearSession();
349
415
  this.status.next(AXPSessionStatus.Expired);
416
+ reject(error);
350
417
  }
351
418
  });
352
419
  }
353
- async setTenant(tenant) {
354
- this.currentTenantSubject.next(tenant);
355
- if (tenant) {
356
- this.updateSession({ tenant: tenant });
357
- await this.refreshToken();
358
- }
359
- }
360
- async setApplication(application) {
361
- this.currentApplicationSubject.next(application);
362
- if (application) {
363
- this.updateSession({ application: application });
364
- await this.refreshToken();
365
- await this.loadPermissions();
366
- await this.loadFeatures();
367
- }
368
- }
369
420
  async loadPermissions() {
370
421
  try {
371
422
  const permissions = await firstValueFrom(this.permissionLoader.getList(this.getContext()));
@@ -387,37 +438,64 @@ class AXPSessionService {
387
438
  }
388
439
  }
389
440
  async signInComplete() {
441
+ // Ensure we have the required data
442
+ if (!this.user) {
443
+ this.status.next(AXPSessionStatus.Unauthenticated);
444
+ return;
445
+ }
446
+ // Set status to Authorized
390
447
  this.status.next(AXPSessionStatus.Authorized);
448
+ // Double-check the status was set correctly
449
+ setTimeout(() => {
450
+ console.log('Status after timeout:', this.status.value);
451
+ }, 100);
391
452
  }
392
453
  setSession(tokens) {
393
454
  const sessionData = {
394
455
  accessToken: tokens.accessToken,
395
456
  refreshToken: tokens.refreshToken,
396
457
  strategy: tokens.strategy,
397
- user: this.user,
458
+ user: tokens.user,
398
459
  application: tokens.application,
399
460
  tenant: tokens.tenant,
400
461
  expiresIn: tokens.expiresIn,
401
462
  idToken: tokens.idToken,
402
463
  };
403
- this.updateSession(sessionData);
404
- }
405
- updateSession(update) {
406
- const currentSession = this.getSessionData() ?? {};
407
- const updatedSession = merge({}, currentSession, update);
408
- localStorage.setItem(AXPSessionService.SESSION_KEY, JSON.stringify(updatedSession));
464
+ // Update subjects
465
+ if (tokens.user) {
466
+ this.currentUserSubject.next(tokens.user);
467
+ }
468
+ if (tokens.tenant) {
469
+ this.currentTenantSubject.next(tokens.tenant);
470
+ }
471
+ if (tokens.application) {
472
+ this.currentApplicationSubject.next(tokens.application);
473
+ }
474
+ localStorage.setItem(AXPSessionService.SESSION_KEY, JSON.stringify(sessionData));
409
475
  }
410
476
  getSessionData() {
411
- const sessionDataString = localStorage.getItem(AXPSessionService.SESSION_KEY);
412
- return sessionDataString ? JSON.parse(sessionDataString) : null;
477
+ try {
478
+ const sessionDataString = localStorage.getItem(AXPSessionService.SESSION_KEY);
479
+ if (sessionDataString) {
480
+ const sessionData = JSON.parse(sessionDataString);
481
+ return sessionData;
482
+ }
483
+ else {
484
+ return null;
485
+ }
486
+ }
487
+ catch (error) {
488
+ localStorage.removeItem(AXPSessionService.SESSION_KEY);
489
+ return null;
490
+ }
413
491
  }
414
492
  clearSession() {
415
493
  //
416
494
  this.currentUserSubject.next(null);
417
495
  //
418
- this.setTenant(null);
496
+ this.currentTenantSubject.next(null);
419
497
  //
420
- this.setApplication(null);
498
+ this.currentApplicationSubject.next(null);
421
499
  //
422
500
  this.permissionsSubject.next([]);
423
501
  //
@@ -453,10 +531,10 @@ class AXPSessionService {
453
531
  application: this.application,
454
532
  });
455
533
  }
456
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPSessionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
457
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPSessionService, providedIn: 'root' }); }
534
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPSessionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
535
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPSessionService, providedIn: 'root' }); }
458
536
  }
459
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPSessionService, decorators: [{
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPSessionService, decorators: [{
460
538
  type: Injectable,
461
539
  args: [{
462
540
  providedIn: 'root',
@@ -467,7 +545,7 @@ class AXPPermissionDirective {
467
545
  constructor(templateRef, viewContainer) {
468
546
  this.templateRef = templateRef;
469
547
  this.viewContainer = viewContainer;
470
- this.hasView = signal(false);
548
+ this.hasView = signal(false, ...(ngDevMode ? [{ debugName: "hasView" }] : []));
471
549
  this.sessionService = inject(AXPSessionService);
472
550
  }
473
551
  set permission(permissionKeys) {
@@ -500,10 +578,10 @@ class AXPPermissionDirective {
500
578
  ngOnDestroy() {
501
579
  this.subscription?.unsubscribe();
502
580
  }
503
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPPermissionDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
504
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.7", type: AXPPermissionDirective, isStandalone: false, selector: "[permission]", inputs: { permission: "permission", permissionElse: "permissionElse" }, ngImport: i0 }); }
581
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPPermissionDirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
582
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.3", type: AXPPermissionDirective, isStandalone: false, selector: "[permission]", inputs: { permission: "permission", permissionElse: "permissionElse" }, ngImport: i0 }); }
505
583
  }
506
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPPermissionDirective, decorators: [{
584
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPPermissionDirective, decorators: [{
507
585
  type: Directive,
508
586
  args: [{
509
587
  selector: '[permission]',
@@ -657,10 +735,10 @@ class AXPPermissionDefinitionService {
657
735
  await this.load();
658
736
  return this.cache?.find(g => g.permissions.find(p => p.name === name))?.permissions.find(p => p.name === name) ?? null;
659
737
  }
660
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPPermissionDefinitionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
661
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPPermissionDefinitionService, providedIn: 'root' }); }
738
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPPermissionDefinitionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
739
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPPermissionDefinitionService, providedIn: 'root' }); }
662
740
  }
663
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPPermissionDefinitionService, decorators: [{
741
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPPermissionDefinitionService, decorators: [{
664
742
  type: Injectable,
665
743
  args: [{ providedIn: 'root' }]
666
744
  }] });
@@ -693,7 +771,7 @@ class AXPPermissionEvaluatorScopeProvider {
693
771
 
694
772
  const AXPAuthGuard = (route, state) => {
695
773
  const sessionService = inject(AXPSessionService);
696
- return sessionService.isAuthenticated$.pipe(first(), map((value) => {
774
+ return sessionService.isAuthenticatedWithLoading$.pipe(first(), map((value) => {
697
775
  if (value) {
698
776
  return true;
699
777
  }
@@ -754,21 +832,16 @@ class AXPAuthModule {
754
832
  f();
755
833
  });
756
834
  }
757
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPAuthModule, deps: [{ token: 'AXPAuthModuleFactory', optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
758
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.7", ngImport: i0, type: AXPAuthModule, declarations: [AXPPermissionDirective, AXPFeatureDirective], exports: [AXPPermissionDirective, AXPFeatureDirective] }); }
759
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPAuthModule, providers: [
835
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthModule, deps: [{ token: 'AXPAuthModuleFactory', optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
836
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthModule, declarations: [AXPPermissionDirective, AXPFeatureDirective], exports: [AXPPermissionDirective, AXPFeatureDirective] }); }
837
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthModule, providers: [
760
838
  provideAppInitializer(() => {
761
- const initializerFn = (initializeAppState)(inject(AXPSessionService));
839
+ const initializerFn = initializeAppState(inject(AXPSessionService));
762
840
  return initializerFn();
763
841
  }),
764
- {
765
- provide: AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER,
766
- useClass: AXPPermissionEvaluatorScopeProvider,
767
- multi: true,
768
- },
769
842
  ] }); }
770
843
  }
771
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPAuthModule, decorators: [{
844
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXPAuthModule, decorators: [{
772
845
  type: NgModule,
773
846
  args: [{
774
847
  imports: [],
@@ -776,14 +849,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
776
849
  declarations: [AXPPermissionDirective, AXPFeatureDirective],
777
850
  providers: [
778
851
  provideAppInitializer(() => {
779
- const initializerFn = (initializeAppState)(inject(AXPSessionService));
852
+ const initializerFn = initializeAppState(inject(AXPSessionService));
780
853
  return initializerFn();
781
854
  }),
782
- {
783
- provide: AXP_EXPRESSION_EVALUATOR_SCOPE_PROVIDER,
784
- useClass: AXPPermissionEvaluatorScopeProvider,
785
- multi: true,
786
- },
787
855
  ],
788
856
  }]
789
857
  }], ctorParameters: () => [{ type: undefined, decorators: [{
@@ -793,9 +861,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
793
861
  args: ['AXPAuthModuleFactory']
794
862
  }] }] });
795
863
 
864
+ class AXPAuthStrategy {
865
+ // OIDC-specific methods (default: throw error)
866
+ startAuthorizationFlow(tenantId, applicationId) {
867
+ throw new Error('startAuthorizationFlow is not implemented for this strategy');
868
+ }
869
+ completeAuthorizationCodeFlow(options) {
870
+ throw new Error('completeAuthorizationCodeFlow is not implemented for this strategy');
871
+ }
872
+ }
873
+
796
874
  /**
797
875
  * Generated bundle index. Do not edit.
798
876
  */
799
877
 
800
- export { AXPAuthGuard, AXPAuthModule, AXPFeatureDirective, AXPFeatureGuard, AXPPermissionDefinitionBuilder, AXPPermissionDefinitionGroupBuilder, AXPPermissionDefinitionProviderContext, AXPPermissionDefinitionService, AXPPermissionDirective, AXPPermissionEvaluatorScopeProvider, AXPPermissionGuard, AXPSessionContext, AXPSessionService, AXPSessionStatus, AXPUnauthenticatedError, AXPUnauthorizedError, AXP_APPLICATION_LOADER, AXP_FEATURE_LOADER, AXP_PERMISSION_DEFINITION_PROVIDER, AXP_PERMISSION_LOADER, AXP_TENANT_LOADER, initializeAppState };
878
+ export { AXPAuthGuard, AXPAuthModule, AXPAuthStrategy, AXPAuthStrategyRegistryService, AXPFeatureDirective, AXPFeatureGuard, AXPPermissionDefinitionBuilder, AXPPermissionDefinitionGroupBuilder, AXPPermissionDefinitionProviderContext, AXPPermissionDefinitionService, AXPPermissionDirective, AXPPermissionEvaluatorScopeProvider, AXPPermissionGuard, AXPSessionContext, AXPSessionService, AXPSessionStatus, AXPUnauthenticatedError, AXPUnauthorizedError, AXP_APPLICATION_LOADER, AXP_FEATURE_LOADER, AXP_PERMISSION_DEFINITION_PROVIDER, AXP_PERMISSION_LOADER, AXP_TENANT_LOADER, initializeAppState };
801
879
  //# sourceMappingURL=acorex-platform-auth.mjs.map