@fctc/interface-logic 1.7.2 → 1.7.4
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/{configs.d.cts → configs.d.mts} +1 -4
- package/dist/configs.d.ts +1 -4
- package/dist/configs.js +146 -124
- package/dist/{configs.cjs → configs.mjs} +111 -161
- package/dist/constants.js +41 -2
- package/dist/{constants.cjs → constants.mjs} +2 -40
- package/dist/environment.d.mts +37 -0
- package/dist/environment.d.ts +35 -54
- package/dist/environment.js +2850 -2906
- package/dist/{environment.cjs → environment.mjs} +2816 -2945
- package/dist/{hooks.d.cts → hooks.d.mts} +7 -2
- package/dist/hooks.d.ts +7 -2
- package/dist/hooks.js +4181 -4520
- package/dist/{hooks.cjs → hooks.mjs} +4081 -4625
- package/dist/{provider.d.cts → provider.d.mts} +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +530 -854
- package/dist/{provider.cjs → provider.mjs} +496 -894
- package/dist/{services.d.cts → services.d.mts} +2 -1
- package/dist/services.d.ts +2 -1
- package/dist/services.js +3866 -4282
- package/dist/{services.cjs → services.mjs} +3826 -4328
- package/dist/{store.d.cts → store.d.mts} +323 -127
- package/dist/store.d.ts +323 -127
- package/dist/store.js +147 -45
- package/dist/{store.cjs → store.mjs} +46 -150
- package/dist/{types.d.cts → types.d.mts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/dist/{utils.d.cts → utils.d.mts} +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +176 -135
- package/dist/{utils.cjs → utils.mjs} +115 -202
- package/dist/{view-type-BGJfDe73.d.ts → view-type-D8ukwj_2.d.mts} +1 -1
- package/dist/{view-type-BGJfDe73.d.cts → view-type-D8ukwj_2.d.ts} +1 -1
- package/package.json +81 -82
- package/dist/environment.d.cts +0 -56
- package/dist/types.cjs +0 -17
- /package/dist/{constants.d.cts → constants.d.mts} +0 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { EnvStore } from './environment.cjs';
|
|
2
|
-
import '@reduxjs/toolkit';
|
|
3
|
-
|
|
4
1
|
declare const axiosClient: {
|
|
5
|
-
init(config:
|
|
2
|
+
init(config: any): {
|
|
6
3
|
get: (url: string, headers: any) => Promise<any>;
|
|
7
4
|
post: (url: string, body: any, headers: any) => Promise<any>;
|
|
8
5
|
post_excel: (url: string, body: any, headers: any) => Promise<any>;
|
package/dist/configs.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { EnvStore } from './environment.js';
|
|
2
|
-
import '@reduxjs/toolkit';
|
|
3
|
-
|
|
4
1
|
declare const axiosClient: {
|
|
5
|
-
init(config:
|
|
2
|
+
init(config: any): {
|
|
6
3
|
get: (url: string, headers: any) => Promise<any>;
|
|
7
4
|
post: (url: string, body: any, headers: any) => Promise<any>;
|
|
8
5
|
post_excel: (url: string, body: any, headers: any) => Promise<any>;
|
package/dist/configs.js
CHANGED
|
@@ -1,30 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
20
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
21
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/configs.ts
|
|
31
|
+
var configs_exports = {};
|
|
32
|
+
__export(configs_exports, {
|
|
33
|
+
axiosClient: () => axiosClient
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(configs_exports);
|
|
22
36
|
|
|
23
37
|
// src/configs/axios-client.ts
|
|
24
|
-
|
|
38
|
+
var import_axios = __toESM(require("axios"));
|
|
25
39
|
|
|
26
40
|
// src/utils/format.ts
|
|
27
|
-
|
|
41
|
+
var import_moment = __toESM(require("moment"));
|
|
28
42
|
|
|
29
43
|
// src/utils/domain/py_tokenizer.ts
|
|
30
44
|
var TokenizerError = class extends Error {
|
|
@@ -1104,6 +1118,22 @@ var PyRelativeDelta = class _PyRelativeDelta {
|
|
|
1104
1118
|
this.microsecond = params.microsecond;
|
|
1105
1119
|
this.weekday = params.weekday;
|
|
1106
1120
|
}
|
|
1121
|
+
years;
|
|
1122
|
+
months;
|
|
1123
|
+
days;
|
|
1124
|
+
hours;
|
|
1125
|
+
minutes;
|
|
1126
|
+
seconds;
|
|
1127
|
+
microseconds;
|
|
1128
|
+
leapDays;
|
|
1129
|
+
year;
|
|
1130
|
+
month;
|
|
1131
|
+
day;
|
|
1132
|
+
hour;
|
|
1133
|
+
minute;
|
|
1134
|
+
second;
|
|
1135
|
+
microsecond;
|
|
1136
|
+
weekday;
|
|
1107
1137
|
negate() {
|
|
1108
1138
|
return new _PyRelativeDelta(this, -1);
|
|
1109
1139
|
}
|
|
@@ -1218,7 +1248,7 @@ function execOnIterable(iterable, func) {
|
|
|
1218
1248
|
if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
|
|
1219
1249
|
iterable = Object.keys(iterable);
|
|
1220
1250
|
}
|
|
1221
|
-
if (typeof
|
|
1251
|
+
if (typeof iterable?.[Symbol.iterator] !== "function") {
|
|
1222
1252
|
throw new EvaluationError("value not iterable");
|
|
1223
1253
|
}
|
|
1224
1254
|
return func(iterable);
|
|
@@ -1541,7 +1571,7 @@ function applyBinaryOp(ast, context) {
|
|
|
1541
1571
|
}
|
|
1542
1572
|
return Math.floor(left / right);
|
|
1543
1573
|
case "**":
|
|
1544
|
-
return
|
|
1574
|
+
return left ** right;
|
|
1545
1575
|
case "==":
|
|
1546
1576
|
return isEqual(left, right);
|
|
1547
1577
|
case "<>":
|
|
@@ -1663,7 +1693,7 @@ function evaluate(ast, context = {}) {
|
|
|
1663
1693
|
const dicts = /* @__PURE__ */ new Set();
|
|
1664
1694
|
let pyContext;
|
|
1665
1695
|
const evalContext = Object.create(context);
|
|
1666
|
-
if (!
|
|
1696
|
+
if (!evalContext?.context) {
|
|
1667
1697
|
Object.defineProperty(evalContext, "context", {
|
|
1668
1698
|
get() {
|
|
1669
1699
|
if (!pyContext) {
|
|
@@ -1674,18 +1704,17 @@ function evaluate(ast, context = {}) {
|
|
|
1674
1704
|
});
|
|
1675
1705
|
}
|
|
1676
1706
|
function _innerEvaluate(ast2) {
|
|
1677
|
-
|
|
1678
|
-
switch (ast2 == null ? void 0 : ast2.type) {
|
|
1707
|
+
switch (ast2?.type) {
|
|
1679
1708
|
case 0:
|
|
1680
1709
|
// Number
|
|
1681
1710
|
case 1:
|
|
1682
1711
|
return ast2.value;
|
|
1683
1712
|
case 5:
|
|
1684
1713
|
if (ast2.value in evalContext) {
|
|
1685
|
-
if (typeof evalContext[ast2.value] === "object" &&
|
|
1686
|
-
return
|
|
1714
|
+
if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id) {
|
|
1715
|
+
return evalContext[ast2.value]?.id;
|
|
1687
1716
|
}
|
|
1688
|
-
return
|
|
1717
|
+
return evalContext[ast2.value] ?? false;
|
|
1689
1718
|
} else if (ast2.value in BUILTINS) {
|
|
1690
1719
|
return BUILTINS[ast2.value];
|
|
1691
1720
|
} else {
|
|
@@ -1722,7 +1751,7 @@ function evaluate(ast, context = {}) {
|
|
|
1722
1751
|
const args = ast2.args.map(_evaluate);
|
|
1723
1752
|
const kwargs = {};
|
|
1724
1753
|
for (const kwarg in ast2.kwargs) {
|
|
1725
|
-
kwargs[kwarg] = _evaluate(ast2
|
|
1754
|
+
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
1726
1755
|
}
|
|
1727
1756
|
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
1728
1757
|
return fnValue.create(...args, kwargs);
|
|
@@ -1801,25 +1830,9 @@ function escapeRegExp(str) {
|
|
|
1801
1830
|
var InvalidDomainError = class extends Error {
|
|
1802
1831
|
};
|
|
1803
1832
|
var Domain = class _Domain {
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
return new _Domain(descr.toString());
|
|
1808
|
-
} else {
|
|
1809
|
-
let rawAST;
|
|
1810
|
-
try {
|
|
1811
|
-
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
1812
|
-
} catch (error) {
|
|
1813
|
-
throw new InvalidDomainError(
|
|
1814
|
-
`Invalid domain representation: ${descr}`,
|
|
1815
|
-
{
|
|
1816
|
-
cause: error
|
|
1817
|
-
}
|
|
1818
|
-
);
|
|
1819
|
-
}
|
|
1820
|
-
this.ast = normalizeDomainAST(rawAST);
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1833
|
+
ast = { type: -1, value: null };
|
|
1834
|
+
static TRUE;
|
|
1835
|
+
static FALSE;
|
|
1823
1836
|
static combine(domains, operator) {
|
|
1824
1837
|
if (domains.length === 0) {
|
|
1825
1838
|
return new _Domain([]);
|
|
@@ -1898,6 +1911,24 @@ var Domain = class _Domain {
|
|
|
1898
1911
|
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
1899
1912
|
return newDomain;
|
|
1900
1913
|
}
|
|
1914
|
+
constructor(descr = []) {
|
|
1915
|
+
if (descr instanceof _Domain) {
|
|
1916
|
+
return new _Domain(descr.toString());
|
|
1917
|
+
} else {
|
|
1918
|
+
let rawAST;
|
|
1919
|
+
try {
|
|
1920
|
+
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
1921
|
+
} catch (error) {
|
|
1922
|
+
throw new InvalidDomainError(
|
|
1923
|
+
`Invalid domain representation: ${descr}`,
|
|
1924
|
+
{
|
|
1925
|
+
cause: error
|
|
1926
|
+
}
|
|
1927
|
+
);
|
|
1928
|
+
}
|
|
1929
|
+
this.ast = normalizeDomainAST(rawAST);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1901
1932
|
contains(record) {
|
|
1902
1933
|
const expr = evaluate(this.ast, record);
|
|
1903
1934
|
return matchDomain(record, expr);
|
|
@@ -1916,7 +1947,7 @@ var Domain = class _Domain {
|
|
|
1916
1947
|
return evaluatedAsList;
|
|
1917
1948
|
}
|
|
1918
1949
|
return this.toString();
|
|
1919
|
-
} catch
|
|
1950
|
+
} catch {
|
|
1920
1951
|
return this.toString();
|
|
1921
1952
|
}
|
|
1922
1953
|
}
|
|
@@ -2116,7 +2147,7 @@ function matchDomain(record, domain) {
|
|
|
2116
2147
|
}
|
|
2117
2148
|
|
|
2118
2149
|
// src/utils/function.ts
|
|
2119
|
-
|
|
2150
|
+
var import_react = require("react");
|
|
2120
2151
|
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2121
2152
|
if (!originalRequest.data) return originalRequest.data;
|
|
2122
2153
|
if (typeof originalRequest.data === "string") {
|
|
@@ -2139,22 +2170,22 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
|
2139
2170
|
|
|
2140
2171
|
// src/utils/storage/local-storage.ts
|
|
2141
2172
|
var localStorageUtils = () => {
|
|
2142
|
-
const setToken = (access_token) =>
|
|
2173
|
+
const setToken = async (access_token) => {
|
|
2143
2174
|
localStorage.setItem("accessToken", access_token);
|
|
2144
|
-
}
|
|
2145
|
-
const setRefreshToken = (refresh_token) =>
|
|
2175
|
+
};
|
|
2176
|
+
const setRefreshToken = async (refresh_token) => {
|
|
2146
2177
|
localStorage.setItem("refreshToken", refresh_token);
|
|
2147
|
-
}
|
|
2148
|
-
const getAccessToken = () =>
|
|
2178
|
+
};
|
|
2179
|
+
const getAccessToken = async () => {
|
|
2149
2180
|
return localStorage.getItem("accessToken");
|
|
2150
|
-
}
|
|
2151
|
-
const getRefreshToken = () =>
|
|
2181
|
+
};
|
|
2182
|
+
const getRefreshToken = async () => {
|
|
2152
2183
|
return localStorage.getItem("refreshToken");
|
|
2153
|
-
}
|
|
2154
|
-
const clearToken = () =>
|
|
2184
|
+
};
|
|
2185
|
+
const clearToken = async () => {
|
|
2155
2186
|
localStorage.removeItem("accessToken");
|
|
2156
2187
|
localStorage.removeItem("refreshToken");
|
|
2157
|
-
}
|
|
2188
|
+
};
|
|
2158
2189
|
return {
|
|
2159
2190
|
setToken,
|
|
2160
2191
|
setRefreshToken,
|
|
@@ -2166,9 +2197,9 @@ var localStorageUtils = () => {
|
|
|
2166
2197
|
|
|
2167
2198
|
// src/utils/storage/session-storage.ts
|
|
2168
2199
|
var sessionStorageUtils = () => {
|
|
2169
|
-
const getBrowserSession = () =>
|
|
2200
|
+
const getBrowserSession = async () => {
|
|
2170
2201
|
return sessionStorage.getItem("browserSession");
|
|
2171
|
-
}
|
|
2202
|
+
};
|
|
2172
2203
|
return {
|
|
2173
2204
|
getBrowserSession
|
|
2174
2205
|
};
|
|
@@ -2177,14 +2208,13 @@ var sessionStorageUtils = () => {
|
|
|
2177
2208
|
// src/configs/axios-client.ts
|
|
2178
2209
|
var axiosClient = {
|
|
2179
2210
|
init(config) {
|
|
2180
|
-
|
|
2181
|
-
const
|
|
2182
|
-
const sessionStorage2 = (_b = config.sessionStorageUtils) != null ? _b : sessionStorageUtils();
|
|
2211
|
+
const localStorage2 = config.localStorageUtils ?? localStorageUtils();
|
|
2212
|
+
const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
|
|
2183
2213
|
const db = config.db;
|
|
2184
2214
|
let isRefreshing = false;
|
|
2185
2215
|
let failedQueue = [];
|
|
2186
2216
|
const processQueue = (error, token = null) => {
|
|
2187
|
-
failedQueue
|
|
2217
|
+
failedQueue?.forEach((prom) => {
|
|
2188
2218
|
if (error) {
|
|
2189
2219
|
prom.reject(error);
|
|
2190
2220
|
} else {
|
|
@@ -2193,44 +2223,39 @@ var axiosClient = {
|
|
|
2193
2223
|
});
|
|
2194
2224
|
failedQueue = [];
|
|
2195
2225
|
};
|
|
2196
|
-
const instance =
|
|
2197
|
-
adapter:
|
|
2226
|
+
const instance = import_axios.default.create({
|
|
2227
|
+
adapter: import_axios.default.defaults.adapter,
|
|
2198
2228
|
baseURL: config.baseUrl,
|
|
2199
2229
|
timeout: 5e4,
|
|
2200
2230
|
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
2201
2231
|
});
|
|
2202
|
-
instance.interceptors.request.use(
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
if (token) {
|
|
2207
|
-
config2.headers["Authorization"] = "Bearer " + token;
|
|
2208
|
-
}
|
|
2209
|
-
return config2;
|
|
2210
|
-
}),
|
|
2211
|
-
(error) => {
|
|
2212
|
-
Promise.reject(error);
|
|
2232
|
+
instance.interceptors.request.use(async (config2) => {
|
|
2233
|
+
const { useRefreshToken, useActionToken, actionToken } = config2;
|
|
2234
|
+
if (useActionToken && actionToken) {
|
|
2235
|
+
config2.headers["Action-Token"] = actionToken;
|
|
2213
2236
|
}
|
|
2214
|
-
|
|
2237
|
+
const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
|
|
2238
|
+
const token = await getToken?.();
|
|
2239
|
+
if (token) config2.headers["Authorization"] = `Bearer ${token}`;
|
|
2240
|
+
return config2;
|
|
2241
|
+
}, Promise.reject);
|
|
2215
2242
|
instance.interceptors.response.use(
|
|
2216
2243
|
(response) => {
|
|
2217
2244
|
return handleResponse(response);
|
|
2218
2245
|
},
|
|
2219
|
-
(error) =>
|
|
2220
|
-
|
|
2221
|
-
const handleError3 = (error2) => __async(null, null, function* () {
|
|
2222
|
-
var _a3;
|
|
2246
|
+
async (error) => {
|
|
2247
|
+
const handleError3 = async (error2) => {
|
|
2223
2248
|
if (!error2.response) {
|
|
2224
2249
|
return error2;
|
|
2225
2250
|
}
|
|
2226
2251
|
const { data } = error2.response;
|
|
2227
|
-
if (data && data.code === 400 && ["invalid_grant"].includes(
|
|
2228
|
-
|
|
2252
|
+
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
2253
|
+
await clearAuthToken();
|
|
2229
2254
|
}
|
|
2230
2255
|
return data;
|
|
2231
|
-
}
|
|
2256
|
+
};
|
|
2232
2257
|
const originalRequest = error.config;
|
|
2233
|
-
if ((
|
|
2258
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
|
|
2234
2259
|
error.response.data.code
|
|
2235
2260
|
)) {
|
|
2236
2261
|
if (isRefreshing) {
|
|
@@ -2243,19 +2268,18 @@ var axiosClient = {
|
|
|
2243
2268
|
token
|
|
2244
2269
|
);
|
|
2245
2270
|
return instance.request(originalRequest);
|
|
2246
|
-
}).catch((err) =>
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
yield clearAuthToken();
|
|
2271
|
+
}).catch(async (err) => {
|
|
2272
|
+
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
2273
|
+
await clearAuthToken();
|
|
2250
2274
|
}
|
|
2251
|
-
})
|
|
2275
|
+
});
|
|
2252
2276
|
}
|
|
2253
|
-
const browserSession =
|
|
2254
|
-
const refreshToken =
|
|
2255
|
-
const accessTokenExp =
|
|
2277
|
+
const browserSession = await sessionStorage2.getBrowserSession();
|
|
2278
|
+
const refreshToken = await localStorage2.getRefreshToken();
|
|
2279
|
+
const accessTokenExp = await localStorage2.getAccessToken();
|
|
2256
2280
|
isRefreshing = true;
|
|
2257
2281
|
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
2258
|
-
|
|
2282
|
+
await clearAuthToken();
|
|
2259
2283
|
} else {
|
|
2260
2284
|
const payload = Object.fromEntries(
|
|
2261
2285
|
Object.entries({
|
|
@@ -2266,9 +2290,8 @@ var axiosClient = {
|
|
|
2266
2290
|
}).filter(([_, value]) => !!value)
|
|
2267
2291
|
);
|
|
2268
2292
|
return new Promise(function(resolve) {
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
`${config.baseUrl}${(_a3 = config.refreshTokenEndpoint) != null ? _a3 : "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2293
|
+
import_axios.default.post(
|
|
2294
|
+
`${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2272
2295
|
payload,
|
|
2273
2296
|
{
|
|
2274
2297
|
headers: {
|
|
@@ -2276,11 +2299,11 @@ var axiosClient = {
|
|
|
2276
2299
|
Authorization: `Bearer ${accessTokenExp}`
|
|
2277
2300
|
}
|
|
2278
2301
|
}
|
|
2279
|
-
).then((res) =>
|
|
2302
|
+
).then(async (res) => {
|
|
2280
2303
|
const data = res.data;
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2304
|
+
await localStorage2.setToken(data.access_token);
|
|
2305
|
+
await localStorage2.setRefreshToken(data.refresh_token);
|
|
2306
|
+
import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2284
2307
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2285
2308
|
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2286
2309
|
originalRequest,
|
|
@@ -2288,26 +2311,25 @@ var axiosClient = {
|
|
|
2288
2311
|
);
|
|
2289
2312
|
processQueue(null, data.access_token);
|
|
2290
2313
|
resolve(instance.request(originalRequest));
|
|
2291
|
-
})
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
yield clearAuthToken();
|
|
2314
|
+
}).catch(async (err) => {
|
|
2315
|
+
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
|
|
2316
|
+
await clearAuthToken();
|
|
2295
2317
|
}
|
|
2296
2318
|
if (err && err.response) {
|
|
2297
|
-
const { error_code } =
|
|
2319
|
+
const { error_code } = err.response?.data || {};
|
|
2298
2320
|
if (error_code === "AUTHEN_FAIL") {
|
|
2299
|
-
|
|
2321
|
+
await clearAuthToken();
|
|
2300
2322
|
}
|
|
2301
2323
|
}
|
|
2302
2324
|
processQueue(err, null);
|
|
2303
|
-
})
|
|
2325
|
+
}).finally(() => {
|
|
2304
2326
|
isRefreshing = false;
|
|
2305
2327
|
});
|
|
2306
2328
|
});
|
|
2307
2329
|
}
|
|
2308
2330
|
}
|
|
2309
|
-
return Promise.reject(
|
|
2310
|
-
}
|
|
2331
|
+
return Promise.reject(await handleError3(error));
|
|
2332
|
+
}
|
|
2311
2333
|
);
|
|
2312
2334
|
const handleResponse = (res) => {
|
|
2313
2335
|
if (res && res.data) {
|
|
@@ -2316,7 +2338,6 @@ var axiosClient = {
|
|
|
2316
2338
|
return res;
|
|
2317
2339
|
};
|
|
2318
2340
|
const handleError2 = (error) => {
|
|
2319
|
-
var _a2, _b2, _c;
|
|
2320
2341
|
if (error.isAxiosError && error.code === "ECONNABORTED") {
|
|
2321
2342
|
console.error("Request Timeout Error:", error);
|
|
2322
2343
|
return "Request Timeout Error";
|
|
@@ -2324,17 +2345,17 @@ var axiosClient = {
|
|
|
2324
2345
|
console.error("Network Error:", error);
|
|
2325
2346
|
return "Network Error";
|
|
2326
2347
|
} else {
|
|
2327
|
-
console.error("Other Error:", error
|
|
2328
|
-
const errorMessage =
|
|
2329
|
-
return { message: errorMessage, status:
|
|
2348
|
+
console.error("Other Error:", error?.response);
|
|
2349
|
+
const errorMessage = error?.response?.data?.message || "An error occurred";
|
|
2350
|
+
return { message: errorMessage, status: error?.response?.status };
|
|
2330
2351
|
}
|
|
2331
2352
|
};
|
|
2332
|
-
const clearAuthToken = () =>
|
|
2333
|
-
|
|
2353
|
+
const clearAuthToken = async () => {
|
|
2354
|
+
await localStorage2.clearToken();
|
|
2334
2355
|
if (typeof window !== "undefined") {
|
|
2335
2356
|
window.location.href = `/login`;
|
|
2336
2357
|
}
|
|
2337
|
-
}
|
|
2358
|
+
};
|
|
2338
2359
|
function formatUrl(url, db2) {
|
|
2339
2360
|
return url + (db2 ? "?db=" + db2 : "");
|
|
2340
2361
|
}
|
|
@@ -2356,6 +2377,7 @@ var axiosClient = {
|
|
|
2356
2377
|
return requests;
|
|
2357
2378
|
}
|
|
2358
2379
|
};
|
|
2359
|
-
export
|
|
2380
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2381
|
+
0 && (module.exports = {
|
|
2360
2382
|
axiosClient
|
|
2361
|
-
};
|
|
2383
|
+
});
|