@abpjs/identity 1.1.0 → 2.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.
package/dist/index.d.mts CHANGED
@@ -70,6 +70,50 @@ declare namespace Identity {
70
70
  password: string;
71
71
  roleNames: string[];
72
72
  }
73
+ /**
74
+ * Input props for RolesComponent
75
+ * @since 2.0.0
76
+ */
77
+ interface RolesComponentInputs {
78
+ /** Callback when a role is created */
79
+ readonly onRoleCreated?: (role: RoleItem) => void;
80
+ /** Callback when a role is updated */
81
+ readonly onRoleUpdated?: (role: RoleItem) => void;
82
+ /** Callback when a role is deleted */
83
+ readonly onRoleDeleted?: (id: string) => void;
84
+ }
85
+ /**
86
+ * Output callbacks for RolesComponent
87
+ * @since 2.0.0
88
+ */
89
+ interface RolesComponentOutputs {
90
+ /** Callback when permission modal visibility changes */
91
+ readonly onVisiblePermissionChange?: (visible: boolean) => void;
92
+ }
93
+ /**
94
+ * Input props for UsersComponent
95
+ * @since 2.0.0
96
+ */
97
+ interface UsersComponentInputs {
98
+ /** Callback when a user is created */
99
+ readonly onUserCreated?: (user: UserItem) => void;
100
+ /** Callback when a user is updated */
101
+ readonly onUserUpdated?: (user: UserItem) => void;
102
+ /** Callback when a user is deleted */
103
+ readonly onUserDeleted?: (id: string) => void;
104
+ /** Password validation rules to display */
105
+ readonly passwordRulesArr?: ('number' | 'small' | 'capital' | 'special')[];
106
+ /** Required minimum password length */
107
+ readonly requiredPasswordLength?: number;
108
+ }
109
+ /**
110
+ * Output callbacks for UsersComponent
111
+ * @since 2.0.0
112
+ */
113
+ interface UsersComponentOutputs {
114
+ /** Callback when permission modal visibility changes */
115
+ readonly onVisiblePermissionChange?: (visible: boolean) => void;
116
+ }
73
117
  }
74
118
 
75
119
  /**
@@ -151,6 +195,118 @@ declare class IdentityService {
151
195
  updateUser(id: string, body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
152
196
  }
153
197
 
198
+ /**
199
+ * IdentityStateService - A stateful service facade for identity operations.
200
+ *
201
+ * This service provides a stateful wrapper around IdentityService, maintaining
202
+ * local state for roles and users. It's the React equivalent of Angular's
203
+ * IdentityStateService which wraps NGXS store operations.
204
+ *
205
+ * For most React use cases, prefer using the hooks (useRoles, useUsers, useIdentity)
206
+ * instead of this class. This class is provided for programmatic/non-hook scenarios.
207
+ *
208
+ * @since 2.0.0
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * import { IdentityStateService, IdentityService } from '@abpjs/identity';
213
+ * import { RestService } from '@abpjs/core';
214
+ *
215
+ * const rest = new RestService();
216
+ * const identityService = new IdentityService(rest);
217
+ * const stateService = new IdentityStateService(identityService);
218
+ *
219
+ * // Fetch and get roles
220
+ * await stateService.dispatchGetRoles();
221
+ * const roles = stateService.getRoles();
222
+ * ```
223
+ */
224
+ declare class IdentityStateService {
225
+ private identityService;
226
+ private roles;
227
+ private rolesTotalCount;
228
+ private users;
229
+ private usersTotalCount;
230
+ constructor(identityService: IdentityService);
231
+ /**
232
+ * Get the current roles from state
233
+ */
234
+ getRoles(): Identity.RoleItem[];
235
+ /**
236
+ * Get the total count of roles
237
+ */
238
+ getRolesTotalCount(): number;
239
+ /**
240
+ * Get the current users from state
241
+ */
242
+ getUsers(): Identity.UserItem[];
243
+ /**
244
+ * Get the total count of users
245
+ */
246
+ getUsersTotalCount(): number;
247
+ /**
248
+ * Fetch roles and update internal state
249
+ * @param params - Optional query parameters for pagination/filtering
250
+ */
251
+ dispatchGetRoles(params?: ABP.PageQueryParams): Promise<Identity.RoleResponse>;
252
+ /**
253
+ * Fetch a role by ID
254
+ * @param id - The role ID
255
+ */
256
+ dispatchGetRoleById(id: string): Promise<Identity.RoleItem>;
257
+ /**
258
+ * Delete a role and refresh the list
259
+ * @param id - The role ID to delete
260
+ */
261
+ dispatchDeleteRole(id: string): Promise<Identity.RoleItem>;
262
+ /**
263
+ * Create a new role and refresh the list
264
+ * @param body - The role data to create
265
+ */
266
+ dispatchCreateRole(body: Identity.RoleSaveRequest): Promise<Identity.RoleItem>;
267
+ /**
268
+ * Update an existing role and refresh the list
269
+ * @param payload - Object containing id and updated role data
270
+ */
271
+ dispatchUpdateRole(payload: {
272
+ id: string;
273
+ body: Identity.RoleSaveRequest;
274
+ }): Promise<Identity.RoleItem>;
275
+ /**
276
+ * Fetch users and update internal state
277
+ * @param params - Optional query parameters for pagination/filtering
278
+ */
279
+ dispatchGetUsers(params?: ABP.PageQueryParams): Promise<Identity.UserResponse>;
280
+ /**
281
+ * Fetch a user by ID
282
+ * @param id - The user ID
283
+ */
284
+ dispatchGetUserById(id: string): Promise<Identity.UserItem>;
285
+ /**
286
+ * Delete a user and refresh the list
287
+ * @param id - The user ID to delete
288
+ */
289
+ dispatchDeleteUser(id: string): Promise<void>;
290
+ /**
291
+ * Create a new user and refresh the list
292
+ * @param body - The user data to create
293
+ */
294
+ dispatchCreateUser(body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
295
+ /**
296
+ * Update an existing user and refresh the list
297
+ * @param payload - Object containing id and updated user data
298
+ */
299
+ dispatchUpdateUser(payload: {
300
+ id: string;
301
+ body: Identity.UserSaveRequest;
302
+ }): Promise<Identity.UserItem>;
303
+ /**
304
+ * Get roles assigned to a user
305
+ * @param id - The user ID
306
+ */
307
+ dispatchGetUserRoles(id: string): Promise<Identity.RoleResponse>;
308
+ }
309
+
154
310
  /**
155
311
  * Result from role operations
156
312
  */
@@ -388,6 +544,11 @@ interface RolesComponentProps {
388
544
  onRoleUpdated?: (role: Identity.RoleItem) => void;
389
545
  /** Optional callback when a role is deleted */
390
546
  onRoleDeleted?: (id: string) => void;
547
+ /**
548
+ * Callback when permission modal visibility changes
549
+ * @since 2.0.0
550
+ */
551
+ onVisiblePermissionChange?: (visible: boolean) => void;
391
552
  }
392
553
  /**
393
554
  * RolesComponent - Component for managing roles
@@ -407,7 +568,7 @@ interface RolesComponentProps {
407
568
  * }
408
569
  * ```
409
570
  */
410
- declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, }: RolesComponentProps): React.ReactElement;
571
+ declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, onVisiblePermissionChange, }: RolesComponentProps): React.ReactElement;
411
572
 
412
573
  /**
413
574
  * Password rule type for validation display
@@ -434,23 +595,14 @@ interface UsersComponentProps {
434
595
  * @since 1.1.0
435
596
  */
436
597
  requiredPasswordLength?: number;
598
+ /**
599
+ * Callback when permission modal visibility changes
600
+ * @since 2.0.0
601
+ */
602
+ onVisiblePermissionChange?: (visible: boolean) => void;
437
603
  }
438
- declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, passwordRulesArr, requiredPasswordLength, }: UsersComponentProps): React.ReactElement;
604
+ declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, passwordRulesArr, requiredPasswordLength, onVisiblePermissionChange, }: UsersComponentProps): React.ReactElement;
439
605
 
440
- /**
441
- * Identity module routes configuration.
442
- * Translated from @abp/ng.identity IDENTITY_ROUTES.
443
- *
444
- * These routes define the navigation structure for the identity module
445
- * within the ABP Framework application.
446
- *
447
- * @deprecated since version 1.0.0. Route configuration is now handled by
448
- * identity config services. This constant is kept for backwards compatibility
449
- * but may be removed in future versions.
450
- */
451
- declare const IDENTITY_ROUTES: {
452
- routes: ABP.FullRoute[];
453
- };
454
606
  /**
455
607
  * Route paths for the identity module.
456
608
  * Use these constants for programmatic navigation.
@@ -485,4 +637,4 @@ declare const IDENTITY_POLICIES: {
485
637
  readonly ROLES_DELETE: "AbpIdentity.Roles.Delete";
486
638
  };
487
639
 
488
- export { IDENTITY_POLICIES, IDENTITY_ROUTES, IDENTITY_ROUTE_PATHS, Identity, IdentityService, type PasswordRule, type RoleOperationResult, RolesComponent, type RolesComponentProps, type SortOrder, type UseIdentityReturn, type UseRolesReturn, type UseUsersReturn, type UserOperationResult, UsersComponent, type UsersComponentProps, useIdentity, useRoles, useUsers };
640
+ export { IDENTITY_POLICIES, IDENTITY_ROUTE_PATHS, Identity, IdentityService, IdentityStateService, type PasswordRule, type RoleOperationResult, RolesComponent, type RolesComponentProps, type SortOrder, type UseIdentityReturn, type UseRolesReturn, type UseUsersReturn, type UserOperationResult, UsersComponent, type UsersComponentProps, useIdentity, useRoles, useUsers };
package/dist/index.d.ts CHANGED
@@ -70,6 +70,50 @@ declare namespace Identity {
70
70
  password: string;
71
71
  roleNames: string[];
72
72
  }
73
+ /**
74
+ * Input props for RolesComponent
75
+ * @since 2.0.0
76
+ */
77
+ interface RolesComponentInputs {
78
+ /** Callback when a role is created */
79
+ readonly onRoleCreated?: (role: RoleItem) => void;
80
+ /** Callback when a role is updated */
81
+ readonly onRoleUpdated?: (role: RoleItem) => void;
82
+ /** Callback when a role is deleted */
83
+ readonly onRoleDeleted?: (id: string) => void;
84
+ }
85
+ /**
86
+ * Output callbacks for RolesComponent
87
+ * @since 2.0.0
88
+ */
89
+ interface RolesComponentOutputs {
90
+ /** Callback when permission modal visibility changes */
91
+ readonly onVisiblePermissionChange?: (visible: boolean) => void;
92
+ }
93
+ /**
94
+ * Input props for UsersComponent
95
+ * @since 2.0.0
96
+ */
97
+ interface UsersComponentInputs {
98
+ /** Callback when a user is created */
99
+ readonly onUserCreated?: (user: UserItem) => void;
100
+ /** Callback when a user is updated */
101
+ readonly onUserUpdated?: (user: UserItem) => void;
102
+ /** Callback when a user is deleted */
103
+ readonly onUserDeleted?: (id: string) => void;
104
+ /** Password validation rules to display */
105
+ readonly passwordRulesArr?: ('number' | 'small' | 'capital' | 'special')[];
106
+ /** Required minimum password length */
107
+ readonly requiredPasswordLength?: number;
108
+ }
109
+ /**
110
+ * Output callbacks for UsersComponent
111
+ * @since 2.0.0
112
+ */
113
+ interface UsersComponentOutputs {
114
+ /** Callback when permission modal visibility changes */
115
+ readonly onVisiblePermissionChange?: (visible: boolean) => void;
116
+ }
73
117
  }
74
118
 
75
119
  /**
@@ -151,6 +195,118 @@ declare class IdentityService {
151
195
  updateUser(id: string, body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
152
196
  }
153
197
 
198
+ /**
199
+ * IdentityStateService - A stateful service facade for identity operations.
200
+ *
201
+ * This service provides a stateful wrapper around IdentityService, maintaining
202
+ * local state for roles and users. It's the React equivalent of Angular's
203
+ * IdentityStateService which wraps NGXS store operations.
204
+ *
205
+ * For most React use cases, prefer using the hooks (useRoles, useUsers, useIdentity)
206
+ * instead of this class. This class is provided for programmatic/non-hook scenarios.
207
+ *
208
+ * @since 2.0.0
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * import { IdentityStateService, IdentityService } from '@abpjs/identity';
213
+ * import { RestService } from '@abpjs/core';
214
+ *
215
+ * const rest = new RestService();
216
+ * const identityService = new IdentityService(rest);
217
+ * const stateService = new IdentityStateService(identityService);
218
+ *
219
+ * // Fetch and get roles
220
+ * await stateService.dispatchGetRoles();
221
+ * const roles = stateService.getRoles();
222
+ * ```
223
+ */
224
+ declare class IdentityStateService {
225
+ private identityService;
226
+ private roles;
227
+ private rolesTotalCount;
228
+ private users;
229
+ private usersTotalCount;
230
+ constructor(identityService: IdentityService);
231
+ /**
232
+ * Get the current roles from state
233
+ */
234
+ getRoles(): Identity.RoleItem[];
235
+ /**
236
+ * Get the total count of roles
237
+ */
238
+ getRolesTotalCount(): number;
239
+ /**
240
+ * Get the current users from state
241
+ */
242
+ getUsers(): Identity.UserItem[];
243
+ /**
244
+ * Get the total count of users
245
+ */
246
+ getUsersTotalCount(): number;
247
+ /**
248
+ * Fetch roles and update internal state
249
+ * @param params - Optional query parameters for pagination/filtering
250
+ */
251
+ dispatchGetRoles(params?: ABP.PageQueryParams): Promise<Identity.RoleResponse>;
252
+ /**
253
+ * Fetch a role by ID
254
+ * @param id - The role ID
255
+ */
256
+ dispatchGetRoleById(id: string): Promise<Identity.RoleItem>;
257
+ /**
258
+ * Delete a role and refresh the list
259
+ * @param id - The role ID to delete
260
+ */
261
+ dispatchDeleteRole(id: string): Promise<Identity.RoleItem>;
262
+ /**
263
+ * Create a new role and refresh the list
264
+ * @param body - The role data to create
265
+ */
266
+ dispatchCreateRole(body: Identity.RoleSaveRequest): Promise<Identity.RoleItem>;
267
+ /**
268
+ * Update an existing role and refresh the list
269
+ * @param payload - Object containing id and updated role data
270
+ */
271
+ dispatchUpdateRole(payload: {
272
+ id: string;
273
+ body: Identity.RoleSaveRequest;
274
+ }): Promise<Identity.RoleItem>;
275
+ /**
276
+ * Fetch users and update internal state
277
+ * @param params - Optional query parameters for pagination/filtering
278
+ */
279
+ dispatchGetUsers(params?: ABP.PageQueryParams): Promise<Identity.UserResponse>;
280
+ /**
281
+ * Fetch a user by ID
282
+ * @param id - The user ID
283
+ */
284
+ dispatchGetUserById(id: string): Promise<Identity.UserItem>;
285
+ /**
286
+ * Delete a user and refresh the list
287
+ * @param id - The user ID to delete
288
+ */
289
+ dispatchDeleteUser(id: string): Promise<void>;
290
+ /**
291
+ * Create a new user and refresh the list
292
+ * @param body - The user data to create
293
+ */
294
+ dispatchCreateUser(body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
295
+ /**
296
+ * Update an existing user and refresh the list
297
+ * @param payload - Object containing id and updated user data
298
+ */
299
+ dispatchUpdateUser(payload: {
300
+ id: string;
301
+ body: Identity.UserSaveRequest;
302
+ }): Promise<Identity.UserItem>;
303
+ /**
304
+ * Get roles assigned to a user
305
+ * @param id - The user ID
306
+ */
307
+ dispatchGetUserRoles(id: string): Promise<Identity.RoleResponse>;
308
+ }
309
+
154
310
  /**
155
311
  * Result from role operations
156
312
  */
@@ -388,6 +544,11 @@ interface RolesComponentProps {
388
544
  onRoleUpdated?: (role: Identity.RoleItem) => void;
389
545
  /** Optional callback when a role is deleted */
390
546
  onRoleDeleted?: (id: string) => void;
547
+ /**
548
+ * Callback when permission modal visibility changes
549
+ * @since 2.0.0
550
+ */
551
+ onVisiblePermissionChange?: (visible: boolean) => void;
391
552
  }
392
553
  /**
393
554
  * RolesComponent - Component for managing roles
@@ -407,7 +568,7 @@ interface RolesComponentProps {
407
568
  * }
408
569
  * ```
409
570
  */
410
- declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, }: RolesComponentProps): React.ReactElement;
571
+ declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, onVisiblePermissionChange, }: RolesComponentProps): React.ReactElement;
411
572
 
412
573
  /**
413
574
  * Password rule type for validation display
@@ -434,23 +595,14 @@ interface UsersComponentProps {
434
595
  * @since 1.1.0
435
596
  */
436
597
  requiredPasswordLength?: number;
598
+ /**
599
+ * Callback when permission modal visibility changes
600
+ * @since 2.0.0
601
+ */
602
+ onVisiblePermissionChange?: (visible: boolean) => void;
437
603
  }
438
- declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, passwordRulesArr, requiredPasswordLength, }: UsersComponentProps): React.ReactElement;
604
+ declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, passwordRulesArr, requiredPasswordLength, onVisiblePermissionChange, }: UsersComponentProps): React.ReactElement;
439
605
 
440
- /**
441
- * Identity module routes configuration.
442
- * Translated from @abp/ng.identity IDENTITY_ROUTES.
443
- *
444
- * These routes define the navigation structure for the identity module
445
- * within the ABP Framework application.
446
- *
447
- * @deprecated since version 1.0.0. Route configuration is now handled by
448
- * identity config services. This constant is kept for backwards compatibility
449
- * but may be removed in future versions.
450
- */
451
- declare const IDENTITY_ROUTES: {
452
- routes: ABP.FullRoute[];
453
- };
454
606
  /**
455
607
  * Route paths for the identity module.
456
608
  * Use these constants for programmatic navigation.
@@ -485,4 +637,4 @@ declare const IDENTITY_POLICIES: {
485
637
  readonly ROLES_DELETE: "AbpIdentity.Roles.Delete";
486
638
  };
487
639
 
488
- export { IDENTITY_POLICIES, IDENTITY_ROUTES, IDENTITY_ROUTE_PATHS, Identity, IdentityService, type PasswordRule, type RoleOperationResult, RolesComponent, type RolesComponentProps, type SortOrder, type UseIdentityReturn, type UseRolesReturn, type UseUsersReturn, type UserOperationResult, UsersComponent, type UsersComponentProps, useIdentity, useRoles, useUsers };
640
+ export { IDENTITY_POLICIES, IDENTITY_ROUTE_PATHS, Identity, IdentityService, IdentityStateService, type PasswordRule, type RoleOperationResult, RolesComponent, type RolesComponentProps, type SortOrder, type UseIdentityReturn, type UseRolesReturn, type UseUsersReturn, type UserOperationResult, UsersComponent, type UsersComponentProps, useIdentity, useRoles, useUsers };
package/dist/index.js CHANGED
@@ -21,9 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  IDENTITY_POLICIES: () => IDENTITY_POLICIES,
24
- IDENTITY_ROUTES: () => IDENTITY_ROUTES,
25
24
  IDENTITY_ROUTE_PATHS: () => IDENTITY_ROUTE_PATHS,
26
25
  IdentityService: () => IdentityService,
26
+ IdentityStateService: () => IdentityStateService,
27
27
  RolesComponent: () => RolesComponent,
28
28
  UsersComponent: () => UsersComponent,
29
29
  useIdentity: () => useIdentity,
@@ -174,6 +174,145 @@ var IdentityService = class {
174
174
  }
175
175
  };
176
176
 
177
+ // src/services/identity-state.service.ts
178
+ var IdentityStateService = class {
179
+ constructor(identityService) {
180
+ // Internal state
181
+ this.roles = [];
182
+ this.rolesTotalCount = 0;
183
+ this.users = [];
184
+ this.usersTotalCount = 0;
185
+ this.identityService = identityService;
186
+ }
187
+ // ========================
188
+ // State Getters
189
+ // ========================
190
+ /**
191
+ * Get the current roles from state
192
+ */
193
+ getRoles() {
194
+ return this.roles;
195
+ }
196
+ /**
197
+ * Get the total count of roles
198
+ */
199
+ getRolesTotalCount() {
200
+ return this.rolesTotalCount;
201
+ }
202
+ /**
203
+ * Get the current users from state
204
+ */
205
+ getUsers() {
206
+ return this.users;
207
+ }
208
+ /**
209
+ * Get the total count of users
210
+ */
211
+ getUsersTotalCount() {
212
+ return this.usersTotalCount;
213
+ }
214
+ // ========================
215
+ // Role Dispatch Methods
216
+ // ========================
217
+ /**
218
+ * Fetch roles and update internal state
219
+ * @param params - Optional query parameters for pagination/filtering
220
+ */
221
+ async dispatchGetRoles(params) {
222
+ const response = await this.identityService.getRoles(params);
223
+ this.roles = response.items;
224
+ this.rolesTotalCount = response.totalCount;
225
+ return response;
226
+ }
227
+ /**
228
+ * Fetch a role by ID
229
+ * @param id - The role ID
230
+ */
231
+ async dispatchGetRoleById(id) {
232
+ return this.identityService.getRoleById(id);
233
+ }
234
+ /**
235
+ * Delete a role and refresh the list
236
+ * @param id - The role ID to delete
237
+ */
238
+ async dispatchDeleteRole(id) {
239
+ const result = await this.identityService.deleteRole(id);
240
+ await this.dispatchGetRoles();
241
+ return result;
242
+ }
243
+ /**
244
+ * Create a new role and refresh the list
245
+ * @param body - The role data to create
246
+ */
247
+ async dispatchCreateRole(body) {
248
+ const result = await this.identityService.createRole(body);
249
+ await this.dispatchGetRoles();
250
+ return result;
251
+ }
252
+ /**
253
+ * Update an existing role and refresh the list
254
+ * @param payload - Object containing id and updated role data
255
+ */
256
+ async dispatchUpdateRole(payload) {
257
+ const result = await this.identityService.updateRole(payload.id, payload.body);
258
+ await this.dispatchGetRoles();
259
+ return result;
260
+ }
261
+ // ========================
262
+ // User Dispatch Methods
263
+ // ========================
264
+ /**
265
+ * Fetch users and update internal state
266
+ * @param params - Optional query parameters for pagination/filtering
267
+ */
268
+ async dispatchGetUsers(params) {
269
+ const response = await this.identityService.getUsers(params);
270
+ this.users = response.items;
271
+ this.usersTotalCount = response.totalCount;
272
+ return response;
273
+ }
274
+ /**
275
+ * Fetch a user by ID
276
+ * @param id - The user ID
277
+ */
278
+ async dispatchGetUserById(id) {
279
+ return this.identityService.getUserById(id);
280
+ }
281
+ /**
282
+ * Delete a user and refresh the list
283
+ * @param id - The user ID to delete
284
+ */
285
+ async dispatchDeleteUser(id) {
286
+ await this.identityService.deleteUser(id);
287
+ await this.dispatchGetUsers();
288
+ }
289
+ /**
290
+ * Create a new user and refresh the list
291
+ * @param body - The user data to create
292
+ */
293
+ async dispatchCreateUser(body) {
294
+ const result = await this.identityService.createUser(body);
295
+ await this.dispatchGetUsers();
296
+ return result;
297
+ }
298
+ /**
299
+ * Update an existing user and refresh the list
300
+ * @param payload - Object containing id and updated user data
301
+ */
302
+ async dispatchUpdateUser(payload) {
303
+ const result = await this.identityService.updateUser(payload.id, payload.body);
304
+ await this.dispatchGetUsers();
305
+ return result;
306
+ }
307
+ /**
308
+ * Get roles assigned to a user
309
+ * @param id - The user ID
310
+ */
311
+ async dispatchGetUserRoles(id) {
312
+ return this.identityService.getUserRoles(id);
313
+ }
314
+ };
315
+
177
316
  // src/hooks/useRoles.ts
178
317
  var import_react = require("react");
179
318
  var import_core = require("@abpjs/core");
@@ -500,7 +639,8 @@ var DEFAULT_FORM_STATE = {
500
639
  function RolesComponent({
501
640
  onRoleCreated,
502
641
  onRoleUpdated,
503
- onRoleDeleted
642
+ onRoleDeleted,
643
+ onVisiblePermissionChange
504
644
  }) {
505
645
  const { t } = (0, import_core3.useLocalization)();
506
646
  const confirmation = (0, import_theme_shared.useConfirmation)();
@@ -707,7 +847,10 @@ function RolesComponent({
707
847
  import_permission_management.PermissionManagementModal,
708
848
  {
709
849
  visible: isPermissionModalOpen,
710
- onVisibleChange: setIsPermissionModalOpen,
850
+ onVisibleChange: (visible) => {
851
+ setIsPermissionModalOpen(visible);
852
+ onVisiblePermissionChange?.(visible);
853
+ },
711
854
  providerName: "R",
712
855
  providerKey: permissionProviderKey
713
856
  }
@@ -752,7 +895,8 @@ function UsersComponent({
752
895
  onUserUpdated,
753
896
  onUserDeleted,
754
897
  passwordRulesArr = [],
755
- requiredPasswordLength = 0
898
+ requiredPasswordLength = 0,
899
+ onVisiblePermissionChange
756
900
  }) {
757
901
  const { t } = (0, import_core4.useLocalization)();
758
902
  const confirmation = (0, import_theme_shared2.useConfirmation)();
@@ -1121,7 +1265,10 @@ function UsersComponent({
1121
1265
  import_permission_management2.PermissionManagementModal,
1122
1266
  {
1123
1267
  visible: isPermissionModalOpen,
1124
- onVisibleChange: setIsPermissionModalOpen,
1268
+ onVisibleChange: (visible) => {
1269
+ setIsPermissionModalOpen(visible);
1270
+ onVisiblePermissionChange?.(visible);
1271
+ },
1125
1272
  providerName: "U",
1126
1273
  providerKey: permissionProviderKey
1127
1274
  }
@@ -1130,38 +1277,6 @@ function UsersComponent({
1130
1277
  }
1131
1278
 
1132
1279
  // src/constants/routes.ts
1133
- var import_core5 = require("@abpjs/core");
1134
- var IDENTITY_ROUTES = {
1135
- routes: [
1136
- {
1137
- name: "AbpUiNavigation::Menu:Administration",
1138
- path: "",
1139
- order: 1,
1140
- wrapper: true
1141
- },
1142
- {
1143
- name: "AbpIdentity::Menu:IdentityManagement",
1144
- path: "identity",
1145
- order: 1,
1146
- parentName: "AbpUiNavigation::Menu:Administration",
1147
- layout: import_core5.eLayoutType.application,
1148
- children: [
1149
- {
1150
- path: "roles",
1151
- name: "AbpIdentity::Roles",
1152
- order: 2,
1153
- requiredPolicy: "AbpIdentity.Roles"
1154
- },
1155
- {
1156
- path: "users",
1157
- name: "AbpIdentity::Users",
1158
- order: 1,
1159
- requiredPolicy: "AbpIdentity.Users"
1160
- }
1161
- ]
1162
- }
1163
- ]
1164
- };
1165
1280
  var IDENTITY_ROUTE_PATHS = {
1166
1281
  /** Base path for identity module */
1167
1282
  BASE: "/identity",
@@ -1191,9 +1306,9 @@ var IDENTITY_POLICIES = {
1191
1306
  // Annotate the CommonJS export names for ESM import in node:
1192
1307
  0 && (module.exports = {
1193
1308
  IDENTITY_POLICIES,
1194
- IDENTITY_ROUTES,
1195
1309
  IDENTITY_ROUTE_PATHS,
1196
1310
  IdentityService,
1311
+ IdentityStateService,
1197
1312
  RolesComponent,
1198
1313
  UsersComponent,
1199
1314
  useIdentity,
package/dist/index.mjs CHANGED
@@ -140,6 +140,145 @@ var IdentityService = class {
140
140
  }
141
141
  };
142
142
 
143
+ // src/services/identity-state.service.ts
144
+ var IdentityStateService = class {
145
+ constructor(identityService) {
146
+ // Internal state
147
+ this.roles = [];
148
+ this.rolesTotalCount = 0;
149
+ this.users = [];
150
+ this.usersTotalCount = 0;
151
+ this.identityService = identityService;
152
+ }
153
+ // ========================
154
+ // State Getters
155
+ // ========================
156
+ /**
157
+ * Get the current roles from state
158
+ */
159
+ getRoles() {
160
+ return this.roles;
161
+ }
162
+ /**
163
+ * Get the total count of roles
164
+ */
165
+ getRolesTotalCount() {
166
+ return this.rolesTotalCount;
167
+ }
168
+ /**
169
+ * Get the current users from state
170
+ */
171
+ getUsers() {
172
+ return this.users;
173
+ }
174
+ /**
175
+ * Get the total count of users
176
+ */
177
+ getUsersTotalCount() {
178
+ return this.usersTotalCount;
179
+ }
180
+ // ========================
181
+ // Role Dispatch Methods
182
+ // ========================
183
+ /**
184
+ * Fetch roles and update internal state
185
+ * @param params - Optional query parameters for pagination/filtering
186
+ */
187
+ async dispatchGetRoles(params) {
188
+ const response = await this.identityService.getRoles(params);
189
+ this.roles = response.items;
190
+ this.rolesTotalCount = response.totalCount;
191
+ return response;
192
+ }
193
+ /**
194
+ * Fetch a role by ID
195
+ * @param id - The role ID
196
+ */
197
+ async dispatchGetRoleById(id) {
198
+ return this.identityService.getRoleById(id);
199
+ }
200
+ /**
201
+ * Delete a role and refresh the list
202
+ * @param id - The role ID to delete
203
+ */
204
+ async dispatchDeleteRole(id) {
205
+ const result = await this.identityService.deleteRole(id);
206
+ await this.dispatchGetRoles();
207
+ return result;
208
+ }
209
+ /**
210
+ * Create a new role and refresh the list
211
+ * @param body - The role data to create
212
+ */
213
+ async dispatchCreateRole(body) {
214
+ const result = await this.identityService.createRole(body);
215
+ await this.dispatchGetRoles();
216
+ return result;
217
+ }
218
+ /**
219
+ * Update an existing role and refresh the list
220
+ * @param payload - Object containing id and updated role data
221
+ */
222
+ async dispatchUpdateRole(payload) {
223
+ const result = await this.identityService.updateRole(payload.id, payload.body);
224
+ await this.dispatchGetRoles();
225
+ return result;
226
+ }
227
+ // ========================
228
+ // User Dispatch Methods
229
+ // ========================
230
+ /**
231
+ * Fetch users and update internal state
232
+ * @param params - Optional query parameters for pagination/filtering
233
+ */
234
+ async dispatchGetUsers(params) {
235
+ const response = await this.identityService.getUsers(params);
236
+ this.users = response.items;
237
+ this.usersTotalCount = response.totalCount;
238
+ return response;
239
+ }
240
+ /**
241
+ * Fetch a user by ID
242
+ * @param id - The user ID
243
+ */
244
+ async dispatchGetUserById(id) {
245
+ return this.identityService.getUserById(id);
246
+ }
247
+ /**
248
+ * Delete a user and refresh the list
249
+ * @param id - The user ID to delete
250
+ */
251
+ async dispatchDeleteUser(id) {
252
+ await this.identityService.deleteUser(id);
253
+ await this.dispatchGetUsers();
254
+ }
255
+ /**
256
+ * Create a new user and refresh the list
257
+ * @param body - The user data to create
258
+ */
259
+ async dispatchCreateUser(body) {
260
+ const result = await this.identityService.createUser(body);
261
+ await this.dispatchGetUsers();
262
+ return result;
263
+ }
264
+ /**
265
+ * Update an existing user and refresh the list
266
+ * @param payload - Object containing id and updated user data
267
+ */
268
+ async dispatchUpdateUser(payload) {
269
+ const result = await this.identityService.updateUser(payload.id, payload.body);
270
+ await this.dispatchGetUsers();
271
+ return result;
272
+ }
273
+ /**
274
+ * Get roles assigned to a user
275
+ * @param id - The user ID
276
+ */
277
+ async dispatchGetUserRoles(id) {
278
+ return this.identityService.getUserRoles(id);
279
+ }
280
+ };
281
+
143
282
  // src/hooks/useRoles.ts
144
283
  import { useState, useCallback, useMemo } from "react";
145
284
  import { useRestService } from "@abpjs/core";
@@ -475,7 +614,8 @@ var DEFAULT_FORM_STATE = {
475
614
  function RolesComponent({
476
615
  onRoleCreated,
477
616
  onRoleUpdated,
478
- onRoleDeleted
617
+ onRoleDeleted,
618
+ onVisiblePermissionChange
479
619
  }) {
480
620
  const { t } = useLocalization();
481
621
  const confirmation = useConfirmation();
@@ -682,7 +822,10 @@ function RolesComponent({
682
822
  PermissionManagementModal,
683
823
  {
684
824
  visible: isPermissionModalOpen,
685
- onVisibleChange: setIsPermissionModalOpen,
825
+ onVisibleChange: (visible) => {
826
+ setIsPermissionModalOpen(visible);
827
+ onVisiblePermissionChange?.(visible);
828
+ },
686
829
  providerName: "R",
687
830
  providerKey: permissionProviderKey
688
831
  }
@@ -738,7 +881,8 @@ function UsersComponent({
738
881
  onUserUpdated,
739
882
  onUserDeleted,
740
883
  passwordRulesArr = [],
741
- requiredPasswordLength = 0
884
+ requiredPasswordLength = 0,
885
+ onVisiblePermissionChange
742
886
  }) {
743
887
  const { t } = useLocalization2();
744
888
  const confirmation = useConfirmation2();
@@ -1107,7 +1251,10 @@ function UsersComponent({
1107
1251
  PermissionManagementModal2,
1108
1252
  {
1109
1253
  visible: isPermissionModalOpen,
1110
- onVisibleChange: setIsPermissionModalOpen,
1254
+ onVisibleChange: (visible) => {
1255
+ setIsPermissionModalOpen(visible);
1256
+ onVisiblePermissionChange?.(visible);
1257
+ },
1111
1258
  providerName: "U",
1112
1259
  providerKey: permissionProviderKey
1113
1260
  }
@@ -1116,38 +1263,6 @@ function UsersComponent({
1116
1263
  }
1117
1264
 
1118
1265
  // src/constants/routes.ts
1119
- import { eLayoutType } from "@abpjs/core";
1120
- var IDENTITY_ROUTES = {
1121
- routes: [
1122
- {
1123
- name: "AbpUiNavigation::Menu:Administration",
1124
- path: "",
1125
- order: 1,
1126
- wrapper: true
1127
- },
1128
- {
1129
- name: "AbpIdentity::Menu:IdentityManagement",
1130
- path: "identity",
1131
- order: 1,
1132
- parentName: "AbpUiNavigation::Menu:Administration",
1133
- layout: eLayoutType.application,
1134
- children: [
1135
- {
1136
- path: "roles",
1137
- name: "AbpIdentity::Roles",
1138
- order: 2,
1139
- requiredPolicy: "AbpIdentity.Roles"
1140
- },
1141
- {
1142
- path: "users",
1143
- name: "AbpIdentity::Users",
1144
- order: 1,
1145
- requiredPolicy: "AbpIdentity.Users"
1146
- }
1147
- ]
1148
- }
1149
- ]
1150
- };
1151
1266
  var IDENTITY_ROUTE_PATHS = {
1152
1267
  /** Base path for identity module */
1153
1268
  BASE: "/identity",
@@ -1176,9 +1291,9 @@ var IDENTITY_POLICIES = {
1176
1291
  };
1177
1292
  export {
1178
1293
  IDENTITY_POLICIES,
1179
- IDENTITY_ROUTES,
1180
1294
  IDENTITY_ROUTE_PATHS,
1181
1295
  IdentityService,
1296
+ IdentityStateService,
1182
1297
  RolesComponent,
1183
1298
  UsersComponent,
1184
1299
  useIdentity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/identity",
3
- "version": "1.1.0",
3
+ "version": "2.1.0",
4
4
  "description": "ABP Framework identity components for React - translated from @abp/ng.identity",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -25,12 +25,12 @@
25
25
  "dependencies": {
26
26
  "@chakra-ui/react": "^3.2.0",
27
27
  "@emotion/react": "^11.11.0",
28
- "@abpjs/core": "1.1.0",
29
- "@abpjs/permission-management": "1.1.0",
30
- "@abpjs/theme-shared": "1.1.0"
28
+ "@abpjs/theme-shared": "2.1.0",
29
+ "@abpjs/core": "2.1.0",
30
+ "@abpjs/permission-management": "2.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@abp/ng.identity": "0.9.0",
33
+ "@abp/ng.identity": "2.1.0",
34
34
  "@testing-library/jest-dom": "^6.9.1",
35
35
  "@testing-library/react": "^14.0.0",
36
36
  "@testing-library/user-event": "^14.6.1",