@mu-cabin/opms-permission 0.8.31 → 0.8.33

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
@@ -205,11 +205,11 @@ function findFirstEnableNode(data) {
205
205
  return null;
206
206
  }
207
207
  function handlePermissionTree(data, key) {
208
- const orgNoAuthMap = {};
208
+ const noAuthMap = {};
209
209
  function processNode(node) {
210
210
  const processedChildren = node.children?.map((child) => processNode(child)).filter((child) => child !== null);
211
211
  if (node.disabled) {
212
- orgNoAuthMap[node[key]] = { ...node, children: [] };
212
+ noAuthMap[node[key]] = { ...node, children: [] };
213
213
  if (!processedChildren?.length) {
214
214
  return null;
215
215
  }
@@ -219,10 +219,10 @@ function handlePermissionTree(data, key) {
219
219
  children: processedChildren || []
220
220
  };
221
221
  }
222
- const orgTree = data.map((node) => processNode(node)).filter((node) => node !== null);
222
+ const tree = data.map((node) => processNode(node)).filter((node) => node !== null);
223
223
  return {
224
- orgTree,
225
- orgNoAuthMap
224
+ tree,
225
+ noAuthMap
226
226
  };
227
227
  }
228
228
 
@@ -315,6 +315,7 @@ var DataHandler = {
315
315
  };
316
316
  });
317
317
  },
318
+ iterateNestedArray,
318
319
  // 获取单位组织
319
320
  // getUnitOptions(orgTree: OrgTreeItem[]): Option[] {
320
321
  // if (!orgTree) return [];
@@ -490,13 +491,13 @@ var Permission = class {
490
491
  storage.setItem(USER_ORG_KEY, orgTreeData);
491
492
  }
492
493
  const data = handlePermissionTree(orgTreeData, "orgId");
493
- const { orgNoAuthMap } = data;
494
- let { orgTree } = data;
495
- if (orgTree.length === 1 && orgTree[0].orgType === "HEAD" && orgTree[0].disabled) {
496
- orgTree = orgTree[0].children || [];
494
+ const { noAuthMap } = data;
495
+ let { tree } = data;
496
+ if (tree.length === 1 && tree[0].orgType === "HEAD" && tree[0].disabled) {
497
+ tree = tree[0].children || [];
497
498
  }
498
499
  this._orgTree = orgTreeData;
499
- return { orgTree: orgTreeData, orgNoAuthMap, authOrgTree: orgTree };
500
+ return { orgTree: orgTreeData, orgNoAuthMap: noAuthMap, authOrgTree: tree };
500
501
  } catch (error) {
501
502
  console.log(error);
502
503
  return null;
package/dist/index.d.mts CHANGED
@@ -81,6 +81,13 @@ interface OrgRecord$1 {
81
81
  systemList: any[];
82
82
  }
83
83
 
84
+ /**
85
+ * 遍历嵌套数组并返回处理后的值
86
+ * @param items 数组
87
+ * @param callback 回调函数
88
+ * @returns 处理后的数组
89
+ */
90
+ declare function iterateNestedArray<T = any>(items: T[], callback: (item: T, parent?: T) => T): T[];
84
91
  declare function findFirstEnableNode(data: OrgTreeItem[]): OrgTreeItem | null;
85
92
 
86
93
  interface OrgRecord {
@@ -102,6 +109,7 @@ interface PermissionOptions {
102
109
  */
103
110
  declare const DataHandler: {
104
111
  iterateOrgTree(orgTree: OrgRecord[]): OrgTreeItem[];
112
+ iterateNestedArray: typeof iterateNestedArray;
105
113
  getAllUnitOptions(orgTree: OrgTreeItem[]): Option[];
106
114
  getCompaniesOptions(orgTree: OrgTreeItem[], hasRootAuth: boolean): Option[];
107
115
  topLevelUnitOrgCodes(orgTree: OrgTreeItem[]): string[];
package/dist/index.d.ts CHANGED
@@ -81,6 +81,13 @@ interface OrgRecord$1 {
81
81
  systemList: any[];
82
82
  }
83
83
 
84
+ /**
85
+ * 遍历嵌套数组并返回处理后的值
86
+ * @param items 数组
87
+ * @param callback 回调函数
88
+ * @returns 处理后的数组
89
+ */
90
+ declare function iterateNestedArray<T = any>(items: T[], callback: (item: T, parent?: T) => T): T[];
84
91
  declare function findFirstEnableNode(data: OrgTreeItem[]): OrgTreeItem | null;
85
92
 
86
93
  interface OrgRecord {
@@ -102,6 +109,7 @@ interface PermissionOptions {
102
109
  */
103
110
  declare const DataHandler: {
104
111
  iterateOrgTree(orgTree: OrgRecord[]): OrgTreeItem[];
112
+ iterateNestedArray: typeof iterateNestedArray;
105
113
  getAllUnitOptions(orgTree: OrgTreeItem[]): Option[];
106
114
  getCompaniesOptions(orgTree: OrgTreeItem[], hasRootAuth: boolean): Option[];
107
115
  topLevelUnitOrgCodes(orgTree: OrgTreeItem[]): string[];
package/dist/index.mjs CHANGED
@@ -166,11 +166,11 @@ function findFirstEnableNode(data) {
166
166
  return null;
167
167
  }
168
168
  function handlePermissionTree(data, key) {
169
- const orgNoAuthMap = {};
169
+ const noAuthMap = {};
170
170
  function processNode(node) {
171
171
  const processedChildren = node.children?.map((child) => processNode(child)).filter((child) => child !== null);
172
172
  if (node.disabled) {
173
- orgNoAuthMap[node[key]] = { ...node, children: [] };
173
+ noAuthMap[node[key]] = { ...node, children: [] };
174
174
  if (!processedChildren?.length) {
175
175
  return null;
176
176
  }
@@ -180,10 +180,10 @@ function handlePermissionTree(data, key) {
180
180
  children: processedChildren || []
181
181
  };
182
182
  }
183
- const orgTree = data.map((node) => processNode(node)).filter((node) => node !== null);
183
+ const tree = data.map((node) => processNode(node)).filter((node) => node !== null);
184
184
  return {
185
- orgTree,
186
- orgNoAuthMap
185
+ tree,
186
+ noAuthMap
187
187
  };
188
188
  }
189
189
 
@@ -276,6 +276,7 @@ var DataHandler = {
276
276
  };
277
277
  });
278
278
  },
279
+ iterateNestedArray,
279
280
  // 获取单位组织
280
281
  // getUnitOptions(orgTree: OrgTreeItem[]): Option[] {
281
282
  // if (!orgTree) return [];
@@ -451,13 +452,13 @@ var Permission = class {
451
452
  storage.setItem(USER_ORG_KEY, orgTreeData);
452
453
  }
453
454
  const data = handlePermissionTree(orgTreeData, "orgId");
454
- const { orgNoAuthMap } = data;
455
- let { orgTree } = data;
456
- if (orgTree.length === 1 && orgTree[0].orgType === "HEAD" && orgTree[0].disabled) {
457
- orgTree = orgTree[0].children || [];
455
+ const { noAuthMap } = data;
456
+ let { tree } = data;
457
+ if (tree.length === 1 && tree[0].orgType === "HEAD" && tree[0].disabled) {
458
+ tree = tree[0].children || [];
458
459
  }
459
460
  this._orgTree = orgTreeData;
460
- return { orgTree: orgTreeData, orgNoAuthMap, authOrgTree: orgTree };
461
+ return { orgTree: orgTreeData, orgNoAuthMap: noAuthMap, authOrgTree: tree };
461
462
  } catch (error) {
462
463
  console.log(error);
463
464
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mu-cabin/opms-permission",
3
- "version": "0.8.31",
3
+ "version": "0.8.33",
4
4
  "description": "Frontend SDK for OPMS permission and auth management.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",