@mu-cabin/opms-permission 0.1.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/README.md +86 -0
- package/dist/index.cjs +529 -0
- package/dist/index.d.mts +171 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.mjs +490 -0
- package/package.json +29 -0
package/dist/index.d.mts
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
interface UserOrganization$1 {
|
2
|
+
orgId: number;
|
3
|
+
orgCode: string;
|
4
|
+
parentOrgId: number | null;
|
5
|
+
parentOrgCode: string | null;
|
6
|
+
branchId: number | null;
|
7
|
+
branchCode: string | null;
|
8
|
+
orgName: string;
|
9
|
+
orgShortName: string;
|
10
|
+
orgType: string;
|
11
|
+
showOrder: number | null;
|
12
|
+
orgCodeSearchPath: string;
|
13
|
+
positionInfo: any[];
|
14
|
+
orgBindType: string;
|
15
|
+
csmOrgCode: string | null;
|
16
|
+
hasPermission: boolean;
|
17
|
+
canModify: boolean;
|
18
|
+
nodeLevel: number;
|
19
|
+
searchPath: string;
|
20
|
+
children: UserOrganization$1[];
|
21
|
+
}
|
22
|
+
interface UserRole {
|
23
|
+
roleId: number;
|
24
|
+
roleName: string;
|
25
|
+
parentRoleId: number | null;
|
26
|
+
grantType: string;
|
27
|
+
nodeLevel: number | null;
|
28
|
+
searchPath: string | null;
|
29
|
+
children: UserRole[];
|
30
|
+
}
|
31
|
+
interface UserInfo$1 {
|
32
|
+
ehrId: number;
|
33
|
+
account: string;
|
34
|
+
crewId: number | null;
|
35
|
+
crewCode: string | null;
|
36
|
+
name: string;
|
37
|
+
individualType: string | null;
|
38
|
+
individualStatus: string | null;
|
39
|
+
opmsRole: string;
|
40
|
+
userOrganizations: UserOrganization$1[];
|
41
|
+
userRoles: UserRole[];
|
42
|
+
uniAccount: string;
|
43
|
+
}
|
44
|
+
|
45
|
+
interface Resource {
|
46
|
+
resourceId: number;
|
47
|
+
resourceCode: string;
|
48
|
+
resourceName?: string;
|
49
|
+
showName?: string;
|
50
|
+
resourceType?: string;
|
51
|
+
defaultResourceType?: string;
|
52
|
+
componentPath?: string;
|
53
|
+
defaultUrl?: string;
|
54
|
+
icon?: string;
|
55
|
+
defaultIcon?: string;
|
56
|
+
openIndicator: string;
|
57
|
+
prefix?: string;
|
58
|
+
children?: Resource[];
|
59
|
+
}
|
60
|
+
interface MenuItem {
|
61
|
+
icon?: string;
|
62
|
+
path: string;
|
63
|
+
name: string;
|
64
|
+
children: MenuItem[];
|
65
|
+
resourceId: number;
|
66
|
+
openIndicator: string;
|
67
|
+
}
|
68
|
+
interface UserInfo {
|
69
|
+
account: string;
|
70
|
+
name: string;
|
71
|
+
ehrId: number;
|
72
|
+
crewCode: string;
|
73
|
+
crewId: number;
|
74
|
+
}
|
75
|
+
interface UserOrganization {
|
76
|
+
orgId: number;
|
77
|
+
orgCode: string;
|
78
|
+
orgName: string;
|
79
|
+
orgShortName: string;
|
80
|
+
orgType: string;
|
81
|
+
}
|
82
|
+
|
83
|
+
interface PermissionOptions {
|
84
|
+
systemId: number;
|
85
|
+
baseUrl: string;
|
86
|
+
ssoBaseUrl: string;
|
87
|
+
}
|
88
|
+
declare class Permission {
|
89
|
+
private _userInfo;
|
90
|
+
private _orgTree;
|
91
|
+
private _orgCompany;
|
92
|
+
private systemId;
|
93
|
+
private baseUrl;
|
94
|
+
resources: Resource[];
|
95
|
+
resourceMap: {
|
96
|
+
[path: string]: Resource;
|
97
|
+
};
|
98
|
+
widgetMap: {
|
99
|
+
[path: string]: Resource;
|
100
|
+
};
|
101
|
+
menuList: MenuItem[];
|
102
|
+
menuMap: {
|
103
|
+
[path: string]: MenuItem;
|
104
|
+
};
|
105
|
+
constructor(options: PermissionOptions);
|
106
|
+
/**
|
107
|
+
* Login using code from URL, save userInfo
|
108
|
+
*/
|
109
|
+
login(): Promise<string>;
|
110
|
+
/**
|
111
|
+
* Logout and clear userInfo
|
112
|
+
*/
|
113
|
+
logout(): Promise<void>;
|
114
|
+
clear(): void;
|
115
|
+
getUserInfo(): Promise<UserInfo$1>;
|
116
|
+
/**
|
117
|
+
* Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
|
118
|
+
*/
|
119
|
+
getResources(): Promise<{
|
120
|
+
resources: Resource[];
|
121
|
+
resourceMap: {
|
122
|
+
[path: string]: Resource;
|
123
|
+
};
|
124
|
+
widgetMap: {
|
125
|
+
[path: string]: Resource;
|
126
|
+
};
|
127
|
+
menuList: MenuItem[];
|
128
|
+
menuMap: Record<number, MenuItem>;
|
129
|
+
}>;
|
130
|
+
/**
|
131
|
+
* Query and process organization tree
|
132
|
+
*/
|
133
|
+
queryOrgs(): Promise<any>;
|
134
|
+
queryCompanies(): Promise<void>;
|
135
|
+
isLogin(): boolean;
|
136
|
+
getToken(): unknown;
|
137
|
+
get userInfo(): UserInfo | null;
|
138
|
+
get hasRootAuth(): boolean;
|
139
|
+
get userOrganizations(): UserOrganization[];
|
140
|
+
get allCompanyOptions(): any;
|
141
|
+
get companyOptions(): any;
|
142
|
+
get firstCompanyOrgCode(): string;
|
143
|
+
get unitOptions(): any;
|
144
|
+
get allUnitOptions(): any;
|
145
|
+
get firstUnitOrgCode(): string;
|
146
|
+
get topLevelUnitOrgCodes(): string[];
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Redirects to SSO login page with a redirect_uri parameter
|
151
|
+
* @param ssoLoginUrl The SSO login URL (e.g. from VITE_SSO_LOGIN_URL)
|
152
|
+
* @param redirectUrl Optional redirect URL (defaults to current location)
|
153
|
+
*/
|
154
|
+
declare function jumpToSSOLogin({ baseUrl, redirectUrl, clientId, }: {
|
155
|
+
baseUrl: string;
|
156
|
+
redirectUrl?: string;
|
157
|
+
clientId?: string;
|
158
|
+
}): void;
|
159
|
+
/**
|
160
|
+
* Redirects to SSO logout page with required parameters
|
161
|
+
* @param baseUrl The SSO base URL (e.g. https://bamtest.ceair.com/idp)
|
162
|
+
* @param redirectToUrl The URL to redirect to after logout
|
163
|
+
* @param clientId Optional clientId/entityId for the SSO system
|
164
|
+
*/
|
165
|
+
declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
|
166
|
+
baseUrl: string;
|
167
|
+
redirectToUrl: string;
|
168
|
+
clientId?: string;
|
169
|
+
}): void;
|
170
|
+
|
171
|
+
export { type MenuItem, Permission as OpmsPermission, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
interface UserOrganization$1 {
|
2
|
+
orgId: number;
|
3
|
+
orgCode: string;
|
4
|
+
parentOrgId: number | null;
|
5
|
+
parentOrgCode: string | null;
|
6
|
+
branchId: number | null;
|
7
|
+
branchCode: string | null;
|
8
|
+
orgName: string;
|
9
|
+
orgShortName: string;
|
10
|
+
orgType: string;
|
11
|
+
showOrder: number | null;
|
12
|
+
orgCodeSearchPath: string;
|
13
|
+
positionInfo: any[];
|
14
|
+
orgBindType: string;
|
15
|
+
csmOrgCode: string | null;
|
16
|
+
hasPermission: boolean;
|
17
|
+
canModify: boolean;
|
18
|
+
nodeLevel: number;
|
19
|
+
searchPath: string;
|
20
|
+
children: UserOrganization$1[];
|
21
|
+
}
|
22
|
+
interface UserRole {
|
23
|
+
roleId: number;
|
24
|
+
roleName: string;
|
25
|
+
parentRoleId: number | null;
|
26
|
+
grantType: string;
|
27
|
+
nodeLevel: number | null;
|
28
|
+
searchPath: string | null;
|
29
|
+
children: UserRole[];
|
30
|
+
}
|
31
|
+
interface UserInfo$1 {
|
32
|
+
ehrId: number;
|
33
|
+
account: string;
|
34
|
+
crewId: number | null;
|
35
|
+
crewCode: string | null;
|
36
|
+
name: string;
|
37
|
+
individualType: string | null;
|
38
|
+
individualStatus: string | null;
|
39
|
+
opmsRole: string;
|
40
|
+
userOrganizations: UserOrganization$1[];
|
41
|
+
userRoles: UserRole[];
|
42
|
+
uniAccount: string;
|
43
|
+
}
|
44
|
+
|
45
|
+
interface Resource {
|
46
|
+
resourceId: number;
|
47
|
+
resourceCode: string;
|
48
|
+
resourceName?: string;
|
49
|
+
showName?: string;
|
50
|
+
resourceType?: string;
|
51
|
+
defaultResourceType?: string;
|
52
|
+
componentPath?: string;
|
53
|
+
defaultUrl?: string;
|
54
|
+
icon?: string;
|
55
|
+
defaultIcon?: string;
|
56
|
+
openIndicator: string;
|
57
|
+
prefix?: string;
|
58
|
+
children?: Resource[];
|
59
|
+
}
|
60
|
+
interface MenuItem {
|
61
|
+
icon?: string;
|
62
|
+
path: string;
|
63
|
+
name: string;
|
64
|
+
children: MenuItem[];
|
65
|
+
resourceId: number;
|
66
|
+
openIndicator: string;
|
67
|
+
}
|
68
|
+
interface UserInfo {
|
69
|
+
account: string;
|
70
|
+
name: string;
|
71
|
+
ehrId: number;
|
72
|
+
crewCode: string;
|
73
|
+
crewId: number;
|
74
|
+
}
|
75
|
+
interface UserOrganization {
|
76
|
+
orgId: number;
|
77
|
+
orgCode: string;
|
78
|
+
orgName: string;
|
79
|
+
orgShortName: string;
|
80
|
+
orgType: string;
|
81
|
+
}
|
82
|
+
|
83
|
+
interface PermissionOptions {
|
84
|
+
systemId: number;
|
85
|
+
baseUrl: string;
|
86
|
+
ssoBaseUrl: string;
|
87
|
+
}
|
88
|
+
declare class Permission {
|
89
|
+
private _userInfo;
|
90
|
+
private _orgTree;
|
91
|
+
private _orgCompany;
|
92
|
+
private systemId;
|
93
|
+
private baseUrl;
|
94
|
+
resources: Resource[];
|
95
|
+
resourceMap: {
|
96
|
+
[path: string]: Resource;
|
97
|
+
};
|
98
|
+
widgetMap: {
|
99
|
+
[path: string]: Resource;
|
100
|
+
};
|
101
|
+
menuList: MenuItem[];
|
102
|
+
menuMap: {
|
103
|
+
[path: string]: MenuItem;
|
104
|
+
};
|
105
|
+
constructor(options: PermissionOptions);
|
106
|
+
/**
|
107
|
+
* Login using code from URL, save userInfo
|
108
|
+
*/
|
109
|
+
login(): Promise<string>;
|
110
|
+
/**
|
111
|
+
* Logout and clear userInfo
|
112
|
+
*/
|
113
|
+
logout(): Promise<void>;
|
114
|
+
clear(): void;
|
115
|
+
getUserInfo(): Promise<UserInfo$1>;
|
116
|
+
/**
|
117
|
+
* Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
|
118
|
+
*/
|
119
|
+
getResources(): Promise<{
|
120
|
+
resources: Resource[];
|
121
|
+
resourceMap: {
|
122
|
+
[path: string]: Resource;
|
123
|
+
};
|
124
|
+
widgetMap: {
|
125
|
+
[path: string]: Resource;
|
126
|
+
};
|
127
|
+
menuList: MenuItem[];
|
128
|
+
menuMap: Record<number, MenuItem>;
|
129
|
+
}>;
|
130
|
+
/**
|
131
|
+
* Query and process organization tree
|
132
|
+
*/
|
133
|
+
queryOrgs(): Promise<any>;
|
134
|
+
queryCompanies(): Promise<void>;
|
135
|
+
isLogin(): boolean;
|
136
|
+
getToken(): unknown;
|
137
|
+
get userInfo(): UserInfo | null;
|
138
|
+
get hasRootAuth(): boolean;
|
139
|
+
get userOrganizations(): UserOrganization[];
|
140
|
+
get allCompanyOptions(): any;
|
141
|
+
get companyOptions(): any;
|
142
|
+
get firstCompanyOrgCode(): string;
|
143
|
+
get unitOptions(): any;
|
144
|
+
get allUnitOptions(): any;
|
145
|
+
get firstUnitOrgCode(): string;
|
146
|
+
get topLevelUnitOrgCodes(): string[];
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Redirects to SSO login page with a redirect_uri parameter
|
151
|
+
* @param ssoLoginUrl The SSO login URL (e.g. from VITE_SSO_LOGIN_URL)
|
152
|
+
* @param redirectUrl Optional redirect URL (defaults to current location)
|
153
|
+
*/
|
154
|
+
declare function jumpToSSOLogin({ baseUrl, redirectUrl, clientId, }: {
|
155
|
+
baseUrl: string;
|
156
|
+
redirectUrl?: string;
|
157
|
+
clientId?: string;
|
158
|
+
}): void;
|
159
|
+
/**
|
160
|
+
* Redirects to SSO logout page with required parameters
|
161
|
+
* @param baseUrl The SSO base URL (e.g. https://bamtest.ceair.com/idp)
|
162
|
+
* @param redirectToUrl The URL to redirect to after logout
|
163
|
+
* @param clientId Optional clientId/entityId for the SSO system
|
164
|
+
*/
|
165
|
+
declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
|
166
|
+
baseUrl: string;
|
167
|
+
redirectToUrl: string;
|
168
|
+
clientId?: string;
|
169
|
+
}): void;
|
170
|
+
|
171
|
+
export { type MenuItem, Permission as OpmsPermission, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
|