@abpjs/identity-pro 0.7.2
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/LICENSE +165 -0
- package/README.md +402 -0
- package/dist/index.d.mts +805 -0
- package/dist/index.d.ts +805 -0
- package/dist/index.js +1910 -0
- package/dist/index.mjs +1909 -0
- package/package.json +90 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
import { ABP, RestService } from '@abpjs/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Identity namespace containing all types related to identity management.
|
|
6
|
+
* Translated from @volo/abp.ng.identity Identity namespace.
|
|
7
|
+
*
|
|
8
|
+
* Pro features include:
|
|
9
|
+
* - Claim type management
|
|
10
|
+
* - User/Role claims management
|
|
11
|
+
*
|
|
12
|
+
* @since 0.7.2
|
|
13
|
+
*/
|
|
14
|
+
declare namespace Identity {
|
|
15
|
+
/**
|
|
16
|
+
* Identity state shape for state management
|
|
17
|
+
*/
|
|
18
|
+
interface State {
|
|
19
|
+
roles: RoleResponse;
|
|
20
|
+
users: UserResponse;
|
|
21
|
+
selectedRole: RoleItem;
|
|
22
|
+
selectedUser: UserItem;
|
|
23
|
+
selectedUserRoles: RoleItem[];
|
|
24
|
+
/** Pro: Claim type names for dropdowns */
|
|
25
|
+
claimTypes: ClaimTypeName[];
|
|
26
|
+
/** Pro: Paginated claim types response */
|
|
27
|
+
claims: ClaimResponse;
|
|
28
|
+
/** Pro: Selected claim type for editing */
|
|
29
|
+
selectedClaim: ClaimType;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Paginated response for roles
|
|
33
|
+
*/
|
|
34
|
+
type RoleResponse = ABP.PagedResponse<RoleItem>;
|
|
35
|
+
/**
|
|
36
|
+
* Request payload for creating/updating a role
|
|
37
|
+
*/
|
|
38
|
+
interface RoleSaveRequest {
|
|
39
|
+
name: string;
|
|
40
|
+
isDefault: boolean;
|
|
41
|
+
isPublic: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Role item returned from the API
|
|
45
|
+
*/
|
|
46
|
+
interface RoleItem extends RoleSaveRequest {
|
|
47
|
+
isStatic: boolean;
|
|
48
|
+
concurrencyStamp: string;
|
|
49
|
+
id: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Paginated response for users
|
|
53
|
+
*/
|
|
54
|
+
type UserResponse = ABP.PagedResponse<UserItem>;
|
|
55
|
+
/**
|
|
56
|
+
* Base user properties
|
|
57
|
+
*/
|
|
58
|
+
interface User {
|
|
59
|
+
userName: string;
|
|
60
|
+
name: string;
|
|
61
|
+
surname: string;
|
|
62
|
+
email: string;
|
|
63
|
+
phoneNumber: string;
|
|
64
|
+
twoFactorEnabled: boolean;
|
|
65
|
+
lockoutEnabled: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* User item returned from the API
|
|
69
|
+
*/
|
|
70
|
+
interface UserItem extends User {
|
|
71
|
+
tenantId: string;
|
|
72
|
+
emailConfirmed: boolean;
|
|
73
|
+
phoneNumberConfirmed: boolean;
|
|
74
|
+
isLockedOut: boolean;
|
|
75
|
+
concurrencyStamp: string;
|
|
76
|
+
id: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Request payload for creating/updating a user
|
|
80
|
+
*/
|
|
81
|
+
interface UserSaveRequest extends User {
|
|
82
|
+
password: string;
|
|
83
|
+
roleNames: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Simple claim type name for dropdowns
|
|
87
|
+
* Pro feature since 0.7.2
|
|
88
|
+
*/
|
|
89
|
+
interface ClaimTypeName {
|
|
90
|
+
name: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Full claim type definition
|
|
94
|
+
* Pro feature since 0.7.2
|
|
95
|
+
*/
|
|
96
|
+
interface ClaimType {
|
|
97
|
+
/** Optional ID for existing claim types */
|
|
98
|
+
id?: string;
|
|
99
|
+
/** Claim type name (e.g., 'email', 'role') */
|
|
100
|
+
name: string;
|
|
101
|
+
/** Whether this claim is required */
|
|
102
|
+
required: boolean;
|
|
103
|
+
/** Whether this claim type is static (built-in) */
|
|
104
|
+
isStatic: boolean;
|
|
105
|
+
/** Regex pattern for value validation */
|
|
106
|
+
regex: string;
|
|
107
|
+
/** Human-readable description of the regex pattern */
|
|
108
|
+
regexDescription: string;
|
|
109
|
+
/** Claim type description */
|
|
110
|
+
description: string;
|
|
111
|
+
/** Value type: 0=String, 1=Int, 2=Boolean, 3=DateTime */
|
|
112
|
+
valueType: number;
|
|
113
|
+
/** String representation of value type */
|
|
114
|
+
valueTypeAsString?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Claim request for assigning claims to users or roles
|
|
118
|
+
* Pro feature since 0.7.2
|
|
119
|
+
*/
|
|
120
|
+
interface ClaimRequest {
|
|
121
|
+
/** User ID (for user claims) */
|
|
122
|
+
userId?: string;
|
|
123
|
+
/** Role ID (for role claims) */
|
|
124
|
+
roleId?: string;
|
|
125
|
+
/** The claim type name */
|
|
126
|
+
claimType: string;
|
|
127
|
+
/** The claim value */
|
|
128
|
+
claimValue: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Paginated response for claim types
|
|
132
|
+
* Pro feature since 0.7.2
|
|
133
|
+
*/
|
|
134
|
+
type ClaimResponse = ABP.PagedResponse<ClaimType>;
|
|
135
|
+
/**
|
|
136
|
+
* Value type enumeration for claim types
|
|
137
|
+
* Pro feature since 0.7.2
|
|
138
|
+
*/
|
|
139
|
+
enum ClaimValueType {
|
|
140
|
+
String = 0,
|
|
141
|
+
Int = 1,
|
|
142
|
+
Boolean = 2,
|
|
143
|
+
DateTime = 3
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Service for managing identity-related API operations.
|
|
149
|
+
* Handles roles, users, and claim types CRUD operations.
|
|
150
|
+
*
|
|
151
|
+
* Pro features include:
|
|
152
|
+
* - Claim type management
|
|
153
|
+
* - User/Role claims management
|
|
154
|
+
*
|
|
155
|
+
* Translated from @volo/abp.ng.identity IdentityService
|
|
156
|
+
* @since 0.7.2
|
|
157
|
+
*/
|
|
158
|
+
declare class IdentityService {
|
|
159
|
+
private rest;
|
|
160
|
+
constructor(rest: RestService);
|
|
161
|
+
/**
|
|
162
|
+
* Get all roles with optional pagination/filtering (v0.9.0)
|
|
163
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
164
|
+
* @returns Promise with paginated role response
|
|
165
|
+
*/
|
|
166
|
+
getRoles(params?: ABP.PageQueryParams): Promise<Identity.RoleResponse>;
|
|
167
|
+
/**
|
|
168
|
+
* Get a role by ID
|
|
169
|
+
* @param id - The role ID
|
|
170
|
+
* @returns Promise with the role item
|
|
171
|
+
*/
|
|
172
|
+
getRoleById(id: string): Promise<Identity.RoleItem>;
|
|
173
|
+
/**
|
|
174
|
+
* Delete a role
|
|
175
|
+
* @param id - The role ID to delete
|
|
176
|
+
* @returns Promise with the deleted role
|
|
177
|
+
*/
|
|
178
|
+
deleteRole(id: string): Promise<Identity.RoleItem>;
|
|
179
|
+
/**
|
|
180
|
+
* Create a new role
|
|
181
|
+
* @param body - The role data to create
|
|
182
|
+
* @returns Promise with the created role
|
|
183
|
+
*/
|
|
184
|
+
createRole(body: Identity.RoleSaveRequest): Promise<Identity.RoleItem>;
|
|
185
|
+
/**
|
|
186
|
+
* Update an existing role
|
|
187
|
+
* @param id - The role ID to update
|
|
188
|
+
* @param body - The updated role data
|
|
189
|
+
* @returns Promise with the updated role
|
|
190
|
+
*/
|
|
191
|
+
updateRole(id: string, body: Identity.RoleSaveRequest): Promise<Identity.RoleItem>;
|
|
192
|
+
/**
|
|
193
|
+
* Get users with pagination and filtering
|
|
194
|
+
* @param params - Query parameters for pagination and filtering
|
|
195
|
+
* @returns Promise with paginated user response
|
|
196
|
+
*/
|
|
197
|
+
getUsers(params?: ABP.PageQueryParams): Promise<Identity.UserResponse>;
|
|
198
|
+
/**
|
|
199
|
+
* Get a user by ID
|
|
200
|
+
* @param id - The user ID
|
|
201
|
+
* @returns Promise with the user item
|
|
202
|
+
*/
|
|
203
|
+
getUserById(id: string): Promise<Identity.UserItem>;
|
|
204
|
+
/**
|
|
205
|
+
* Get roles assigned to a user
|
|
206
|
+
* @param id - The user ID
|
|
207
|
+
* @returns Promise with the user's roles
|
|
208
|
+
*/
|
|
209
|
+
getUserRoles(id: string): Promise<Identity.RoleResponse>;
|
|
210
|
+
/**
|
|
211
|
+
* Delete a user
|
|
212
|
+
* @param id - The user ID to delete
|
|
213
|
+
* @returns Promise resolving when complete
|
|
214
|
+
*/
|
|
215
|
+
deleteUser(id: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Create a new user
|
|
218
|
+
* @param body - The user data to create
|
|
219
|
+
* @returns Promise with the created user
|
|
220
|
+
*/
|
|
221
|
+
createUser(body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
|
|
222
|
+
/**
|
|
223
|
+
* Update an existing user
|
|
224
|
+
* @param id - The user ID to update
|
|
225
|
+
* @param body - The updated user data
|
|
226
|
+
* @returns Promise with the updated user
|
|
227
|
+
*/
|
|
228
|
+
updateUser(id: string, body: Identity.UserSaveRequest): Promise<Identity.UserItem>;
|
|
229
|
+
/**
|
|
230
|
+
* Get all claim type names for dropdowns
|
|
231
|
+
* Pro feature since 0.7.2
|
|
232
|
+
* @returns Promise with claim type names
|
|
233
|
+
*/
|
|
234
|
+
getClaimTypeNames(): Promise<Identity.ClaimTypeName[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Get claim types with pagination
|
|
237
|
+
* Pro feature since 0.7.2
|
|
238
|
+
* @param params - Query parameters for pagination and filtering
|
|
239
|
+
* @returns Promise with paginated claim types response
|
|
240
|
+
*/
|
|
241
|
+
getClaimTypes(params?: ABP.PageQueryParams): Promise<Identity.ClaimResponse>;
|
|
242
|
+
/**
|
|
243
|
+
* Get a claim type by ID
|
|
244
|
+
* Pro feature since 0.7.2
|
|
245
|
+
* @param id - The claim type ID
|
|
246
|
+
* @returns Promise with the claim type
|
|
247
|
+
*/
|
|
248
|
+
getClaimTypeById(id: string): Promise<Identity.ClaimType>;
|
|
249
|
+
/**
|
|
250
|
+
* Create a new claim type
|
|
251
|
+
* Pro feature since 0.7.2
|
|
252
|
+
* @param body - The claim type data
|
|
253
|
+
* @returns Promise with the created claim type
|
|
254
|
+
*/
|
|
255
|
+
createClaimType(body: Identity.ClaimType): Promise<Identity.ClaimType>;
|
|
256
|
+
/**
|
|
257
|
+
* Update an existing claim type
|
|
258
|
+
* Pro feature since 0.7.2
|
|
259
|
+
* @param body - The claim type data (must include id)
|
|
260
|
+
* @returns Promise with the updated claim type
|
|
261
|
+
*/
|
|
262
|
+
updateClaimType(body: Identity.ClaimType): Promise<Identity.ClaimType>;
|
|
263
|
+
/**
|
|
264
|
+
* Delete a claim type
|
|
265
|
+
* Pro feature since 0.7.2
|
|
266
|
+
* @param id - The claim type ID to delete
|
|
267
|
+
* @returns Promise resolving when complete
|
|
268
|
+
*/
|
|
269
|
+
deleteClaimType(id: string): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Get claims for a user or role
|
|
272
|
+
* Pro feature since 0.7.2
|
|
273
|
+
* @param body - Object with id and type ('users' | 'roles')
|
|
274
|
+
* @returns Promise with claim requests
|
|
275
|
+
*/
|
|
276
|
+
getClaims(body: {
|
|
277
|
+
id: string;
|
|
278
|
+
type: 'roles' | 'users';
|
|
279
|
+
}): Promise<Identity.ClaimRequest[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Update claims for a user or role
|
|
282
|
+
* Pro feature since 0.7.2
|
|
283
|
+
* @param body - Object with id, type, and claims array
|
|
284
|
+
* @returns Promise resolving when complete
|
|
285
|
+
*/
|
|
286
|
+
updateClaims(body: {
|
|
287
|
+
id: string;
|
|
288
|
+
type: 'roles' | 'users';
|
|
289
|
+
claims: Identity.ClaimRequest[];
|
|
290
|
+
}): Promise<void>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Result from role operations
|
|
295
|
+
*/
|
|
296
|
+
interface RoleOperationResult {
|
|
297
|
+
success: boolean;
|
|
298
|
+
error?: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Sort order type
|
|
302
|
+
* @since 1.0.0
|
|
303
|
+
*/
|
|
304
|
+
type SortOrder = 'asc' | 'desc' | '';
|
|
305
|
+
/**
|
|
306
|
+
* Return type for useRoles hook
|
|
307
|
+
*/
|
|
308
|
+
interface UseRolesReturn {
|
|
309
|
+
/** List of roles */
|
|
310
|
+
roles: Identity.RoleItem[];
|
|
311
|
+
/** Total count of roles */
|
|
312
|
+
totalCount: number;
|
|
313
|
+
/** Currently selected role for editing */
|
|
314
|
+
selectedRole: Identity.RoleItem | null;
|
|
315
|
+
/** Loading state */
|
|
316
|
+
isLoading: boolean;
|
|
317
|
+
/** Error message if any */
|
|
318
|
+
error: string | null;
|
|
319
|
+
/** Current sort key @since 1.0.0 */
|
|
320
|
+
sortKey: string;
|
|
321
|
+
/** Current sort order @since 1.0.0 */
|
|
322
|
+
sortOrder: SortOrder;
|
|
323
|
+
/** Fetch all roles with optional pagination/filtering */
|
|
324
|
+
fetchRoles: (params?: ABP.PageQueryParams) => Promise<RoleOperationResult>;
|
|
325
|
+
/** Get a role by ID and set it as selected */
|
|
326
|
+
getRoleById: (id: string) => Promise<RoleOperationResult>;
|
|
327
|
+
/** Create a new role */
|
|
328
|
+
createRole: (role: Identity.RoleSaveRequest) => Promise<RoleOperationResult>;
|
|
329
|
+
/** Update an existing role */
|
|
330
|
+
updateRole: (id: string, role: Identity.RoleSaveRequest) => Promise<RoleOperationResult>;
|
|
331
|
+
/** Delete a role */
|
|
332
|
+
deleteRole: (id: string) => Promise<RoleOperationResult>;
|
|
333
|
+
/** Set the selected role */
|
|
334
|
+
setSelectedRole: (role: Identity.RoleItem | null) => void;
|
|
335
|
+
/** Set sort key @since 1.0.0 */
|
|
336
|
+
setSortKey: (key: string) => void;
|
|
337
|
+
/** Set sort order @since 1.0.0 */
|
|
338
|
+
setSortOrder: (order: SortOrder) => void;
|
|
339
|
+
/** Reset state */
|
|
340
|
+
reset: () => void;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Hook for managing roles
|
|
344
|
+
*
|
|
345
|
+
* This hook provides all the state and actions needed for role management.
|
|
346
|
+
* It handles fetching, creating, updating, and deleting roles.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```tsx
|
|
350
|
+
* function RolesPage() {
|
|
351
|
+
* const {
|
|
352
|
+
* roles,
|
|
353
|
+
* isLoading,
|
|
354
|
+
* fetchRoles,
|
|
355
|
+
* createRole,
|
|
356
|
+
* deleteRole,
|
|
357
|
+
* } = useRoles();
|
|
358
|
+
*
|
|
359
|
+
* useEffect(() => {
|
|
360
|
+
* fetchRoles();
|
|
361
|
+
* }, [fetchRoles]);
|
|
362
|
+
*
|
|
363
|
+
* const handleCreate = async (data: Identity.RoleSaveRequest) => {
|
|
364
|
+
* const result = await createRole(data);
|
|
365
|
+
* if (result.success) {
|
|
366
|
+
* // Handle success
|
|
367
|
+
* }
|
|
368
|
+
* };
|
|
369
|
+
*
|
|
370
|
+
* return (
|
|
371
|
+
* <div>
|
|
372
|
+
* {roles.map(role => (
|
|
373
|
+
* <div key={role.id}>{role.name}</div>
|
|
374
|
+
* ))}
|
|
375
|
+
* </div>
|
|
376
|
+
* );
|
|
377
|
+
* }
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare function useRoles(): UseRolesReturn;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Result from user operations
|
|
384
|
+
*/
|
|
385
|
+
interface UserOperationResult {
|
|
386
|
+
success: boolean;
|
|
387
|
+
error?: string;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Return type for useUsers hook
|
|
391
|
+
*/
|
|
392
|
+
interface UseUsersReturn {
|
|
393
|
+
/** List of users */
|
|
394
|
+
users: Identity.UserItem[];
|
|
395
|
+
/** Total count of users */
|
|
396
|
+
totalCount: number;
|
|
397
|
+
/** Currently selected user for editing */
|
|
398
|
+
selectedUser: Identity.UserItem | null;
|
|
399
|
+
/** Roles assigned to the selected user */
|
|
400
|
+
selectedUserRoles: Identity.RoleItem[];
|
|
401
|
+
/** Loading state */
|
|
402
|
+
isLoading: boolean;
|
|
403
|
+
/** Error message if any */
|
|
404
|
+
error: string | null;
|
|
405
|
+
/** Current page query parameters */
|
|
406
|
+
pageQuery: ABP.PageQueryParams;
|
|
407
|
+
/** Current sort key @since 1.0.0 */
|
|
408
|
+
sortKey: string;
|
|
409
|
+
/** Current sort order @since 1.0.0 */
|
|
410
|
+
sortOrder: SortOrder;
|
|
411
|
+
/** Fetch users with pagination */
|
|
412
|
+
fetchUsers: (params?: ABP.PageQueryParams) => Promise<UserOperationResult>;
|
|
413
|
+
/** Get a user by ID and set it as selected */
|
|
414
|
+
getUserById: (id: string) => Promise<UserOperationResult>;
|
|
415
|
+
/** Get roles for a user */
|
|
416
|
+
getUserRoles: (id: string) => Promise<UserOperationResult>;
|
|
417
|
+
/** Create a new user */
|
|
418
|
+
createUser: (user: Identity.UserSaveRequest) => Promise<UserOperationResult>;
|
|
419
|
+
/** Update an existing user */
|
|
420
|
+
updateUser: (id: string, user: Identity.UserSaveRequest) => Promise<UserOperationResult>;
|
|
421
|
+
/** Delete a user */
|
|
422
|
+
deleteUser: (id: string) => Promise<UserOperationResult>;
|
|
423
|
+
/** Set the selected user */
|
|
424
|
+
setSelectedUser: (user: Identity.UserItem | null) => void;
|
|
425
|
+
/** Set page query parameters */
|
|
426
|
+
setPageQuery: (query: ABP.PageQueryParams) => void;
|
|
427
|
+
/** Set sort key @since 1.0.0 */
|
|
428
|
+
setSortKey: (key: string) => void;
|
|
429
|
+
/** Set sort order @since 1.0.0 */
|
|
430
|
+
setSortOrder: (order: SortOrder) => void;
|
|
431
|
+
/** Reset state */
|
|
432
|
+
reset: () => void;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Hook for managing users
|
|
436
|
+
*
|
|
437
|
+
* This hook provides all the state and actions needed for user management.
|
|
438
|
+
* It handles fetching, creating, updating, and deleting users with pagination support.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```tsx
|
|
442
|
+
* function UsersPage() {
|
|
443
|
+
* const {
|
|
444
|
+
* users,
|
|
445
|
+
* totalCount,
|
|
446
|
+
* isLoading,
|
|
447
|
+
* pageQuery,
|
|
448
|
+
* fetchUsers,
|
|
449
|
+
* createUser,
|
|
450
|
+
* deleteUser,
|
|
451
|
+
* setPageQuery,
|
|
452
|
+
* } = useUsers();
|
|
453
|
+
*
|
|
454
|
+
* useEffect(() => {
|
|
455
|
+
* fetchUsers();
|
|
456
|
+
* }, [fetchUsers]);
|
|
457
|
+
*
|
|
458
|
+
* const handlePageChange = (page: number) => {
|
|
459
|
+
* setPageQuery({ ...pageQuery, skipCount: page * 10 });
|
|
460
|
+
* fetchUsers({ ...pageQuery, skipCount: page * 10 });
|
|
461
|
+
* };
|
|
462
|
+
*
|
|
463
|
+
* return (
|
|
464
|
+
* <div>
|
|
465
|
+
* {users.map(user => (
|
|
466
|
+
* <div key={user.id}>{user.userName}</div>
|
|
467
|
+
* ))}
|
|
468
|
+
* </div>
|
|
469
|
+
* );
|
|
470
|
+
* }
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
declare function useUsers(): UseUsersReturn;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Combined identity management return type
|
|
477
|
+
*/
|
|
478
|
+
interface UseIdentityReturn {
|
|
479
|
+
/** Role management hook */
|
|
480
|
+
roles: UseRolesReturn;
|
|
481
|
+
/** User management hook */
|
|
482
|
+
users: UseUsersReturn;
|
|
483
|
+
/** Combined loading state */
|
|
484
|
+
isLoading: boolean;
|
|
485
|
+
/** Combined error state */
|
|
486
|
+
error: string | null;
|
|
487
|
+
/** Reset all state */
|
|
488
|
+
resetAll: () => void;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Hook that combines role and user management for identity operations
|
|
492
|
+
*
|
|
493
|
+
* This hook provides a unified interface for managing both roles and users.
|
|
494
|
+
* It combines the useRoles and useUsers hooks for convenience.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```tsx
|
|
498
|
+
* function IdentityManagement() {
|
|
499
|
+
* const { roles, users, isLoading } = useIdentity();
|
|
500
|
+
*
|
|
501
|
+
* useEffect(() => {
|
|
502
|
+
* roles.fetchRoles();
|
|
503
|
+
* users.fetchUsers();
|
|
504
|
+
* }, []);
|
|
505
|
+
*
|
|
506
|
+
* return (
|
|
507
|
+
* <div>
|
|
508
|
+
* <h2>Roles</h2>
|
|
509
|
+
* {roles.roles.map(role => <div key={role.id}>{role.name}</div>)}
|
|
510
|
+
*
|
|
511
|
+
* <h2>Users</h2>
|
|
512
|
+
* {users.users.map(user => <div key={user.id}>{user.userName}</div>)}
|
|
513
|
+
* </div>
|
|
514
|
+
* );
|
|
515
|
+
* }
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
declare function useIdentity(): UseIdentityReturn;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Result from claim operations
|
|
522
|
+
* @since 0.7.2
|
|
523
|
+
*/
|
|
524
|
+
interface ClaimOperationResult {
|
|
525
|
+
success: boolean;
|
|
526
|
+
error?: string;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Return type for useClaims hook
|
|
530
|
+
* @since 0.7.2
|
|
531
|
+
*/
|
|
532
|
+
interface UseClaimsReturn {
|
|
533
|
+
/** List of claim types */
|
|
534
|
+
claimTypes: Identity.ClaimType[];
|
|
535
|
+
/** Total count of claim types */
|
|
536
|
+
totalCount: number;
|
|
537
|
+
/** Claim type names for dropdowns */
|
|
538
|
+
claimTypeNames: Identity.ClaimTypeName[];
|
|
539
|
+
/** Currently selected claim type for editing */
|
|
540
|
+
selectedClaimType: Identity.ClaimType | null;
|
|
541
|
+
/** Loading state */
|
|
542
|
+
isLoading: boolean;
|
|
543
|
+
/** Error message if any */
|
|
544
|
+
error: string | null;
|
|
545
|
+
/** Current sort key */
|
|
546
|
+
sortKey: string;
|
|
547
|
+
/** Current sort order */
|
|
548
|
+
sortOrder: SortOrder;
|
|
549
|
+
/** Fetch all claim types with optional pagination/filtering */
|
|
550
|
+
fetchClaimTypes: (params?: ABP.PageQueryParams) => Promise<ClaimOperationResult>;
|
|
551
|
+
/** Fetch claim type names for dropdowns */
|
|
552
|
+
fetchClaimTypeNames: () => Promise<ClaimOperationResult>;
|
|
553
|
+
/** Get a claim type by ID and set it as selected */
|
|
554
|
+
getClaimTypeById: (id: string) => Promise<ClaimOperationResult>;
|
|
555
|
+
/** Create a new claim type */
|
|
556
|
+
createClaimType: (claimType: Identity.ClaimType) => Promise<ClaimOperationResult>;
|
|
557
|
+
/** Update an existing claim type */
|
|
558
|
+
updateClaimType: (claimType: Identity.ClaimType) => Promise<ClaimOperationResult>;
|
|
559
|
+
/** Delete a claim type */
|
|
560
|
+
deleteClaimType: (id: string) => Promise<ClaimOperationResult>;
|
|
561
|
+
/** Set the selected claim type */
|
|
562
|
+
setSelectedClaimType: (claimType: Identity.ClaimType | null) => void;
|
|
563
|
+
/** Set sort key */
|
|
564
|
+
setSortKey: (key: string) => void;
|
|
565
|
+
/** Set sort order */
|
|
566
|
+
setSortOrder: (order: SortOrder) => void;
|
|
567
|
+
/** Reset state */
|
|
568
|
+
reset: () => void;
|
|
569
|
+
/** Get claims for a user or role */
|
|
570
|
+
getClaims: (id: string, type: 'users' | 'roles') => Promise<Identity.ClaimRequest[]>;
|
|
571
|
+
/** Update claims for a user or role */
|
|
572
|
+
updateClaims: (id: string, type: 'users' | 'roles', claims: Identity.ClaimRequest[]) => Promise<ClaimOperationResult>;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Hook for managing claim types
|
|
576
|
+
*
|
|
577
|
+
* This hook provides all the state and actions needed for claim type management.
|
|
578
|
+
* It handles fetching, creating, updating, and deleting claim types.
|
|
579
|
+
*
|
|
580
|
+
* Pro feature since 0.7.2
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```tsx
|
|
584
|
+
* function ClaimsPage() {
|
|
585
|
+
* const {
|
|
586
|
+
* claimTypes,
|
|
587
|
+
* isLoading,
|
|
588
|
+
* fetchClaimTypes,
|
|
589
|
+
* createClaimType,
|
|
590
|
+
* deleteClaimType,
|
|
591
|
+
* } = useClaims();
|
|
592
|
+
*
|
|
593
|
+
* useEffect(() => {
|
|
594
|
+
* fetchClaimTypes();
|
|
595
|
+
* }, [fetchClaimTypes]);
|
|
596
|
+
*
|
|
597
|
+
* const handleCreate = async (data: Identity.ClaimType) => {
|
|
598
|
+
* const result = await createClaimType(data);
|
|
599
|
+
* if (result.success) {
|
|
600
|
+
* // Handle success
|
|
601
|
+
* }
|
|
602
|
+
* };
|
|
603
|
+
*
|
|
604
|
+
* return (
|
|
605
|
+
* <div>
|
|
606
|
+
* {claimTypes.map(claim => (
|
|
607
|
+
* <div key={claim.id}>{claim.name}</div>
|
|
608
|
+
* ))}
|
|
609
|
+
* </div>
|
|
610
|
+
* );
|
|
611
|
+
* }
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
declare function useClaims(): UseClaimsReturn;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Props for RolesComponent
|
|
618
|
+
*/
|
|
619
|
+
interface RolesComponentProps {
|
|
620
|
+
/** Optional callback when a role is created */
|
|
621
|
+
onRoleCreated?: (role: Identity.RoleItem) => void;
|
|
622
|
+
/** Optional callback when a role is updated */
|
|
623
|
+
onRoleUpdated?: (role: Identity.RoleItem) => void;
|
|
624
|
+
/** Optional callback when a role is deleted */
|
|
625
|
+
onRoleDeleted?: (id: string) => void;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* RolesComponent - Component for managing roles
|
|
629
|
+
*
|
|
630
|
+
* This is the React equivalent of Angular's RolesComponent.
|
|
631
|
+
* It displays a table of roles with CRUD operations and permission management.
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```tsx
|
|
635
|
+
* function IdentityPage() {
|
|
636
|
+
* return (
|
|
637
|
+
* <RolesComponent
|
|
638
|
+
* onRoleCreated={(role) => console.log('Role created:', role)}
|
|
639
|
+
* onRoleDeleted={(id) => console.log('Role deleted:', id)}
|
|
640
|
+
* />
|
|
641
|
+
* );
|
|
642
|
+
* }
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
declare function RolesComponent({ onRoleCreated, onRoleUpdated, onRoleDeleted, }: RolesComponentProps): React.ReactElement;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Props for UsersComponent
|
|
649
|
+
*/
|
|
650
|
+
interface UsersComponentProps {
|
|
651
|
+
/** Optional callback when a user is created */
|
|
652
|
+
onUserCreated?: (user: Identity.UserItem) => void;
|
|
653
|
+
/** Optional callback when a user is updated */
|
|
654
|
+
onUserUpdated?: (user: Identity.UserItem) => void;
|
|
655
|
+
/** Optional callback when a user is deleted */
|
|
656
|
+
onUserDeleted?: (id: string) => void;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* UsersComponent - Component for managing users
|
|
660
|
+
*
|
|
661
|
+
* This is the React equivalent of Angular's UsersComponent.
|
|
662
|
+
* It displays a table of users with CRUD operations, role assignment, and permission management.
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* ```tsx
|
|
666
|
+
* function IdentityPage() {
|
|
667
|
+
* return (
|
|
668
|
+
* <UsersComponent
|
|
669
|
+
* onUserCreated={(user) => console.log('User created:', user)}
|
|
670
|
+
* onUserDeleted={(id) => console.log('User deleted:', id)}
|
|
671
|
+
* />
|
|
672
|
+
* );
|
|
673
|
+
* }
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
declare function UsersComponent({ onUserCreated, onUserUpdated, onUserDeleted, }: UsersComponentProps): React.ReactElement;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Props for ClaimsComponent
|
|
680
|
+
* @since 0.7.2
|
|
681
|
+
*/
|
|
682
|
+
interface ClaimsComponentProps {
|
|
683
|
+
/** Optional callback when a claim type is created */
|
|
684
|
+
onClaimTypeCreated?: (claimType: Identity.ClaimType) => void;
|
|
685
|
+
/** Optional callback when a claim type is updated */
|
|
686
|
+
onClaimTypeUpdated?: (claimType: Identity.ClaimType) => void;
|
|
687
|
+
/** Optional callback when a claim type is deleted */
|
|
688
|
+
onClaimTypeDeleted?: (id: string) => void;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* ClaimsComponent - Component for managing claim types
|
|
692
|
+
*
|
|
693
|
+
* This is the React equivalent of Angular's ClaimsComponent.
|
|
694
|
+
* It displays a table of claim types with CRUD operations.
|
|
695
|
+
*
|
|
696
|
+
* Pro feature since 0.7.2
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```tsx
|
|
700
|
+
* function IdentityProPage() {
|
|
701
|
+
* return (
|
|
702
|
+
* <ClaimsComponent
|
|
703
|
+
* onClaimTypeCreated={(claim) => console.log('Claim type created:', claim)}
|
|
704
|
+
* onClaimTypeDeleted={(id) => console.log('Claim type deleted:', id)}
|
|
705
|
+
* />
|
|
706
|
+
* );
|
|
707
|
+
* }
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
declare function ClaimsComponent({ onClaimTypeCreated, onClaimTypeUpdated, onClaimTypeDeleted, }: ClaimsComponentProps): React.ReactElement;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Props for ClaimModal component
|
|
714
|
+
* @since 0.7.2
|
|
715
|
+
*/
|
|
716
|
+
interface ClaimModalProps {
|
|
717
|
+
/** Whether the modal is visible */
|
|
718
|
+
visible: boolean;
|
|
719
|
+
/** Callback when visibility changes */
|
|
720
|
+
onVisibleChange: (visible: boolean) => void;
|
|
721
|
+
/** Subject ID (user or role ID) */
|
|
722
|
+
subjectId: string;
|
|
723
|
+
/** Subject type ('users' or 'roles') */
|
|
724
|
+
subjectType: 'users' | 'roles';
|
|
725
|
+
/** Callback when claims are saved */
|
|
726
|
+
onSaved?: () => void;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* ClaimModal - Modal for managing claims on users or roles
|
|
730
|
+
*
|
|
731
|
+
* This is the React equivalent of Angular's ClaimModalComponent.
|
|
732
|
+
* It allows adding, editing, and removing claims for a user or role.
|
|
733
|
+
*
|
|
734
|
+
* Pro feature since 0.7.2
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* ```tsx
|
|
738
|
+
* function UserClaimsButton({ userId }: { userId: string }) {
|
|
739
|
+
* const [showClaimModal, setShowClaimModal] = useState(false);
|
|
740
|
+
*
|
|
741
|
+
* return (
|
|
742
|
+
* <>
|
|
743
|
+
* <Button onClick={() => setShowClaimModal(true)}>Manage Claims</Button>
|
|
744
|
+
* <ClaimModal
|
|
745
|
+
* visible={showClaimModal}
|
|
746
|
+
* onVisibleChange={setShowClaimModal}
|
|
747
|
+
* subjectId={userId}
|
|
748
|
+
* subjectType="users"
|
|
749
|
+
* />
|
|
750
|
+
* </>
|
|
751
|
+
* );
|
|
752
|
+
* }
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
declare function ClaimModal({ visible, onVisibleChange, subjectId, subjectType, onSaved, }: ClaimModalProps): React.ReactElement;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Identity module routes configuration.
|
|
759
|
+
* Translated from @abp/ng.identity IDENTITY_ROUTES.
|
|
760
|
+
*
|
|
761
|
+
* These routes define the navigation structure for the identity module
|
|
762
|
+
* within the ABP Framework application.
|
|
763
|
+
*
|
|
764
|
+
* @deprecated since version 1.0.0. Route configuration is now handled by
|
|
765
|
+
* identity config services. This constant is kept for backwards compatibility
|
|
766
|
+
* but may be removed in future versions.
|
|
767
|
+
*/
|
|
768
|
+
declare const IDENTITY_ROUTES: {
|
|
769
|
+
routes: ABP.FullRoute[];
|
|
770
|
+
};
|
|
771
|
+
/**
|
|
772
|
+
* Route paths for the identity module.
|
|
773
|
+
* Use these constants for programmatic navigation.
|
|
774
|
+
*/
|
|
775
|
+
declare const IDENTITY_ROUTE_PATHS: {
|
|
776
|
+
/** Base path for identity module */
|
|
777
|
+
readonly BASE: "/identity";
|
|
778
|
+
/** Roles management path */
|
|
779
|
+
readonly ROLES: "/identity/roles";
|
|
780
|
+
/** Users management path */
|
|
781
|
+
readonly USERS: "/identity/users";
|
|
782
|
+
};
|
|
783
|
+
/**
|
|
784
|
+
* Required policies for identity module routes.
|
|
785
|
+
*/
|
|
786
|
+
declare const IDENTITY_POLICIES: {
|
|
787
|
+
/** Policy for roles management */
|
|
788
|
+
readonly ROLES: "AbpIdentity.Roles";
|
|
789
|
+
/** Policy for users management */
|
|
790
|
+
readonly USERS: "AbpIdentity.Users";
|
|
791
|
+
/** Policy for creating users */
|
|
792
|
+
readonly USERS_CREATE: "AbpIdentity.Users.Create";
|
|
793
|
+
/** Policy for updating users */
|
|
794
|
+
readonly USERS_UPDATE: "AbpIdentity.Users.Update";
|
|
795
|
+
/** Policy for deleting users */
|
|
796
|
+
readonly USERS_DELETE: "AbpIdentity.Users.Delete";
|
|
797
|
+
/** Policy for creating roles */
|
|
798
|
+
readonly ROLES_CREATE: "AbpIdentity.Roles.Create";
|
|
799
|
+
/** Policy for updating roles */
|
|
800
|
+
readonly ROLES_UPDATE: "AbpIdentity.Roles.Update";
|
|
801
|
+
/** Policy for deleting roles */
|
|
802
|
+
readonly ROLES_DELETE: "AbpIdentity.Roles.Delete";
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
export { ClaimModal, type ClaimModalProps, type ClaimOperationResult, ClaimsComponent, type ClaimsComponentProps, IDENTITY_POLICIES, IDENTITY_ROUTES, IDENTITY_ROUTE_PATHS, Identity, IdentityService, type RoleOperationResult, RolesComponent, type RolesComponentProps, type SortOrder, type UseClaimsReturn, type UseIdentityReturn, type UseRolesReturn, type UseUsersReturn, type UserOperationResult, UsersComponent, type UsersComponentProps, useClaims, useIdentity, useRoles, useUsers };
|