@laiye_packages/uci 1.0.7 → 1.0.8
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/app/base/index.d.ts +1 -0
- package/dist/app/index.d.ts +9 -2
- package/dist/app/organization/api/department.d.ts +205 -11
- package/dist/app/organization/api/license.d.ts +5 -0
- package/dist/app/organization/api/permission.d.ts +240 -58
- package/dist/app/organization/api/session.d.ts +9 -0
- package/dist/app/organization/api/user.d.ts +311 -21
- package/dist/app/organization/app/index.d.ts +71 -0
- package/dist/app/organization/authorizer/base.d.ts +1 -1
- package/dist/app/organization/authorizer/web.d.ts +51 -1
- package/dist/config/app.d.ts +1 -0
- package/dist/config/crypto.d.ts +1 -0
- package/dist/index.js +322 -30
- package/dist/index.js.map +1 -1
- package/dist/permission/index.d.ts +27 -1
- package/dist/session/index.d.ts +27 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3272,7 +3272,7 @@ var __webpack_modules__ = {
|
|
|
3272
3272
|
}
|
|
3273
3273
|
exports._extends = _extends;
|
|
3274
3274
|
},
|
|
3275
|
-
"../../node_modules/.pnpm/dayjs@1.11.
|
|
3275
|
+
"../../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/dayjs.min.js": function(module) {
|
|
3276
3276
|
!function(t, e) {
|
|
3277
3277
|
module.exports = e();
|
|
3278
3278
|
}(0, function() {
|
|
@@ -3624,7 +3624,7 @@ var __webpack_modules__ = {
|
|
|
3624
3624
|
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
3625
3625
|
});
|
|
3626
3626
|
},
|
|
3627
|
-
"../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.
|
|
3627
|
+
"../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.9_react-dom@18.3.1_react@18.3.1_typescript@5.9.3_webpack@5.105.4/node_modules/@module-federation/enhanced/dist/src/runtime.js": function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3628
3628
|
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3629
3629
|
if (void 0 === k2) k2 = k;
|
|
3630
3630
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -3950,7 +3950,7 @@ function __webpack_require__(moduleId) {
|
|
|
3950
3950
|
(()=>{
|
|
3951
3951
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
3952
3952
|
})();
|
|
3953
|
-
var dayjs_min = __webpack_require__("../../node_modules/.pnpm/dayjs@1.11.
|
|
3953
|
+
var dayjs_min = __webpack_require__("../../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/dayjs.min.js");
|
|
3954
3954
|
var dayjs_min_default = /*#__PURE__*/ __webpack_require__.n(dayjs_min);
|
|
3955
3955
|
var logger_LYLogLevel = /*#__PURE__*/ function(LYLogLevel) {
|
|
3956
3956
|
LYLogLevel[LYLogLevel["NONE"] = 0] = "NONE";
|
|
@@ -4515,12 +4515,12 @@ http_ts_decorate([
|
|
|
4515
4515
|
], LYHttpConfig.prototype, "retry", void 0);
|
|
4516
4516
|
class LYCryptoConfig extends LYBaseConfigModel {
|
|
4517
4517
|
constructor(...args){
|
|
4518
|
-
super(...args), this.type = 'default';
|
|
4518
|
+
super(...args), this.type = 'default', this.encrypt_public_key = '';
|
|
4519
4519
|
}
|
|
4520
4520
|
}
|
|
4521
4521
|
class LYAppConfig extends LYBaseConfigModel {
|
|
4522
4522
|
constructor(...args){
|
|
4523
|
-
super(...args), this.name = '', this.version = '';
|
|
4523
|
+
super(...args), this.name = '', this.version = '', this.display_name = '';
|
|
4524
4524
|
}
|
|
4525
4525
|
}
|
|
4526
4526
|
class LYAddressConfig extends LYBaseConfigModel {
|
|
@@ -9704,18 +9704,32 @@ class LYAppHttpError extends LYBaseHttpError {
|
|
|
9704
9704
|
}
|
|
9705
9705
|
}
|
|
9706
9706
|
class LYAppPermission extends LYObject {
|
|
9707
|
-
constructor(app_name, codes){
|
|
9707
|
+
constructor(app_name, codes, allCodes){
|
|
9708
9708
|
super(), this._codes = {};
|
|
9709
9709
|
this._app_name = app_name;
|
|
9710
9710
|
this._codes = codes;
|
|
9711
|
+
this._allCodes = allCodes;
|
|
9711
9712
|
}
|
|
9712
9713
|
get app_name() {
|
|
9713
9714
|
return this._app_name;
|
|
9714
9715
|
}
|
|
9716
|
+
get codes() {
|
|
9717
|
+
return Object.keys(this._codes);
|
|
9718
|
+
}
|
|
9719
|
+
get allCodes() {
|
|
9720
|
+
return this._allCodes;
|
|
9721
|
+
}
|
|
9722
|
+
setAllCodes(codes) {
|
|
9723
|
+
this._allCodes = codes;
|
|
9724
|
+
}
|
|
9715
9725
|
getActions(code) {
|
|
9716
9726
|
if (!(code in this._codes)) return [];
|
|
9717
9727
|
return this._codes[code];
|
|
9718
9728
|
}
|
|
9729
|
+
hasPermission(code) {
|
|
9730
|
+
if (this._allCodes.length > 0 && !this._allCodes.includes(code)) return true;
|
|
9731
|
+
return code in this._codes;
|
|
9732
|
+
}
|
|
9719
9733
|
}
|
|
9720
9734
|
function session_ts_decorate(decorators, target, key, desc) {
|
|
9721
9735
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -9731,6 +9745,12 @@ class LYSession extends LYObject {
|
|
|
9731
9745
|
static{
|
|
9732
9746
|
this._CHECK_INTERVAL = 10000;
|
|
9733
9747
|
}
|
|
9748
|
+
static setAllCodesProvider(provider) {
|
|
9749
|
+
LYSession._allCodesProvider = provider;
|
|
9750
|
+
}
|
|
9751
|
+
static setOnSessionCreated(callback) {
|
|
9752
|
+
LYSession._onSessionCreated = callback;
|
|
9753
|
+
}
|
|
9734
9754
|
static get() {
|
|
9735
9755
|
if (!LYSession._session) {
|
|
9736
9756
|
const session = sharedLocalStorage.getSync(SESSION_KEY);
|
|
@@ -9762,6 +9782,9 @@ class LYSession extends LYObject {
|
|
|
9762
9782
|
country_code: country_code || ''
|
|
9763
9783
|
});
|
|
9764
9784
|
LYSession._startRefreshTimer();
|
|
9785
|
+
if (LYSession._onSessionCreated) LYSession._onSessionCreated().catch((err)=>{
|
|
9786
|
+
console.error('Session created callback error:', err);
|
|
9787
|
+
});
|
|
9765
9788
|
return LYSession._session;
|
|
9766
9789
|
}
|
|
9767
9790
|
static clear() {
|
|
@@ -9785,7 +9808,8 @@ class LYSession extends LYObject {
|
|
|
9785
9808
|
this._phone = phone || '';
|
|
9786
9809
|
this._country_code = country_code || '';
|
|
9787
9810
|
this._permissions = Object.entries(permissions || {}).reduce((acc, [app_name, codes])=>{
|
|
9788
|
-
|
|
9811
|
+
const allCodes = LYSession._allCodesProvider ? LYSession._allCodesProvider(app_name) : [];
|
|
9812
|
+
acc[app_name] = new LYAppPermission(app_name, codes, allCodes);
|
|
9789
9813
|
return acc;
|
|
9790
9814
|
}, {});
|
|
9791
9815
|
}
|
|
@@ -9879,7 +9903,8 @@ class LYSession extends LYObject {
|
|
|
9879
9903
|
if (void 0 !== phone) LYSession._session._phone = phone;
|
|
9880
9904
|
if (void 0 !== country_code) LYSession._session._country_code = country_code;
|
|
9881
9905
|
LYSession._session._permissions = Object.entries(permissions || {}).reduce((acc, [app_name, codes])=>{
|
|
9882
|
-
|
|
9906
|
+
const allCodes = LYSession._allCodesProvider ? LYSession._allCodesProvider(app_name) : [];
|
|
9907
|
+
acc[app_name] = new LYAppPermission(app_name, codes, allCodes);
|
|
9883
9908
|
return acc;
|
|
9884
9909
|
}, {});
|
|
9885
9910
|
sharedLocalStorage.setSync(SESSION_KEY, {
|
|
@@ -10507,7 +10532,7 @@ LYi18n = i18n_ts_decorate([
|
|
|
10507
10532
|
String
|
|
10508
10533
|
])
|
|
10509
10534
|
], LYi18n);
|
|
10510
|
-
var runtime = __webpack_require__("../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.
|
|
10535
|
+
var runtime = __webpack_require__("../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.9_react-dom@18.3.1_react@18.3.1_typescript@5.9.3_webpack@5.105.4/node_modules/@module-federation/enhanced/dist/src/runtime.js");
|
|
10511
10536
|
class LYBaseCrypto {
|
|
10512
10537
|
}
|
|
10513
10538
|
function registerCryptoImpl(name1) {
|
|
@@ -11158,6 +11183,7 @@ class base_LYBaseApp extends LYObject {
|
|
|
11158
11183
|
async doLoad() {
|
|
11159
11184
|
await this.initI18n();
|
|
11160
11185
|
}
|
|
11186
|
+
async updatePermissions() {}
|
|
11161
11187
|
getBaseUrl() {
|
|
11162
11188
|
const config = LYConfig.get();
|
|
11163
11189
|
const url = new URL(window.location.href);
|
|
@@ -11309,8 +11335,14 @@ class LYUserApi {
|
|
|
11309
11335
|
const response = await this._httpClient.get('/user', params);
|
|
11310
11336
|
return response.data;
|
|
11311
11337
|
}
|
|
11312
|
-
async
|
|
11313
|
-
const response = await this._httpClient.
|
|
11338
|
+
async setPassword(newPassword) {
|
|
11339
|
+
const response = await this._httpClient.post("/user/password/init", {
|
|
11340
|
+
new_password: newPassword
|
|
11341
|
+
});
|
|
11342
|
+
return response.data;
|
|
11343
|
+
}
|
|
11344
|
+
async get(id) {
|
|
11345
|
+
const response = await this._httpClient.get(`/user/${id}`);
|
|
11314
11346
|
return response.data;
|
|
11315
11347
|
}
|
|
11316
11348
|
async add(user) {
|
|
@@ -11320,15 +11352,15 @@ class LYUserApi {
|
|
|
11320
11352
|
});
|
|
11321
11353
|
return response.data.id;
|
|
11322
11354
|
}
|
|
11323
|
-
async update(
|
|
11324
|
-
const response = await this._httpClient.post(`/user/patch/${
|
|
11355
|
+
async update(id, user) {
|
|
11356
|
+
const response = await this._httpClient.post(`/user/patch/${id}`, {
|
|
11325
11357
|
...user,
|
|
11326
11358
|
password: user.password
|
|
11327
11359
|
});
|
|
11328
11360
|
return response.data.count;
|
|
11329
11361
|
}
|
|
11330
|
-
async remove(
|
|
11331
|
-
const response = await this._httpClient.post(`/user/delete/${
|
|
11362
|
+
async remove(id, request) {
|
|
11363
|
+
const response = await this._httpClient.post(`/user/delete/${id}`, request);
|
|
11332
11364
|
return response.data.count;
|
|
11333
11365
|
}
|
|
11334
11366
|
async accountCheck(request) {
|
|
@@ -11347,10 +11379,10 @@ class LYUserApi {
|
|
|
11347
11379
|
const response = await this._httpClient.get(`/user/username-check/${name1}`);
|
|
11348
11380
|
return response.data.available;
|
|
11349
11381
|
}
|
|
11350
|
-
async changePassword(
|
|
11382
|
+
async changePassword(request) {
|
|
11351
11383
|
const response = await this._httpClient.post("/user/password/change", {
|
|
11352
|
-
current_password:
|
|
11353
|
-
new_password:
|
|
11384
|
+
current_password: request.current_password,
|
|
11385
|
+
new_password: request.new_password
|
|
11354
11386
|
});
|
|
11355
11387
|
return response.data;
|
|
11356
11388
|
}
|
|
@@ -11360,6 +11392,14 @@ class LYUserApi {
|
|
|
11360
11392
|
});
|
|
11361
11393
|
return response.data;
|
|
11362
11394
|
}
|
|
11395
|
+
async getSettings() {
|
|
11396
|
+
const response = await this._httpClient.get("/user/settings");
|
|
11397
|
+
return response.data;
|
|
11398
|
+
}
|
|
11399
|
+
async updateSettings(request) {
|
|
11400
|
+
const response = await this._httpClient.post("/user/settings/patch", request);
|
|
11401
|
+
return response.data.count;
|
|
11402
|
+
}
|
|
11363
11403
|
}
|
|
11364
11404
|
const base_ORGANIZATION_APP_NAME = 'organization';
|
|
11365
11405
|
class LYBaseAuthorizer extends LYObject {
|
|
@@ -11406,18 +11446,96 @@ class LYWebAuthorizer extends LYBaseAuthorizer {
|
|
|
11406
11446
|
this._sessionApi = sessionApi;
|
|
11407
11447
|
LYSession.setRefreshCallback(this._refreshSession.bind(this));
|
|
11408
11448
|
}
|
|
11409
|
-
|
|
11449
|
+
static parseClientLoginParams() {
|
|
11450
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
11451
|
+
const hash = window.location.hash;
|
|
11452
|
+
const hashParams = new URLSearchParams(hash.includes('?') ? hash.split('?')[1] : '');
|
|
11453
|
+
const getParam = (key)=>searchParams.get(key) || hashParams.get(key) || void 0;
|
|
11454
|
+
return {
|
|
11455
|
+
response_type: getParam('response_type'),
|
|
11456
|
+
client_id: getParam('client_id'),
|
|
11457
|
+
return_url: getParam('return_url'),
|
|
11458
|
+
api_base_url: getParam('api_base_url'),
|
|
11459
|
+
state: getParam('state'),
|
|
11460
|
+
tenant_name: getParam('tenant_name'),
|
|
11461
|
+
client_type: getParam('client_type'),
|
|
11462
|
+
code: getParam('code')
|
|
11463
|
+
};
|
|
11464
|
+
}
|
|
11465
|
+
static getClientLoginArgs() {
|
|
11466
|
+
return LYWebAuthorizer.parseClientLoginParams();
|
|
11467
|
+
}
|
|
11468
|
+
static isClientLoginRequest() {
|
|
11469
|
+
const params = LYWebAuthorizer.getClientLoginArgs();
|
|
11470
|
+
return 'app' === params.client_type && !!params.client_id && !!params.return_url;
|
|
11471
|
+
}
|
|
11472
|
+
static isClientLoginCallback() {
|
|
11473
|
+
const params = LYWebAuthorizer.getClientLoginArgs();
|
|
11474
|
+
return !!params.code && !!params.return_url;
|
|
11475
|
+
}
|
|
11476
|
+
static handleClientLoginCallback() {
|
|
11477
|
+
const params = LYWebAuthorizer.getClientLoginArgs();
|
|
11478
|
+
if (!params.code || !params.return_url) return;
|
|
11479
|
+
const redirectUrl = new URL(params.return_url);
|
|
11480
|
+
redirectUrl.searchParams.set('code', params.code);
|
|
11481
|
+
redirectUrl.searchParams.set('state', params.state || '');
|
|
11482
|
+
redirectUrl.searchParams.set('tenant_name', params.tenant_name || '');
|
|
11483
|
+
redirectUrl.searchParams.set('api_base_url', params.api_base_url || '');
|
|
11484
|
+
window.location.href = redirectUrl.toString();
|
|
11485
|
+
}
|
|
11486
|
+
async signinWithResponse(args) {
|
|
11487
|
+
const clientParams = LYWebAuthorizer.getClientLoginArgs();
|
|
11488
|
+
const isClientLogin = 'app' === clientParams.client_type && !!clientParams.client_id && !!clientParams.return_url;
|
|
11489
|
+
const finalArgs = {
|
|
11490
|
+
...args,
|
|
11491
|
+
client_type: isClientLogin ? 'app' : args.client_type,
|
|
11492
|
+
client_data: isClientLogin ? {
|
|
11493
|
+
redirect_uri: clientParams.return_url,
|
|
11494
|
+
state: clientParams.state || '',
|
|
11495
|
+
client_id: clientParams.client_id
|
|
11496
|
+
} : args.client_data
|
|
11497
|
+
};
|
|
11410
11498
|
const response = await this._sessionApi.create({
|
|
11411
|
-
name:
|
|
11412
|
-
password:
|
|
11413
|
-
email:
|
|
11414
|
-
phone:
|
|
11415
|
-
country_code:
|
|
11416
|
-
account_type:
|
|
11417
|
-
verification_code:
|
|
11418
|
-
verification_code_id:
|
|
11419
|
-
|
|
11420
|
-
|
|
11499
|
+
name: finalArgs.name,
|
|
11500
|
+
password: finalArgs.password,
|
|
11501
|
+
email: finalArgs.email,
|
|
11502
|
+
phone: finalArgs.phone,
|
|
11503
|
+
country_code: finalArgs.country_code,
|
|
11504
|
+
account_type: finalArgs.account_type,
|
|
11505
|
+
verification_code: finalArgs.verification_code,
|
|
11506
|
+
verification_code_id: finalArgs.verification_code_id,
|
|
11507
|
+
client_type: finalArgs.client_type,
|
|
11508
|
+
client_data: finalArgs.client_data
|
|
11509
|
+
});
|
|
11510
|
+
if ('app' === finalArgs.client_type) {
|
|
11511
|
+
LYSession.create("web", '', response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes, response.is_first_login, response.display_name, response.email, response.phone, response.country_code);
|
|
11512
|
+
if (response.is_first_login) return response;
|
|
11513
|
+
if (response.auth_code) {
|
|
11514
|
+
const hashParams = new URLSearchParams({
|
|
11515
|
+
code: response.auth_code,
|
|
11516
|
+
return_url: finalArgs.client_data.redirect_uri,
|
|
11517
|
+
state: finalArgs.client_data.state,
|
|
11518
|
+
tenant_name: clientParams.tenant_name || '',
|
|
11519
|
+
api_base_url: clientParams.api_base_url || ''
|
|
11520
|
+
});
|
|
11521
|
+
setTimeout(()=>{
|
|
11522
|
+
window.location.href = `/view/organization/${clientParams.tenant_name}/#client-login?${hashParams.toString()}`;
|
|
11523
|
+
}, 0);
|
|
11524
|
+
}
|
|
11525
|
+
return {
|
|
11526
|
+
...response,
|
|
11527
|
+
redirect_handled: true
|
|
11528
|
+
};
|
|
11529
|
+
}
|
|
11530
|
+
LYSession.create("web", '', response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes, response.is_first_login, response.display_name, response.email, response.phone, response.country_code);
|
|
11531
|
+
this.emit('status-change', 'signed-in');
|
|
11532
|
+
if (finalArgs.redirect_uri) setTimeout(()=>{
|
|
11533
|
+
window.location.href = finalArgs.redirect_uri;
|
|
11534
|
+
}, 0);
|
|
11535
|
+
return response;
|
|
11536
|
+
}
|
|
11537
|
+
async _signin(args) {
|
|
11538
|
+
await this.signinWithResponse(args);
|
|
11421
11539
|
}
|
|
11422
11540
|
async _signout(args) {
|
|
11423
11541
|
const session = LYSession.get();
|
|
@@ -11656,6 +11774,10 @@ class LYLicenseApi {
|
|
|
11656
11774
|
});
|
|
11657
11775
|
return response.data;
|
|
11658
11776
|
}
|
|
11777
|
+
async getCustomerInfo() {
|
|
11778
|
+
const response = await this._httpClient.get("/license/customer-info");
|
|
11779
|
+
return response.data;
|
|
11780
|
+
}
|
|
11659
11781
|
}
|
|
11660
11782
|
class LYOEMApi {
|
|
11661
11783
|
constructor(httpClient){
|
|
@@ -11721,6 +11843,128 @@ class LYVerificationCodesApi {
|
|
|
11721
11843
|
return response.data;
|
|
11722
11844
|
}
|
|
11723
11845
|
}
|
|
11846
|
+
class LYPermissionApi {
|
|
11847
|
+
constructor(httpClient){
|
|
11848
|
+
this._httpClient = httpClient;
|
|
11849
|
+
}
|
|
11850
|
+
async getRoles(request) {
|
|
11851
|
+
const result = await this._httpClient.get('/role', request);
|
|
11852
|
+
return result.data;
|
|
11853
|
+
}
|
|
11854
|
+
async addRole(request) {
|
|
11855
|
+
const result = await this._httpClient.post('/role', request);
|
|
11856
|
+
return result.data;
|
|
11857
|
+
}
|
|
11858
|
+
async getRole(id) {
|
|
11859
|
+
const result = await this._httpClient.get(`/role/${id}`);
|
|
11860
|
+
return result.data;
|
|
11861
|
+
}
|
|
11862
|
+
async del(id) {
|
|
11863
|
+
const result = await this._httpClient.post(`/role/delete/${id}`);
|
|
11864
|
+
return result.data;
|
|
11865
|
+
}
|
|
11866
|
+
async update(id, role) {
|
|
11867
|
+
const result = await this._httpClient.post(`/role/patch/${id}`, role);
|
|
11868
|
+
return result.data;
|
|
11869
|
+
}
|
|
11870
|
+
async getMeta(type = "web") {
|
|
11871
|
+
const result = await this._httpClient.get("/permission/meta", {
|
|
11872
|
+
type
|
|
11873
|
+
});
|
|
11874
|
+
return result.data;
|
|
11875
|
+
}
|
|
11876
|
+
async getPermissionTemplates() {
|
|
11877
|
+
const result = await this._httpClient.get('/permission-templates');
|
|
11878
|
+
return result.data;
|
|
11879
|
+
}
|
|
11880
|
+
async getPermissionEntity(appName, tableName) {
|
|
11881
|
+
const result = await this._httpClient.get(`/permission/entity/${appName}/${tableName}`);
|
|
11882
|
+
return result.data;
|
|
11883
|
+
}
|
|
11884
|
+
async updatePermissionEntity(appName, tableName, request) {
|
|
11885
|
+
const result = await this._httpClient.post(`/permission/entity/patch/${appName}/${tableName}`, request);
|
|
11886
|
+
return result.data;
|
|
11887
|
+
}
|
|
11888
|
+
}
|
|
11889
|
+
class LYDepartmentApi {
|
|
11890
|
+
constructor(httpClient){
|
|
11891
|
+
this._httpClient = httpClient;
|
|
11892
|
+
}
|
|
11893
|
+
async query(params) {
|
|
11894
|
+
const response = await this._httpClient.get('/department', params);
|
|
11895
|
+
return response.data;
|
|
11896
|
+
}
|
|
11897
|
+
async get(id) {
|
|
11898
|
+
const response = await this._httpClient.get(`/department/${id}`);
|
|
11899
|
+
return response.data;
|
|
11900
|
+
}
|
|
11901
|
+
async add(department) {
|
|
11902
|
+
const response = await this._httpClient.post("/department", department);
|
|
11903
|
+
return response.data.id;
|
|
11904
|
+
}
|
|
11905
|
+
async update(id, department) {
|
|
11906
|
+
const response = await this._httpClient.post(`/department/patch/${id}`, department);
|
|
11907
|
+
return response.data.count;
|
|
11908
|
+
}
|
|
11909
|
+
async remove(id) {
|
|
11910
|
+
const response = await this._httpClient.post(`/department/delete/${id}`);
|
|
11911
|
+
return response.data.count;
|
|
11912
|
+
}
|
|
11913
|
+
async batchUpdate(departments) {
|
|
11914
|
+
const response = await this._httpClient.post('/department/patch', {
|
|
11915
|
+
departments
|
|
11916
|
+
});
|
|
11917
|
+
return response.data.count;
|
|
11918
|
+
}
|
|
11919
|
+
async getUsers(departmentId, managerOnly = false) {
|
|
11920
|
+
const response = await this._httpClient.get(`/department/${departmentId}/users`, {
|
|
11921
|
+
manager_only: managerOnly
|
|
11922
|
+
});
|
|
11923
|
+
return response.data;
|
|
11924
|
+
}
|
|
11925
|
+
async addUsers(departmentId, userIds, isManager = false) {
|
|
11926
|
+
const response = await this._httpClient.post(`/department/${departmentId}/users`, {
|
|
11927
|
+
user_ids: userIds,
|
|
11928
|
+
is_manager: isManager
|
|
11929
|
+
});
|
|
11930
|
+
return response.data.count;
|
|
11931
|
+
}
|
|
11932
|
+
async removeUsers(departmentId, userIds) {
|
|
11933
|
+
const response = await this._httpClient.post(`/department/${departmentId}/users/delete`, {
|
|
11934
|
+
user_ids: userIds
|
|
11935
|
+
});
|
|
11936
|
+
return response.data.count;
|
|
11937
|
+
}
|
|
11938
|
+
async getUserDepartments(userId, managerOnly = false) {
|
|
11939
|
+
const response = await this._httpClient.get(`/user/${userId}/department`, {
|
|
11940
|
+
manager_only: managerOnly
|
|
11941
|
+
});
|
|
11942
|
+
return response.data;
|
|
11943
|
+
}
|
|
11944
|
+
async moveUserToDepartment(userId, departmentId, newDepartmentId, isManager) {
|
|
11945
|
+
const response = await this._httpClient.post(`/user/${userId}/department/patch/${departmentId}`, {
|
|
11946
|
+
new_department_id: newDepartmentId,
|
|
11947
|
+
is_manager: isManager
|
|
11948
|
+
});
|
|
11949
|
+
return response.data.count;
|
|
11950
|
+
}
|
|
11951
|
+
async queryUserDepartmentDataPermissions(params) {
|
|
11952
|
+
const response = await this._httpClient.get('/user-department-data-permission', params);
|
|
11953
|
+
return response.data;
|
|
11954
|
+
}
|
|
11955
|
+
async createUserDepartmentDataPermission(request) {
|
|
11956
|
+
const response = await this._httpClient.post('/user-department-data-permission', request);
|
|
11957
|
+
return response.data.id;
|
|
11958
|
+
}
|
|
11959
|
+
async deleteUserDepartmentDataPermission(permissionId) {
|
|
11960
|
+
const response = await this._httpClient.post(`/user-department-data-permission/delete/${permissionId}`);
|
|
11961
|
+
return response.data.count;
|
|
11962
|
+
}
|
|
11963
|
+
async patchUserDepartmentDataPermission(permissionId, request) {
|
|
11964
|
+
const response = await this._httpClient.post(`/user-department-data-permission/patch/${permissionId}`, request);
|
|
11965
|
+
return response.data.count;
|
|
11966
|
+
}
|
|
11967
|
+
}
|
|
11724
11968
|
function app_ts_decorate(decorators, target, key, desc) {
|
|
11725
11969
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11726
11970
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11732,11 +11976,13 @@ function app_ts_metadata(k, v) {
|
|
|
11732
11976
|
}
|
|
11733
11977
|
class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
11734
11978
|
constructor(name1, version, description){
|
|
11735
|
-
super(name1, version, description);
|
|
11979
|
+
super(name1, version, description), this._permissionMeta = {};
|
|
11736
11980
|
LYOrganizationApp._instance = this;
|
|
11737
11981
|
this._sessionApi = new session_LYSessionApi(this.httpClient);
|
|
11738
11982
|
this._userApi = new LYUserApi(this.httpClient);
|
|
11739
11983
|
this._licenseApi = new LYLicenseApi(this.httpClient);
|
|
11984
|
+
this._permissionApi = new LYPermissionApi(this.httpClient);
|
|
11985
|
+
this._departmentApi = new LYDepartmentApi(this.httpClient);
|
|
11740
11986
|
this._oemApi = new LYOEMApi(this.httpClient);
|
|
11741
11987
|
this._verificationCodesApi = new LYVerificationCodesApi(this.httpClient);
|
|
11742
11988
|
this._authorizers = {
|
|
@@ -11765,8 +12011,54 @@ class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
|
11765
12011
|
get verificationCodesApi() {
|
|
11766
12012
|
return this._verificationCodesApi;
|
|
11767
12013
|
}
|
|
12014
|
+
get permissionApi() {
|
|
12015
|
+
return this._permissionApi;
|
|
12016
|
+
}
|
|
12017
|
+
get departmentApi() {
|
|
12018
|
+
return this._departmentApi;
|
|
12019
|
+
}
|
|
12020
|
+
getAllPermissionCodes(appName) {
|
|
12021
|
+
const meta = this._permissionMeta[appName];
|
|
12022
|
+
if (!meta || !meta.codes) return [];
|
|
12023
|
+
return meta.codes.map((code)=>code.name);
|
|
12024
|
+
}
|
|
12025
|
+
getPermissionMeta() {
|
|
12026
|
+
return this._permissionMeta;
|
|
12027
|
+
}
|
|
12028
|
+
async getLayout() {
|
|
12029
|
+
const result = await this._httpClient.get('/portal/layout');
|
|
12030
|
+
return result.data;
|
|
12031
|
+
}
|
|
12032
|
+
async getMetrics() {
|
|
12033
|
+
const result = await this._httpClient.get("/portal/core-metrics");
|
|
12034
|
+
return result.data;
|
|
12035
|
+
}
|
|
11768
12036
|
async doLoad() {
|
|
11769
12037
|
await super.doLoad();
|
|
12038
|
+
LYSession.setAllCodesProvider((appName)=>this.getAllPermissionCodes(appName));
|
|
12039
|
+
LYSession.setOnSessionCreated(async ()=>{
|
|
12040
|
+
await this.loadPermissionMeta();
|
|
12041
|
+
});
|
|
12042
|
+
}
|
|
12043
|
+
async loadPermissionMeta() {
|
|
12044
|
+
try {
|
|
12045
|
+
this._permissionMeta = await this._permissionApi.getMeta('web');
|
|
12046
|
+
this.logger.info('Permission meta loaded');
|
|
12047
|
+
this._updateSessionAllCodes();
|
|
12048
|
+
} catch (error) {
|
|
12049
|
+
this.logger.error('Failed to load permission meta');
|
|
12050
|
+
this.logger.error(error);
|
|
12051
|
+
}
|
|
12052
|
+
}
|
|
12053
|
+
_updateSessionAllCodes() {
|
|
12054
|
+
const session = LYSession.get();
|
|
12055
|
+
if (session) {
|
|
12056
|
+
const permissions = session.permissions;
|
|
12057
|
+
for (const appName of Object.keys(permissions)){
|
|
12058
|
+
const allCodes = this.getAllPermissionCodes(appName);
|
|
12059
|
+
permissions[appName].setAllCodes(allCodes);
|
|
12060
|
+
}
|
|
12061
|
+
}
|
|
11770
12062
|
}
|
|
11771
12063
|
async mergeOEM(originResources) {
|
|
11772
12064
|
try {
|