@fctc/interface-logic 1.7.2 → 1.7.3
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 -1
- package/dist/configs.js +140 -115
- package/dist/{configs.cjs → configs.mjs} +105 -152
- package/dist/constants.js +41 -2
- package/dist/{constants.cjs → constants.mjs} +2 -40
- package/dist/environment.js +190 -170
- package/dist/{environment.cjs → environment.mjs} +156 -210
- package/dist/{hooks.d.cts → hooks.d.mts} +1 -1
- package/dist/hooks.js +1730 -1792
- package/dist/{hooks.cjs → hooks.mjs} +1631 -1897
- package/dist/{provider.d.cts → provider.d.mts} +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +594 -610
- package/dist/{provider.cjs → provider.mjs} +560 -650
- package/dist/{services.d.cts → services.d.mts} +1 -1
- package/dist/services.js +1439 -1562
- package/dist/{services.cjs → services.mjs} +1399 -1608
- package/dist/{store.d.cts → store.d.mts} +127 -127
- package/dist/store.d.ts +127 -127
- package/dist/store.js +129 -41
- package/dist/{store.cjs → store.mjs} +28 -146
- package/dist/{types.d.cts → types.d.mts} +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/package.json +1 -2
- package/dist/types.cjs +0 -17
- /package/dist/{constants.d.cts → constants.d.mts} +0 -0
- /package/dist/{environment.d.cts → environment.d.mts} +0 -0
- /package/dist/{view-type-BGJfDe73.d.cts → view-type-BGJfDe73.d.mts} +0 -0
package/dist/environment.js
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
11
|
};
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
reject(e);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
var rejected = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.throw(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
-
});
|
|
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;
|
|
40
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/environment.ts
|
|
31
|
+
var environment_exports = {};
|
|
32
|
+
__export(environment_exports, {
|
|
33
|
+
EnvStore: () => EnvStore,
|
|
34
|
+
getEnv: () => getEnv,
|
|
35
|
+
initEnv: () => initEnv
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(environment_exports);
|
|
41
38
|
|
|
42
39
|
// src/configs/axios-client.ts
|
|
43
|
-
|
|
40
|
+
var import_axios = __toESM(require("axios"));
|
|
44
41
|
|
|
45
42
|
// src/utils/format.ts
|
|
46
|
-
|
|
43
|
+
var import_moment = __toESM(require("moment"));
|
|
47
44
|
|
|
48
45
|
// src/utils/domain/py_tokenizer.ts
|
|
49
46
|
var TokenizerError = class extends Error {
|
|
@@ -1123,6 +1120,22 @@ var PyRelativeDelta = class _PyRelativeDelta {
|
|
|
1123
1120
|
this.microsecond = params.microsecond;
|
|
1124
1121
|
this.weekday = params.weekday;
|
|
1125
1122
|
}
|
|
1123
|
+
years;
|
|
1124
|
+
months;
|
|
1125
|
+
days;
|
|
1126
|
+
hours;
|
|
1127
|
+
minutes;
|
|
1128
|
+
seconds;
|
|
1129
|
+
microseconds;
|
|
1130
|
+
leapDays;
|
|
1131
|
+
year;
|
|
1132
|
+
month;
|
|
1133
|
+
day;
|
|
1134
|
+
hour;
|
|
1135
|
+
minute;
|
|
1136
|
+
second;
|
|
1137
|
+
microsecond;
|
|
1138
|
+
weekday;
|
|
1126
1139
|
negate() {
|
|
1127
1140
|
return new _PyRelativeDelta(this, -1);
|
|
1128
1141
|
}
|
|
@@ -1237,7 +1250,7 @@ function execOnIterable(iterable, func) {
|
|
|
1237
1250
|
if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
|
|
1238
1251
|
iterable = Object.keys(iterable);
|
|
1239
1252
|
}
|
|
1240
|
-
if (typeof
|
|
1253
|
+
if (typeof iterable?.[Symbol.iterator] !== "function") {
|
|
1241
1254
|
throw new EvaluationError("value not iterable");
|
|
1242
1255
|
}
|
|
1243
1256
|
return func(iterable);
|
|
@@ -1560,7 +1573,7 @@ function applyBinaryOp(ast, context) {
|
|
|
1560
1573
|
}
|
|
1561
1574
|
return Math.floor(left / right);
|
|
1562
1575
|
case "**":
|
|
1563
|
-
return
|
|
1576
|
+
return left ** right;
|
|
1564
1577
|
case "==":
|
|
1565
1578
|
return isEqual(left, right);
|
|
1566
1579
|
case "<>":
|
|
@@ -1682,7 +1695,7 @@ function evaluate(ast, context = {}) {
|
|
|
1682
1695
|
const dicts = /* @__PURE__ */ new Set();
|
|
1683
1696
|
let pyContext;
|
|
1684
1697
|
const evalContext = Object.create(context);
|
|
1685
|
-
if (!
|
|
1698
|
+
if (!evalContext?.context) {
|
|
1686
1699
|
Object.defineProperty(evalContext, "context", {
|
|
1687
1700
|
get() {
|
|
1688
1701
|
if (!pyContext) {
|
|
@@ -1693,18 +1706,17 @@ function evaluate(ast, context = {}) {
|
|
|
1693
1706
|
});
|
|
1694
1707
|
}
|
|
1695
1708
|
function _innerEvaluate(ast2) {
|
|
1696
|
-
|
|
1697
|
-
switch (ast2 == null ? void 0 : ast2.type) {
|
|
1709
|
+
switch (ast2?.type) {
|
|
1698
1710
|
case 0:
|
|
1699
1711
|
// Number
|
|
1700
1712
|
case 1:
|
|
1701
1713
|
return ast2.value;
|
|
1702
1714
|
case 5:
|
|
1703
1715
|
if (ast2.value in evalContext) {
|
|
1704
|
-
if (typeof evalContext[ast2.value] === "object" &&
|
|
1705
|
-
return
|
|
1716
|
+
if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id) {
|
|
1717
|
+
return evalContext[ast2.value]?.id;
|
|
1706
1718
|
}
|
|
1707
|
-
return
|
|
1719
|
+
return evalContext[ast2.value] ?? false;
|
|
1708
1720
|
} else if (ast2.value in BUILTINS) {
|
|
1709
1721
|
return BUILTINS[ast2.value];
|
|
1710
1722
|
} else {
|
|
@@ -1741,7 +1753,7 @@ function evaluate(ast, context = {}) {
|
|
|
1741
1753
|
const args = ast2.args.map(_evaluate);
|
|
1742
1754
|
const kwargs = {};
|
|
1743
1755
|
for (const kwarg in ast2.kwargs) {
|
|
1744
|
-
kwargs[kwarg] = _evaluate(ast2
|
|
1756
|
+
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
1745
1757
|
}
|
|
1746
1758
|
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
1747
1759
|
return fnValue.create(...args, kwargs);
|
|
@@ -1820,25 +1832,9 @@ function escapeRegExp(str) {
|
|
|
1820
1832
|
var InvalidDomainError = class extends Error {
|
|
1821
1833
|
};
|
|
1822
1834
|
var Domain = class _Domain {
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
return new _Domain(descr.toString());
|
|
1827
|
-
} else {
|
|
1828
|
-
let rawAST;
|
|
1829
|
-
try {
|
|
1830
|
-
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
1831
|
-
} catch (error) {
|
|
1832
|
-
throw new InvalidDomainError(
|
|
1833
|
-
`Invalid domain representation: ${descr}`,
|
|
1834
|
-
{
|
|
1835
|
-
cause: error
|
|
1836
|
-
}
|
|
1837
|
-
);
|
|
1838
|
-
}
|
|
1839
|
-
this.ast = normalizeDomainAST(rawAST);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1835
|
+
ast = { type: -1, value: null };
|
|
1836
|
+
static TRUE;
|
|
1837
|
+
static FALSE;
|
|
1842
1838
|
static combine(domains, operator) {
|
|
1843
1839
|
if (domains.length === 0) {
|
|
1844
1840
|
return new _Domain([]);
|
|
@@ -1917,6 +1913,24 @@ var Domain = class _Domain {
|
|
|
1917
1913
|
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
1918
1914
|
return newDomain;
|
|
1919
1915
|
}
|
|
1916
|
+
constructor(descr = []) {
|
|
1917
|
+
if (descr instanceof _Domain) {
|
|
1918
|
+
return new _Domain(descr.toString());
|
|
1919
|
+
} else {
|
|
1920
|
+
let rawAST;
|
|
1921
|
+
try {
|
|
1922
|
+
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
1923
|
+
} catch (error) {
|
|
1924
|
+
throw new InvalidDomainError(
|
|
1925
|
+
`Invalid domain representation: ${descr}`,
|
|
1926
|
+
{
|
|
1927
|
+
cause: error
|
|
1928
|
+
}
|
|
1929
|
+
);
|
|
1930
|
+
}
|
|
1931
|
+
this.ast = normalizeDomainAST(rawAST);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1920
1934
|
contains(record) {
|
|
1921
1935
|
const expr = evaluate(this.ast, record);
|
|
1922
1936
|
return matchDomain(record, expr);
|
|
@@ -1935,7 +1949,7 @@ var Domain = class _Domain {
|
|
|
1935
1949
|
return evaluatedAsList;
|
|
1936
1950
|
}
|
|
1937
1951
|
return this.toString();
|
|
1938
|
-
} catch
|
|
1952
|
+
} catch {
|
|
1939
1953
|
return this.toString();
|
|
1940
1954
|
}
|
|
1941
1955
|
}
|
|
@@ -2135,7 +2149,7 @@ function matchDomain(record, domain) {
|
|
|
2135
2149
|
}
|
|
2136
2150
|
|
|
2137
2151
|
// src/utils/function.ts
|
|
2138
|
-
|
|
2152
|
+
var import_react = require("react");
|
|
2139
2153
|
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2140
2154
|
if (!originalRequest.data) return originalRequest.data;
|
|
2141
2155
|
if (typeof originalRequest.data === "string") {
|
|
@@ -2158,22 +2172,22 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
|
2158
2172
|
|
|
2159
2173
|
// src/utils/storage/local-storage.ts
|
|
2160
2174
|
var localStorageUtils = () => {
|
|
2161
|
-
const setToken = (access_token) =>
|
|
2175
|
+
const setToken = async (access_token) => {
|
|
2162
2176
|
localStorage.setItem("accessToken", access_token);
|
|
2163
|
-
}
|
|
2164
|
-
const setRefreshToken = (refresh_token) =>
|
|
2177
|
+
};
|
|
2178
|
+
const setRefreshToken = async (refresh_token) => {
|
|
2165
2179
|
localStorage.setItem("refreshToken", refresh_token);
|
|
2166
|
-
}
|
|
2167
|
-
const getAccessToken = () =>
|
|
2180
|
+
};
|
|
2181
|
+
const getAccessToken = async () => {
|
|
2168
2182
|
return localStorage.getItem("accessToken");
|
|
2169
|
-
}
|
|
2170
|
-
const getRefreshToken = () =>
|
|
2183
|
+
};
|
|
2184
|
+
const getRefreshToken = async () => {
|
|
2171
2185
|
return localStorage.getItem("refreshToken");
|
|
2172
|
-
}
|
|
2173
|
-
const clearToken = () =>
|
|
2186
|
+
};
|
|
2187
|
+
const clearToken = async () => {
|
|
2174
2188
|
localStorage.removeItem("accessToken");
|
|
2175
2189
|
localStorage.removeItem("refreshToken");
|
|
2176
|
-
}
|
|
2190
|
+
};
|
|
2177
2191
|
return {
|
|
2178
2192
|
setToken,
|
|
2179
2193
|
setRefreshToken,
|
|
@@ -2185,9 +2199,9 @@ var localStorageUtils = () => {
|
|
|
2185
2199
|
|
|
2186
2200
|
// src/utils/storage/session-storage.ts
|
|
2187
2201
|
var sessionStorageUtils = () => {
|
|
2188
|
-
const getBrowserSession = () =>
|
|
2202
|
+
const getBrowserSession = async () => {
|
|
2189
2203
|
return sessionStorage.getItem("browserSession");
|
|
2190
|
-
}
|
|
2204
|
+
};
|
|
2191
2205
|
return {
|
|
2192
2206
|
getBrowserSession
|
|
2193
2207
|
};
|
|
@@ -2196,14 +2210,13 @@ var sessionStorageUtils = () => {
|
|
|
2196
2210
|
// src/configs/axios-client.ts
|
|
2197
2211
|
var axiosClient = {
|
|
2198
2212
|
init(config) {
|
|
2199
|
-
|
|
2200
|
-
const
|
|
2201
|
-
const sessionStorage2 = (_b = config.sessionStorageUtils) != null ? _b : sessionStorageUtils();
|
|
2213
|
+
const localStorage2 = config.localStorageUtils ?? localStorageUtils();
|
|
2214
|
+
const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
|
|
2202
2215
|
const db = config.db;
|
|
2203
2216
|
let isRefreshing = false;
|
|
2204
2217
|
let failedQueue = [];
|
|
2205
2218
|
const processQueue = (error, token = null) => {
|
|
2206
|
-
failedQueue
|
|
2219
|
+
failedQueue?.forEach((prom) => {
|
|
2207
2220
|
if (error) {
|
|
2208
2221
|
prom.reject(error);
|
|
2209
2222
|
} else {
|
|
@@ -2212,21 +2225,21 @@ var axiosClient = {
|
|
|
2212
2225
|
});
|
|
2213
2226
|
failedQueue = [];
|
|
2214
2227
|
};
|
|
2215
|
-
const instance =
|
|
2216
|
-
adapter:
|
|
2228
|
+
const instance = import_axios.default.create({
|
|
2229
|
+
adapter: import_axios.default.defaults.adapter,
|
|
2217
2230
|
baseURL: config.baseUrl,
|
|
2218
2231
|
timeout: 5e4,
|
|
2219
2232
|
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
2220
2233
|
});
|
|
2221
2234
|
instance.interceptors.request.use(
|
|
2222
|
-
(config2) =>
|
|
2235
|
+
async (config2) => {
|
|
2223
2236
|
const useRefreshToken = config2.useRefreshToken;
|
|
2224
|
-
const token = useRefreshToken ?
|
|
2237
|
+
const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
|
|
2225
2238
|
if (token) {
|
|
2226
2239
|
config2.headers["Authorization"] = "Bearer " + token;
|
|
2227
2240
|
}
|
|
2228
2241
|
return config2;
|
|
2229
|
-
}
|
|
2242
|
+
},
|
|
2230
2243
|
(error) => {
|
|
2231
2244
|
Promise.reject(error);
|
|
2232
2245
|
}
|
|
@@ -2235,21 +2248,19 @@ var axiosClient = {
|
|
|
2235
2248
|
(response) => {
|
|
2236
2249
|
return handleResponse(response);
|
|
2237
2250
|
},
|
|
2238
|
-
(error) =>
|
|
2239
|
-
|
|
2240
|
-
const handleError3 = (error2) => __async(null, null, function* () {
|
|
2241
|
-
var _a3;
|
|
2251
|
+
async (error) => {
|
|
2252
|
+
const handleError3 = async (error2) => {
|
|
2242
2253
|
if (!error2.response) {
|
|
2243
2254
|
return error2;
|
|
2244
2255
|
}
|
|
2245
2256
|
const { data } = error2.response;
|
|
2246
|
-
if (data && data.code === 400 && ["invalid_grant"].includes(
|
|
2247
|
-
|
|
2257
|
+
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
2258
|
+
await clearAuthToken();
|
|
2248
2259
|
}
|
|
2249
2260
|
return data;
|
|
2250
|
-
}
|
|
2261
|
+
};
|
|
2251
2262
|
const originalRequest = error.config;
|
|
2252
|
-
if ((
|
|
2263
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
|
|
2253
2264
|
error.response.data.code
|
|
2254
2265
|
)) {
|
|
2255
2266
|
if (isRefreshing) {
|
|
@@ -2262,19 +2273,18 @@ var axiosClient = {
|
|
|
2262
2273
|
token
|
|
2263
2274
|
);
|
|
2264
2275
|
return instance.request(originalRequest);
|
|
2265
|
-
}).catch((err) =>
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
yield clearAuthToken();
|
|
2276
|
+
}).catch(async (err) => {
|
|
2277
|
+
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
2278
|
+
await clearAuthToken();
|
|
2269
2279
|
}
|
|
2270
|
-
})
|
|
2280
|
+
});
|
|
2271
2281
|
}
|
|
2272
|
-
const browserSession =
|
|
2273
|
-
const refreshToken =
|
|
2274
|
-
const accessTokenExp =
|
|
2282
|
+
const browserSession = await sessionStorage2.getBrowserSession();
|
|
2283
|
+
const refreshToken = await localStorage2.getRefreshToken();
|
|
2284
|
+
const accessTokenExp = await localStorage2.getAccessToken();
|
|
2275
2285
|
isRefreshing = true;
|
|
2276
2286
|
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
2277
|
-
|
|
2287
|
+
await clearAuthToken();
|
|
2278
2288
|
} else {
|
|
2279
2289
|
const payload = Object.fromEntries(
|
|
2280
2290
|
Object.entries({
|
|
@@ -2285,9 +2295,8 @@ var axiosClient = {
|
|
|
2285
2295
|
}).filter(([_, value]) => !!value)
|
|
2286
2296
|
);
|
|
2287
2297
|
return new Promise(function(resolve) {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
`${config.baseUrl}${(_a3 = config.refreshTokenEndpoint) != null ? _a3 : "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2298
|
+
import_axios.default.post(
|
|
2299
|
+
`${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2291
2300
|
payload,
|
|
2292
2301
|
{
|
|
2293
2302
|
headers: {
|
|
@@ -2295,11 +2304,11 @@ var axiosClient = {
|
|
|
2295
2304
|
Authorization: `Bearer ${accessTokenExp}`
|
|
2296
2305
|
}
|
|
2297
2306
|
}
|
|
2298
|
-
).then((res) =>
|
|
2307
|
+
).then(async (res) => {
|
|
2299
2308
|
const data = res.data;
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2309
|
+
await localStorage2.setToken(data.access_token);
|
|
2310
|
+
await localStorage2.setRefreshToken(data.refresh_token);
|
|
2311
|
+
import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2303
2312
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2304
2313
|
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2305
2314
|
originalRequest,
|
|
@@ -2307,26 +2316,25 @@ var axiosClient = {
|
|
|
2307
2316
|
);
|
|
2308
2317
|
processQueue(null, data.access_token);
|
|
2309
2318
|
resolve(instance.request(originalRequest));
|
|
2310
|
-
})
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
yield clearAuthToken();
|
|
2319
|
+
}).catch(async (err) => {
|
|
2320
|
+
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") {
|
|
2321
|
+
await clearAuthToken();
|
|
2314
2322
|
}
|
|
2315
2323
|
if (err && err.response) {
|
|
2316
|
-
const { error_code } =
|
|
2324
|
+
const { error_code } = err.response?.data || {};
|
|
2317
2325
|
if (error_code === "AUTHEN_FAIL") {
|
|
2318
|
-
|
|
2326
|
+
await clearAuthToken();
|
|
2319
2327
|
}
|
|
2320
2328
|
}
|
|
2321
2329
|
processQueue(err, null);
|
|
2322
|
-
})
|
|
2330
|
+
}).finally(() => {
|
|
2323
2331
|
isRefreshing = false;
|
|
2324
2332
|
});
|
|
2325
2333
|
});
|
|
2326
2334
|
}
|
|
2327
2335
|
}
|
|
2328
|
-
return Promise.reject(
|
|
2329
|
-
}
|
|
2336
|
+
return Promise.reject(await handleError3(error));
|
|
2337
|
+
}
|
|
2330
2338
|
);
|
|
2331
2339
|
const handleResponse = (res) => {
|
|
2332
2340
|
if (res && res.data) {
|
|
@@ -2335,7 +2343,6 @@ var axiosClient = {
|
|
|
2335
2343
|
return res;
|
|
2336
2344
|
};
|
|
2337
2345
|
const handleError2 = (error) => {
|
|
2338
|
-
var _a2, _b2, _c;
|
|
2339
2346
|
if (error.isAxiosError && error.code === "ECONNABORTED") {
|
|
2340
2347
|
console.error("Request Timeout Error:", error);
|
|
2341
2348
|
return "Request Timeout Error";
|
|
@@ -2343,17 +2350,17 @@ var axiosClient = {
|
|
|
2343
2350
|
console.error("Network Error:", error);
|
|
2344
2351
|
return "Network Error";
|
|
2345
2352
|
} else {
|
|
2346
|
-
console.error("Other Error:", error
|
|
2347
|
-
const errorMessage =
|
|
2348
|
-
return { message: errorMessage, status:
|
|
2353
|
+
console.error("Other Error:", error?.response);
|
|
2354
|
+
const errorMessage = error?.response?.data?.message || "An error occurred";
|
|
2355
|
+
return { message: errorMessage, status: error?.response?.status };
|
|
2349
2356
|
}
|
|
2350
2357
|
};
|
|
2351
|
-
const clearAuthToken = () =>
|
|
2352
|
-
|
|
2358
|
+
const clearAuthToken = async () => {
|
|
2359
|
+
await localStorage2.clearToken();
|
|
2353
2360
|
if (typeof window !== "undefined") {
|
|
2354
2361
|
window.location.href = `/login`;
|
|
2355
2362
|
}
|
|
2356
|
-
}
|
|
2363
|
+
};
|
|
2357
2364
|
function formatUrl(url, db2) {
|
|
2358
2365
|
return url + (db2 ? "?db=" + db2 : "");
|
|
2359
2366
|
}
|
|
@@ -2377,14 +2384,14 @@ var axiosClient = {
|
|
|
2377
2384
|
};
|
|
2378
2385
|
|
|
2379
2386
|
// src/store/index.ts
|
|
2380
|
-
|
|
2387
|
+
var import_react_redux = require("react-redux");
|
|
2381
2388
|
|
|
2382
2389
|
// src/store/reducers/breadcrums-slice/index.ts
|
|
2383
|
-
|
|
2390
|
+
var import_toolkit = require("@reduxjs/toolkit");
|
|
2384
2391
|
var initialState = {
|
|
2385
2392
|
breadCrumbs: []
|
|
2386
2393
|
};
|
|
2387
|
-
var breadcrumbsSlice = createSlice({
|
|
2394
|
+
var breadcrumbsSlice = (0, import_toolkit.createSlice)({
|
|
2388
2395
|
name: "breadcrumbs",
|
|
2389
2396
|
initialState,
|
|
2390
2397
|
reducers: {
|
|
@@ -2397,7 +2404,7 @@ var { setBreadCrumbs } = breadcrumbsSlice.actions;
|
|
|
2397
2404
|
var breadcrums_slice_default = breadcrumbsSlice.reducer;
|
|
2398
2405
|
|
|
2399
2406
|
// src/store/reducers/env-slice/index.ts
|
|
2400
|
-
|
|
2407
|
+
var import_toolkit2 = require("@reduxjs/toolkit");
|
|
2401
2408
|
var initialState2 = {
|
|
2402
2409
|
baseUrl: "",
|
|
2403
2410
|
requests: null,
|
|
@@ -2418,7 +2425,7 @@ var initialState2 = {
|
|
|
2418
2425
|
tz: "Asia/Saigon"
|
|
2419
2426
|
}
|
|
2420
2427
|
};
|
|
2421
|
-
var envSlice =
|
|
2428
|
+
var envSlice = (0, import_toolkit2.createSlice)({
|
|
2422
2429
|
name: "env",
|
|
2423
2430
|
initialState: initialState2,
|
|
2424
2431
|
reducers: {
|
|
@@ -2465,7 +2472,7 @@ var {
|
|
|
2465
2472
|
var env_slice_default = envSlice.reducer;
|
|
2466
2473
|
|
|
2467
2474
|
// src/store/reducers/excel-slice/index.ts
|
|
2468
|
-
|
|
2475
|
+
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
2469
2476
|
var initialState3 = {
|
|
2470
2477
|
dataParse: null,
|
|
2471
2478
|
idFile: null,
|
|
@@ -2474,7 +2481,7 @@ var initialState3 = {
|
|
|
2474
2481
|
selectedFile: null,
|
|
2475
2482
|
errorData: null
|
|
2476
2483
|
};
|
|
2477
|
-
var excelSlice =
|
|
2484
|
+
var excelSlice = (0, import_toolkit3.createSlice)({
|
|
2478
2485
|
name: "excel",
|
|
2479
2486
|
initialState: initialState3,
|
|
2480
2487
|
reducers: {
|
|
@@ -2509,7 +2516,7 @@ var {
|
|
|
2509
2516
|
var excel_slice_default = excelSlice.reducer;
|
|
2510
2517
|
|
|
2511
2518
|
// src/store/reducers/form-slice/index.ts
|
|
2512
|
-
|
|
2519
|
+
var import_toolkit4 = require("@reduxjs/toolkit");
|
|
2513
2520
|
var initialState4 = {
|
|
2514
2521
|
viewDataStore: {},
|
|
2515
2522
|
isShowingModalDetail: false,
|
|
@@ -2519,7 +2526,7 @@ var initialState4 = {
|
|
|
2519
2526
|
listSubject: {},
|
|
2520
2527
|
dataUser: {}
|
|
2521
2528
|
};
|
|
2522
|
-
var formSlice =
|
|
2529
|
+
var formSlice = (0, import_toolkit4.createSlice)({
|
|
2523
2530
|
name: "form",
|
|
2524
2531
|
initialState: initialState4,
|
|
2525
2532
|
reducers: {
|
|
@@ -2558,15 +2565,15 @@ var {
|
|
|
2558
2565
|
var form_slice_default = formSlice.reducer;
|
|
2559
2566
|
|
|
2560
2567
|
// src/store/reducers/header-slice/index.ts
|
|
2561
|
-
|
|
2562
|
-
var headerSlice =
|
|
2568
|
+
var import_toolkit5 = require("@reduxjs/toolkit");
|
|
2569
|
+
var headerSlice = (0, import_toolkit5.createSlice)({
|
|
2563
2570
|
name: "header",
|
|
2564
2571
|
initialState: {
|
|
2565
2572
|
value: { allowedCompanyIds: [] }
|
|
2566
2573
|
},
|
|
2567
2574
|
reducers: {
|
|
2568
2575
|
setHeader: (state, action) => {
|
|
2569
|
-
state.value =
|
|
2576
|
+
state.value = { ...state.value, ...action.payload };
|
|
2570
2577
|
},
|
|
2571
2578
|
setAllowedCompanyIds: (state, action) => {
|
|
2572
2579
|
state.value.allowedCompanyIds = action.payload;
|
|
@@ -2577,7 +2584,7 @@ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
|
|
|
2577
2584
|
var header_slice_default = headerSlice.reducer;
|
|
2578
2585
|
|
|
2579
2586
|
// src/store/reducers/list-slice/index.ts
|
|
2580
|
-
|
|
2587
|
+
var import_toolkit6 = require("@reduxjs/toolkit");
|
|
2581
2588
|
var initialState5 = {
|
|
2582
2589
|
pageLimit: 10,
|
|
2583
2590
|
fields: {},
|
|
@@ -2591,7 +2598,7 @@ var initialState5 = {
|
|
|
2591
2598
|
page: 0,
|
|
2592
2599
|
domainTable: []
|
|
2593
2600
|
};
|
|
2594
|
-
var listSlice =
|
|
2601
|
+
var listSlice = (0, import_toolkit6.createSlice)({
|
|
2595
2602
|
name: "list",
|
|
2596
2603
|
initialState: initialState5,
|
|
2597
2604
|
reducers: {
|
|
@@ -2642,13 +2649,13 @@ var {
|
|
|
2642
2649
|
var list_slice_default = listSlice.reducer;
|
|
2643
2650
|
|
|
2644
2651
|
// src/store/reducers/login-slice/index.ts
|
|
2645
|
-
|
|
2652
|
+
var import_toolkit7 = require("@reduxjs/toolkit");
|
|
2646
2653
|
var initialState6 = {
|
|
2647
2654
|
db: "",
|
|
2648
2655
|
redirectTo: "/",
|
|
2649
2656
|
forgotPasswordUrl: "/"
|
|
2650
2657
|
};
|
|
2651
|
-
var loginSlice =
|
|
2658
|
+
var loginSlice = (0, import_toolkit7.createSlice)({
|
|
2652
2659
|
name: "login",
|
|
2653
2660
|
initialState: initialState6,
|
|
2654
2661
|
reducers: {
|
|
@@ -2667,14 +2674,14 @@ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
|
|
|
2667
2674
|
var login_slice_default = loginSlice.reducer;
|
|
2668
2675
|
|
|
2669
2676
|
// src/store/reducers/navbar-slice/index.ts
|
|
2670
|
-
|
|
2677
|
+
var import_toolkit8 = require("@reduxjs/toolkit");
|
|
2671
2678
|
var initialState7 = {
|
|
2672
2679
|
menuFocus: {},
|
|
2673
2680
|
menuAction: {},
|
|
2674
2681
|
navbarWidth: 250,
|
|
2675
2682
|
menuList: []
|
|
2676
2683
|
};
|
|
2677
|
-
var navbarSlice =
|
|
2684
|
+
var navbarSlice = (0, import_toolkit8.createSlice)({
|
|
2678
2685
|
name: "navbar",
|
|
2679
2686
|
initialState: initialState7,
|
|
2680
2687
|
reducers: {
|
|
@@ -2696,11 +2703,11 @@ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSl
|
|
|
2696
2703
|
var navbar_slice_default = navbarSlice.reducer;
|
|
2697
2704
|
|
|
2698
2705
|
// src/store/reducers/profile-slice/index.ts
|
|
2699
|
-
|
|
2706
|
+
var import_toolkit9 = require("@reduxjs/toolkit");
|
|
2700
2707
|
var initialState8 = {
|
|
2701
2708
|
profile: {}
|
|
2702
2709
|
};
|
|
2703
|
-
var profileSlice =
|
|
2710
|
+
var profileSlice = (0, import_toolkit9.createSlice)({
|
|
2704
2711
|
name: "profile",
|
|
2705
2712
|
initialState: initialState8,
|
|
2706
2713
|
reducers: {
|
|
@@ -2713,7 +2720,7 @@ var { setProfile } = profileSlice.actions;
|
|
|
2713
2720
|
var profile_slice_default = profileSlice.reducer;
|
|
2714
2721
|
|
|
2715
2722
|
// src/store/reducers/search-slice/index.ts
|
|
2716
|
-
|
|
2723
|
+
var import_toolkit10 = require("@reduxjs/toolkit");
|
|
2717
2724
|
var initialState9 = {
|
|
2718
2725
|
groupByDomain: null,
|
|
2719
2726
|
searchBy: [],
|
|
@@ -2725,7 +2732,7 @@ var initialState9 = {
|
|
|
2725
2732
|
filterBy: [],
|
|
2726
2733
|
groupBy: []
|
|
2727
2734
|
};
|
|
2728
|
-
var searchSlice =
|
|
2735
|
+
var searchSlice = (0, import_toolkit10.createSlice)({
|
|
2729
2736
|
name: "search",
|
|
2730
2737
|
initialState: initialState9,
|
|
2731
2738
|
reducers: {
|
|
@@ -2799,7 +2806,7 @@ var {
|
|
|
2799
2806
|
var search_slice_default = searchSlice.reducer;
|
|
2800
2807
|
|
|
2801
2808
|
// src/store/store.ts
|
|
2802
|
-
|
|
2809
|
+
var import_toolkit11 = require("@reduxjs/toolkit");
|
|
2803
2810
|
|
|
2804
2811
|
// node_modules/redux/dist/redux.mjs
|
|
2805
2812
|
function formatProdErrorMessage(code) {
|
|
@@ -2983,7 +2990,7 @@ var rootReducer = combineReducers({
|
|
|
2983
2990
|
excel: excel_slice_default,
|
|
2984
2991
|
profile: profile_slice_default
|
|
2985
2992
|
});
|
|
2986
|
-
var envStore = configureStore({
|
|
2993
|
+
var envStore = (0, import_toolkit11.configureStore)({
|
|
2987
2994
|
reducer: rootReducer,
|
|
2988
2995
|
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
2989
2996
|
serializableCheck: false
|
|
@@ -2991,7 +2998,20 @@ var envStore = configureStore({
|
|
|
2991
2998
|
});
|
|
2992
2999
|
|
|
2993
3000
|
// src/environment/EnvStore.ts
|
|
2994
|
-
var
|
|
3001
|
+
var EnvStore = class _EnvStore {
|
|
3002
|
+
static instance = null;
|
|
3003
|
+
envStore;
|
|
3004
|
+
baseUrl;
|
|
3005
|
+
requests;
|
|
3006
|
+
context;
|
|
3007
|
+
defaultCompany;
|
|
3008
|
+
config;
|
|
3009
|
+
companies;
|
|
3010
|
+
user;
|
|
3011
|
+
db;
|
|
3012
|
+
localStorageUtils;
|
|
3013
|
+
sessionStorageUtils;
|
|
3014
|
+
refreshTokenEndpoint;
|
|
2995
3015
|
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
2996
3016
|
this.envStore = envStore2;
|
|
2997
3017
|
this.localStorageUtils = localStorageUtils2;
|
|
@@ -3010,25 +3030,26 @@ var _EnvStore = class _EnvStore {
|
|
|
3010
3030
|
}
|
|
3011
3031
|
setup() {
|
|
3012
3032
|
const env = this.envStore.getState().env;
|
|
3013
|
-
this.baseUrl = env
|
|
3014
|
-
this.requests = env
|
|
3015
|
-
this.context = env
|
|
3016
|
-
this.defaultCompany = env
|
|
3017
|
-
this.config = env
|
|
3018
|
-
this.companies =
|
|
3019
|
-
this.user = env
|
|
3020
|
-
this.db = env
|
|
3021
|
-
this.refreshTokenEndpoint = env
|
|
3033
|
+
this.baseUrl = env?.baseUrl;
|
|
3034
|
+
this.requests = env?.requests;
|
|
3035
|
+
this.context = env?.context;
|
|
3036
|
+
this.defaultCompany = env?.defaultCompany;
|
|
3037
|
+
this.config = env?.config;
|
|
3038
|
+
this.companies = env?.companies || [];
|
|
3039
|
+
this.user = env?.user;
|
|
3040
|
+
this.db = env?.db;
|
|
3041
|
+
this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
|
|
3022
3042
|
console.log("Env setup:", this);
|
|
3023
3043
|
}
|
|
3024
3044
|
setupEnv(envConfig) {
|
|
3025
3045
|
const dispatch = this.envStore.dispatch;
|
|
3026
|
-
const env =
|
|
3046
|
+
const env = {
|
|
3047
|
+
...envConfig,
|
|
3027
3048
|
localStorageUtils: this.localStorageUtils,
|
|
3028
3049
|
sessionStorageUtils: this.sessionStorageUtils
|
|
3029
|
-
}
|
|
3050
|
+
};
|
|
3030
3051
|
const requests = axiosClient.init(env);
|
|
3031
|
-
dispatch(setEnv(
|
|
3052
|
+
dispatch(setEnv({ ...env, requests }));
|
|
3032
3053
|
this.setup();
|
|
3033
3054
|
}
|
|
3034
3055
|
setUid(uid) {
|
|
@@ -3062,8 +3083,6 @@ var _EnvStore = class _EnvStore {
|
|
|
3062
3083
|
this.setup();
|
|
3063
3084
|
}
|
|
3064
3085
|
};
|
|
3065
|
-
_EnvStore.instance = null;
|
|
3066
|
-
var EnvStore = _EnvStore;
|
|
3067
3086
|
function initEnv({
|
|
3068
3087
|
localStorageUtils: localStorageUtils2,
|
|
3069
3088
|
sessionStorageUtils: sessionStorageUtils2
|
|
@@ -3077,8 +3096,9 @@ function getEnv() {
|
|
|
3077
3096
|
}
|
|
3078
3097
|
return instance;
|
|
3079
3098
|
}
|
|
3080
|
-
export
|
|
3099
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3100
|
+
0 && (module.exports = {
|
|
3081
3101
|
EnvStore,
|
|
3082
3102
|
getEnv,
|
|
3083
3103
|
initEnv
|
|
3084
|
-
};
|
|
3104
|
+
});
|