@mu-cabin/opms-permission 0.8.27 → 0.8.29

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.cjs CHANGED
@@ -204,6 +204,27 @@ function findFirstEnableNode(data) {
204
204
  }
205
205
  return null;
206
206
  }
207
+ function handleOrgTreeByPermission(data) {
208
+ const orgNoAuthMap = {};
209
+ function processNode(node) {
210
+ const processedChildren = node.children?.map((child) => processNode(child)).filter((child) => child !== null);
211
+ if (node.disabled) {
212
+ orgNoAuthMap[node.orgId] = node;
213
+ if (!processedChildren?.length) {
214
+ return null;
215
+ }
216
+ }
217
+ return {
218
+ ...node,
219
+ children: processedChildren || []
220
+ };
221
+ }
222
+ const orgTree = data.map((node) => processNode(node)).filter((node) => node !== null);
223
+ return {
224
+ orgTree,
225
+ orgNoAuthMap
226
+ };
227
+ }
207
228
 
208
229
  // src/api.ts
209
230
  var import_axios = __toESM(require("axios"));
@@ -464,8 +485,9 @@ var Permission = class {
464
485
  orgId: item.orgId
465
486
  };
466
487
  });
488
+ const { orgTree, orgNoAuthMap } = handleOrgTreeByPermission(newTree);
467
489
  this._orgTree = newTree;
468
- return newTree;
490
+ return { orgTree: newTree, orgNoAuthMap, authOrgTree: orgTree };
469
491
  } catch (error) {
470
492
  console.log(error);
471
493
  return null;
package/dist/index.d.mts CHANGED
@@ -167,7 +167,11 @@ declare class Permission {
167
167
  /**
168
168
  * Query and process organization tree
169
169
  */
170
- queryUserOrgs(): Promise<any[] | null>;
170
+ queryUserOrgs(): Promise<{
171
+ orgTree: OrgTreeItem[];
172
+ orgNoAuthMap: Record<number, OrgTreeItem>;
173
+ authOrgTree: OrgTreeItem[];
174
+ } | null>;
171
175
  queryCompanies(): Promise<OrgRecord[]>;
172
176
  isLogin(): boolean;
173
177
  getToken(): string | null;
package/dist/index.d.ts CHANGED
@@ -167,7 +167,11 @@ declare class Permission {
167
167
  /**
168
168
  * Query and process organization tree
169
169
  */
170
- queryUserOrgs(): Promise<any[] | null>;
170
+ queryUserOrgs(): Promise<{
171
+ orgTree: OrgTreeItem[];
172
+ orgNoAuthMap: Record<number, OrgTreeItem>;
173
+ authOrgTree: OrgTreeItem[];
174
+ } | null>;
171
175
  queryCompanies(): Promise<OrgRecord[]>;
172
176
  isLogin(): boolean;
173
177
  getToken(): string | null;
package/dist/index.mjs CHANGED
@@ -165,6 +165,27 @@ function findFirstEnableNode(data) {
165
165
  }
166
166
  return null;
167
167
  }
168
+ function handleOrgTreeByPermission(data) {
169
+ const orgNoAuthMap = {};
170
+ function processNode(node) {
171
+ const processedChildren = node.children?.map((child) => processNode(child)).filter((child) => child !== null);
172
+ if (node.disabled) {
173
+ orgNoAuthMap[node.orgId] = node;
174
+ if (!processedChildren?.length) {
175
+ return null;
176
+ }
177
+ }
178
+ return {
179
+ ...node,
180
+ children: processedChildren || []
181
+ };
182
+ }
183
+ const orgTree = data.map((node) => processNode(node)).filter((node) => node !== null);
184
+ return {
185
+ orgTree,
186
+ orgNoAuthMap
187
+ };
188
+ }
168
189
 
169
190
  // src/api.ts
170
191
  import axios from "axios";
@@ -425,8 +446,9 @@ var Permission = class {
425
446
  orgId: item.orgId
426
447
  };
427
448
  });
449
+ const { orgTree, orgNoAuthMap } = handleOrgTreeByPermission(newTree);
428
450
  this._orgTree = newTree;
429
- return newTree;
451
+ return { orgTree: newTree, orgNoAuthMap, authOrgTree: orgTree };
430
452
  } catch (error) {
431
453
  console.log(error);
432
454
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mu-cabin/opms-permission",
3
- "version": "0.8.27",
3
+ "version": "0.8.29",
4
4
  "description": "Frontend SDK for OPMS permission and auth management.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",