@mu-cabin/opms-permission 0.9.9 → 0.9.10

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
@@ -44,7 +44,8 @@ __export(index_exports, {
44
44
  logout: () => logout,
45
45
  queryOrgCompanies: () => queryOrgCompanies,
46
46
  queryOrgCustom: () => queryOrgCustom,
47
- queryResource: () => queryResource
47
+ queryResource: () => queryResource,
48
+ superLogin: () => superLogin
48
49
  });
49
50
  module.exports = __toCommonJS(index_exports);
50
51
 
@@ -365,6 +366,12 @@ async function login(baseUrl, authorizationCode) {
365
366
  }
366
367
  );
367
368
  }
369
+ async function superLogin(baseUrl, params) {
370
+ return await axiosClient.post(
371
+ `${baseUrl}/opmsDefaultAuth/superLogin`,
372
+ params
373
+ );
374
+ }
368
375
  async function logout(baseUrl) {
369
376
  return await axiosClient.post(
370
377
  `${baseUrl}/opmsDefaultAuth/logout`
@@ -400,9 +407,9 @@ async function queryOrgCompanies(baseUrl, params) {
400
407
  params
401
408
  );
402
409
  }
403
- function queryOrgCustom(params) {
410
+ function queryOrgCustom(baseUrl, params) {
404
411
  return import_axios.default.post(
405
- "/api/opmsDefaultUser/queryOrgCustom",
412
+ `${baseUrl}/opmsDefaultUser/queryOrgCustom`,
406
413
  params
407
414
  );
408
415
  }
@@ -629,6 +636,23 @@ var Permission = class {
629
636
  isEventSupported(event) {
630
637
  return this.eventEmitter.isEventAllowed(event);
631
638
  }
639
+ async superLogin(userName, password) {
640
+ this.clear();
641
+ const { obj, msg, code } = await superLogin(this.baseUrl, {
642
+ userName,
643
+ password
644
+ });
645
+ if (code !== 200 || !obj.token) {
646
+ return Promise.reject({
647
+ code,
648
+ msg
649
+ });
650
+ }
651
+ const { token } = obj;
652
+ storage.setItem(TOKEN_KEY, token);
653
+ this.emit("tokenChange", token);
654
+ return token;
655
+ }
632
656
  /**
633
657
  * Login using code from URL, save userInfo
634
658
  */
@@ -778,7 +802,7 @@ var Permission = class {
778
802
  orgCompanyList = storage.getItem(USER_TOTAL_COMPANY_KEY);
779
803
  }
780
804
  if (!orgCompanyList) {
781
- const { obj } = await queryOrgCustom({
805
+ const { obj } = await queryOrgCustom(this.baseUrl, {
782
806
  resultView: "LIST",
783
807
  orgCodeSource: "COS",
784
808
  direction: "FROM_SELF_TO_LEAF",
@@ -936,5 +960,6 @@ function jumpToSSOLogout({
936
960
  logout,
937
961
  queryOrgCompanies,
938
962
  queryOrgCustom,
939
- queryResource
963
+ queryResource,
964
+ superLogin
940
965
  });
package/dist/index.d.mts CHANGED
@@ -101,6 +101,12 @@ interface UserOrgTreeParams {
101
101
  declare function login(baseUrl: string, authorizationCode: string): Promise<ApiResponse<{
102
102
  token: string;
103
103
  }>>;
104
+ declare function superLogin(baseUrl: string, params: {
105
+ userName: string;
106
+ password: string;
107
+ }): Promise<ApiResponse<{
108
+ token: string;
109
+ }>>;
104
110
  declare function logout(baseUrl: string): Promise<ApiResponse<void>>;
105
111
  declare function getUserInfo(baseUrl: string): Promise<ApiResponse<UserInfo$1>>;
106
112
  declare function queryResource(baseUrl: string, params: {
@@ -128,7 +134,7 @@ interface QueryOrgCustomParams {
128
134
  /**
129
135
  * 根据查询条件自定义组织机构查询
130
136
  */
131
- declare function queryOrgCustom(params: QueryOrgCustomParams): Promise<ApiResponse<OrgRecord$1[]>>;
137
+ declare function queryOrgCustom(baseUrl: string, params: QueryOrgCustomParams): Promise<ApiResponse<OrgRecord$1[]>>;
132
138
 
133
139
  interface MenuItem {
134
140
  icon?: string;
@@ -337,6 +343,7 @@ declare class Permission {
337
343
  * Check if an event is supported
338
344
  */
339
345
  isEventSupported(event: string): event is PermissionEventType;
346
+ superLogin(userName: string, password: string): Promise<string>;
340
347
  /**
341
348
  * Login using code from URL, save userInfo
342
349
  */
@@ -440,4 +447,4 @@ declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
440
447
  clientId?: string;
441
448
  }): void;
442
449
 
443
- export { type ApiResponse, type ChildOrganization, type CodeSourceType, DataHandler, EnumOrgQueryMode, EnumOrgQueryScope, EventEmitter, type MenuItem, type OpenIndicatorType, Permission as OpmsPermission, type Option, type OrgDirectionType, type OrgRecord, type OrgTreeItem, type OrgType, type PermissionEventListener, type PermissionEventMap, type PermissionEventType, type QueryOrgCustomParams, type Resource, type ResourceType, type ResultViewType, type UserInfo, type UserOrgTreeParams, type UserOrganization, type UserRole, getOrgTree, getUserInfo, getUserOrgTree, jumpToSSOLogin, jumpToSSOLogout, login, logout, queryOrgCompanies, queryOrgCustom, queryResource };
450
+ export { type ApiResponse, type ChildOrganization, type CodeSourceType, DataHandler, EnumOrgQueryMode, EnumOrgQueryScope, EventEmitter, type MenuItem, type OpenIndicatorType, Permission as OpmsPermission, type Option, type OrgDirectionType, type OrgRecord, type OrgTreeItem, type OrgType, type PermissionEventListener, type PermissionEventMap, type PermissionEventType, type QueryOrgCustomParams, type Resource, type ResourceType, type ResultViewType, type UserInfo, type UserOrgTreeParams, type UserOrganization, type UserRole, getOrgTree, getUserInfo, getUserOrgTree, jumpToSSOLogin, jumpToSSOLogout, login, logout, queryOrgCompanies, queryOrgCustom, queryResource, superLogin };
package/dist/index.d.ts CHANGED
@@ -101,6 +101,12 @@ interface UserOrgTreeParams {
101
101
  declare function login(baseUrl: string, authorizationCode: string): Promise<ApiResponse<{
102
102
  token: string;
103
103
  }>>;
104
+ declare function superLogin(baseUrl: string, params: {
105
+ userName: string;
106
+ password: string;
107
+ }): Promise<ApiResponse<{
108
+ token: string;
109
+ }>>;
104
110
  declare function logout(baseUrl: string): Promise<ApiResponse<void>>;
105
111
  declare function getUserInfo(baseUrl: string): Promise<ApiResponse<UserInfo$1>>;
106
112
  declare function queryResource(baseUrl: string, params: {
@@ -128,7 +134,7 @@ interface QueryOrgCustomParams {
128
134
  /**
129
135
  * 根据查询条件自定义组织机构查询
130
136
  */
131
- declare function queryOrgCustom(params: QueryOrgCustomParams): Promise<ApiResponse<OrgRecord$1[]>>;
137
+ declare function queryOrgCustom(baseUrl: string, params: QueryOrgCustomParams): Promise<ApiResponse<OrgRecord$1[]>>;
132
138
 
133
139
  interface MenuItem {
134
140
  icon?: string;
@@ -337,6 +343,7 @@ declare class Permission {
337
343
  * Check if an event is supported
338
344
  */
339
345
  isEventSupported(event: string): event is PermissionEventType;
346
+ superLogin(userName: string, password: string): Promise<string>;
340
347
  /**
341
348
  * Login using code from URL, save userInfo
342
349
  */
@@ -440,4 +447,4 @@ declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
440
447
  clientId?: string;
441
448
  }): void;
442
449
 
443
- export { type ApiResponse, type ChildOrganization, type CodeSourceType, DataHandler, EnumOrgQueryMode, EnumOrgQueryScope, EventEmitter, type MenuItem, type OpenIndicatorType, Permission as OpmsPermission, type Option, type OrgDirectionType, type OrgRecord, type OrgTreeItem, type OrgType, type PermissionEventListener, type PermissionEventMap, type PermissionEventType, type QueryOrgCustomParams, type Resource, type ResourceType, type ResultViewType, type UserInfo, type UserOrgTreeParams, type UserOrganization, type UserRole, getOrgTree, getUserInfo, getUserOrgTree, jumpToSSOLogin, jumpToSSOLogout, login, logout, queryOrgCompanies, queryOrgCustom, queryResource };
450
+ export { type ApiResponse, type ChildOrganization, type CodeSourceType, DataHandler, EnumOrgQueryMode, EnumOrgQueryScope, EventEmitter, type MenuItem, type OpenIndicatorType, Permission as OpmsPermission, type Option, type OrgDirectionType, type OrgRecord, type OrgTreeItem, type OrgType, type PermissionEventListener, type PermissionEventMap, type PermissionEventType, type QueryOrgCustomParams, type Resource, type ResourceType, type ResultViewType, type UserInfo, type UserOrgTreeParams, type UserOrganization, type UserRole, getOrgTree, getUserInfo, getUserOrgTree, jumpToSSOLogin, jumpToSSOLogout, login, logout, queryOrgCompanies, queryOrgCustom, queryResource, superLogin };
package/dist/index.mjs CHANGED
@@ -315,6 +315,12 @@ async function login(baseUrl, authorizationCode) {
315
315
  }
316
316
  );
317
317
  }
318
+ async function superLogin(baseUrl, params) {
319
+ return await axiosClient.post(
320
+ `${baseUrl}/opmsDefaultAuth/superLogin`,
321
+ params
322
+ );
323
+ }
318
324
  async function logout(baseUrl) {
319
325
  return await axiosClient.post(
320
326
  `${baseUrl}/opmsDefaultAuth/logout`
@@ -350,9 +356,9 @@ async function queryOrgCompanies(baseUrl, params) {
350
356
  params
351
357
  );
352
358
  }
353
- function queryOrgCustom(params) {
359
+ function queryOrgCustom(baseUrl, params) {
354
360
  return axios.post(
355
- "/api/opmsDefaultUser/queryOrgCustom",
361
+ `${baseUrl}/opmsDefaultUser/queryOrgCustom`,
356
362
  params
357
363
  );
358
364
  }
@@ -579,6 +585,23 @@ var Permission = class {
579
585
  isEventSupported(event) {
580
586
  return this.eventEmitter.isEventAllowed(event);
581
587
  }
588
+ async superLogin(userName, password) {
589
+ this.clear();
590
+ const { obj, msg, code } = await superLogin(this.baseUrl, {
591
+ userName,
592
+ password
593
+ });
594
+ if (code !== 200 || !obj.token) {
595
+ return Promise.reject({
596
+ code,
597
+ msg
598
+ });
599
+ }
600
+ const { token } = obj;
601
+ storage.setItem(TOKEN_KEY, token);
602
+ this.emit("tokenChange", token);
603
+ return token;
604
+ }
582
605
  /**
583
606
  * Login using code from URL, save userInfo
584
607
  */
@@ -728,7 +751,7 @@ var Permission = class {
728
751
  orgCompanyList = storage.getItem(USER_TOTAL_COMPANY_KEY);
729
752
  }
730
753
  if (!orgCompanyList) {
731
- const { obj } = await queryOrgCustom({
754
+ const { obj } = await queryOrgCustom(this.baseUrl, {
732
755
  resultView: "LIST",
733
756
  orgCodeSource: "COS",
734
757
  direction: "FROM_SELF_TO_LEAF",
@@ -885,5 +908,6 @@ export {
885
908
  logout,
886
909
  queryOrgCompanies,
887
910
  queryOrgCustom,
888
- queryResource
911
+ queryResource,
912
+ superLogin
889
913
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mu-cabin/opms-permission",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "description": "Frontend SDK for OPMS permission and auth management.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",