@laiye_packages/uci 1.0.7 → 1.0.9
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 +326 -37
- 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 +3 -3
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.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) {
|
|
@@ -10599,9 +10624,8 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10599
10624
|
signature(data, privateKey) {
|
|
10600
10625
|
try {
|
|
10601
10626
|
this._validateKey(privateKey, 32, 'SM2 private');
|
|
10602
|
-
const dataHex = this._uint8ArrayToHex(data);
|
|
10603
10627
|
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10604
|
-
const signature = sm2.doSignature(
|
|
10628
|
+
const signature = sm2.doSignature(Array.from(data), privateKeyHex);
|
|
10605
10629
|
if (!signature) throw new LYCryptoError('SM2 signature failed');
|
|
10606
10630
|
return signature;
|
|
10607
10631
|
} catch (error) {
|
|
@@ -10612,9 +10636,8 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10612
10636
|
verify(data, publicKey, signature) {
|
|
10613
10637
|
try {
|
|
10614
10638
|
this._validatePublicKey(publicKey);
|
|
10615
|
-
const dataHex = this._uint8ArrayToHex(data);
|
|
10616
10639
|
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10617
|
-
return sm2.doVerifySignature(
|
|
10640
|
+
return sm2.doVerifySignature(Array.from(data), signature, publicKeyHex);
|
|
10618
10641
|
} catch (error) {
|
|
10619
10642
|
if (error instanceof LYCryptoError) throw error;
|
|
10620
10643
|
throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -10623,9 +10646,8 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10623
10646
|
encryptAsymmetric(data, publicKey) {
|
|
10624
10647
|
try {
|
|
10625
10648
|
this._validatePublicKey(publicKey);
|
|
10626
|
-
const dataHex = this._uint8ArrayToHex(data);
|
|
10627
10649
|
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10628
|
-
const encrypted = sm2.doEncrypt(
|
|
10650
|
+
const encrypted = sm2.doEncrypt(Array.from(data), publicKeyHex);
|
|
10629
10651
|
if (!encrypted) throw new LYCryptoError('SM2 encryption failed');
|
|
10630
10652
|
return this._hexToUint8Array(encrypted);
|
|
10631
10653
|
} catch (error) {
|
|
@@ -10640,7 +10662,7 @@ class LYSMCrypto extends LYBaseCrypto {
|
|
|
10640
10662
|
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10641
10663
|
const decrypted = sm2.doDecrypt(dataHex, privateKeyHex);
|
|
10642
10664
|
if (!decrypted) throw new LYCryptoError('SM2 decryption failed');
|
|
10643
|
-
return
|
|
10665
|
+
return new TextEncoder().encode(decrypted);
|
|
10644
10666
|
} catch (error) {
|
|
10645
10667
|
if (error instanceof LYCryptoError) throw error;
|
|
10646
10668
|
throw new LYCryptoError(`SM2 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -11158,6 +11180,7 @@ class base_LYBaseApp extends LYObject {
|
|
|
11158
11180
|
async doLoad() {
|
|
11159
11181
|
await this.initI18n();
|
|
11160
11182
|
}
|
|
11183
|
+
async updatePermissions() {}
|
|
11161
11184
|
getBaseUrl() {
|
|
11162
11185
|
const config = LYConfig.get();
|
|
11163
11186
|
const url = new URL(window.location.href);
|
|
@@ -11309,8 +11332,14 @@ class LYUserApi {
|
|
|
11309
11332
|
const response = await this._httpClient.get('/user', params);
|
|
11310
11333
|
return response.data;
|
|
11311
11334
|
}
|
|
11312
|
-
async
|
|
11313
|
-
const response = await this._httpClient.
|
|
11335
|
+
async setPassword(newPassword) {
|
|
11336
|
+
const response = await this._httpClient.post("/user/password/init", {
|
|
11337
|
+
new_password: newPassword
|
|
11338
|
+
});
|
|
11339
|
+
return response.data;
|
|
11340
|
+
}
|
|
11341
|
+
async get(id) {
|
|
11342
|
+
const response = await this._httpClient.get(`/user/${id}`);
|
|
11314
11343
|
return response.data;
|
|
11315
11344
|
}
|
|
11316
11345
|
async add(user) {
|
|
@@ -11320,15 +11349,15 @@ class LYUserApi {
|
|
|
11320
11349
|
});
|
|
11321
11350
|
return response.data.id;
|
|
11322
11351
|
}
|
|
11323
|
-
async update(
|
|
11324
|
-
const response = await this._httpClient.post(`/user/patch/${
|
|
11352
|
+
async update(id, user) {
|
|
11353
|
+
const response = await this._httpClient.post(`/user/patch/${id}`, {
|
|
11325
11354
|
...user,
|
|
11326
11355
|
password: user.password
|
|
11327
11356
|
});
|
|
11328
11357
|
return response.data.count;
|
|
11329
11358
|
}
|
|
11330
|
-
async remove(
|
|
11331
|
-
const response = await this._httpClient.post(`/user/delete/${
|
|
11359
|
+
async remove(id, request) {
|
|
11360
|
+
const response = await this._httpClient.post(`/user/delete/${id}`, request);
|
|
11332
11361
|
return response.data.count;
|
|
11333
11362
|
}
|
|
11334
11363
|
async accountCheck(request) {
|
|
@@ -11347,10 +11376,10 @@ class LYUserApi {
|
|
|
11347
11376
|
const response = await this._httpClient.get(`/user/username-check/${name1}`);
|
|
11348
11377
|
return response.data.available;
|
|
11349
11378
|
}
|
|
11350
|
-
async changePassword(
|
|
11379
|
+
async changePassword(request) {
|
|
11351
11380
|
const response = await this._httpClient.post("/user/password/change", {
|
|
11352
|
-
current_password:
|
|
11353
|
-
new_password:
|
|
11381
|
+
current_password: request.current_password,
|
|
11382
|
+
new_password: request.new_password
|
|
11354
11383
|
});
|
|
11355
11384
|
return response.data;
|
|
11356
11385
|
}
|
|
@@ -11360,6 +11389,14 @@ class LYUserApi {
|
|
|
11360
11389
|
});
|
|
11361
11390
|
return response.data;
|
|
11362
11391
|
}
|
|
11392
|
+
async getSettings() {
|
|
11393
|
+
const response = await this._httpClient.get("/user/settings");
|
|
11394
|
+
return response.data;
|
|
11395
|
+
}
|
|
11396
|
+
async updateSettings(request) {
|
|
11397
|
+
const response = await this._httpClient.post("/user/settings/patch", request);
|
|
11398
|
+
return response.data.count;
|
|
11399
|
+
}
|
|
11363
11400
|
}
|
|
11364
11401
|
const base_ORGANIZATION_APP_NAME = 'organization';
|
|
11365
11402
|
class LYBaseAuthorizer extends LYObject {
|
|
@@ -11406,18 +11443,96 @@ class LYWebAuthorizer extends LYBaseAuthorizer {
|
|
|
11406
11443
|
this._sessionApi = sessionApi;
|
|
11407
11444
|
LYSession.setRefreshCallback(this._refreshSession.bind(this));
|
|
11408
11445
|
}
|
|
11409
|
-
|
|
11446
|
+
static parseClientLoginParams() {
|
|
11447
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
11448
|
+
const hash = window.location.hash;
|
|
11449
|
+
const hashParams = new URLSearchParams(hash.includes('?') ? hash.split('?')[1] : '');
|
|
11450
|
+
const getParam = (key)=>searchParams.get(key) || hashParams.get(key) || void 0;
|
|
11451
|
+
return {
|
|
11452
|
+
response_type: getParam('response_type'),
|
|
11453
|
+
client_id: getParam('client_id'),
|
|
11454
|
+
return_url: getParam('return_url'),
|
|
11455
|
+
api_base_url: getParam('api_base_url'),
|
|
11456
|
+
state: getParam('state'),
|
|
11457
|
+
tenant_name: getParam('tenant_name'),
|
|
11458
|
+
client_type: getParam('client_type'),
|
|
11459
|
+
code: getParam('code')
|
|
11460
|
+
};
|
|
11461
|
+
}
|
|
11462
|
+
static getClientLoginArgs() {
|
|
11463
|
+
return LYWebAuthorizer.parseClientLoginParams();
|
|
11464
|
+
}
|
|
11465
|
+
static isClientLoginRequest() {
|
|
11466
|
+
const params = LYWebAuthorizer.getClientLoginArgs();
|
|
11467
|
+
return 'app' === params.client_type && !!params.client_id && !!params.return_url;
|
|
11468
|
+
}
|
|
11469
|
+
static isClientLoginCallback() {
|
|
11470
|
+
const params = LYWebAuthorizer.getClientLoginArgs();
|
|
11471
|
+
return !!params.code && !!params.return_url;
|
|
11472
|
+
}
|
|
11473
|
+
static handleClientLoginCallback() {
|
|
11474
|
+
const params = LYWebAuthorizer.getClientLoginArgs();
|
|
11475
|
+
if (!params.code || !params.return_url) return;
|
|
11476
|
+
const redirectUrl = new URL(params.return_url);
|
|
11477
|
+
redirectUrl.searchParams.set('code', params.code);
|
|
11478
|
+
redirectUrl.searchParams.set('state', params.state || '');
|
|
11479
|
+
redirectUrl.searchParams.set('tenant_name', params.tenant_name || '');
|
|
11480
|
+
redirectUrl.searchParams.set('api_base_url', params.api_base_url || '');
|
|
11481
|
+
window.location.href = redirectUrl.toString();
|
|
11482
|
+
}
|
|
11483
|
+
async signinWithResponse(args) {
|
|
11484
|
+
const clientParams = LYWebAuthorizer.getClientLoginArgs();
|
|
11485
|
+
const isClientLogin = 'app' === clientParams.client_type && !!clientParams.client_id && !!clientParams.return_url;
|
|
11486
|
+
const finalArgs = {
|
|
11487
|
+
...args,
|
|
11488
|
+
client_type: isClientLogin ? 'app' : args.client_type,
|
|
11489
|
+
client_data: isClientLogin ? {
|
|
11490
|
+
redirect_uri: clientParams.return_url,
|
|
11491
|
+
state: clientParams.state || '',
|
|
11492
|
+
client_id: clientParams.client_id
|
|
11493
|
+
} : args.client_data
|
|
11494
|
+
};
|
|
11410
11495
|
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
|
-
|
|
11496
|
+
name: finalArgs.name,
|
|
11497
|
+
password: finalArgs.password,
|
|
11498
|
+
email: finalArgs.email,
|
|
11499
|
+
phone: finalArgs.phone,
|
|
11500
|
+
country_code: finalArgs.country_code,
|
|
11501
|
+
account_type: finalArgs.account_type,
|
|
11502
|
+
verification_code: finalArgs.verification_code,
|
|
11503
|
+
verification_code_id: finalArgs.verification_code_id,
|
|
11504
|
+
client_type: finalArgs.client_type,
|
|
11505
|
+
client_data: finalArgs.client_data
|
|
11506
|
+
});
|
|
11507
|
+
if ('app' === finalArgs.client_type) {
|
|
11508
|
+
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);
|
|
11509
|
+
if (response.is_first_login) return response;
|
|
11510
|
+
if (response.auth_code) {
|
|
11511
|
+
const hashParams = new URLSearchParams({
|
|
11512
|
+
code: response.auth_code,
|
|
11513
|
+
return_url: finalArgs.client_data.redirect_uri,
|
|
11514
|
+
state: finalArgs.client_data.state,
|
|
11515
|
+
tenant_name: clientParams.tenant_name || '',
|
|
11516
|
+
api_base_url: clientParams.api_base_url || ''
|
|
11517
|
+
});
|
|
11518
|
+
setTimeout(()=>{
|
|
11519
|
+
window.location.href = `/view/organization/${clientParams.tenant_name}/#client-login?${hashParams.toString()}`;
|
|
11520
|
+
}, 0);
|
|
11521
|
+
}
|
|
11522
|
+
return {
|
|
11523
|
+
...response,
|
|
11524
|
+
redirect_handled: true
|
|
11525
|
+
};
|
|
11526
|
+
}
|
|
11527
|
+
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);
|
|
11528
|
+
this.emit('status-change', 'signed-in');
|
|
11529
|
+
if (finalArgs.redirect_uri) setTimeout(()=>{
|
|
11530
|
+
window.location.href = finalArgs.redirect_uri;
|
|
11531
|
+
}, 0);
|
|
11532
|
+
return response;
|
|
11533
|
+
}
|
|
11534
|
+
async _signin(args) {
|
|
11535
|
+
await this.signinWithResponse(args);
|
|
11421
11536
|
}
|
|
11422
11537
|
async _signout(args) {
|
|
11423
11538
|
const session = LYSession.get();
|
|
@@ -11656,6 +11771,10 @@ class LYLicenseApi {
|
|
|
11656
11771
|
});
|
|
11657
11772
|
return response.data;
|
|
11658
11773
|
}
|
|
11774
|
+
async getCustomerInfo() {
|
|
11775
|
+
const response = await this._httpClient.get("/license/customer-info");
|
|
11776
|
+
return response.data;
|
|
11777
|
+
}
|
|
11659
11778
|
}
|
|
11660
11779
|
class LYOEMApi {
|
|
11661
11780
|
constructor(httpClient){
|
|
@@ -11721,6 +11840,128 @@ class LYVerificationCodesApi {
|
|
|
11721
11840
|
return response.data;
|
|
11722
11841
|
}
|
|
11723
11842
|
}
|
|
11843
|
+
class LYPermissionApi {
|
|
11844
|
+
constructor(httpClient){
|
|
11845
|
+
this._httpClient = httpClient;
|
|
11846
|
+
}
|
|
11847
|
+
async getRoles(request) {
|
|
11848
|
+
const result = await this._httpClient.get('/role', request);
|
|
11849
|
+
return result.data;
|
|
11850
|
+
}
|
|
11851
|
+
async addRole(request) {
|
|
11852
|
+
const result = await this._httpClient.post('/role', request);
|
|
11853
|
+
return result.data;
|
|
11854
|
+
}
|
|
11855
|
+
async getRole(id) {
|
|
11856
|
+
const result = await this._httpClient.get(`/role/${id}`);
|
|
11857
|
+
return result.data;
|
|
11858
|
+
}
|
|
11859
|
+
async del(id) {
|
|
11860
|
+
const result = await this._httpClient.post(`/role/delete/${id}`);
|
|
11861
|
+
return result.data;
|
|
11862
|
+
}
|
|
11863
|
+
async update(id, role) {
|
|
11864
|
+
const result = await this._httpClient.post(`/role/patch/${id}`, role);
|
|
11865
|
+
return result.data;
|
|
11866
|
+
}
|
|
11867
|
+
async getMeta(type = "web") {
|
|
11868
|
+
const result = await this._httpClient.get("/permission/meta", {
|
|
11869
|
+
type
|
|
11870
|
+
});
|
|
11871
|
+
return result.data;
|
|
11872
|
+
}
|
|
11873
|
+
async getPermissionTemplates() {
|
|
11874
|
+
const result = await this._httpClient.get('/permission-templates');
|
|
11875
|
+
return result.data;
|
|
11876
|
+
}
|
|
11877
|
+
async getPermissionEntity(appName, tableName) {
|
|
11878
|
+
const result = await this._httpClient.get(`/permission/entity/${appName}/${tableName}`);
|
|
11879
|
+
return result.data;
|
|
11880
|
+
}
|
|
11881
|
+
async updatePermissionEntity(appName, tableName, request) {
|
|
11882
|
+
const result = await this._httpClient.post(`/permission/entity/patch/${appName}/${tableName}`, request);
|
|
11883
|
+
return result.data;
|
|
11884
|
+
}
|
|
11885
|
+
}
|
|
11886
|
+
class LYDepartmentApi {
|
|
11887
|
+
constructor(httpClient){
|
|
11888
|
+
this._httpClient = httpClient;
|
|
11889
|
+
}
|
|
11890
|
+
async query(params) {
|
|
11891
|
+
const response = await this._httpClient.get('/department', params);
|
|
11892
|
+
return response.data;
|
|
11893
|
+
}
|
|
11894
|
+
async get(id) {
|
|
11895
|
+
const response = await this._httpClient.get(`/department/${id}`);
|
|
11896
|
+
return response.data;
|
|
11897
|
+
}
|
|
11898
|
+
async add(department) {
|
|
11899
|
+
const response = await this._httpClient.post("/department", department);
|
|
11900
|
+
return response.data.id;
|
|
11901
|
+
}
|
|
11902
|
+
async update(id, department) {
|
|
11903
|
+
const response = await this._httpClient.post(`/department/patch/${id}`, department);
|
|
11904
|
+
return response.data.count;
|
|
11905
|
+
}
|
|
11906
|
+
async remove(id) {
|
|
11907
|
+
const response = await this._httpClient.post(`/department/delete/${id}`);
|
|
11908
|
+
return response.data.count;
|
|
11909
|
+
}
|
|
11910
|
+
async batchUpdate(departments) {
|
|
11911
|
+
const response = await this._httpClient.post('/department/patch', {
|
|
11912
|
+
departments
|
|
11913
|
+
});
|
|
11914
|
+
return response.data.count;
|
|
11915
|
+
}
|
|
11916
|
+
async getUsers(departmentId, managerOnly = false) {
|
|
11917
|
+
const response = await this._httpClient.get(`/department/${departmentId}/users`, {
|
|
11918
|
+
manager_only: managerOnly
|
|
11919
|
+
});
|
|
11920
|
+
return response.data;
|
|
11921
|
+
}
|
|
11922
|
+
async addUsers(departmentId, userIds, isManager = false) {
|
|
11923
|
+
const response = await this._httpClient.post(`/department/${departmentId}/users`, {
|
|
11924
|
+
user_ids: userIds,
|
|
11925
|
+
is_manager: isManager
|
|
11926
|
+
});
|
|
11927
|
+
return response.data.count;
|
|
11928
|
+
}
|
|
11929
|
+
async removeUsers(departmentId, userIds) {
|
|
11930
|
+
const response = await this._httpClient.post(`/department/${departmentId}/users/delete`, {
|
|
11931
|
+
user_ids: userIds
|
|
11932
|
+
});
|
|
11933
|
+
return response.data.count;
|
|
11934
|
+
}
|
|
11935
|
+
async getUserDepartments(userId, managerOnly = false) {
|
|
11936
|
+
const response = await this._httpClient.get(`/user/${userId}/department`, {
|
|
11937
|
+
manager_only: managerOnly
|
|
11938
|
+
});
|
|
11939
|
+
return response.data;
|
|
11940
|
+
}
|
|
11941
|
+
async moveUserToDepartment(userId, departmentId, newDepartmentId, isManager) {
|
|
11942
|
+
const response = await this._httpClient.post(`/user/${userId}/department/patch/${departmentId}`, {
|
|
11943
|
+
new_department_id: newDepartmentId,
|
|
11944
|
+
is_manager: isManager
|
|
11945
|
+
});
|
|
11946
|
+
return response.data.count;
|
|
11947
|
+
}
|
|
11948
|
+
async queryUserDepartmentDataPermissions(params) {
|
|
11949
|
+
const response = await this._httpClient.get('/user-department-data-permission', params);
|
|
11950
|
+
return response.data;
|
|
11951
|
+
}
|
|
11952
|
+
async createUserDepartmentDataPermission(request) {
|
|
11953
|
+
const response = await this._httpClient.post('/user-department-data-permission', request);
|
|
11954
|
+
return response.data.id;
|
|
11955
|
+
}
|
|
11956
|
+
async deleteUserDepartmentDataPermission(permissionId) {
|
|
11957
|
+
const response = await this._httpClient.post(`/user-department-data-permission/delete/${permissionId}`);
|
|
11958
|
+
return response.data.count;
|
|
11959
|
+
}
|
|
11960
|
+
async patchUserDepartmentDataPermission(permissionId, request) {
|
|
11961
|
+
const response = await this._httpClient.post(`/user-department-data-permission/patch/${permissionId}`, request);
|
|
11962
|
+
return response.data.count;
|
|
11963
|
+
}
|
|
11964
|
+
}
|
|
11724
11965
|
function app_ts_decorate(decorators, target, key, desc) {
|
|
11725
11966
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11726
11967
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11732,11 +11973,13 @@ function app_ts_metadata(k, v) {
|
|
|
11732
11973
|
}
|
|
11733
11974
|
class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
11734
11975
|
constructor(name1, version, description){
|
|
11735
|
-
super(name1, version, description);
|
|
11976
|
+
super(name1, version, description), this._permissionMeta = {};
|
|
11736
11977
|
LYOrganizationApp._instance = this;
|
|
11737
11978
|
this._sessionApi = new session_LYSessionApi(this.httpClient);
|
|
11738
11979
|
this._userApi = new LYUserApi(this.httpClient);
|
|
11739
11980
|
this._licenseApi = new LYLicenseApi(this.httpClient);
|
|
11981
|
+
this._permissionApi = new LYPermissionApi(this.httpClient);
|
|
11982
|
+
this._departmentApi = new LYDepartmentApi(this.httpClient);
|
|
11740
11983
|
this._oemApi = new LYOEMApi(this.httpClient);
|
|
11741
11984
|
this._verificationCodesApi = new LYVerificationCodesApi(this.httpClient);
|
|
11742
11985
|
this._authorizers = {
|
|
@@ -11765,8 +12008,54 @@ class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
|
11765
12008
|
get verificationCodesApi() {
|
|
11766
12009
|
return this._verificationCodesApi;
|
|
11767
12010
|
}
|
|
12011
|
+
get permissionApi() {
|
|
12012
|
+
return this._permissionApi;
|
|
12013
|
+
}
|
|
12014
|
+
get departmentApi() {
|
|
12015
|
+
return this._departmentApi;
|
|
12016
|
+
}
|
|
12017
|
+
getAllPermissionCodes(appName) {
|
|
12018
|
+
const meta = this._permissionMeta[appName];
|
|
12019
|
+
if (!meta || !meta.codes) return [];
|
|
12020
|
+
return meta.codes.map((code)=>code.name);
|
|
12021
|
+
}
|
|
12022
|
+
getPermissionMeta() {
|
|
12023
|
+
return this._permissionMeta;
|
|
12024
|
+
}
|
|
12025
|
+
async getLayout() {
|
|
12026
|
+
const result = await this._httpClient.get('/portal/layout');
|
|
12027
|
+
return result.data;
|
|
12028
|
+
}
|
|
12029
|
+
async getMetrics() {
|
|
12030
|
+
const result = await this._httpClient.get("/portal/core-metrics");
|
|
12031
|
+
return result.data;
|
|
12032
|
+
}
|
|
11768
12033
|
async doLoad() {
|
|
11769
12034
|
await super.doLoad();
|
|
12035
|
+
LYSession.setAllCodesProvider((appName)=>this.getAllPermissionCodes(appName));
|
|
12036
|
+
LYSession.setOnSessionCreated(async ()=>{
|
|
12037
|
+
await this.loadPermissionMeta();
|
|
12038
|
+
});
|
|
12039
|
+
}
|
|
12040
|
+
async loadPermissionMeta() {
|
|
12041
|
+
try {
|
|
12042
|
+
this._permissionMeta = await this._permissionApi.getMeta('web');
|
|
12043
|
+
this.logger.info('Permission meta loaded');
|
|
12044
|
+
this._updateSessionAllCodes();
|
|
12045
|
+
} catch (error) {
|
|
12046
|
+
this.logger.error('Failed to load permission meta');
|
|
12047
|
+
this.logger.error(error);
|
|
12048
|
+
}
|
|
12049
|
+
}
|
|
12050
|
+
_updateSessionAllCodes() {
|
|
12051
|
+
const session = LYSession.get();
|
|
12052
|
+
if (session) {
|
|
12053
|
+
const permissions = session.permissions;
|
|
12054
|
+
for (const appName of Object.keys(permissions)){
|
|
12055
|
+
const allCodes = this.getAllPermissionCodes(appName);
|
|
12056
|
+
permissions[appName].setAllCodes(allCodes);
|
|
12057
|
+
}
|
|
12058
|
+
}
|
|
11770
12059
|
}
|
|
11771
12060
|
async mergeOEM(originResources) {
|
|
11772
12061
|
try {
|