@abpjs/identity-pro 2.7.0 → 2.9.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.mjs CHANGED
@@ -10,11 +10,96 @@ var Identity;
10
10
  })(ClaimValueType = Identity2.ClaimValueType || (Identity2.ClaimValueType = {}));
11
11
  })(Identity || (Identity = {}));
12
12
 
13
+ // src/models/get-organization-unit-input.ts
14
+ function createGetOrganizationUnitInput(initialValues) {
15
+ return {
16
+ filter: "",
17
+ sorting: "",
18
+ skipCount: 0,
19
+ maxResultCount: 10,
20
+ ...initialValues
21
+ };
22
+ }
23
+
24
+ // src/models/organization-unit-create-dto.ts
25
+ function createOrganizationUnitCreateDto(initialValues) {
26
+ return {
27
+ displayName: "",
28
+ parentId: void 0,
29
+ extraProperties: [],
30
+ ...initialValues
31
+ };
32
+ }
33
+
34
+ // src/models/organization-unit-create-or-update-dto-base.ts
35
+ function createOrganizationUnitCreateOrUpdateDtoBase(initialValues) {
36
+ return {
37
+ displayName: "",
38
+ ...initialValues
39
+ };
40
+ }
41
+
42
+ // src/models/organization-unit-move-input.ts
43
+ function createOrganizationUnitMoveInput(initialValues) {
44
+ return {
45
+ newParentId: void 0,
46
+ ...initialValues
47
+ };
48
+ }
49
+
50
+ // src/models/organization-unit-role-input.ts
51
+ function createOrganizationUnitRoleInput(initialValues) {
52
+ return {
53
+ roleIds: [],
54
+ ...initialValues
55
+ };
56
+ }
57
+
58
+ // src/models/organization-unit-update-dto.ts
59
+ function createOrganizationUnitUpdateDto(initialValues) {
60
+ return {
61
+ displayName: "",
62
+ extraProperties: void 0,
63
+ ...initialValues
64
+ };
65
+ }
66
+
67
+ // src/models/organization-unit-user-input.ts
68
+ function createOrganizationUnitUserInput(initialValues) {
69
+ return {
70
+ userIds: [],
71
+ ...initialValues
72
+ };
73
+ }
74
+
75
+ // src/models/organization-unit-with-details-dto.ts
76
+ function createOrganizationUnitWithDetailsDto(initialValues) {
77
+ return {
78
+ parentId: void 0,
79
+ code: "",
80
+ displayName: "",
81
+ roles: [],
82
+ isDeleted: false,
83
+ deleterId: void 0,
84
+ deletionTime: void 0,
85
+ lastModificationTime: void 0,
86
+ lastModifierId: void 0,
87
+ creationTime: (/* @__PURE__ */ new Date()).toISOString(),
88
+ creatorId: void 0,
89
+ id: "",
90
+ extraProperties: [],
91
+ ...initialValues
92
+ };
93
+ }
94
+
13
95
  // src/enums/components.ts
14
96
  var eIdentityComponents = {
15
97
  Claims: "Identity.ClaimsComponent",
16
98
  Roles: "Identity.RolesComponent",
17
- Users: "Identity.UsersComponent"
99
+ Users: "Identity.UsersComponent",
100
+ OrganizationUnits: "Identity.OrganizationUnitsComponent",
101
+ OrganizationMembers: "Identity.OrganizationMembersComponent",
102
+ OrganizationRoles: "Identity.OrganizationRolesComponent"
18
103
  };
19
104
 
20
105
  // src/enums/route-names.ts
@@ -23,7 +108,8 @@ var eIdentityRouteNames = {
23
108
  IdentityManagement: "AbpIdentity::Menu:IdentityManagement",
24
109
  Roles: "AbpIdentity::Roles",
25
110
  Users: "AbpIdentity::Users",
26
- ClaimTypes: "AbpIdentity::ClaimTypes"
111
+ ClaimTypes: "AbpIdentity::ClaimTypes",
112
+ OrganizationUnits: "AbpIdentity::OrganizationUnits"
27
113
  };
28
114
 
29
115
  // src/services/identity.service.ts
@@ -146,6 +232,18 @@ var IdentityService = class {
146
232
  url: `/api/identity/users/${id}/roles`
147
233
  });
148
234
  }
235
+ /**
236
+ * Get organization units assigned to a user
237
+ * @since 2.9.0
238
+ * @param id - The user ID
239
+ * @returns Promise with the user's organization units
240
+ */
241
+ getUserOrganizationUnits(id) {
242
+ return this.rest.request({
243
+ method: "GET",
244
+ url: `/api/identity/users/${id}/organization-units`
245
+ });
246
+ }
149
247
  /**
150
248
  * Change a user's password (admin action)
151
249
  * @since 2.7.0
@@ -566,6 +664,165 @@ var IdentityStateService = class {
566
664
  }
567
665
  };
568
666
 
667
+ // src/services/organization-unit.service.ts
668
+ var OrganizationUnitService = class {
669
+ constructor(rest) {
670
+ /**
671
+ * The API name used for REST requests.
672
+ */
673
+ this.apiName = "default";
674
+ this.rest = rest;
675
+ }
676
+ /**
677
+ * Add roles to an organization unit
678
+ * @param body - The role IDs to add
679
+ * @param id - The organization unit ID
680
+ * @returns Promise resolving when complete
681
+ */
682
+ addRolesByIdAndInput(body, id) {
683
+ return this.rest.request({
684
+ method: "POST",
685
+ url: `/api/identity/organization-units/${id}/roles`,
686
+ body
687
+ });
688
+ }
689
+ /**
690
+ * Add members (users) to an organization unit
691
+ * @param body - The user IDs to add
692
+ * @param id - The organization unit ID
693
+ * @returns Promise resolving when complete
694
+ */
695
+ addMembersByIdAndInput(body, id) {
696
+ return this.rest.request({
697
+ method: "POST",
698
+ url: `/api/identity/organization-units/${id}/members`,
699
+ body
700
+ });
701
+ }
702
+ /**
703
+ * Create a new organization unit
704
+ * @param body - The organization unit data
705
+ * @returns Promise with the created organization unit
706
+ */
707
+ createByInput(body) {
708
+ return this.rest.request({
709
+ method: "POST",
710
+ url: "/api/identity/organization-units",
711
+ body
712
+ });
713
+ }
714
+ /**
715
+ * Delete an organization unit
716
+ * @param id - The organization unit ID to delete
717
+ * @returns Promise resolving when complete
718
+ */
719
+ deleteById(id) {
720
+ return this.rest.request({
721
+ method: "DELETE",
722
+ url: `/api/identity/organization-units/${id}`
723
+ });
724
+ }
725
+ /**
726
+ * Get an organization unit by ID
727
+ * @param id - The organization unit ID
728
+ * @returns Promise with the organization unit
729
+ */
730
+ getById(id) {
731
+ return this.rest.request({
732
+ method: "GET",
733
+ url: `/api/identity/organization-units/${id}`
734
+ });
735
+ }
736
+ /**
737
+ * Get organization units with optional filtering and pagination
738
+ * @param params - Query parameters for filtering and pagination
739
+ * @returns Promise with paginated organization units
740
+ */
741
+ getListByInput(params) {
742
+ return this.rest.request({
743
+ method: "GET",
744
+ url: "/api/identity/organization-units",
745
+ params
746
+ });
747
+ }
748
+ /**
749
+ * Get roles assigned to an organization unit
750
+ * @param params - Query parameters for pagination
751
+ * @param id - The organization unit ID
752
+ * @returns Promise with paginated roles
753
+ */
754
+ getRolesById(params, id) {
755
+ return this.rest.request({
756
+ method: "GET",
757
+ url: `/api/identity/organization-units/${id}/roles`,
758
+ params
759
+ });
760
+ }
761
+ /**
762
+ * Get members (users) of an organization unit
763
+ * @param params - Query parameters for pagination
764
+ * @param id - The organization unit ID
765
+ * @returns Promise with paginated users
766
+ */
767
+ getMembersById(params, id) {
768
+ return this.rest.request({
769
+ method: "GET",
770
+ url: `/api/identity/organization-units/${id}/members`,
771
+ params
772
+ });
773
+ }
774
+ /**
775
+ * Move an organization unit to a new parent
776
+ * @param body - The move input with new parent ID
777
+ * @param id - The organization unit ID to move
778
+ * @returns Promise resolving when complete
779
+ */
780
+ moveByIdAndInput(body, id) {
781
+ return this.rest.request({
782
+ method: "PUT",
783
+ url: `/api/identity/organization-units/${id}/move`,
784
+ body
785
+ });
786
+ }
787
+ /**
788
+ * Update an organization unit
789
+ * @param body - The updated organization unit data
790
+ * @param id - The organization unit ID to update
791
+ * @returns Promise with the updated organization unit
792
+ */
793
+ updateByIdAndInput(body, id) {
794
+ return this.rest.request({
795
+ method: "PUT",
796
+ url: `/api/identity/organization-units/${id}`,
797
+ body
798
+ });
799
+ }
800
+ /**
801
+ * Remove a member (user) from an organization unit
802
+ * @param id - The organization unit ID
803
+ * @param memberId - The user ID to remove
804
+ * @returns Promise resolving when complete
805
+ */
806
+ removeMemberByIdAndMemberId(id, memberId) {
807
+ return this.rest.request({
808
+ method: "DELETE",
809
+ url: `/api/identity/organization-units/${id}/members/${memberId}`
810
+ });
811
+ }
812
+ /**
813
+ * Remove a role from an organization unit
814
+ * @param id - The organization unit ID
815
+ * @param roleId - The role ID to remove
816
+ * @returns Promise resolving when complete
817
+ */
818
+ removeRoleByIdAndRoleId(id, roleId) {
819
+ return this.rest.request({
820
+ method: "DELETE",
821
+ url: `/api/identity/organization-units/${id}/roles/${roleId}`
822
+ });
823
+ }
824
+ };
825
+
569
826
  // src/hooks/useRoles.ts
570
827
  import { useState, useCallback, useMemo } from "react";
571
828
  import { useRestService } from "@abpjs/core";
@@ -1487,7 +1744,9 @@ function UsersComponent({
1487
1744
  password: formState.password,
1488
1745
  lockoutEnabled: formState.lockoutEnabled,
1489
1746
  twoFactorEnabled: formState.twoFactorEnabled,
1490
- roleNames: formState.roleNames
1747
+ roleNames: formState.roleNames,
1748
+ organizationUnitIds: []
1749
+ // v2.9.0: Organization unit assignment (can be extended with UI)
1491
1750
  };
1492
1751
  let result;
1493
1752
  if (selectedUser?.id) {
@@ -2255,6 +2514,187 @@ var IDENTITY_POLICIES = {
2255
2514
  /** Policy for deleting roles */
2256
2515
  ROLES_DELETE: "AbpIdentity.Roles.Delete"
2257
2516
  };
2517
+
2518
+ // src/utils/tree-adapter.ts
2519
+ function createTreeNode(entity, nameResolver) {
2520
+ const resolvedName = nameResolver ? nameResolver(entity) : entity.displayName || entity.name || "";
2521
+ return {
2522
+ entity,
2523
+ title: resolvedName,
2524
+ key: entity.id,
2525
+ icon: null,
2526
+ children: [],
2527
+ isLeaf: true,
2528
+ checked: false,
2529
+ selected: false,
2530
+ expanded: false,
2531
+ selectable: true,
2532
+ disabled: false,
2533
+ disableCheckbox: false,
2534
+ parentNode: null,
2535
+ parentId: entity.parentId,
2536
+ id: entity.id
2537
+ };
2538
+ }
2539
+ var TreeAdapter = class {
2540
+ /**
2541
+ * Creates a new TreeAdapter instance.
2542
+ * @param list - Optional initial list of entities
2543
+ * @param nameResolver - Optional function to resolve display names
2544
+ */
2545
+ constructor(list = [], nameResolver) {
2546
+ this.nameResolver = nameResolver;
2547
+ this.list = [];
2548
+ this.tree = [];
2549
+ this.nodeMap = /* @__PURE__ */ new Map();
2550
+ this.setList(list);
2551
+ }
2552
+ /**
2553
+ * Sets the list and rebuilds the tree.
2554
+ * @param list - The new list of entities
2555
+ */
2556
+ setList(list) {
2557
+ this.list = list;
2558
+ this.buildTree();
2559
+ }
2560
+ /**
2561
+ * Gets the original flat list.
2562
+ * @returns The flat list of entities
2563
+ */
2564
+ getList() {
2565
+ return this.list;
2566
+ }
2567
+ /**
2568
+ * Gets the tree structure.
2569
+ * @returns Array of root TreeNodes
2570
+ */
2571
+ getTree() {
2572
+ return this.tree;
2573
+ }
2574
+ /**
2575
+ * Gets a node by its ID.
2576
+ * @param id - The node ID
2577
+ * @returns The TreeNode or undefined
2578
+ */
2579
+ getNodeById(id) {
2580
+ return this.nodeMap.get(id);
2581
+ }
2582
+ /**
2583
+ * Handles a drop operation (moving a node).
2584
+ * Updates the internal structure after drag-and-drop.
2585
+ * @param node - The node that was dropped
2586
+ */
2587
+ handleDrop(node) {
2588
+ const entity = node.entity;
2589
+ if (node.parentNode) {
2590
+ entity.parentId = node.parentNode.id;
2591
+ } else {
2592
+ entity.parentId = null;
2593
+ }
2594
+ this.buildTree();
2595
+ }
2596
+ /**
2597
+ * Handles removing a node from the tree.
2598
+ * @param node - The node to remove
2599
+ */
2600
+ handleRemove(node) {
2601
+ this.list = this.list.filter((item) => item.id !== node.id);
2602
+ this.buildTree();
2603
+ }
2604
+ /**
2605
+ * Builds the tree structure from the flat list.
2606
+ */
2607
+ buildTree() {
2608
+ this.nodeMap.clear();
2609
+ this.tree = [];
2610
+ for (const item of this.list) {
2611
+ const node = createTreeNode(item, this.nameResolver);
2612
+ this.nodeMap.set(item.id, node);
2613
+ }
2614
+ for (const item of this.list) {
2615
+ const node = this.nodeMap.get(item.id);
2616
+ if (item.parentId && this.nodeMap.has(item.parentId)) {
2617
+ const parentNode = this.nodeMap.get(item.parentId);
2618
+ parentNode.children.push(node);
2619
+ parentNode.isLeaf = false;
2620
+ node.parentNode = parentNode;
2621
+ } else {
2622
+ this.tree.push(node);
2623
+ }
2624
+ }
2625
+ this.sortChildren(this.tree);
2626
+ }
2627
+ /**
2628
+ * Recursively sorts children by title.
2629
+ * @param nodes - Array of nodes to sort
2630
+ */
2631
+ sortChildren(nodes) {
2632
+ nodes.sort((a, b) => (a.title || "").localeCompare(b.title || ""));
2633
+ for (const node of nodes) {
2634
+ if (node.children.length > 0) {
2635
+ this.sortChildren(node.children);
2636
+ }
2637
+ }
2638
+ }
2639
+ /**
2640
+ * Expands all nodes in the tree.
2641
+ */
2642
+ expandAll() {
2643
+ for (const node of this.nodeMap.values()) {
2644
+ node.expanded = true;
2645
+ }
2646
+ }
2647
+ /**
2648
+ * Collapses all nodes in the tree.
2649
+ */
2650
+ collapseAll() {
2651
+ for (const node of this.nodeMap.values()) {
2652
+ node.expanded = false;
2653
+ }
2654
+ }
2655
+ /**
2656
+ * Gets all expanded node keys.
2657
+ * @returns Array of expanded node IDs
2658
+ */
2659
+ getExpandedKeys() {
2660
+ return Array.from(this.nodeMap.values()).filter((node) => node.expanded).map((node) => node.key);
2661
+ }
2662
+ /**
2663
+ * Sets expanded state for specific nodes.
2664
+ * @param keys - Array of node IDs to expand
2665
+ */
2666
+ setExpandedKeys(keys) {
2667
+ const keySet = new Set(keys);
2668
+ for (const node of this.nodeMap.values()) {
2669
+ node.expanded = keySet.has(node.key);
2670
+ }
2671
+ }
2672
+ /**
2673
+ * Finds a node and all its ancestors.
2674
+ * Useful for expanding path to a specific node.
2675
+ * @param id - The target node ID
2676
+ * @returns Array of nodes from root to target
2677
+ */
2678
+ getPathToNode(id) {
2679
+ const path = [];
2680
+ let current = this.nodeMap.get(id);
2681
+ while (current) {
2682
+ path.unshift(current);
2683
+ current = current.parentNode || void 0;
2684
+ }
2685
+ return path;
2686
+ }
2687
+ /**
2688
+ * Expands the path to a specific node.
2689
+ * @param id - The target node ID
2690
+ */
2691
+ expandPathToNode(id) {
2692
+ const path = this.getPathToNode(id);
2693
+ for (const node of path) {
2694
+ node.expanded = true;
2695
+ }
2696
+ }
2697
+ };
2258
2698
  export {
2259
2699
  ClaimModal,
2260
2700
  ClaimsComponent,
@@ -2264,8 +2704,19 @@ export {
2264
2704
  Identity,
2265
2705
  IdentityService,
2266
2706
  IdentityStateService,
2707
+ OrganizationUnitService,
2267
2708
  RolesComponent,
2709
+ TreeAdapter,
2268
2710
  UsersComponent,
2711
+ createGetOrganizationUnitInput,
2712
+ createOrganizationUnitCreateDto,
2713
+ createOrganizationUnitCreateOrUpdateDtoBase,
2714
+ createOrganizationUnitMoveInput,
2715
+ createOrganizationUnitRoleInput,
2716
+ createOrganizationUnitUpdateDto,
2717
+ createOrganizationUnitUserInput,
2718
+ createOrganizationUnitWithDetailsDto,
2719
+ createTreeNode,
2269
2720
  eIdentityComponents,
2270
2721
  eIdentityRouteNames,
2271
2722
  useClaims,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/identity-pro",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "ABP Framework identity pro components for React - translated from @volo/abp.ng.identity",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,12 +27,12 @@
27
27
  "@chakra-ui/react": "^3.2.0",
28
28
  "@emotion/react": "^11.11.0",
29
29
  "react-icons": "^5.3.0",
30
- "@abpjs/theme-shared": "2.7.0",
31
- "@abpjs/core": "2.7.0",
32
- "@abpjs/permission-management": "2.7.0"
30
+ "@abpjs/core": "2.9.0",
31
+ "@abpjs/theme-shared": "2.9.0",
32
+ "@abpjs/permission-management": "2.9.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@volo/abp.ng.identity": "2.7.0",
35
+ "@volo/abp.ng.identity": "2.9.0",
36
36
  "@testing-library/jest-dom": "^6.9.1",
37
37
  "@testing-library/react": "^14.0.0",
38
38
  "@testing-library/user-event": "^14.6.1",