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