@mu-cabin/opms-permission 0.8.35 → 0.9.1

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
@@ -1,18 +1,121 @@
1
+ interface ApiResponse<T> {
2
+ obj: T;
3
+ success: boolean;
4
+ msg: string;
5
+ code: number;
6
+ }
7
+ type ResourceType = 'MENU' | 'FOLDER' | 'WIDGET' | 'UNDEFINED';
8
+ type OpenIndicatorType = 'INNER_COMPONENT' | 'OUTER_URL';
1
9
  interface Resource {
2
- resourceId: number;
3
- resourceCode: string;
4
- resourceName?: string;
5
- showName?: string;
6
- resourceType?: string;
7
- defaultResourceType?: string;
10
+ belongingContainerId: number;
11
+ belongingContainerType: string;
8
12
  componentPath?: string;
9
- defaultUrl?: string;
10
- icon?: string;
11
13
  defaultIcon?: string;
12
- openIndicator: string;
13
- prefix?: string;
14
+ defaultResourceType: string;
15
+ defaultUrl?: string;
16
+ nodeLevel?: number;
17
+ poolParentResourceId?: number;
18
+ poolShowOrder?: number;
19
+ resourceId: number;
20
+ resourceName: string;
21
+ showName: string;
22
+ resourceCode: string;
23
+ searchPath?: string;
14
24
  children?: Resource[];
25
+ prefix: string;
26
+ resourceType: ResourceType;
27
+ icon?: string;
28
+ openIndicator: OpenIndicatorType;
29
+ orgQueryMode: EnumOrgQueryMode;
30
+ orgQueryScope: EnumOrgQueryScope;
31
+ }
32
+ type CodeSourceType = 'FLY_NET' | 'COS' | 'CSM';
33
+ interface OrgRecord$1 {
34
+ orgId: number;
35
+ orgName: string;
36
+ orgShortName: string;
37
+ orgCode: string;
38
+ nodeLevel: number;
39
+ hasPermission: boolean;
40
+ children?: OrgRecord$1[];
41
+ orgQueryMode?: EnumOrgQueryMode;
15
42
  }
43
+ interface UserOrganization$1 {
44
+ orgId: number;
45
+ orgCode: string;
46
+ parentOrgId: number | null;
47
+ parentOrgCode: string | null;
48
+ branchId: number | null;
49
+ branchCode: string | null;
50
+ orgName: string;
51
+ orgShortName: string;
52
+ orgType: string;
53
+ showOrder: number | null;
54
+ orgCodeSearchPath: string;
55
+ positionInfo: any[];
56
+ orgBindType: string;
57
+ csmOrgCode: string | null;
58
+ hasPermission: boolean;
59
+ canModify: boolean;
60
+ nodeLevel: number;
61
+ searchPath: string;
62
+ children: UserOrganization$1[];
63
+ }
64
+ interface UserRole {
65
+ roleId: number;
66
+ roleName: string;
67
+ parentRoleId: number | null;
68
+ grantType: string;
69
+ nodeLevel: number | null;
70
+ searchPath: string | null;
71
+ children: UserRole[];
72
+ }
73
+ interface UserInfo$1 {
74
+ ehrId: number;
75
+ account: string;
76
+ crewId: number | null;
77
+ crewCode: string | null;
78
+ name: string;
79
+ individualType: string | null;
80
+ individualStatus: string | null;
81
+ opmsRole: string;
82
+ userOrganizations: UserOrganization$1[];
83
+ userRoles: UserRole[];
84
+ uniAccount: string;
85
+ }
86
+ declare enum EnumOrgQueryMode {
87
+ BY_ROLES = "BY_ROLES",// 配置了页面权限的方式
88
+ BY_DEPT = "BY_DEPT"
89
+ }
90
+ declare enum EnumOrgQueryScope {
91
+ ONLY_BRANCH = "ONLY_BRANCH",// 查询到子公司
92
+ STEWARD_UNIT = "STEWARD_UNIT",// 查询到乘务部(如果用户是业务部门的话包含所有乘务部), 不包括业务部门
93
+ WITH_DEPARTMENT = "WITH_DEPARTMENT"
94
+ }
95
+ interface UserOrgTreeParams {
96
+ orgQueryMode: keyof typeof EnumOrgQueryMode;
97
+ orgQueryScope: keyof typeof EnumOrgQueryScope;
98
+ menuResourceId?: number;
99
+ stewardUnitLevel?: number;
100
+ keepHead?: boolean;
101
+ }
102
+ declare function login(baseUrl: string, authorizationCode: string): Promise<ApiResponse<{
103
+ token: string;
104
+ }>>;
105
+ declare function logout(baseUrl: string): Promise<ApiResponse<void>>;
106
+ declare function getUserInfo(baseUrl: string): Promise<ApiResponse<UserInfo$1>>;
107
+ declare function queryResource(baseUrl: string, params: {
108
+ systemId: string;
109
+ }): Promise<ApiResponse<Resource[]>>;
110
+ declare function getOrgTree(baseUrl: string, params: {
111
+ systemId: string;
112
+ name: CodeSourceType;
113
+ }): Promise<ApiResponse<OrgRecord$1>>;
114
+ declare function getUserOrgTree(baseUrl: string, params: UserOrgTreeParams): Promise<ApiResponse<OrgRecord$1[]>>;
115
+ declare function queryOrgCompanies(baseUrl: string, params: {
116
+ queryAllBranches?: boolean;
117
+ }): Promise<ApiResponse<OrgRecord$1[]>>;
118
+
16
119
  interface MenuItem {
17
120
  icon?: string;
18
121
  path: string;
@@ -58,7 +161,7 @@ interface ChildOrganization {
58
161
  orgShortName: string;
59
162
  orgType: string;
60
163
  }
61
- interface OrgRecord$1 {
164
+ interface OrgRecord {
62
165
  allOrgTags: boolean;
63
166
  allSystem: boolean;
64
167
  canModify: boolean;
@@ -97,16 +200,6 @@ declare function handlePermissionTree<T extends {
97
200
  noAuthMap: Record<number | string, T>;
98
201
  };
99
202
 
100
- interface OrgRecord {
101
- orgId: number;
102
- orgName: string;
103
- orgShortName: string;
104
- orgCode: string;
105
- nodeLevel: number;
106
- hasPermission: boolean;
107
- children?: OrgRecord[];
108
- }
109
-
110
203
  interface PermissionOptions {
111
204
  systemId: string;
112
205
  baseUrl: string;
@@ -115,7 +208,7 @@ interface PermissionOptions {
115
208
  * 组织树处理工具
116
209
  */
117
210
  declare const DataHandler: {
118
- iterateOrgTree(orgTree: OrgRecord[]): OrgTreeItem[];
211
+ iterateOrgTree(orgTree: OrgRecord$1[]): OrgTreeItem[];
119
212
  iterateNestedArray: typeof iterateNestedArray;
120
213
  getAllUnitOptions(orgTree: OrgTreeItem[]): Option[];
121
214
  getCompaniesOptions(orgTree: OrgTreeItem[], hasRootAuth: boolean): Option[];
@@ -140,8 +233,6 @@ declare const DataHandler: {
140
233
  };
141
234
  declare class Permission {
142
235
  private _userInfo;
143
- private _orgTree;
144
- private _orgCompany;
145
236
  private systemId;
146
237
  private baseUrl;
147
238
  resources: Resource[];
@@ -165,7 +256,7 @@ declare class Permission {
165
256
  */
166
257
  logout(clearData?: boolean): Promise<void>;
167
258
  clear(): void;
168
- getUserInfo(): Promise<UserInfo | null>;
259
+ getUserInfo(): Promise<UserInfo$1>;
169
260
  /**
170
261
  * Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
171
262
  */
@@ -181,27 +272,56 @@ declare class Permission {
181
272
  menuMap: Record<number, MenuItem>;
182
273
  }>;
183
274
  /**
184
- * Query and process organization tree
275
+ * Generate cache key for user orgs query
276
+ */
277
+ private generateUserOrgsCacheKey;
278
+ /**
279
+ * Query and process organization tree with caching
185
280
  */
186
- queryUserOrgs(): Promise<{
281
+ queryUserOrgs(params: UserOrgTreeParams, config?: {
282
+ force?: boolean;
283
+ cacheTimeout?: number;
284
+ }): Promise<{
187
285
  orgTree: OrgTreeItem[];
188
- orgNoAuthMap: Record<number, OrgTreeItem>;
189
- authOrgTree: OrgTreeItem[];
190
286
  } | null>;
191
- queryCompanies(): Promise<OrgRecord[]>;
192
287
  isLogin(): boolean;
193
288
  getToken(): string | null;
194
289
  setToken(token: string): void;
195
- get userInfo(): UserInfo | null;
196
- get hasRootAuth(): boolean;
197
- get userOrganizations(): UserOrganization[];
198
- get allCompanyOptions(): Option[];
199
- get companyOptions(): Option[];
200
- get firstCompanyOrgCode(): string;
201
- get unitOptions(): Option[];
202
- get allUnitOptions(): Option[];
203
- get firstUnitOrgCode(): string;
204
- get topLevelUnitOrgCodes(): string[];
290
+ /**
291
+ * Get storage information for debugging and monitoring
292
+ */
293
+ getStorageInfo(): {
294
+ permissionKeys: {
295
+ resourceKey: string;
296
+ tokenKey: string;
297
+ userInfoKey: string;
298
+ };
299
+ hasData: {
300
+ resources: boolean;
301
+ token: boolean;
302
+ userInfo: boolean;
303
+ };
304
+ cacheInfo: {
305
+ userOrgsCacheCount: number;
306
+ userOrgsCacheKeys: string[];
307
+ };
308
+ systemId: number | string | undefined;
309
+ currentVersion: string;
310
+ totalKeys: number;
311
+ systemKeys: number;
312
+ };
313
+ /**
314
+ * Get current storage version
315
+ */
316
+ getStorageVersion(): string;
317
+ /**
318
+ * Clear all storage data for this system
319
+ */
320
+ clearStorage(): void;
321
+ /**
322
+ * Clear user orgs cache for specific parameters or all
323
+ */
324
+ clearUserOrgsCache(params?: UserOrgTreeParams): void;
205
325
  }
206
326
 
207
327
  /**
@@ -226,4 +346,4 @@ declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
226
346
  clientId?: string;
227
347
  }): void;
228
348
 
229
- export { type ChildOrganization, DataHandler, type MenuItem, Permission as OpmsPermission, type Option, type OrgRecord$1 as OrgRecord, type OrgTreeItem, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
349
+ export { type ApiResponse, type ChildOrganization, type CodeSourceType, DataHandler, EnumOrgQueryMode, EnumOrgQueryScope, type MenuItem, type OpenIndicatorType, Permission as OpmsPermission, type Option, type OrgRecord, type OrgTreeItem, type Resource, type ResourceType, type UserInfo, type UserOrgTreeParams, type UserOrganization, type UserRole, getOrgTree, getUserInfo, getUserOrgTree, jumpToSSOLogin, jumpToSSOLogout, login, logout, queryOrgCompanies, queryResource };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,121 @@
1
+ interface ApiResponse<T> {
2
+ obj: T;
3
+ success: boolean;
4
+ msg: string;
5
+ code: number;
6
+ }
7
+ type ResourceType = 'MENU' | 'FOLDER' | 'WIDGET' | 'UNDEFINED';
8
+ type OpenIndicatorType = 'INNER_COMPONENT' | 'OUTER_URL';
1
9
  interface Resource {
2
- resourceId: number;
3
- resourceCode: string;
4
- resourceName?: string;
5
- showName?: string;
6
- resourceType?: string;
7
- defaultResourceType?: string;
10
+ belongingContainerId: number;
11
+ belongingContainerType: string;
8
12
  componentPath?: string;
9
- defaultUrl?: string;
10
- icon?: string;
11
13
  defaultIcon?: string;
12
- openIndicator: string;
13
- prefix?: string;
14
+ defaultResourceType: string;
15
+ defaultUrl?: string;
16
+ nodeLevel?: number;
17
+ poolParentResourceId?: number;
18
+ poolShowOrder?: number;
19
+ resourceId: number;
20
+ resourceName: string;
21
+ showName: string;
22
+ resourceCode: string;
23
+ searchPath?: string;
14
24
  children?: Resource[];
25
+ prefix: string;
26
+ resourceType: ResourceType;
27
+ icon?: string;
28
+ openIndicator: OpenIndicatorType;
29
+ orgQueryMode: EnumOrgQueryMode;
30
+ orgQueryScope: EnumOrgQueryScope;
31
+ }
32
+ type CodeSourceType = 'FLY_NET' | 'COS' | 'CSM';
33
+ interface OrgRecord$1 {
34
+ orgId: number;
35
+ orgName: string;
36
+ orgShortName: string;
37
+ orgCode: string;
38
+ nodeLevel: number;
39
+ hasPermission: boolean;
40
+ children?: OrgRecord$1[];
41
+ orgQueryMode?: EnumOrgQueryMode;
15
42
  }
43
+ interface UserOrganization$1 {
44
+ orgId: number;
45
+ orgCode: string;
46
+ parentOrgId: number | null;
47
+ parentOrgCode: string | null;
48
+ branchId: number | null;
49
+ branchCode: string | null;
50
+ orgName: string;
51
+ orgShortName: string;
52
+ orgType: string;
53
+ showOrder: number | null;
54
+ orgCodeSearchPath: string;
55
+ positionInfo: any[];
56
+ orgBindType: string;
57
+ csmOrgCode: string | null;
58
+ hasPermission: boolean;
59
+ canModify: boolean;
60
+ nodeLevel: number;
61
+ searchPath: string;
62
+ children: UserOrganization$1[];
63
+ }
64
+ interface UserRole {
65
+ roleId: number;
66
+ roleName: string;
67
+ parentRoleId: number | null;
68
+ grantType: string;
69
+ nodeLevel: number | null;
70
+ searchPath: string | null;
71
+ children: UserRole[];
72
+ }
73
+ interface UserInfo$1 {
74
+ ehrId: number;
75
+ account: string;
76
+ crewId: number | null;
77
+ crewCode: string | null;
78
+ name: string;
79
+ individualType: string | null;
80
+ individualStatus: string | null;
81
+ opmsRole: string;
82
+ userOrganizations: UserOrganization$1[];
83
+ userRoles: UserRole[];
84
+ uniAccount: string;
85
+ }
86
+ declare enum EnumOrgQueryMode {
87
+ BY_ROLES = "BY_ROLES",// 配置了页面权限的方式
88
+ BY_DEPT = "BY_DEPT"
89
+ }
90
+ declare enum EnumOrgQueryScope {
91
+ ONLY_BRANCH = "ONLY_BRANCH",// 查询到子公司
92
+ STEWARD_UNIT = "STEWARD_UNIT",// 查询到乘务部(如果用户是业务部门的话包含所有乘务部), 不包括业务部门
93
+ WITH_DEPARTMENT = "WITH_DEPARTMENT"
94
+ }
95
+ interface UserOrgTreeParams {
96
+ orgQueryMode: keyof typeof EnumOrgQueryMode;
97
+ orgQueryScope: keyof typeof EnumOrgQueryScope;
98
+ menuResourceId?: number;
99
+ stewardUnitLevel?: number;
100
+ keepHead?: boolean;
101
+ }
102
+ declare function login(baseUrl: string, authorizationCode: string): Promise<ApiResponse<{
103
+ token: string;
104
+ }>>;
105
+ declare function logout(baseUrl: string): Promise<ApiResponse<void>>;
106
+ declare function getUserInfo(baseUrl: string): Promise<ApiResponse<UserInfo$1>>;
107
+ declare function queryResource(baseUrl: string, params: {
108
+ systemId: string;
109
+ }): Promise<ApiResponse<Resource[]>>;
110
+ declare function getOrgTree(baseUrl: string, params: {
111
+ systemId: string;
112
+ name: CodeSourceType;
113
+ }): Promise<ApiResponse<OrgRecord$1>>;
114
+ declare function getUserOrgTree(baseUrl: string, params: UserOrgTreeParams): Promise<ApiResponse<OrgRecord$1[]>>;
115
+ declare function queryOrgCompanies(baseUrl: string, params: {
116
+ queryAllBranches?: boolean;
117
+ }): Promise<ApiResponse<OrgRecord$1[]>>;
118
+
16
119
  interface MenuItem {
17
120
  icon?: string;
18
121
  path: string;
@@ -58,7 +161,7 @@ interface ChildOrganization {
58
161
  orgShortName: string;
59
162
  orgType: string;
60
163
  }
61
- interface OrgRecord$1 {
164
+ interface OrgRecord {
62
165
  allOrgTags: boolean;
63
166
  allSystem: boolean;
64
167
  canModify: boolean;
@@ -97,16 +200,6 @@ declare function handlePermissionTree<T extends {
97
200
  noAuthMap: Record<number | string, T>;
98
201
  };
99
202
 
100
- interface OrgRecord {
101
- orgId: number;
102
- orgName: string;
103
- orgShortName: string;
104
- orgCode: string;
105
- nodeLevel: number;
106
- hasPermission: boolean;
107
- children?: OrgRecord[];
108
- }
109
-
110
203
  interface PermissionOptions {
111
204
  systemId: string;
112
205
  baseUrl: string;
@@ -115,7 +208,7 @@ interface PermissionOptions {
115
208
  * 组织树处理工具
116
209
  */
117
210
  declare const DataHandler: {
118
- iterateOrgTree(orgTree: OrgRecord[]): OrgTreeItem[];
211
+ iterateOrgTree(orgTree: OrgRecord$1[]): OrgTreeItem[];
119
212
  iterateNestedArray: typeof iterateNestedArray;
120
213
  getAllUnitOptions(orgTree: OrgTreeItem[]): Option[];
121
214
  getCompaniesOptions(orgTree: OrgTreeItem[], hasRootAuth: boolean): Option[];
@@ -140,8 +233,6 @@ declare const DataHandler: {
140
233
  };
141
234
  declare class Permission {
142
235
  private _userInfo;
143
- private _orgTree;
144
- private _orgCompany;
145
236
  private systemId;
146
237
  private baseUrl;
147
238
  resources: Resource[];
@@ -165,7 +256,7 @@ declare class Permission {
165
256
  */
166
257
  logout(clearData?: boolean): Promise<void>;
167
258
  clear(): void;
168
- getUserInfo(): Promise<UserInfo | null>;
259
+ getUserInfo(): Promise<UserInfo$1>;
169
260
  /**
170
261
  * Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
171
262
  */
@@ -181,27 +272,56 @@ declare class Permission {
181
272
  menuMap: Record<number, MenuItem>;
182
273
  }>;
183
274
  /**
184
- * Query and process organization tree
275
+ * Generate cache key for user orgs query
276
+ */
277
+ private generateUserOrgsCacheKey;
278
+ /**
279
+ * Query and process organization tree with caching
185
280
  */
186
- queryUserOrgs(): Promise<{
281
+ queryUserOrgs(params: UserOrgTreeParams, config?: {
282
+ force?: boolean;
283
+ cacheTimeout?: number;
284
+ }): Promise<{
187
285
  orgTree: OrgTreeItem[];
188
- orgNoAuthMap: Record<number, OrgTreeItem>;
189
- authOrgTree: OrgTreeItem[];
190
286
  } | null>;
191
- queryCompanies(): Promise<OrgRecord[]>;
192
287
  isLogin(): boolean;
193
288
  getToken(): string | null;
194
289
  setToken(token: string): void;
195
- get userInfo(): UserInfo | null;
196
- get hasRootAuth(): boolean;
197
- get userOrganizations(): UserOrganization[];
198
- get allCompanyOptions(): Option[];
199
- get companyOptions(): Option[];
200
- get firstCompanyOrgCode(): string;
201
- get unitOptions(): Option[];
202
- get allUnitOptions(): Option[];
203
- get firstUnitOrgCode(): string;
204
- get topLevelUnitOrgCodes(): string[];
290
+ /**
291
+ * Get storage information for debugging and monitoring
292
+ */
293
+ getStorageInfo(): {
294
+ permissionKeys: {
295
+ resourceKey: string;
296
+ tokenKey: string;
297
+ userInfoKey: string;
298
+ };
299
+ hasData: {
300
+ resources: boolean;
301
+ token: boolean;
302
+ userInfo: boolean;
303
+ };
304
+ cacheInfo: {
305
+ userOrgsCacheCount: number;
306
+ userOrgsCacheKeys: string[];
307
+ };
308
+ systemId: number | string | undefined;
309
+ currentVersion: string;
310
+ totalKeys: number;
311
+ systemKeys: number;
312
+ };
313
+ /**
314
+ * Get current storage version
315
+ */
316
+ getStorageVersion(): string;
317
+ /**
318
+ * Clear all storage data for this system
319
+ */
320
+ clearStorage(): void;
321
+ /**
322
+ * Clear user orgs cache for specific parameters or all
323
+ */
324
+ clearUserOrgsCache(params?: UserOrgTreeParams): void;
205
325
  }
206
326
 
207
327
  /**
@@ -226,4 +346,4 @@ declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
226
346
  clientId?: string;
227
347
  }): void;
228
348
 
229
- export { type ChildOrganization, DataHandler, type MenuItem, Permission as OpmsPermission, type Option, type OrgRecord$1 as OrgRecord, type OrgTreeItem, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
349
+ export { type ApiResponse, type ChildOrganization, type CodeSourceType, DataHandler, EnumOrgQueryMode, EnumOrgQueryScope, type MenuItem, type OpenIndicatorType, Permission as OpmsPermission, type Option, type OrgRecord, type OrgTreeItem, type Resource, type ResourceType, type UserInfo, type UserOrgTreeParams, type UserOrganization, type UserRole, getOrgTree, getUserInfo, getUserOrgTree, jumpToSSOLogin, jumpToSSOLogout, login, logout, queryOrgCompanies, queryResource };