@laiye_packages/uci 1.0.6 → 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 +2 -0
- package/dist/app/bill/api/admin.d.ts +41 -0
- package/dist/app/bill/api/types.d.ts +258 -0
- package/dist/app/bill/api/user.d.ts +18 -0
- package/dist/app/bill/app/index.d.ts +16 -0
- package/dist/app/bill/app/order.d.ts +70 -0
- package/dist/app/bill/index.d.ts +1 -0
- package/dist/app/index.d.ts +13 -4
- 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 +1290 -713
- 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
|
@@ -2,11 +2,11 @@ import { openDB } from "idb";
|
|
|
2
2
|
import events, { EventEmitter } from "events";
|
|
3
3
|
import axios from "axios";
|
|
4
4
|
import { cloneDeep } from "lodash";
|
|
5
|
-
import { sm2, sm3, sm4 } from "sm-crypto";
|
|
6
|
-
import i18next from "i18next";
|
|
7
|
-
import js_sha256 from "js-sha256";
|
|
8
5
|
import qs from "qs";
|
|
9
6
|
import downloadjs from "downloadjs";
|
|
7
|
+
import i18next from "i18next";
|
|
8
|
+
import { sm2, sm3, sm4 } from "sm-crypto";
|
|
9
|
+
import js_sha256 from "js-sha256";
|
|
10
10
|
var __webpack_modules__ = {
|
|
11
11
|
"../../node_modules/.pnpm/@module-federation+error-codes@0.8.12/node_modules/@module-federation/error-codes/dist/index.cjs.js": function(__unused_webpack_module, exports) {
|
|
12
12
|
const RUNTIME_001 = 'RUNTIME-001';
|
|
@@ -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 {
|
|
@@ -9703,20 +9703,33 @@ class LYAppHttpError extends LYBaseHttpError {
|
|
|
9703
9703
|
return this._code;
|
|
9704
9704
|
}
|
|
9705
9705
|
}
|
|
9706
|
-
var runtime = __webpack_require__("../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.4_react-dom@18.3.1_react@18.3.1_typescript@5.9.3_webpack@5.104.1/node_modules/@module-federation/enhanced/dist/src/runtime.js");
|
|
9707
9706
|
class LYAppPermission extends LYObject {
|
|
9708
|
-
constructor(app_name, codes){
|
|
9707
|
+
constructor(app_name, codes, allCodes){
|
|
9709
9708
|
super(), this._codes = {};
|
|
9710
9709
|
this._app_name = app_name;
|
|
9711
9710
|
this._codes = codes;
|
|
9711
|
+
this._allCodes = allCodes;
|
|
9712
9712
|
}
|
|
9713
9713
|
get app_name() {
|
|
9714
9714
|
return this._app_name;
|
|
9715
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
|
+
}
|
|
9716
9725
|
getActions(code) {
|
|
9717
9726
|
if (!(code in this._codes)) return [];
|
|
9718
9727
|
return this._codes[code];
|
|
9719
9728
|
}
|
|
9729
|
+
hasPermission(code) {
|
|
9730
|
+
if (this._allCodes.length > 0 && !this._allCodes.includes(code)) return true;
|
|
9731
|
+
return code in this._codes;
|
|
9732
|
+
}
|
|
9720
9733
|
}
|
|
9721
9734
|
function session_ts_decorate(decorators, target, key, desc) {
|
|
9722
9735
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -9732,6 +9745,12 @@ class LYSession extends LYObject {
|
|
|
9732
9745
|
static{
|
|
9733
9746
|
this._CHECK_INTERVAL = 10000;
|
|
9734
9747
|
}
|
|
9748
|
+
static setAllCodesProvider(provider) {
|
|
9749
|
+
LYSession._allCodesProvider = provider;
|
|
9750
|
+
}
|
|
9751
|
+
static setOnSessionCreated(callback) {
|
|
9752
|
+
LYSession._onSessionCreated = callback;
|
|
9753
|
+
}
|
|
9735
9754
|
static get() {
|
|
9736
9755
|
if (!LYSession._session) {
|
|
9737
9756
|
const session = sharedLocalStorage.getSync(SESSION_KEY);
|
|
@@ -9763,6 +9782,9 @@ class LYSession extends LYObject {
|
|
|
9763
9782
|
country_code: country_code || ''
|
|
9764
9783
|
});
|
|
9765
9784
|
LYSession._startRefreshTimer();
|
|
9785
|
+
if (LYSession._onSessionCreated) LYSession._onSessionCreated().catch((err)=>{
|
|
9786
|
+
console.error('Session created callback error:', err);
|
|
9787
|
+
});
|
|
9766
9788
|
return LYSession._session;
|
|
9767
9789
|
}
|
|
9768
9790
|
static clear() {
|
|
@@ -9786,7 +9808,8 @@ class LYSession extends LYObject {
|
|
|
9786
9808
|
this._phone = phone || '';
|
|
9787
9809
|
this._country_code = country_code || '';
|
|
9788
9810
|
this._permissions = Object.entries(permissions || {}).reduce((acc, [app_name, codes])=>{
|
|
9789
|
-
|
|
9811
|
+
const allCodes = LYSession._allCodesProvider ? LYSession._allCodesProvider(app_name) : [];
|
|
9812
|
+
acc[app_name] = new LYAppPermission(app_name, codes, allCodes);
|
|
9790
9813
|
return acc;
|
|
9791
9814
|
}, {});
|
|
9792
9815
|
}
|
|
@@ -9880,7 +9903,8 @@ class LYSession extends LYObject {
|
|
|
9880
9903
|
if (void 0 !== phone) LYSession._session._phone = phone;
|
|
9881
9904
|
if (void 0 !== country_code) LYSession._session._country_code = country_code;
|
|
9882
9905
|
LYSession._session._permissions = Object.entries(permissions || {}).reduce((acc, [app_name, codes])=>{
|
|
9883
|
-
|
|
9906
|
+
const allCodes = LYSession._allCodesProvider ? LYSession._allCodesProvider(app_name) : [];
|
|
9907
|
+
acc[app_name] = new LYAppPermission(app_name, codes, allCodes);
|
|
9884
9908
|
return acc;
|
|
9885
9909
|
}, {});
|
|
9886
9910
|
sharedLocalStorage.setSync(SESSION_KEY, {
|
|
@@ -9959,166 +9983,716 @@ LYSession = session_ts_decorate([
|
|
|
9959
9983
|
String
|
|
9960
9984
|
])
|
|
9961
9985
|
], LYSession);
|
|
9962
|
-
|
|
9963
|
-
}
|
|
9964
|
-
function registerCryptoImpl(name1) {
|
|
9965
|
-
return function(impl) {
|
|
9966
|
-
if (cryptoImpl[name1]) throw new Error(`Crypto implementation for ${name1} already registered`);
|
|
9967
|
-
cryptoImpl[name1] = impl;
|
|
9968
|
-
return impl;
|
|
9969
|
-
};
|
|
9970
|
-
}
|
|
9971
|
-
const cryptoImpl = {
|
|
9972
|
-
default: void 0,
|
|
9973
|
-
sm: void 0,
|
|
9974
|
-
gm: void 0
|
|
9975
|
-
};
|
|
9976
|
-
function sm_ts_decorate(decorators, target, key, desc) {
|
|
9986
|
+
function http_base_ts_decorate(decorators, target, key, desc) {
|
|
9977
9987
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9978
9988
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
9979
9989
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9980
9990
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9981
9991
|
}
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
9992
|
+
function base_ts_metadata(k, v) {
|
|
9993
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
9994
|
+
}
|
|
9995
|
+
class LYHttpClient extends LYObject {
|
|
9996
|
+
constructor(baseUrl){
|
|
9997
|
+
super();
|
|
9998
|
+
this._client = axios.create({
|
|
9999
|
+
baseURL: baseUrl
|
|
10000
|
+
});
|
|
10001
|
+
this._baseUrl = baseUrl || '';
|
|
9993
10002
|
}
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
const result = new Uint8Array(hex.length / 2);
|
|
9997
|
-
for(let i = 0; i < hex.length; i += 2)result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
9998
|
-
return result;
|
|
10003
|
+
get baseUrl() {
|
|
10004
|
+
return this._baseUrl;
|
|
9999
10005
|
}
|
|
10000
|
-
|
|
10001
|
-
|
|
10006
|
+
get key_converter() {
|
|
10007
|
+
return this._key_converter;
|
|
10002
10008
|
}
|
|
10003
|
-
|
|
10004
|
-
|
|
10009
|
+
set key_converter(converter) {
|
|
10010
|
+
this._key_converter = converter;
|
|
10005
10011
|
}
|
|
10006
|
-
|
|
10007
|
-
return
|
|
10012
|
+
_convert_request(data) {
|
|
10013
|
+
if (!this._key_converter) return data;
|
|
10014
|
+
const result = {};
|
|
10015
|
+
for(const key in data)result[this._key_converter.convert_request(key)] = data[key];
|
|
10016
|
+
return result;
|
|
10008
10017
|
}
|
|
10009
|
-
|
|
10010
|
-
return
|
|
10018
|
+
_convert_response(data) {
|
|
10019
|
+
if (!this._key_converter) return data;
|
|
10020
|
+
const result = {};
|
|
10021
|
+
for(const key in data)result[this._key_converter.convert_response(key)] = data[key];
|
|
10022
|
+
return result;
|
|
10011
10023
|
}
|
|
10012
|
-
|
|
10024
|
+
_get_headers() {}
|
|
10025
|
+
async _request(config) {
|
|
10026
|
+
const { method, data, params, ...rest } = config;
|
|
10027
|
+
let { data: requestData, params: requestParams } = config;
|
|
10028
|
+
if (requestData) requestData = this._convert_request(requestData);
|
|
10029
|
+
if (requestParams) requestParams = this._convert_request(requestParams);
|
|
10013
10030
|
try {
|
|
10014
|
-
this.
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10031
|
+
const response = await this._client.request({
|
|
10032
|
+
method,
|
|
10033
|
+
url: config.url,
|
|
10034
|
+
data: requestData,
|
|
10035
|
+
params: requestParams,
|
|
10036
|
+
...rest,
|
|
10037
|
+
paramsSerializer: (params)=>qs.stringify(params, {
|
|
10038
|
+
arrayFormat: 'repeat'
|
|
10039
|
+
}),
|
|
10040
|
+
headers: {
|
|
10041
|
+
...this._get_headers(),
|
|
10042
|
+
...config?.headers
|
|
10043
|
+
},
|
|
10044
|
+
onUploadProgress: (progressEvent)=>{
|
|
10045
|
+
if (config?.onUploadProgress) config.onUploadProgress(progressEvent.loaded / progressEvent.total);
|
|
10046
|
+
},
|
|
10047
|
+
onDownloadProgress: (progressEvent)=>{
|
|
10048
|
+
if (config?.onDownloadProgress) config.onDownloadProgress(progressEvent.loaded / progressEvent.total);
|
|
10049
|
+
}
|
|
10023
10050
|
});
|
|
10024
|
-
if (!
|
|
10025
|
-
return this.
|
|
10051
|
+
if (!response.headers['content-type'].includes('json')) return response;
|
|
10052
|
+
return this._convert_response(response.data);
|
|
10026
10053
|
} catch (error) {
|
|
10027
|
-
if (error
|
|
10028
|
-
|
|
10054
|
+
if (axios.isAxiosError(error)) {
|
|
10055
|
+
const url = error.config?.url || config.url;
|
|
10056
|
+
if (401 === error.status) try {
|
|
10057
|
+
LYSession.clear();
|
|
10058
|
+
} catch (error) {
|
|
10059
|
+
console.error(error);
|
|
10060
|
+
} finally{
|
|
10061
|
+
window.location.reload();
|
|
10062
|
+
}
|
|
10063
|
+
if (error.response) throw new LYHttpStatusError(error.response?.data?.detail || error.message, url, method, error, error.response.status);
|
|
10064
|
+
if (error.request) throw new LYNetworkError(error.message, url, method, error);
|
|
10065
|
+
throw new LYConfigError(error.message, url, method, error);
|
|
10066
|
+
}
|
|
10067
|
+
throw error;
|
|
10029
10068
|
}
|
|
10030
10069
|
}
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
const ivHex = this._uint8ArrayToHex(paddedIv);
|
|
10037
|
-
const dataHex = this._uint8ArrayToHex(data);
|
|
10038
|
-
const decrypted = sm4.decrypt(dataHex, keyHex, {
|
|
10039
|
-
iv: ivHex,
|
|
10040
|
-
mode: 'cbc',
|
|
10041
|
-
padding: 'pkcs#7'
|
|
10042
|
-
});
|
|
10043
|
-
if (!decrypted) throw new LYCryptoError('SM4 decryption failed');
|
|
10044
|
-
return this._hexToUint8Array(decrypted);
|
|
10045
|
-
} catch (error) {
|
|
10046
|
-
if (error instanceof LYCryptoError) throw error;
|
|
10047
|
-
throw new LYCryptoError(`SM4 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10048
|
-
}
|
|
10070
|
+
async withRetry(fn) {
|
|
10071
|
+
let config = LYConfig.get().http.retry;
|
|
10072
|
+
config = fn(config.clone());
|
|
10073
|
+
Date.now();
|
|
10074
|
+
return this;
|
|
10049
10075
|
}
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
return signature;
|
|
10058
|
-
} catch (error) {
|
|
10059
|
-
if (error instanceof LYCryptoError) throw error;
|
|
10060
|
-
throw new LYCryptoError(`SM2 signature error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10061
|
-
}
|
|
10076
|
+
async get(url, query, config) {
|
|
10077
|
+
return this._request({
|
|
10078
|
+
method: 'GET',
|
|
10079
|
+
url,
|
|
10080
|
+
params: query,
|
|
10081
|
+
...config
|
|
10082
|
+
});
|
|
10062
10083
|
}
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
}
|
|
10070
|
-
if (error instanceof LYCryptoError) throw error;
|
|
10071
|
-
throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10072
|
-
}
|
|
10084
|
+
async post(url, data, config) {
|
|
10085
|
+
return this._request({
|
|
10086
|
+
method: 'POST',
|
|
10087
|
+
url,
|
|
10088
|
+
data: data,
|
|
10089
|
+
...config
|
|
10090
|
+
});
|
|
10073
10091
|
}
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
return this._hexToUint8Array(encrypted);
|
|
10082
|
-
} catch (error) {
|
|
10083
|
-
if (error instanceof LYCryptoError) throw error;
|
|
10084
|
-
throw new LYCryptoError(`SM2 encryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10085
|
-
}
|
|
10092
|
+
async put(url, data, config) {
|
|
10093
|
+
return this._request({
|
|
10094
|
+
method: 'PUT',
|
|
10095
|
+
url,
|
|
10096
|
+
data: data,
|
|
10097
|
+
...config
|
|
10098
|
+
});
|
|
10086
10099
|
}
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
return this._hexToUint8Array(decrypted);
|
|
10095
|
-
} catch (error) {
|
|
10096
|
-
if (error instanceof LYCryptoError) throw error;
|
|
10097
|
-
throw new LYCryptoError(`SM2 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10098
|
-
}
|
|
10100
|
+
async delete(url, query, config) {
|
|
10101
|
+
return this._request({
|
|
10102
|
+
method: 'DELETE',
|
|
10103
|
+
url,
|
|
10104
|
+
params: query,
|
|
10105
|
+
...config
|
|
10106
|
+
});
|
|
10099
10107
|
}
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
if (!hmacResult) throw new LYCryptoError('SM3 HMAC failed');
|
|
10108
|
-
return this._hexToUint8Array(hmacResult);
|
|
10109
|
-
}
|
|
10110
|
-
{
|
|
10111
|
-
const hashResult = sm3(data);
|
|
10112
|
-
if (!hashResult) throw new LYCryptoError('SM3 hash failed');
|
|
10113
|
-
return this._hexToUint8Array(hashResult);
|
|
10114
|
-
}
|
|
10115
|
-
} catch (error) {
|
|
10116
|
-
if (error instanceof LYCryptoError) throw error;
|
|
10117
|
-
throw new LYCryptoError(`SM3 hash error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10118
|
-
}
|
|
10108
|
+
async patch(url, data, config) {
|
|
10109
|
+
return this._request({
|
|
10110
|
+
method: 'PATCH',
|
|
10111
|
+
url,
|
|
10112
|
+
data: data,
|
|
10113
|
+
...config
|
|
10114
|
+
});
|
|
10119
10115
|
}
|
|
10120
10116
|
}
|
|
10121
|
-
|
|
10117
|
+
LYHttpClient = http_base_ts_decorate([
|
|
10118
|
+
register('LYHttpClient'),
|
|
10119
|
+
base_ts_metadata("design:type", Function),
|
|
10120
|
+
base_ts_metadata("design:paramtypes", [
|
|
10121
|
+
String
|
|
10122
|
+
])
|
|
10123
|
+
], LYHttpClient);
|
|
10124
|
+
function src_http_ts_decorate(decorators, target, key, desc) {
|
|
10125
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10126
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10127
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10128
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10129
|
+
}
|
|
10130
|
+
function src_http_ts_metadata(k, v) {
|
|
10131
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10132
|
+
}
|
|
10133
|
+
const ROUTE_PREFIX_WEB_API = 'web';
|
|
10134
|
+
class http_LYAppHttpClient extends LYHttpClient {
|
|
10135
|
+
constructor(app_name, headerProvider){
|
|
10136
|
+
super(`/${ROUTE_PREFIX_WEB_API}/${app_name}`);
|
|
10137
|
+
this._headerProvider = headerProvider;
|
|
10138
|
+
}
|
|
10139
|
+
_getUrl(url) {
|
|
10140
|
+
return url;
|
|
10141
|
+
}
|
|
10142
|
+
_get_headers() {
|
|
10143
|
+
return this._headerProvider.headers;
|
|
10144
|
+
}
|
|
10145
|
+
async _request(config) {
|
|
10146
|
+
const { method, data, ...rest } = config;
|
|
10147
|
+
let url = this._getUrl(config.url);
|
|
10148
|
+
if ('GET' !== method && 'POST' !== method) throw new LYError(`Method ${method} not allowed`);
|
|
10149
|
+
const response = await super._request({
|
|
10150
|
+
method,
|
|
10151
|
+
data,
|
|
10152
|
+
...rest,
|
|
10153
|
+
url
|
|
10154
|
+
});
|
|
10155
|
+
if (void 0 !== response.status) return response;
|
|
10156
|
+
const result = response;
|
|
10157
|
+
if ('not_exists' === result.code) return result;
|
|
10158
|
+
if ('success' !== result.code) {
|
|
10159
|
+
url = `${this.baseUrl}/${url}`;
|
|
10160
|
+
throw new LYAppHttpError(result.message, url, method, new Error(), result.code);
|
|
10161
|
+
}
|
|
10162
|
+
return result;
|
|
10163
|
+
}
|
|
10164
|
+
async uploadFile(params, config) {
|
|
10165
|
+
const formData = new FormData();
|
|
10166
|
+
if (params.id) formData.append('id', params.id);
|
|
10167
|
+
if (params.ref_id) formData.append('ref_id', params.ref_id);
|
|
10168
|
+
if (params.ref_type) formData.append('ref_type', params.ref_type);
|
|
10169
|
+
if (void 0 !== params.expire) formData.append('expire', String(params.expire));
|
|
10170
|
+
if (void 0 !== params.ignore_session) formData.append('ignore_session', String(params.ignore_session));
|
|
10171
|
+
if (params.extra) formData.append('extra', JSON.stringify(params.extra));
|
|
10172
|
+
formData.append('total_size', String(params.total_size || params.chunk?.size));
|
|
10173
|
+
if (void 0 !== params.encryption) formData.append('encryption', String(params.encryption));
|
|
10174
|
+
if (params.state) formData.append('state', JSON.stringify(params.state));
|
|
10175
|
+
if (params.level) formData.append('level', params.level);
|
|
10176
|
+
formData.append('chunk', params.chunk);
|
|
10177
|
+
const response = await this.post("/file", formData, {
|
|
10178
|
+
...config,
|
|
10179
|
+
headers: {
|
|
10180
|
+
'Content-Type': 'multipart/form-data',
|
|
10181
|
+
...config?.headers
|
|
10182
|
+
}
|
|
10183
|
+
});
|
|
10184
|
+
return response;
|
|
10185
|
+
}
|
|
10186
|
+
async uploadFileInChunks(params, config) {
|
|
10187
|
+
const file = params.chunk;
|
|
10188
|
+
const chunkSize = config?.chunkSize || 20971520;
|
|
10189
|
+
const startChunkIndex = config?.startChunkIndex || 0;
|
|
10190
|
+
const totalChunks = Math.ceil(file.size / chunkSize);
|
|
10191
|
+
let uploadedChunks = 0;
|
|
10192
|
+
let currentState = params.state;
|
|
10193
|
+
let fileId = params.id;
|
|
10194
|
+
for(let chunkIndex = startChunkIndex; chunkIndex < totalChunks; chunkIndex++){
|
|
10195
|
+
const start = chunkIndex * chunkSize;
|
|
10196
|
+
const end = Math.min(start + chunkSize, file.size);
|
|
10197
|
+
const chunk = file.slice(start, end);
|
|
10198
|
+
try {
|
|
10199
|
+
const uploadParams = {
|
|
10200
|
+
...params,
|
|
10201
|
+
chunk: new File([
|
|
10202
|
+
chunk
|
|
10203
|
+
], file.name, {
|
|
10204
|
+
type: file.type
|
|
10205
|
+
}),
|
|
10206
|
+
state: currentState,
|
|
10207
|
+
id: fileId,
|
|
10208
|
+
total_size: file.size
|
|
10209
|
+
};
|
|
10210
|
+
const response = await this.uploadFile(uploadParams, config);
|
|
10211
|
+
fileId = response.data?.id || fileId;
|
|
10212
|
+
currentState = response.data?.state || currentState;
|
|
10213
|
+
uploadedChunks++;
|
|
10214
|
+
const progress = uploadedChunks / (totalChunks - startChunkIndex) * 100;
|
|
10215
|
+
config?.onProgress?.(progress);
|
|
10216
|
+
} catch (error) {
|
|
10217
|
+
this.emit('upload_failed', {
|
|
10218
|
+
error,
|
|
10219
|
+
file,
|
|
10220
|
+
fileId,
|
|
10221
|
+
state: currentState,
|
|
10222
|
+
params,
|
|
10223
|
+
failedChunkIndex: chunkIndex,
|
|
10224
|
+
uploadedChunks
|
|
10225
|
+
});
|
|
10226
|
+
throw error;
|
|
10227
|
+
}
|
|
10228
|
+
}
|
|
10229
|
+
return {
|
|
10230
|
+
id: fileId,
|
|
10231
|
+
state: currentState
|
|
10232
|
+
};
|
|
10233
|
+
}
|
|
10234
|
+
async download(fileId, fileName, config) {
|
|
10235
|
+
config?.chunkSize;
|
|
10236
|
+
const resumeFromByte = config?.resumeFromByte || 0;
|
|
10237
|
+
const url = `${this.baseUrl}/${this._getUrl(`/file/${fileId}`)}`;
|
|
10238
|
+
const headers = {
|
|
10239
|
+
Accept: '*/*',
|
|
10240
|
+
...this._get_headers(),
|
|
10241
|
+
...config?.headers
|
|
10242
|
+
};
|
|
10243
|
+
const blob = new Blob();
|
|
10244
|
+
let reader;
|
|
10245
|
+
try {
|
|
10246
|
+
const downloadResponse = await fetch(url, {
|
|
10247
|
+
method: 'GET',
|
|
10248
|
+
headers: {
|
|
10249
|
+
...headers,
|
|
10250
|
+
...resumeFromByte > 0 && {
|
|
10251
|
+
Range: `bytes=${resumeFromByte}-`
|
|
10252
|
+
}
|
|
10253
|
+
},
|
|
10254
|
+
credentials: 'include'
|
|
10255
|
+
});
|
|
10256
|
+
if (!downloadResponse.ok) throw new Error(`Download request failed: ${downloadResponse.status} ${downloadResponse.statusText}`);
|
|
10257
|
+
reader = downloadResponse.body?.getReader();
|
|
10258
|
+
if (!reader) throw new Error('Response body is not readable');
|
|
10259
|
+
const contentLength = parseInt(downloadResponse.headers.get('content-length') || '0');
|
|
10260
|
+
const contentType = downloadResponse.headers.get('content-type') || 'application/octet-stream';
|
|
10261
|
+
const contentRange = downloadResponse.headers.get('content-range');
|
|
10262
|
+
const contentDisposition = downloadResponse.headers.get('content-disposition');
|
|
10263
|
+
let totalSize = contentLength;
|
|
10264
|
+
if (contentRange) {
|
|
10265
|
+
const match = contentRange.match(/bytes \d+-\d+\/(\d+)/);
|
|
10266
|
+
if (match) totalSize = parseInt(match[1]);
|
|
10267
|
+
}
|
|
10268
|
+
let finalFileName = fileName;
|
|
10269
|
+
if (!finalFileName && contentDisposition) {
|
|
10270
|
+
const utf8Match = contentDisposition.match(/filename\*=UTF-8''([^;]+)/);
|
|
10271
|
+
if (utf8Match) finalFileName = decodeURIComponent(utf8Match[1]);
|
|
10272
|
+
else {
|
|
10273
|
+
const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
|
10274
|
+
if (filenameMatch && filenameMatch[1]) finalFileName = filenameMatch[1].replace(/['"]/g, '');
|
|
10275
|
+
}
|
|
10276
|
+
}
|
|
10277
|
+
const chunks = [];
|
|
10278
|
+
let totalLoaded = 0;
|
|
10279
|
+
let progress = 0;
|
|
10280
|
+
let blob;
|
|
10281
|
+
while(true){
|
|
10282
|
+
const { done, value } = await reader.read();
|
|
10283
|
+
if (done) break;
|
|
10284
|
+
chunks.push(value);
|
|
10285
|
+
totalLoaded += value.length;
|
|
10286
|
+
const newProgress = totalSize > 0 ? totalLoaded / totalSize * 100 : 0;
|
|
10287
|
+
if (newProgress !== progress) {
|
|
10288
|
+
progress = newProgress;
|
|
10289
|
+
config?.onProgress?.(progress);
|
|
10290
|
+
}
|
|
10291
|
+
}
|
|
10292
|
+
blob = new Blob(chunks, {
|
|
10293
|
+
type: contentType
|
|
10294
|
+
});
|
|
10295
|
+
return {
|
|
10296
|
+
blob,
|
|
10297
|
+
fileName: finalFileName,
|
|
10298
|
+
contentType,
|
|
10299
|
+
totalSize: totalSize || blob.size
|
|
10300
|
+
};
|
|
10301
|
+
} catch (error) {
|
|
10302
|
+
if (reader) reader.cancel();
|
|
10303
|
+
this.emit('download_failed', {
|
|
10304
|
+
error,
|
|
10305
|
+
fileId,
|
|
10306
|
+
fileName,
|
|
10307
|
+
blob
|
|
10308
|
+
});
|
|
10309
|
+
throw error;
|
|
10310
|
+
}
|
|
10311
|
+
}
|
|
10312
|
+
async downloadFile(fileId, fileName, config) {
|
|
10313
|
+
const result = await this.download(fileId, fileName, config);
|
|
10314
|
+
downloadjs(result.blob, result.fileName, result.contentType);
|
|
10315
|
+
}
|
|
10316
|
+
async *stream(url, config) {
|
|
10317
|
+
const { data, delimiter = '\n', headers: customHeaders } = config || {};
|
|
10318
|
+
const fullUrl = `${this.baseUrl}/${this._getUrl(url)}`;
|
|
10319
|
+
const headers = {
|
|
10320
|
+
...this._get_headers(),
|
|
10321
|
+
...customHeaders,
|
|
10322
|
+
Accept: 'text/event-stream',
|
|
10323
|
+
'Content-Type': 'application/json'
|
|
10324
|
+
};
|
|
10325
|
+
const abortController = new AbortController();
|
|
10326
|
+
if (config?.signal) config.signal.addEventListener('abort', ()=>{
|
|
10327
|
+
abortController.abort();
|
|
10328
|
+
});
|
|
10329
|
+
const requestOptions = {
|
|
10330
|
+
method: 'POST',
|
|
10331
|
+
headers,
|
|
10332
|
+
signal: abortController.signal,
|
|
10333
|
+
body: JSON.stringify(data)
|
|
10334
|
+
};
|
|
10335
|
+
try {
|
|
10336
|
+
const response = await fetch(fullUrl, requestOptions);
|
|
10337
|
+
if (!response.ok || !response.body) throw new Error(`SSE connection failed: ${response.status}`);
|
|
10338
|
+
const reader = response.body.getReader();
|
|
10339
|
+
const decoder = new TextDecoder();
|
|
10340
|
+
let buffer = '';
|
|
10341
|
+
try {
|
|
10342
|
+
while(true){
|
|
10343
|
+
const { value, done } = await reader.read();
|
|
10344
|
+
if (done) break;
|
|
10345
|
+
const chunk = decoder.decode(value, {
|
|
10346
|
+
stream: true
|
|
10347
|
+
});
|
|
10348
|
+
buffer += chunk;
|
|
10349
|
+
const parts = buffer.split(delimiter);
|
|
10350
|
+
buffer = parts.pop() ?? '';
|
|
10351
|
+
for (const part of parts){
|
|
10352
|
+
const trimmed = part.trim();
|
|
10353
|
+
if (0 !== trimmed.length) yield this.parseChunk(trimmed);
|
|
10354
|
+
}
|
|
10355
|
+
}
|
|
10356
|
+
if (buffer.trim()) yield this.parseChunk(buffer);
|
|
10357
|
+
} finally{
|
|
10358
|
+
reader.releaseLock();
|
|
10359
|
+
}
|
|
10360
|
+
} catch (error) {
|
|
10361
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
10362
|
+
throw new Error(errorMessage);
|
|
10363
|
+
}
|
|
10364
|
+
}
|
|
10365
|
+
parseChunk(text) {
|
|
10366
|
+
Uint8Array;
|
|
10367
|
+
try {
|
|
10368
|
+
return JSON.parse(text);
|
|
10369
|
+
} catch {
|
|
10370
|
+
return text;
|
|
10371
|
+
}
|
|
10372
|
+
}
|
|
10373
|
+
}
|
|
10374
|
+
http_LYAppHttpClient = src_http_ts_decorate([
|
|
10375
|
+
register('LYAppHttpClient'),
|
|
10376
|
+
src_http_ts_metadata("design:type", Function),
|
|
10377
|
+
src_http_ts_metadata("design:paramtypes", [
|
|
10378
|
+
String,
|
|
10379
|
+
"undefined" == typeof IHeaderProvider ? Object : IHeaderProvider
|
|
10380
|
+
])
|
|
10381
|
+
], http_LYAppHttpClient);
|
|
10382
|
+
class LYOrganizationHttpClient extends http_LYAppHttpClient {
|
|
10383
|
+
static getTenantName() {
|
|
10384
|
+
const url = window.location.pathname;
|
|
10385
|
+
const parts = url.split('/');
|
|
10386
|
+
const index = parts.findIndex((part)=>'view' === part);
|
|
10387
|
+
if (-1 === index || index + 1 >= parts.length) return '';
|
|
10388
|
+
return parts[index + 2];
|
|
10389
|
+
}
|
|
10390
|
+
_getUrl(url) {
|
|
10391
|
+
url = super._getUrl(url);
|
|
10392
|
+
let tenantName = LYOrganizationHttpClient.getTenantName();
|
|
10393
|
+
if ('development' === process.env.NODE_ENV) tenantName = "laiye";
|
|
10394
|
+
if (tenantName) url = url.startsWith('/') ? `${tenantName}${url}` : `${tenantName}/${url}`;
|
|
10395
|
+
return url;
|
|
10396
|
+
}
|
|
10397
|
+
}
|
|
10398
|
+
LYOrganizationHttpClient = src_http_ts_decorate([
|
|
10399
|
+
register('LOrganizationHttpClient')
|
|
10400
|
+
], LYOrganizationHttpClient);
|
|
10401
|
+
function i18n_ts_decorate(decorators, target, key, desc) {
|
|
10402
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10403
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10404
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10405
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10406
|
+
}
|
|
10407
|
+
function i18n_ts_metadata(k, v) {
|
|
10408
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10409
|
+
}
|
|
10410
|
+
var i18n_LYLangEnum = /*#__PURE__*/ function(LYLangEnum) {
|
|
10411
|
+
LYLangEnum["zh-CN"] = "简体中文";
|
|
10412
|
+
LYLangEnum["en-US"] = "English";
|
|
10413
|
+
return LYLangEnum;
|
|
10414
|
+
}({});
|
|
10415
|
+
const i18n_langKeys = Object.keys(i18n_LYLangEnum);
|
|
10416
|
+
const languages = {};
|
|
10417
|
+
const LANG_KEY = 'lang';
|
|
10418
|
+
class LYi18n extends LYObject {
|
|
10419
|
+
constructor(namespace){
|
|
10420
|
+
super();
|
|
10421
|
+
this._namespace = namespace || 'LY.';
|
|
10422
|
+
}
|
|
10423
|
+
get t() {
|
|
10424
|
+
return (rest, options)=>{
|
|
10425
|
+
if (!rest) return "<Null>";
|
|
10426
|
+
if (rest.includes(':')) return rest.startsWith(`${this.namespace}:`) ? i18next.t(rest, options) : i18next.t(`${this.namespace}.${rest}`, options);
|
|
10427
|
+
return i18next.t(`${this.namespace}:${rest}`, options);
|
|
10428
|
+
};
|
|
10429
|
+
}
|
|
10430
|
+
get lang() {
|
|
10431
|
+
return this._lang || this.resolveLanguage();
|
|
10432
|
+
}
|
|
10433
|
+
get languages() {
|
|
10434
|
+
return languages;
|
|
10435
|
+
}
|
|
10436
|
+
get namespace() {
|
|
10437
|
+
return this._namespace;
|
|
10438
|
+
}
|
|
10439
|
+
async initialize() {
|
|
10440
|
+
if (!this._lang) this._lang = this.resolveLanguage();
|
|
10441
|
+
i18next.on('languageChanged', (lang)=>{
|
|
10442
|
+
if (this._lang !== lang) {
|
|
10443
|
+
this._lang = lang;
|
|
10444
|
+
this.emit('lang-changed', lang);
|
|
10445
|
+
}
|
|
10446
|
+
});
|
|
10447
|
+
if (i18next.isInitialized) return;
|
|
10448
|
+
const defaultVariables = {};
|
|
10449
|
+
const env = LYEnv.getInstance(this._namespace);
|
|
10450
|
+
for(const key in env)defaultVariables['$' + key] = env[key];
|
|
10451
|
+
await i18next.init({
|
|
10452
|
+
fallbackLng: 'zh-CN',
|
|
10453
|
+
lng: this._lang,
|
|
10454
|
+
defaultNS: this.namespace,
|
|
10455
|
+
returnObjects: true,
|
|
10456
|
+
interpolation: {
|
|
10457
|
+
escapeValue: false,
|
|
10458
|
+
defaultVariables
|
|
10459
|
+
}
|
|
10460
|
+
});
|
|
10461
|
+
await this.changeLanguage(this._lang);
|
|
10462
|
+
}
|
|
10463
|
+
fallbackLng(lang) {
|
|
10464
|
+
if (lang.includes('en')) return 'en-US';
|
|
10465
|
+
return 'zh-CN';
|
|
10466
|
+
}
|
|
10467
|
+
resolveLanguage() {
|
|
10468
|
+
const langKeys = Object.keys(this.languages);
|
|
10469
|
+
if (1 === langKeys.length) return this.fallbackLng(langKeys[0]);
|
|
10470
|
+
const searchParams = new URLSearchParams(location.search);
|
|
10471
|
+
let lang = searchParams.get(LANG_KEY);
|
|
10472
|
+
if (lang) {
|
|
10473
|
+
lang = this.fallbackLng(lang);
|
|
10474
|
+
return lang;
|
|
10475
|
+
}
|
|
10476
|
+
if (!sharedLocalStorage.getSync(LANG_KEY)) {
|
|
10477
|
+
lang = this.fallbackLng(navigator.language);
|
|
10478
|
+
return lang;
|
|
10479
|
+
}
|
|
10480
|
+
lang = sharedLocalStorage.getSync(LANG_KEY) || 'zh-CN';
|
|
10481
|
+
return lang;
|
|
10482
|
+
}
|
|
10483
|
+
async loadResource(urlOrJson, lang, namespace) {
|
|
10484
|
+
if ('string' == typeof urlOrJson) {
|
|
10485
|
+
const res = await this.getUrlResource(urlOrJson);
|
|
10486
|
+
if (!res) return;
|
|
10487
|
+
urlOrJson = res;
|
|
10488
|
+
}
|
|
10489
|
+
if (!urlOrJson) return;
|
|
10490
|
+
lang = lang || this._lang;
|
|
10491
|
+
namespace = namespace ? `${this.namespace}.${namespace}` : this.namespace;
|
|
10492
|
+
i18next.addResourceBundle(lang, namespace, urlOrJson);
|
|
10493
|
+
}
|
|
10494
|
+
async getUrlResource(resourceUrl) {
|
|
10495
|
+
try {
|
|
10496
|
+
const res = await axios.get(`${resourceUrl}?v=${window.buildTime}`);
|
|
10497
|
+
return res.data;
|
|
10498
|
+
} catch (error) {
|
|
10499
|
+
this.logger.error("loadUrlResource error");
|
|
10500
|
+
this.logger.error(error);
|
|
10501
|
+
}
|
|
10502
|
+
}
|
|
10503
|
+
async changeLanguage(lang) {
|
|
10504
|
+
this.logger.info(`changeLanguage lang to ${lang}`);
|
|
10505
|
+
this._lang = lang;
|
|
10506
|
+
i18next.isInitialized && await i18next.changeLanguage(lang);
|
|
10507
|
+
sharedLocalStorage.setSync(LANG_KEY, lang);
|
|
10508
|
+
const url = new URL(window.location.href);
|
|
10509
|
+
url.searchParams.delete(LANG_KEY);
|
|
10510
|
+
window.history.replaceState(null, '', url);
|
|
10511
|
+
i18next.isInitialized && this.emit('lang-changed', lang);
|
|
10512
|
+
}
|
|
10513
|
+
getResource(key, lang) {
|
|
10514
|
+
lang = lang || this._lang;
|
|
10515
|
+
let index = key.indexOf(':');
|
|
10516
|
+
key = index <= 0 ? `${this.namespace}:${key}` : key.startsWith(`${this.namespace}:`) ? key : `${this.namespace}.${key}`;
|
|
10517
|
+
index = key.indexOf(':');
|
|
10518
|
+
const ns = key.substring(0, index);
|
|
10519
|
+
const keys = key.substring(index + 1);
|
|
10520
|
+
if (!ns || !keys) return {};
|
|
10521
|
+
const res = i18next.getResourceBundle(lang, ns);
|
|
10522
|
+
if (!res) return {};
|
|
10523
|
+
const resource = keys.split('.').reduce((result, key)=>result[key], res);
|
|
10524
|
+
if (!resource && keys === this.namespace) return res;
|
|
10525
|
+
return resource;
|
|
10526
|
+
}
|
|
10527
|
+
}
|
|
10528
|
+
LYi18n = i18n_ts_decorate([
|
|
10529
|
+
register('LYi18n'),
|
|
10530
|
+
i18n_ts_metadata("design:type", Function),
|
|
10531
|
+
i18n_ts_metadata("design:paramtypes", [
|
|
10532
|
+
String
|
|
10533
|
+
])
|
|
10534
|
+
], LYi18n);
|
|
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");
|
|
10536
|
+
class LYBaseCrypto {
|
|
10537
|
+
}
|
|
10538
|
+
function registerCryptoImpl(name1) {
|
|
10539
|
+
return function(impl) {
|
|
10540
|
+
if (cryptoImpl[name1]) throw new Error(`Crypto implementation for ${name1} already registered`);
|
|
10541
|
+
cryptoImpl[name1] = impl;
|
|
10542
|
+
return impl;
|
|
10543
|
+
};
|
|
10544
|
+
}
|
|
10545
|
+
const cryptoImpl = {
|
|
10546
|
+
default: void 0,
|
|
10547
|
+
sm: void 0,
|
|
10548
|
+
gm: void 0
|
|
10549
|
+
};
|
|
10550
|
+
function sm_ts_decorate(decorators, target, key, desc) {
|
|
10551
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10552
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10553
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10554
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10555
|
+
}
|
|
10556
|
+
class LYSMCrypto extends LYBaseCrypto {
|
|
10557
|
+
_paddingIv(iv) {
|
|
10558
|
+
if (iv.length < 16) {
|
|
10559
|
+
const padded = new Uint8Array(16);
|
|
10560
|
+
padded.set(iv);
|
|
10561
|
+
return padded;
|
|
10562
|
+
}
|
|
10563
|
+
return iv.slice(0, 16);
|
|
10564
|
+
}
|
|
10565
|
+
_uint8ArrayToHex(array) {
|
|
10566
|
+
return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
10567
|
+
}
|
|
10568
|
+
_hexToUint8Array(hex) {
|
|
10569
|
+
if (hex.length % 2 !== 0) throw new LYCryptoError('Invalid hex string length');
|
|
10570
|
+
const result = new Uint8Array(hex.length / 2);
|
|
10571
|
+
for(let i = 0; i < hex.length; i += 2)result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
10572
|
+
return result;
|
|
10573
|
+
}
|
|
10574
|
+
_validateKey(key, expectedLength, keyType) {
|
|
10575
|
+
if (key.length !== expectedLength) throw new LYCryptoError(`Invalid ${keyType} key length: expected ${expectedLength}, got ${key.length}`);
|
|
10576
|
+
}
|
|
10577
|
+
_validatePublicKey(key) {
|
|
10578
|
+
if (64 !== key.length && 65 !== key.length) throw new LYCryptoError(`Invalid SM2 public key length: expected 64 or 65, got ${key.length}`);
|
|
10579
|
+
}
|
|
10580
|
+
getSymmetricBlockSize(iv, key) {
|
|
10581
|
+
return 16;
|
|
10582
|
+
}
|
|
10583
|
+
getAsymmetricBlockSize(publicKey) {
|
|
10584
|
+
return 16;
|
|
10585
|
+
}
|
|
10586
|
+
encryptSymmetric(data, iv, key) {
|
|
10587
|
+
try {
|
|
10588
|
+
this._validateKey(key, 16, 'SM4');
|
|
10589
|
+
const paddedIv = this._paddingIv(iv);
|
|
10590
|
+
const keyHex = this._uint8ArrayToHex(key);
|
|
10591
|
+
const ivHex = this._uint8ArrayToHex(paddedIv);
|
|
10592
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10593
|
+
const encrypted = sm4.encrypt(dataHex, keyHex, {
|
|
10594
|
+
iv: ivHex,
|
|
10595
|
+
mode: 'cbc',
|
|
10596
|
+
padding: 'pkcs#7'
|
|
10597
|
+
});
|
|
10598
|
+
if (!encrypted) throw new LYCryptoError('SM4 encryption failed');
|
|
10599
|
+
return this._hexToUint8Array(encrypted);
|
|
10600
|
+
} catch (error) {
|
|
10601
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10602
|
+
throw new LYCryptoError(`SM4 encryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10603
|
+
}
|
|
10604
|
+
}
|
|
10605
|
+
decryptSymmetric(data, iv, key) {
|
|
10606
|
+
try {
|
|
10607
|
+
this._validateKey(key, 16, 'SM4');
|
|
10608
|
+
const paddedIv = this._paddingIv(iv);
|
|
10609
|
+
const keyHex = this._uint8ArrayToHex(key);
|
|
10610
|
+
const ivHex = this._uint8ArrayToHex(paddedIv);
|
|
10611
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10612
|
+
const decrypted = sm4.decrypt(dataHex, keyHex, {
|
|
10613
|
+
iv: ivHex,
|
|
10614
|
+
mode: 'cbc',
|
|
10615
|
+
padding: 'pkcs#7'
|
|
10616
|
+
});
|
|
10617
|
+
if (!decrypted) throw new LYCryptoError('SM4 decryption failed');
|
|
10618
|
+
return this._hexToUint8Array(decrypted);
|
|
10619
|
+
} catch (error) {
|
|
10620
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10621
|
+
throw new LYCryptoError(`SM4 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10622
|
+
}
|
|
10623
|
+
}
|
|
10624
|
+
signature(data, privateKey) {
|
|
10625
|
+
try {
|
|
10626
|
+
this._validateKey(privateKey, 32, 'SM2 private');
|
|
10627
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10628
|
+
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10629
|
+
const signature = sm2.doSignature(dataHex, privateKeyHex);
|
|
10630
|
+
if (!signature) throw new LYCryptoError('SM2 signature failed');
|
|
10631
|
+
return signature;
|
|
10632
|
+
} catch (error) {
|
|
10633
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10634
|
+
throw new LYCryptoError(`SM2 signature error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10635
|
+
}
|
|
10636
|
+
}
|
|
10637
|
+
verify(data, publicKey, signature) {
|
|
10638
|
+
try {
|
|
10639
|
+
this._validatePublicKey(publicKey);
|
|
10640
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10641
|
+
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10642
|
+
return sm2.doVerifySignature(dataHex, signature, publicKeyHex);
|
|
10643
|
+
} catch (error) {
|
|
10644
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10645
|
+
throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10646
|
+
}
|
|
10647
|
+
}
|
|
10648
|
+
encryptAsymmetric(data, publicKey) {
|
|
10649
|
+
try {
|
|
10650
|
+
this._validatePublicKey(publicKey);
|
|
10651
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10652
|
+
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10653
|
+
const encrypted = sm2.doEncrypt(dataHex, publicKeyHex);
|
|
10654
|
+
if (!encrypted) throw new LYCryptoError('SM2 encryption failed');
|
|
10655
|
+
return this._hexToUint8Array(encrypted);
|
|
10656
|
+
} catch (error) {
|
|
10657
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10658
|
+
throw new LYCryptoError(`SM2 encryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10659
|
+
}
|
|
10660
|
+
}
|
|
10661
|
+
decryptAsymmetric(data, privateKey) {
|
|
10662
|
+
try {
|
|
10663
|
+
this._validateKey(privateKey, 32, 'SM2 private');
|
|
10664
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10665
|
+
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10666
|
+
const decrypted = sm2.doDecrypt(dataHex, privateKeyHex);
|
|
10667
|
+
if (!decrypted) throw new LYCryptoError('SM2 decryption failed');
|
|
10668
|
+
return this._hexToUint8Array(decrypted);
|
|
10669
|
+
} catch (error) {
|
|
10670
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10671
|
+
throw new LYCryptoError(`SM2 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10672
|
+
}
|
|
10673
|
+
}
|
|
10674
|
+
hash(data, key) {
|
|
10675
|
+
try {
|
|
10676
|
+
if (key) {
|
|
10677
|
+
const hmacResult = sm3(data, {
|
|
10678
|
+
key,
|
|
10679
|
+
mode: 'hmac'
|
|
10680
|
+
});
|
|
10681
|
+
if (!hmacResult) throw new LYCryptoError('SM3 HMAC failed');
|
|
10682
|
+
return this._hexToUint8Array(hmacResult);
|
|
10683
|
+
}
|
|
10684
|
+
{
|
|
10685
|
+
const hashResult = sm3(data);
|
|
10686
|
+
if (!hashResult) throw new LYCryptoError('SM3 hash failed');
|
|
10687
|
+
return this._hexToUint8Array(hashResult);
|
|
10688
|
+
}
|
|
10689
|
+
} catch (error) {
|
|
10690
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10691
|
+
throw new LYCryptoError(`SM3 hash error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10692
|
+
}
|
|
10693
|
+
}
|
|
10694
|
+
}
|
|
10695
|
+
LYSMCrypto = sm_ts_decorate([
|
|
10122
10696
|
registerCryptoImpl("sm")
|
|
10123
10697
|
], LYSMCrypto);
|
|
10124
10698
|
function gm_ts_decorate(decorators, target, key, desc) {
|
|
@@ -10438,152 +11012,19 @@ LYCrypto = crypto_ts_decorate([
|
|
|
10438
11012
|
crypto_ts_metadata("design:paramtypes", [])
|
|
10439
11013
|
], LYCrypto);
|
|
10440
11014
|
const crypto_crypto = new LYCrypto();
|
|
10441
|
-
function i18n_ts_decorate(decorators, target, key, desc) {
|
|
10442
|
-
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10443
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10444
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10445
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10446
|
-
}
|
|
10447
|
-
function i18n_ts_metadata(k, v) {
|
|
10448
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10449
|
-
}
|
|
10450
|
-
var i18n_LYLangEnum = /*#__PURE__*/ function(LYLangEnum) {
|
|
10451
|
-
LYLangEnum["zh-CN"] = "简体中文";
|
|
10452
|
-
LYLangEnum["en-US"] = "English";
|
|
10453
|
-
return LYLangEnum;
|
|
10454
|
-
}({});
|
|
10455
|
-
const i18n_langKeys = Object.keys(i18n_LYLangEnum);
|
|
10456
|
-
const languages = {};
|
|
10457
|
-
const LANG_KEY = 'lang';
|
|
10458
|
-
class LYi18n extends LYObject {
|
|
10459
|
-
constructor(namespace){
|
|
10460
|
-
super();
|
|
10461
|
-
this._namespace = namespace || 'LY.';
|
|
10462
|
-
}
|
|
10463
|
-
get t() {
|
|
10464
|
-
return (rest, options)=>{
|
|
10465
|
-
if (!rest) return "<Null>";
|
|
10466
|
-
if (rest.includes(':')) return rest.startsWith(`${this.namespace}:`) ? i18next.t(rest, options) : i18next.t(`${this.namespace}.${rest}`, options);
|
|
10467
|
-
return i18next.t(`${this.namespace}:${rest}`, options);
|
|
10468
|
-
};
|
|
10469
|
-
}
|
|
10470
|
-
get lang() {
|
|
10471
|
-
return this._lang || this.resolveLanguage();
|
|
10472
|
-
}
|
|
10473
|
-
get languages() {
|
|
10474
|
-
return languages;
|
|
10475
|
-
}
|
|
10476
|
-
get namespace() {
|
|
10477
|
-
return this._namespace;
|
|
10478
|
-
}
|
|
10479
|
-
async initialize() {
|
|
10480
|
-
if (!this._lang) this._lang = this.resolveLanguage();
|
|
10481
|
-
i18next.on('languageChanged', (lang)=>{
|
|
10482
|
-
if (this._lang !== lang) {
|
|
10483
|
-
this._lang = lang;
|
|
10484
|
-
this.emit('lang-changed', lang);
|
|
10485
|
-
}
|
|
10486
|
-
});
|
|
10487
|
-
if (i18next.isInitialized) return;
|
|
10488
|
-
const defaultVariables = {};
|
|
10489
|
-
const env = LYEnv.getInstance(this._namespace);
|
|
10490
|
-
for(const key in env)defaultVariables['$' + key] = env[key];
|
|
10491
|
-
await i18next.init({
|
|
10492
|
-
fallbackLng: 'zh-CN',
|
|
10493
|
-
lng: this._lang,
|
|
10494
|
-
defaultNS: this.namespace,
|
|
10495
|
-
returnObjects: true,
|
|
10496
|
-
interpolation: {
|
|
10497
|
-
escapeValue: false,
|
|
10498
|
-
defaultVariables
|
|
10499
|
-
}
|
|
10500
|
-
});
|
|
10501
|
-
await this.changeLanguage(this._lang);
|
|
10502
|
-
}
|
|
10503
|
-
fallbackLng(lang) {
|
|
10504
|
-
if (lang.includes('en')) return 'en-US';
|
|
10505
|
-
return 'zh-CN';
|
|
10506
|
-
}
|
|
10507
|
-
resolveLanguage() {
|
|
10508
|
-
const langKeys = Object.keys(this.languages);
|
|
10509
|
-
if (1 === langKeys.length) return this.fallbackLng(langKeys[0]);
|
|
10510
|
-
const searchParams = new URLSearchParams(location.search);
|
|
10511
|
-
let lang = searchParams.get(LANG_KEY);
|
|
10512
|
-
if (lang) {
|
|
10513
|
-
lang = this.fallbackLng(lang);
|
|
10514
|
-
return lang;
|
|
10515
|
-
}
|
|
10516
|
-
if (!sharedLocalStorage.getSync(LANG_KEY)) {
|
|
10517
|
-
lang = this.fallbackLng(navigator.language);
|
|
10518
|
-
return lang;
|
|
10519
|
-
}
|
|
10520
|
-
lang = sharedLocalStorage.getSync(LANG_KEY) || 'zh-CN';
|
|
10521
|
-
return lang;
|
|
10522
|
-
}
|
|
10523
|
-
async loadResource(urlOrJson, lang, namespace) {
|
|
10524
|
-
if ('string' == typeof urlOrJson) {
|
|
10525
|
-
const res = await this.getUrlResource(urlOrJson);
|
|
10526
|
-
if (!res) return;
|
|
10527
|
-
urlOrJson = res;
|
|
10528
|
-
}
|
|
10529
|
-
if (!urlOrJson) return;
|
|
10530
|
-
lang = lang || this._lang;
|
|
10531
|
-
namespace = namespace ? `${this.namespace}.${namespace}` : this.namespace;
|
|
10532
|
-
i18next.addResourceBundle(lang, namespace, urlOrJson);
|
|
10533
|
-
}
|
|
10534
|
-
async getUrlResource(resourceUrl) {
|
|
10535
|
-
try {
|
|
10536
|
-
const res = await axios.get(resourceUrl);
|
|
10537
|
-
return res.data;
|
|
10538
|
-
} catch (error) {
|
|
10539
|
-
this.logger.error("loadUrlResource error");
|
|
10540
|
-
this.logger.error(error);
|
|
10541
|
-
}
|
|
10542
|
-
}
|
|
10543
|
-
async changeLanguage(lang) {
|
|
10544
|
-
this.logger.info(`changeLanguage lang to ${lang}`);
|
|
10545
|
-
this._lang = lang;
|
|
10546
|
-
i18next.isInitialized && await i18next.changeLanguage(lang);
|
|
10547
|
-
sharedLocalStorage.setSync(LANG_KEY, lang);
|
|
10548
|
-
const url = new URL(window.location.href);
|
|
10549
|
-
url.searchParams.delete(LANG_KEY);
|
|
10550
|
-
window.history.replaceState(null, '', url);
|
|
10551
|
-
i18next.isInitialized && this.emit('lang-changed', lang);
|
|
10552
|
-
}
|
|
10553
|
-
getResource(key, lang) {
|
|
10554
|
-
lang = lang || this._lang;
|
|
10555
|
-
let index = key.indexOf(':');
|
|
10556
|
-
key = index <= 0 ? `${this.namespace}:${key}` : key.startsWith(`${this.namespace}:`) ? key : `${this.namespace}.${key}`;
|
|
10557
|
-
index = key.indexOf(':');
|
|
10558
|
-
const ns = key.substring(0, index);
|
|
10559
|
-
const keys = key.substring(index + 1);
|
|
10560
|
-
if (!ns || !keys) return {};
|
|
10561
|
-
const res = i18next.getResourceBundle(lang, ns);
|
|
10562
|
-
if (!res) return {};
|
|
10563
|
-
const resource = keys.split('.').reduce((result, key)=>result[key], res);
|
|
10564
|
-
if (!resource && keys === this.namespace) return res;
|
|
10565
|
-
return resource;
|
|
10566
|
-
}
|
|
10567
|
-
}
|
|
10568
|
-
LYi18n = i18n_ts_decorate([
|
|
10569
|
-
register('LYi18n'),
|
|
10570
|
-
i18n_ts_metadata("design:type", Function),
|
|
10571
|
-
i18n_ts_metadata("design:paramtypes", [
|
|
10572
|
-
String
|
|
10573
|
-
])
|
|
10574
|
-
], LYi18n);
|
|
10575
11015
|
function app_base_ts_decorate(decorators, target, key, desc) {
|
|
10576
11016
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10577
11017
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10578
11018
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10579
11019
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10580
11020
|
}
|
|
10581
|
-
function
|
|
11021
|
+
function app_base_ts_metadata(k, v) {
|
|
10582
11022
|
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10583
11023
|
}
|
|
10584
11024
|
const CONFIG_URL = "/uci/system_info";
|
|
10585
11025
|
const TENANT_APP_NAME = 'tenant';
|
|
10586
11026
|
const ORGANIZATION_APP_NAME = 'organization';
|
|
11027
|
+
const BILL_APP_NAME = "billing";
|
|
10587
11028
|
(0, runtime.init)({
|
|
10588
11029
|
name: 'uci',
|
|
10589
11030
|
remotes: []
|
|
@@ -10633,6 +11074,9 @@ class base_LYBaseApp extends LYObject {
|
|
|
10633
11074
|
} else if (app.name === ORGANIZATION_APP_NAME) {
|
|
10634
11075
|
const Constructor = LYObject.getClass('LYOrganizationApp');
|
|
10635
11076
|
base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
|
|
11077
|
+
} else if (app.name === BILL_APP_NAME) {
|
|
11078
|
+
const Constructor = LYObject.getClass('LYBillApp');
|
|
11079
|
+
base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
|
|
10636
11080
|
} else {
|
|
10637
11081
|
const specificAppClassName = this.getAppClassName(app.name);
|
|
10638
11082
|
let Constructor;
|
|
@@ -10739,6 +11183,7 @@ class base_LYBaseApp extends LYObject {
|
|
|
10739
11183
|
async doLoad() {
|
|
10740
11184
|
await this.initI18n();
|
|
10741
11185
|
}
|
|
11186
|
+
async updatePermissions() {}
|
|
10742
11187
|
getBaseUrl() {
|
|
10743
11188
|
const config = LYConfig.get();
|
|
10744
11189
|
const url = new URL(window.location.href);
|
|
@@ -10832,8 +11277,8 @@ class base_LYBaseApp extends LYObject {
|
|
|
10832
11277
|
}
|
|
10833
11278
|
base_LYBaseApp = app_base_ts_decorate([
|
|
10834
11279
|
register('LYBaseApp'),
|
|
10835
|
-
|
|
10836
|
-
|
|
11280
|
+
app_base_ts_metadata("design:type", Function),
|
|
11281
|
+
app_base_ts_metadata("design:paramtypes", [
|
|
10837
11282
|
String,
|
|
10838
11283
|
String,
|
|
10839
11284
|
String
|
|
@@ -10890,8 +11335,14 @@ class LYUserApi {
|
|
|
10890
11335
|
const response = await this._httpClient.get('/user', params);
|
|
10891
11336
|
return response.data;
|
|
10892
11337
|
}
|
|
10893
|
-
async
|
|
10894
|
-
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}`);
|
|
10895
11346
|
return response.data;
|
|
10896
11347
|
}
|
|
10897
11348
|
async add(user) {
|
|
@@ -10901,15 +11352,15 @@ class LYUserApi {
|
|
|
10901
11352
|
});
|
|
10902
11353
|
return response.data.id;
|
|
10903
11354
|
}
|
|
10904
|
-
async update(
|
|
10905
|
-
const response = await this._httpClient.post(`/user/patch/${
|
|
11355
|
+
async update(id, user) {
|
|
11356
|
+
const response = await this._httpClient.post(`/user/patch/${id}`, {
|
|
10906
11357
|
...user,
|
|
10907
11358
|
password: user.password
|
|
10908
11359
|
});
|
|
10909
11360
|
return response.data.count;
|
|
10910
11361
|
}
|
|
10911
|
-
async remove(
|
|
10912
|
-
const response = await this._httpClient.post(`/user/delete/${
|
|
11362
|
+
async remove(id, request) {
|
|
11363
|
+
const response = await this._httpClient.post(`/user/delete/${id}`, request);
|
|
10913
11364
|
return response.data.count;
|
|
10914
11365
|
}
|
|
10915
11366
|
async accountCheck(request) {
|
|
@@ -10928,10 +11379,10 @@ class LYUserApi {
|
|
|
10928
11379
|
const response = await this._httpClient.get(`/user/username-check/${name1}`);
|
|
10929
11380
|
return response.data.available;
|
|
10930
11381
|
}
|
|
10931
|
-
async changePassword(
|
|
11382
|
+
async changePassword(request) {
|
|
10932
11383
|
const response = await this._httpClient.post("/user/password/change", {
|
|
10933
|
-
current_password:
|
|
10934
|
-
new_password:
|
|
11384
|
+
current_password: request.current_password,
|
|
11385
|
+
new_password: request.new_password
|
|
10935
11386
|
});
|
|
10936
11387
|
return response.data;
|
|
10937
11388
|
}
|
|
@@ -10941,6 +11392,14 @@ class LYUserApi {
|
|
|
10941
11392
|
});
|
|
10942
11393
|
return response.data;
|
|
10943
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
|
+
}
|
|
10944
11403
|
}
|
|
10945
11404
|
const base_ORGANIZATION_APP_NAME = 'organization';
|
|
10946
11405
|
class LYBaseAuthorizer extends LYObject {
|
|
@@ -10987,18 +11446,96 @@ class LYWebAuthorizer extends LYBaseAuthorizer {
|
|
|
10987
11446
|
this._sessionApi = sessionApi;
|
|
10988
11447
|
LYSession.setRefreshCallback(this._refreshSession.bind(this));
|
|
10989
11448
|
}
|
|
10990
|
-
|
|
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
|
+
};
|
|
10991
11498
|
const response = await this._sessionApi.create({
|
|
10992
|
-
name:
|
|
10993
|
-
password:
|
|
10994
|
-
email:
|
|
10995
|
-
phone:
|
|
10996
|
-
country_code:
|
|
10997
|
-
account_type:
|
|
10998
|
-
verification_code:
|
|
10999
|
-
verification_code_id:
|
|
11000
|
-
|
|
11001
|
-
|
|
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);
|
|
11002
11539
|
}
|
|
11003
11540
|
async _signout(args) {
|
|
11004
11541
|
const session = LYSession.get();
|
|
@@ -11237,6 +11774,10 @@ class LYLicenseApi {
|
|
|
11237
11774
|
});
|
|
11238
11775
|
return response.data;
|
|
11239
11776
|
}
|
|
11777
|
+
async getCustomerInfo() {
|
|
11778
|
+
const response = await this._httpClient.get("/license/customer-info");
|
|
11779
|
+
return response.data;
|
|
11780
|
+
}
|
|
11240
11781
|
}
|
|
11241
11782
|
class LYOEMApi {
|
|
11242
11783
|
constructor(httpClient){
|
|
@@ -11272,35 +11813,157 @@ class LYOEMApi {
|
|
|
11272
11813
|
const result = await this._httpClient.get("/oem/resource", request);
|
|
11273
11814
|
return result.data;
|
|
11274
11815
|
}
|
|
11275
|
-
async createResource(request) {
|
|
11276
|
-
const result = await this._httpClient.post("/oem/resource/create", request);
|
|
11277
|
-
return result.data;
|
|
11816
|
+
async createResource(request) {
|
|
11817
|
+
const result = await this._httpClient.post("/oem/resource/create", request);
|
|
11818
|
+
return result.data;
|
|
11819
|
+
}
|
|
11820
|
+
async updateResource(request) {
|
|
11821
|
+
const result = await this._httpClient.post("/oem/resource/patch", request);
|
|
11822
|
+
return result.data;
|
|
11823
|
+
}
|
|
11824
|
+
async deleteResource(request) {
|
|
11825
|
+
const result = await this._httpClient.post("/oem/resource/delete", request);
|
|
11826
|
+
return result.data;
|
|
11827
|
+
}
|
|
11828
|
+
}
|
|
11829
|
+
class LYVerificationCodesApi {
|
|
11830
|
+
constructor(httpClient){
|
|
11831
|
+
this._httpClient = httpClient;
|
|
11832
|
+
}
|
|
11833
|
+
async send(request) {
|
|
11834
|
+
const response = await this._httpClient.post('/verification-codes', {
|
|
11835
|
+
...request
|
|
11836
|
+
});
|
|
11837
|
+
return response.data;
|
|
11838
|
+
}
|
|
11839
|
+
async check(request) {
|
|
11840
|
+
const response = await this._httpClient.post(`/verification-codes/${request.verification_code_id}/usage`, {
|
|
11841
|
+
...request
|
|
11842
|
+
});
|
|
11843
|
+
return response.data;
|
|
11844
|
+
}
|
|
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;
|
|
11278
11912
|
}
|
|
11279
|
-
async
|
|
11280
|
-
const
|
|
11281
|
-
|
|
11913
|
+
async batchUpdate(departments) {
|
|
11914
|
+
const response = await this._httpClient.post('/department/patch', {
|
|
11915
|
+
departments
|
|
11916
|
+
});
|
|
11917
|
+
return response.data.count;
|
|
11282
11918
|
}
|
|
11283
|
-
async
|
|
11284
|
-
const
|
|
11285
|
-
|
|
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;
|
|
11286
11924
|
}
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
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;
|
|
11291
11931
|
}
|
|
11292
|
-
async
|
|
11293
|
-
const response = await this._httpClient.post(
|
|
11294
|
-
|
|
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
|
|
11295
11941
|
});
|
|
11296
11942
|
return response.data;
|
|
11297
11943
|
}
|
|
11298
|
-
async
|
|
11299
|
-
const response = await this._httpClient.post(`/
|
|
11300
|
-
|
|
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
|
|
11301
11948
|
});
|
|
11949
|
+
return response.data.count;
|
|
11950
|
+
}
|
|
11951
|
+
async queryUserDepartmentDataPermissions(params) {
|
|
11952
|
+
const response = await this._httpClient.get('/user-department-data-permission', params);
|
|
11302
11953
|
return response.data;
|
|
11303
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
|
+
}
|
|
11304
11967
|
}
|
|
11305
11968
|
function app_ts_decorate(decorators, target, key, desc) {
|
|
11306
11969
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -11313,11 +11976,13 @@ function app_ts_metadata(k, v) {
|
|
|
11313
11976
|
}
|
|
11314
11977
|
class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
11315
11978
|
constructor(name1, version, description){
|
|
11316
|
-
super(name1, version, description);
|
|
11979
|
+
super(name1, version, description), this._permissionMeta = {};
|
|
11317
11980
|
LYOrganizationApp._instance = this;
|
|
11318
11981
|
this._sessionApi = new session_LYSessionApi(this.httpClient);
|
|
11319
11982
|
this._userApi = new LYUserApi(this.httpClient);
|
|
11320
11983
|
this._licenseApi = new LYLicenseApi(this.httpClient);
|
|
11984
|
+
this._permissionApi = new LYPermissionApi(this.httpClient);
|
|
11985
|
+
this._departmentApi = new LYDepartmentApi(this.httpClient);
|
|
11321
11986
|
this._oemApi = new LYOEMApi(this.httpClient);
|
|
11322
11987
|
this._verificationCodesApi = new LYVerificationCodesApi(this.httpClient);
|
|
11323
11988
|
this._authorizers = {
|
|
@@ -11346,8 +12011,54 @@ class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
|
11346
12011
|
get verificationCodesApi() {
|
|
11347
12012
|
return this._verificationCodesApi;
|
|
11348
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
|
+
}
|
|
11349
12036
|
async doLoad() {
|
|
11350
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
|
+
}
|
|
11351
12062
|
}
|
|
11352
12063
|
async mergeOEM(originResources) {
|
|
11353
12064
|
try {
|
|
@@ -11772,434 +12483,300 @@ LYTenantApp = tenant_app_ts_decorate([
|
|
|
11772
12483
|
String
|
|
11773
12484
|
])
|
|
11774
12485
|
], LYTenantApp);
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11779
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11780
|
-
}
|
|
11781
|
-
class LYApp extends LYBaseOrganizationApp {
|
|
11782
|
-
}
|
|
11783
|
-
LYApp = src_app_ts_decorate([
|
|
11784
|
-
register('LYApp')
|
|
11785
|
-
], LYApp);
|
|
11786
|
-
function http_base_ts_decorate(decorators, target, key, desc) {
|
|
11787
|
-
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11788
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
11789
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11790
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11791
|
-
}
|
|
11792
|
-
function http_base_ts_metadata(k, v) {
|
|
11793
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
11794
|
-
}
|
|
11795
|
-
class LYHttpClient extends LYObject {
|
|
11796
|
-
constructor(baseUrl){
|
|
11797
|
-
super();
|
|
11798
|
-
this._client = axios.create({
|
|
11799
|
-
baseURL: baseUrl
|
|
11800
|
-
});
|
|
11801
|
-
this._baseUrl = baseUrl || '';
|
|
12486
|
+
class LYAdminApi {
|
|
12487
|
+
constructor(httpClient){
|
|
12488
|
+
this._httpClient = httpClient;
|
|
11802
12489
|
}
|
|
11803
|
-
|
|
11804
|
-
|
|
12490
|
+
async getProducts(params) {
|
|
12491
|
+
const res = await this._httpClient.get('/admin/products', params);
|
|
12492
|
+
return res.data;
|
|
11805
12493
|
}
|
|
11806
|
-
|
|
11807
|
-
|
|
12494
|
+
async createProduct(product) {
|
|
12495
|
+
const res = await this._httpClient.post('/admin/products', product);
|
|
12496
|
+
return res.data;
|
|
11808
12497
|
}
|
|
11809
|
-
|
|
11810
|
-
this.
|
|
12498
|
+
async updateProduct(id, product) {
|
|
12499
|
+
const res = await this._httpClient.post(`/admin/products/patch/${id}`, product);
|
|
12500
|
+
return res.data;
|
|
11811
12501
|
}
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
for(const key in data)result[this._key_converter.convert_request(key)] = data[key];
|
|
11816
|
-
return result;
|
|
12502
|
+
async delProduct(id) {
|
|
12503
|
+
const res = await this._httpClient.post(`/admin/products/delete/${id}`);
|
|
12504
|
+
return res.data;
|
|
11817
12505
|
}
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
for(const key in data)result[this._key_converter.convert_response(key)] = data[key];
|
|
11822
|
-
return result;
|
|
12506
|
+
async query(id) {
|
|
12507
|
+
const res = await this._httpClient.get(`/admin/products/${id}`);
|
|
12508
|
+
return res.data;
|
|
11823
12509
|
}
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
let { data: requestData, params: requestParams } = config;
|
|
11828
|
-
if (requestData) requestData = this._convert_request(requestData);
|
|
11829
|
-
if (requestParams) requestParams = this._convert_request(requestParams);
|
|
11830
|
-
try {
|
|
11831
|
-
const response = await this._client.request({
|
|
11832
|
-
method,
|
|
11833
|
-
url: config.url,
|
|
11834
|
-
data: requestData,
|
|
11835
|
-
params: requestParams,
|
|
11836
|
-
...rest,
|
|
11837
|
-
paramsSerializer: (params)=>qs.stringify(params, {
|
|
11838
|
-
arrayFormat: 'repeat'
|
|
11839
|
-
}),
|
|
11840
|
-
headers: {
|
|
11841
|
-
...this._get_headers(),
|
|
11842
|
-
...config?.headers
|
|
11843
|
-
},
|
|
11844
|
-
onUploadProgress: (progressEvent)=>{
|
|
11845
|
-
if (config?.onUploadProgress) config.onUploadProgress(progressEvent.loaded / progressEvent.total);
|
|
11846
|
-
},
|
|
11847
|
-
onDownloadProgress: (progressEvent)=>{
|
|
11848
|
-
if (config?.onDownloadProgress) config.onDownloadProgress(progressEvent.loaded / progressEvent.total);
|
|
11849
|
-
}
|
|
11850
|
-
});
|
|
11851
|
-
if (!response.headers['content-type'].includes('json')) return response;
|
|
11852
|
-
return this._convert_response(response.data);
|
|
11853
|
-
} catch (error) {
|
|
11854
|
-
if (axios.isAxiosError(error)) {
|
|
11855
|
-
const url = error.config?.url || config.url;
|
|
11856
|
-
if (401 === error.status) try {
|
|
11857
|
-
const app = base_LYBaseApp.get(ORGANIZATION_APP_NAME);
|
|
11858
|
-
app.getAuthorizer().signout({
|
|
11859
|
-
redirect_uri: window.location.href
|
|
11860
|
-
});
|
|
11861
|
-
} catch (error) {
|
|
11862
|
-
console.error(error);
|
|
11863
|
-
window.location.reload();
|
|
11864
|
-
}
|
|
11865
|
-
if (error.response) throw new LYHttpStatusError(error.response?.data?.detail || error.message, url, method, error, error.response.status);
|
|
11866
|
-
if (error.request) throw new LYNetworkError(error.message, url, method, error);
|
|
11867
|
-
throw new LYConfigError(error.message, url, method, error);
|
|
11868
|
-
}
|
|
11869
|
-
throw error;
|
|
11870
|
-
}
|
|
12510
|
+
async getPrices(param) {
|
|
12511
|
+
const res = await this._httpClient.get('/admin/prices', param);
|
|
12512
|
+
return res.data;
|
|
11871
12513
|
}
|
|
11872
|
-
async
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
Date.now();
|
|
11876
|
-
return this;
|
|
12514
|
+
async createPrice(price) {
|
|
12515
|
+
const res = await this._httpClient.post('/admin/prices', price);
|
|
12516
|
+
return res.data;
|
|
11877
12517
|
}
|
|
11878
|
-
async
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
url,
|
|
11882
|
-
params: query,
|
|
11883
|
-
...config
|
|
11884
|
-
});
|
|
12518
|
+
async updatePrice(id, price) {
|
|
12519
|
+
const res = await this._httpClient.post(`/admin/prices/patch/${id}`, price);
|
|
12520
|
+
return res.data;
|
|
11885
12521
|
}
|
|
11886
|
-
async
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
url,
|
|
11890
|
-
data: data,
|
|
11891
|
-
...config
|
|
11892
|
-
});
|
|
12522
|
+
async delPrice(id) {
|
|
12523
|
+
const res = await this._httpClient.post(`/admin/prices/delete/${id}`);
|
|
12524
|
+
return res.data;
|
|
11893
12525
|
}
|
|
11894
|
-
async
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
url,
|
|
11898
|
-
data: data,
|
|
11899
|
-
...config
|
|
11900
|
-
});
|
|
12526
|
+
async queryPrice(param) {
|
|
12527
|
+
const res = await this._httpClient.get('/admin/prices', param);
|
|
12528
|
+
return res.data;
|
|
11901
12529
|
}
|
|
11902
|
-
async
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
url,
|
|
11906
|
-
params: query,
|
|
11907
|
-
...config
|
|
11908
|
-
});
|
|
12530
|
+
async getPlatforms(param) {
|
|
12531
|
+
const res = await this._httpClient.get('/admin/platforms', param);
|
|
12532
|
+
return res.data;
|
|
11909
12533
|
}
|
|
11910
|
-
async
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
12534
|
+
async createPlatform(platform) {
|
|
12535
|
+
const res = await this._httpClient.post('/admin/platforms', platform);
|
|
12536
|
+
return res.data;
|
|
12537
|
+
}
|
|
12538
|
+
async updatePlatform(id, platform) {
|
|
12539
|
+
const res = await this._httpClient.post(`/admin/platforms/patch/${id}`, platform);
|
|
12540
|
+
return res.data;
|
|
12541
|
+
}
|
|
12542
|
+
async delPlatform(id) {
|
|
12543
|
+
const res = await this._httpClient.post(`/admin/platforms/delete/${id}`);
|
|
12544
|
+
return res.data;
|
|
12545
|
+
}
|
|
12546
|
+
async queryPlatform(id) {
|
|
12547
|
+
const res = await this._httpClient.get(`/admin/platforms/${id}`);
|
|
12548
|
+
return res.data;
|
|
12549
|
+
}
|
|
12550
|
+
async getOrders(param) {
|
|
12551
|
+
const res = await this._httpClient.get('/admin/orders', param);
|
|
12552
|
+
return res.data;
|
|
12553
|
+
}
|
|
12554
|
+
async getOrderDetails(id) {
|
|
12555
|
+
const res = await this._httpClient.get(`/admin/orders/${id}`);
|
|
12556
|
+
return res.data;
|
|
11917
12557
|
}
|
|
11918
12558
|
}
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
http_base_ts_metadata("design:paramtypes", [
|
|
11923
|
-
String
|
|
11924
|
-
])
|
|
11925
|
-
], LYHttpClient);
|
|
11926
|
-
function src_http_ts_decorate(decorators, target, key, desc) {
|
|
11927
|
-
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11928
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
11929
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11930
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11931
|
-
}
|
|
11932
|
-
function src_http_ts_metadata(k, v) {
|
|
11933
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
11934
|
-
}
|
|
11935
|
-
const ROUTE_PREFIX_WEB_API = 'web';
|
|
11936
|
-
class http_LYAppHttpClient extends LYHttpClient {
|
|
11937
|
-
constructor(app_name, headerProvider){
|
|
11938
|
-
super(`/${ROUTE_PREFIX_WEB_API}/${app_name}`);
|
|
11939
|
-
this._headerProvider = headerProvider;
|
|
12559
|
+
class api_user_LYUserApi {
|
|
12560
|
+
constructor(httpClient){
|
|
12561
|
+
this._httpClient = httpClient;
|
|
11940
12562
|
}
|
|
11941
|
-
|
|
11942
|
-
|
|
12563
|
+
async getProductsByApp(param) {
|
|
12564
|
+
const res = await this._httpClient.get('/products', param);
|
|
12565
|
+
return res.data;
|
|
11943
12566
|
}
|
|
11944
|
-
|
|
11945
|
-
|
|
12567
|
+
async getPlatformList() {
|
|
12568
|
+
const res = await this._httpClient.get('/platforms');
|
|
12569
|
+
return res.data;
|
|
11946
12570
|
}
|
|
11947
|
-
async
|
|
11948
|
-
const
|
|
11949
|
-
|
|
11950
|
-
if ('GET' !== method && 'POST' !== method) throw new LYError(`Method ${method} not allowed`);
|
|
11951
|
-
const response = await super._request({
|
|
11952
|
-
method,
|
|
11953
|
-
data,
|
|
11954
|
-
...rest,
|
|
11955
|
-
url
|
|
11956
|
-
});
|
|
11957
|
-
if (void 0 !== response.status) return response;
|
|
11958
|
-
const result = response;
|
|
11959
|
-
if ('not_exists' === result.code) return result;
|
|
11960
|
-
if ('success' !== result.code) {
|
|
11961
|
-
url = `${this.baseUrl}/${url}`;
|
|
11962
|
-
throw new LYAppHttpError(result.message, url, method, new Error(), result.code);
|
|
11963
|
-
}
|
|
11964
|
-
return result;
|
|
12571
|
+
async getOrderStatus(id) {
|
|
12572
|
+
const res = await this._httpClient.get(`/orders/status/${id}`);
|
|
12573
|
+
return res.data;
|
|
11965
12574
|
}
|
|
11966
|
-
async
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
const
|
|
11980
|
-
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
12575
|
+
async getOrders(params) {
|
|
12576
|
+
return this._httpClient.get('/orders', params);
|
|
12577
|
+
}
|
|
12578
|
+
async purchases(params) {
|
|
12579
|
+
const res = await this._httpClient.post('/purchases', params);
|
|
12580
|
+
return res.data;
|
|
12581
|
+
}
|
|
12582
|
+
async webhooks() {}
|
|
12583
|
+
async subscription(param) {
|
|
12584
|
+
const res = await this._httpClient.post("/subscriptions", param);
|
|
12585
|
+
return res.data;
|
|
12586
|
+
}
|
|
12587
|
+
async getSubscriptionByApp(param) {
|
|
12588
|
+
const res = await this._httpClient.get("/subscriptions/my", param);
|
|
12589
|
+
return res.data;
|
|
12590
|
+
}
|
|
12591
|
+
async cancelSubscription(param) {
|
|
12592
|
+
const res = await this._httpClient.post("/subscriptions/cancel", param);
|
|
12593
|
+
return res.data;
|
|
12594
|
+
}
|
|
12595
|
+
async releaseSchedule(id, param) {
|
|
12596
|
+
const res = await this._httpClient.post(`/subscriptions/schedule/delete/${id}`, param);
|
|
12597
|
+
return res.data;
|
|
12598
|
+
}
|
|
12599
|
+
async previewPurchase(id, price_id) {
|
|
12600
|
+
const res = await this._httpClient.get(`/subscriptions/preview/${id}`, {
|
|
12601
|
+
price_id
|
|
11985
12602
|
});
|
|
11986
|
-
return
|
|
12603
|
+
return res.data;
|
|
11987
12604
|
}
|
|
11988
|
-
async
|
|
11989
|
-
const
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
12027
|
-
|
|
12028
|
-
|
|
12029
|
-
|
|
12605
|
+
async changeSubscription(id, param) {
|
|
12606
|
+
const res = await this._httpClient.post(`/subscriptions/${id}/patch`, param);
|
|
12607
|
+
return res.data;
|
|
12608
|
+
}
|
|
12609
|
+
}
|
|
12610
|
+
function order_ts_decorate(decorators, target, key, desc) {
|
|
12611
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12612
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
12613
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12614
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12615
|
+
}
|
|
12616
|
+
function order_ts_metadata(k, v) {
|
|
12617
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
12618
|
+
}
|
|
12619
|
+
class LYOrder extends LYObject {
|
|
12620
|
+
constructor(userApi){
|
|
12621
|
+
super(), this._status = 'pending', this._pollTimer = null, this._pollInterval = 2000, this._isPolling = false, this._data = null;
|
|
12622
|
+
this._userApi = userApi;
|
|
12623
|
+
}
|
|
12624
|
+
get id() {
|
|
12625
|
+
return this._data?.order_id;
|
|
12626
|
+
}
|
|
12627
|
+
get no() {
|
|
12628
|
+
return this._data?.order_no;
|
|
12629
|
+
}
|
|
12630
|
+
get productName() {
|
|
12631
|
+
return this._data?.product_name;
|
|
12632
|
+
}
|
|
12633
|
+
get priceName() {
|
|
12634
|
+
return this._data?.price_name;
|
|
12635
|
+
}
|
|
12636
|
+
get actualAmount() {
|
|
12637
|
+
return this._data?.actual_amount;
|
|
12638
|
+
}
|
|
12639
|
+
get currency() {
|
|
12640
|
+
return this._data.currency;
|
|
12641
|
+
}
|
|
12642
|
+
get platformName() {
|
|
12643
|
+
return this._data?.platform_name;
|
|
12644
|
+
}
|
|
12645
|
+
get paymentUrl() {
|
|
12646
|
+
return this._data?.payment_url;
|
|
12647
|
+
}
|
|
12648
|
+
get qrCodeUrl() {
|
|
12649
|
+
return this._data?.qr_code_url;
|
|
12650
|
+
}
|
|
12651
|
+
get paymentForm() {
|
|
12652
|
+
return this._data?.payment_form || null;
|
|
12653
|
+
}
|
|
12654
|
+
get expiresAt() {
|
|
12655
|
+
return this._data?.expires_at;
|
|
12656
|
+
}
|
|
12657
|
+
get status() {
|
|
12658
|
+
return this._status;
|
|
12659
|
+
}
|
|
12660
|
+
_updateStatus(newStatus) {
|
|
12661
|
+
if (this._status !== newStatus) {
|
|
12662
|
+
this._status = newStatus;
|
|
12663
|
+
this.emit('status', newStatus, this.id);
|
|
12030
12664
|
}
|
|
12031
|
-
return {
|
|
12032
|
-
id: fileId,
|
|
12033
|
-
state: currentState
|
|
12034
|
-
};
|
|
12035
12665
|
}
|
|
12036
|
-
async
|
|
12037
|
-
config?.chunkSize;
|
|
12038
|
-
const resumeFromByte = config?.resumeFromByte || 0;
|
|
12039
|
-
const url = `${this.baseUrl}/${this._getUrl(`/file/${fileId}`)}`;
|
|
12040
|
-
const headers = {
|
|
12041
|
-
Accept: '*/*',
|
|
12042
|
-
...this._get_headers(),
|
|
12043
|
-
...config?.headers
|
|
12044
|
-
};
|
|
12045
|
-
const blob = new Blob();
|
|
12046
|
-
let reader;
|
|
12666
|
+
async pay(params) {
|
|
12047
12667
|
try {
|
|
12048
|
-
const
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
Range: `bytes=${resumeFromByte}-`
|
|
12054
|
-
}
|
|
12055
|
-
},
|
|
12056
|
-
credentials: 'include'
|
|
12057
|
-
});
|
|
12058
|
-
if (!downloadResponse.ok) throw new Error(`Download request failed: ${downloadResponse.status} ${downloadResponse.statusText}`);
|
|
12059
|
-
reader = downloadResponse.body?.getReader();
|
|
12060
|
-
if (!reader) throw new Error('Response body is not readable');
|
|
12061
|
-
const contentLength = parseInt(downloadResponse.headers.get('content-length') || '0');
|
|
12062
|
-
const contentType = downloadResponse.headers.get('content-type') || 'application/octet-stream';
|
|
12063
|
-
const contentRange = downloadResponse.headers.get('content-range');
|
|
12064
|
-
const contentDisposition = downloadResponse.headers.get('content-disposition');
|
|
12065
|
-
let totalSize = contentLength;
|
|
12066
|
-
if (contentRange) {
|
|
12067
|
-
const match = contentRange.match(/bytes \d+-\d+\/(\d+)/);
|
|
12068
|
-
if (match) totalSize = parseInt(match[1]);
|
|
12069
|
-
}
|
|
12070
|
-
let finalFileName = fileName;
|
|
12071
|
-
if (!finalFileName && contentDisposition) {
|
|
12072
|
-
const utf8Match = contentDisposition.match(/filename\*=UTF-8''([^;]+)/);
|
|
12073
|
-
if (utf8Match) finalFileName = decodeURIComponent(utf8Match[1]);
|
|
12074
|
-
else {
|
|
12075
|
-
const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
|
12076
|
-
if (filenameMatch && filenameMatch[1]) finalFileName = filenameMatch[1].replace(/['"]/g, '');
|
|
12077
|
-
}
|
|
12078
|
-
}
|
|
12079
|
-
const chunks = [];
|
|
12080
|
-
let totalLoaded = 0;
|
|
12081
|
-
let progress = 0;
|
|
12082
|
-
let blob;
|
|
12083
|
-
while(true){
|
|
12084
|
-
const { done, value } = await reader.read();
|
|
12085
|
-
if (done) break;
|
|
12086
|
-
chunks.push(value);
|
|
12087
|
-
totalLoaded += value.length;
|
|
12088
|
-
const newProgress = totalSize > 0 ? totalLoaded / totalSize * 100 : 0;
|
|
12089
|
-
if (newProgress !== progress) {
|
|
12090
|
-
progress = newProgress;
|
|
12091
|
-
config?.onProgress?.(progress);
|
|
12092
|
-
}
|
|
12093
|
-
}
|
|
12094
|
-
blob = new Blob(chunks, {
|
|
12095
|
-
type: contentType
|
|
12096
|
-
});
|
|
12097
|
-
return {
|
|
12098
|
-
blob,
|
|
12099
|
-
fileName: finalFileName,
|
|
12100
|
-
contentType,
|
|
12101
|
-
totalSize: totalSize || blob.size
|
|
12102
|
-
};
|
|
12668
|
+
const result = await this._userApi.purchases(params);
|
|
12669
|
+
this._data = result;
|
|
12670
|
+
this._updateStatus('pending');
|
|
12671
|
+
this._startPolling();
|
|
12672
|
+
return this._data;
|
|
12103
12673
|
} catch (error) {
|
|
12104
|
-
|
|
12105
|
-
this.emit('download_failed', {
|
|
12106
|
-
error,
|
|
12107
|
-
fileId,
|
|
12108
|
-
fileName,
|
|
12109
|
-
blob
|
|
12110
|
-
});
|
|
12674
|
+
this._updateStatus('failed');
|
|
12111
12675
|
throw error;
|
|
12112
12676
|
}
|
|
12113
12677
|
}
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12678
|
+
_startPolling() {
|
|
12679
|
+
if (this._isPolling) return;
|
|
12680
|
+
this._isPolling = true;
|
|
12681
|
+
this._doPoll();
|
|
12117
12682
|
}
|
|
12118
|
-
async
|
|
12119
|
-
const { data, delimiter = '\n', headers: customHeaders } = config || {};
|
|
12120
|
-
const fullUrl = `${this.baseUrl}/${this._getUrl(url)}`;
|
|
12121
|
-
const headers = {
|
|
12122
|
-
...this._get_headers(),
|
|
12123
|
-
...customHeaders,
|
|
12124
|
-
Accept: 'text/event-stream',
|
|
12125
|
-
'Content-Type': 'application/json'
|
|
12126
|
-
};
|
|
12127
|
-
const abortController = new AbortController();
|
|
12128
|
-
if (config?.signal) config.signal.addEventListener('abort', ()=>{
|
|
12129
|
-
abortController.abort();
|
|
12130
|
-
});
|
|
12131
|
-
const requestOptions = {
|
|
12132
|
-
method: 'POST',
|
|
12133
|
-
headers,
|
|
12134
|
-
signal: abortController.signal,
|
|
12135
|
-
body: JSON.stringify(data)
|
|
12136
|
-
};
|
|
12683
|
+
async _doPoll() {
|
|
12137
12684
|
try {
|
|
12138
|
-
const
|
|
12139
|
-
if (
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
try {
|
|
12144
|
-
while(true){
|
|
12145
|
-
const { value, done } = await reader.read();
|
|
12146
|
-
if (done) break;
|
|
12147
|
-
const chunk = decoder.decode(value, {
|
|
12148
|
-
stream: true
|
|
12149
|
-
});
|
|
12150
|
-
buffer += chunk;
|
|
12151
|
-
const parts = buffer.split(delimiter);
|
|
12152
|
-
buffer = parts.pop() ?? '';
|
|
12153
|
-
for (const part of parts){
|
|
12154
|
-
const trimmed = part.trim();
|
|
12155
|
-
if (0 !== trimmed.length) yield this.parseChunk(trimmed);
|
|
12156
|
-
}
|
|
12157
|
-
}
|
|
12158
|
-
if (buffer.trim()) yield this.parseChunk(buffer);
|
|
12159
|
-
} finally{
|
|
12160
|
-
reader.releaseLock();
|
|
12685
|
+
const orderStatus = await this._userApi.getOrderStatus(this.id);
|
|
12686
|
+
if ('pending' !== orderStatus.status) {
|
|
12687
|
+
this._stopPolling();
|
|
12688
|
+
this._updateStatus(orderStatus.status);
|
|
12689
|
+
return;
|
|
12161
12690
|
}
|
|
12691
|
+
this._pollTimer = setTimeout(()=>this._doPoll(), this._pollInterval);
|
|
12162
12692
|
} catch (error) {
|
|
12163
|
-
|
|
12164
|
-
|
|
12693
|
+
this.logger.error(`查询订单 ${this.id} 状态失败:`, error);
|
|
12694
|
+
this._stopPolling();
|
|
12695
|
+
this._updateStatus('failed');
|
|
12165
12696
|
}
|
|
12166
12697
|
}
|
|
12167
|
-
|
|
12168
|
-
|
|
12698
|
+
_stopPolling() {
|
|
12699
|
+
this._isPolling = false;
|
|
12700
|
+
if (this._pollTimer) {
|
|
12701
|
+
clearTimeout(this._pollTimer);
|
|
12702
|
+
this._pollTimer = null;
|
|
12703
|
+
}
|
|
12704
|
+
}
|
|
12705
|
+
destroy() {
|
|
12706
|
+
this._stopPolling();
|
|
12707
|
+
this.removeAllListeners();
|
|
12708
|
+
}
|
|
12709
|
+
async refresh() {
|
|
12169
12710
|
try {
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
return
|
|
12711
|
+
const orderStatus = await this._userApi.getOrderStatus(this.id);
|
|
12712
|
+
this._updateStatus(orderStatus.status);
|
|
12713
|
+
return this._status;
|
|
12714
|
+
} catch (error) {
|
|
12715
|
+
this.logger.error(`刷新订单 ${this.id} 状态失败:`, error);
|
|
12716
|
+
return this._status;
|
|
12173
12717
|
}
|
|
12174
12718
|
}
|
|
12175
12719
|
}
|
|
12176
|
-
|
|
12177
|
-
register('
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
"undefined" == typeof IHeaderProvider ? Object : IHeaderProvider
|
|
12720
|
+
LYOrder = order_ts_decorate([
|
|
12721
|
+
register('LYOrder'),
|
|
12722
|
+
order_ts_metadata("design:type", Function),
|
|
12723
|
+
order_ts_metadata("design:paramtypes", [
|
|
12724
|
+
void 0 === api_user_LYUserApi ? Object : api_user_LYUserApi
|
|
12182
12725
|
])
|
|
12183
|
-
],
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12726
|
+
], LYOrder);
|
|
12727
|
+
function bill_app_ts_decorate(decorators, target, key, desc) {
|
|
12728
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12729
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
12730
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12731
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12732
|
+
}
|
|
12733
|
+
function bill_app_ts_metadata(k, v) {
|
|
12734
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
12735
|
+
}
|
|
12736
|
+
class LYBillApp extends LYBaseOrganizationApp {
|
|
12737
|
+
constructor(name1, version, description){
|
|
12738
|
+
super(name1, version, description);
|
|
12739
|
+
LYBillApp._instance = this;
|
|
12740
|
+
this._userApi = new api_user_LYUserApi(this._httpClient);
|
|
12741
|
+
this._adminApi = new LYAdminApi(this._httpClient);
|
|
12191
12742
|
}
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
return
|
|
12743
|
+
get userApi() {
|
|
12744
|
+
return this._userApi;
|
|
12745
|
+
}
|
|
12746
|
+
get adminApi() {
|
|
12747
|
+
return this._adminApi;
|
|
12748
|
+
}
|
|
12749
|
+
static get instance() {
|
|
12750
|
+
if (!LYBillApp._instance) throw new Error('LYBillApp not initialized');
|
|
12751
|
+
return LYBillApp._instance;
|
|
12752
|
+
}
|
|
12753
|
+
createOrder() {
|
|
12754
|
+
const order = new LYOrder(this._userApi);
|
|
12755
|
+
return order;
|
|
12197
12756
|
}
|
|
12757
|
+
changeSubscription(id, param) {}
|
|
12198
12758
|
}
|
|
12199
|
-
|
|
12200
|
-
register('
|
|
12201
|
-
|
|
12759
|
+
LYBillApp = bill_app_ts_decorate([
|
|
12760
|
+
register('LYBillApp'),
|
|
12761
|
+
bill_app_ts_metadata("design:type", Function),
|
|
12762
|
+
bill_app_ts_metadata("design:paramtypes", [
|
|
12763
|
+
String,
|
|
12764
|
+
String,
|
|
12765
|
+
String
|
|
12766
|
+
])
|
|
12767
|
+
], LYBillApp);
|
|
12768
|
+
function src_app_ts_decorate(decorators, target, key, desc) {
|
|
12769
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12770
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
12771
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12772
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12773
|
+
}
|
|
12774
|
+
class LYApp extends LYBaseOrganizationApp {
|
|
12775
|
+
}
|
|
12776
|
+
LYApp = src_app_ts_decorate([
|
|
12777
|
+
register('LYApp')
|
|
12778
|
+
], LYApp);
|
|
12202
12779
|
var __webpack_exports__FRAMEWORK_NAME = "uci";
|
|
12203
|
-
export { LANG_KEY, LYApp, http_LYAppHttpClient as LYAppHttpClient, LYAppPermission, base_LYBaseApp as LYBaseApp, LYCloudStorage, LYConfig, LYCrypto, LYCryptoError, LYDefaultLogFormatter, LYDirectAuthorizer, LYEnv, LYError, LYGatewayAuthorizer, LYIndexedDBLogStorage, i18n_LYLangEnum as LYLangEnum, LYLocalStorage, logger_LYLogLevel as LYLogLevel, LYLogger, LYObject, LYObservable, LYOrganizationApp, LYOrganizationHttpClient, LYOwnerObservable, LYRedirectAuthorizer, LYSession, LYSessionStorage, LYTenantApp, LYTenantAuthorizer, LYTenantSession, LYWebAuthorizer, LYi18n, ORGANIZATION_APP_NAME, REMOTE_ENTRY, REMOTE_MODULE, TENANT_APP_NAME, crypto_crypto as crypto, isElectron, isIframe, i18n_langKeys as langKeys, languages, logger, observable_observe as observe, register, setCloudStorageImpl, setFormatter, setPrintToConsole, setStorage, sharedCloudStorage, sharedLocalStorage, wait, __webpack_exports__FRAMEWORK_NAME as FRAMEWORK_NAME };
|
|
12780
|
+
export { BILL_APP_NAME, LANG_KEY, LYApp, http_LYAppHttpClient as LYAppHttpClient, LYAppPermission, base_LYBaseApp as LYBaseApp, LYBillApp, LYCloudStorage, LYConfig, LYCrypto, LYCryptoError, LYDefaultLogFormatter, LYDirectAuthorizer, LYEnv, LYError, LYGatewayAuthorizer, LYIndexedDBLogStorage, i18n_LYLangEnum as LYLangEnum, LYLocalStorage, logger_LYLogLevel as LYLogLevel, LYLogger, LYObject, LYObservable, LYOrder, LYOrganizationApp, LYOrganizationHttpClient, LYOwnerObservable, LYRedirectAuthorizer, LYSession, LYSessionStorage, LYTenantApp, LYTenantAuthorizer, LYTenantSession, LYWebAuthorizer, LYi18n, ORGANIZATION_APP_NAME, REMOTE_ENTRY, REMOTE_MODULE, TENANT_APP_NAME, crypto_crypto as crypto, isElectron, isIframe, i18n_langKeys as langKeys, languages, logger, observable_observe as observe, register, setCloudStorageImpl, setFormatter, setPrintToConsole, setStorage, sharedCloudStorage, sharedLocalStorage, wait, __webpack_exports__FRAMEWORK_NAME as FRAMEWORK_NAME };
|
|
12204
12781
|
|
|
12205
12782
|
//# sourceMappingURL=index.js.map
|