@fctc/interface-logic 1.5.8 → 1.6.0
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.mts +0 -1
- package/dist/configs.d.ts +0 -1
- package/dist/configs.js +103 -116
- package/dist/configs.mjs +102 -117
- package/dist/constants.js +1 -0
- package/dist/environment.d.mts +3 -20
- package/dist/environment.d.ts +3 -20
- package/dist/environment.js +142 -159
- package/dist/environment.mjs +141 -162
- package/dist/hooks.d.mts +6 -1
- package/dist/hooks.d.ts +6 -1
- package/dist/hooks.js +1569 -1704
- package/dist/hooks.mjs +1523 -1663
- package/dist/provider.d.mts +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +528 -583
- package/dist/provider.mjs +527 -586
- package/dist/services.d.mts +1 -0
- package/dist/services.d.ts +1 -0
- package/dist/services.js +1388 -1541
- package/dist/services.mjs +1387 -1544
- package/dist/store.d.mts +155 -127
- package/dist/store.d.ts +155 -127
- package/dist/store.js +4 -15
- package/dist/store.mjs +3 -18
- package/dist/types.js +1 -0
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +95 -116
- package/dist/utils.mjs +94 -119
- package/package.json +81 -82
package/dist/environment.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __pow = Math.pow;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -43,26 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
43
26
|
mod
|
|
44
27
|
));
|
|
45
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
-
var __async = (__this, __arguments, generator) => {
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
var fulfilled = (value) => {
|
|
49
|
-
try {
|
|
50
|
-
step(generator.next(value));
|
|
51
|
-
} catch (e) {
|
|
52
|
-
reject(e);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var rejected = (value) => {
|
|
56
|
-
try {
|
|
57
|
-
step(generator.throw(value));
|
|
58
|
-
} catch (e) {
|
|
59
|
-
reject(e);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
63
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
29
|
|
|
67
30
|
// src/environment.ts
|
|
68
31
|
var environment_exports = {};
|
|
@@ -1158,6 +1121,22 @@ var PyRelativeDelta = class _PyRelativeDelta {
|
|
|
1158
1121
|
this.microsecond = params.microsecond;
|
|
1159
1122
|
this.weekday = params.weekday;
|
|
1160
1123
|
}
|
|
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;
|
|
1161
1140
|
negate() {
|
|
1162
1141
|
return new _PyRelativeDelta(this, -1);
|
|
1163
1142
|
}
|
|
@@ -1272,7 +1251,7 @@ function execOnIterable(iterable, func) {
|
|
|
1272
1251
|
if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
|
|
1273
1252
|
iterable = Object.keys(iterable);
|
|
1274
1253
|
}
|
|
1275
|
-
if (typeof
|
|
1254
|
+
if (typeof iterable?.[Symbol.iterator] !== "function") {
|
|
1276
1255
|
throw new EvaluationError("value not iterable");
|
|
1277
1256
|
}
|
|
1278
1257
|
return func(iterable);
|
|
@@ -1595,7 +1574,7 @@ function applyBinaryOp(ast, context) {
|
|
|
1595
1574
|
}
|
|
1596
1575
|
return Math.floor(left / right);
|
|
1597
1576
|
case "**":
|
|
1598
|
-
return
|
|
1577
|
+
return left ** right;
|
|
1599
1578
|
case "==":
|
|
1600
1579
|
return isEqual(left, right);
|
|
1601
1580
|
case "<>":
|
|
@@ -1717,7 +1696,7 @@ function evaluate(ast, context = {}) {
|
|
|
1717
1696
|
const dicts = /* @__PURE__ */ new Set();
|
|
1718
1697
|
let pyContext;
|
|
1719
1698
|
const evalContext = Object.create(context);
|
|
1720
|
-
if (!
|
|
1699
|
+
if (!evalContext?.context) {
|
|
1721
1700
|
Object.defineProperty(evalContext, "context", {
|
|
1722
1701
|
get() {
|
|
1723
1702
|
if (!pyContext) {
|
|
@@ -1728,18 +1707,17 @@ function evaluate(ast, context = {}) {
|
|
|
1728
1707
|
});
|
|
1729
1708
|
}
|
|
1730
1709
|
function _innerEvaluate(ast2) {
|
|
1731
|
-
|
|
1732
|
-
switch (ast2 == null ? void 0 : ast2.type) {
|
|
1710
|
+
switch (ast2?.type) {
|
|
1733
1711
|
case 0:
|
|
1734
1712
|
// Number
|
|
1735
1713
|
case 1:
|
|
1736
1714
|
return ast2.value;
|
|
1737
1715
|
case 5:
|
|
1738
1716
|
if (ast2.value in evalContext) {
|
|
1739
|
-
if (typeof evalContext[ast2.value] === "object" &&
|
|
1740
|
-
return
|
|
1717
|
+
if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id) {
|
|
1718
|
+
return evalContext[ast2.value]?.id;
|
|
1741
1719
|
}
|
|
1742
|
-
return
|
|
1720
|
+
return evalContext[ast2.value] ?? false;
|
|
1743
1721
|
} else if (ast2.value in BUILTINS) {
|
|
1744
1722
|
return BUILTINS[ast2.value];
|
|
1745
1723
|
} else {
|
|
@@ -1776,7 +1754,7 @@ function evaluate(ast, context = {}) {
|
|
|
1776
1754
|
const args = ast2.args.map(_evaluate);
|
|
1777
1755
|
const kwargs = {};
|
|
1778
1756
|
for (const kwarg in ast2.kwargs) {
|
|
1779
|
-
kwargs[kwarg] = _evaluate(ast2
|
|
1757
|
+
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
1780
1758
|
}
|
|
1781
1759
|
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
1782
1760
|
return fnValue.create(...args, kwargs);
|
|
@@ -1855,25 +1833,9 @@ function escapeRegExp(str) {
|
|
|
1855
1833
|
var InvalidDomainError = class extends Error {
|
|
1856
1834
|
};
|
|
1857
1835
|
var Domain = class _Domain {
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
return new _Domain(descr.toString());
|
|
1862
|
-
} else {
|
|
1863
|
-
let rawAST;
|
|
1864
|
-
try {
|
|
1865
|
-
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
1866
|
-
} catch (error) {
|
|
1867
|
-
throw new InvalidDomainError(
|
|
1868
|
-
`Invalid domain representation: ${descr}`,
|
|
1869
|
-
{
|
|
1870
|
-
cause: error
|
|
1871
|
-
}
|
|
1872
|
-
);
|
|
1873
|
-
}
|
|
1874
|
-
this.ast = normalizeDomainAST(rawAST);
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1836
|
+
ast = { type: -1, value: null };
|
|
1837
|
+
static TRUE;
|
|
1838
|
+
static FALSE;
|
|
1877
1839
|
static combine(domains, operator) {
|
|
1878
1840
|
if (domains.length === 0) {
|
|
1879
1841
|
return new _Domain([]);
|
|
@@ -1952,6 +1914,24 @@ var Domain = class _Domain {
|
|
|
1952
1914
|
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
1953
1915
|
return newDomain;
|
|
1954
1916
|
}
|
|
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
|
+
}
|
|
1955
1935
|
contains(record) {
|
|
1956
1936
|
const expr = evaluate(this.ast, record);
|
|
1957
1937
|
return matchDomain(record, expr);
|
|
@@ -1970,7 +1950,7 @@ var Domain = class _Domain {
|
|
|
1970
1950
|
return evaluatedAsList;
|
|
1971
1951
|
}
|
|
1972
1952
|
return this.toString();
|
|
1973
|
-
} catch
|
|
1953
|
+
} catch {
|
|
1974
1954
|
return this.toString();
|
|
1975
1955
|
}
|
|
1976
1956
|
}
|
|
@@ -2193,22 +2173,22 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
|
2193
2173
|
|
|
2194
2174
|
// src/utils/storage/local-storage.ts
|
|
2195
2175
|
var localStorageUtils = () => {
|
|
2196
|
-
const setToken = (access_token) =>
|
|
2176
|
+
const setToken = async (access_token) => {
|
|
2197
2177
|
localStorage.setItem("accessToken", access_token);
|
|
2198
|
-
}
|
|
2199
|
-
const setRefreshToken = (refresh_token) =>
|
|
2178
|
+
};
|
|
2179
|
+
const setRefreshToken = async (refresh_token) => {
|
|
2200
2180
|
localStorage.setItem("refreshToken", refresh_token);
|
|
2201
|
-
}
|
|
2202
|
-
const getAccessToken = () =>
|
|
2181
|
+
};
|
|
2182
|
+
const getAccessToken = async () => {
|
|
2203
2183
|
return localStorage.getItem("accessToken");
|
|
2204
|
-
}
|
|
2205
|
-
const getRefreshToken = () =>
|
|
2184
|
+
};
|
|
2185
|
+
const getRefreshToken = async () => {
|
|
2206
2186
|
return localStorage.getItem("refreshToken");
|
|
2207
|
-
}
|
|
2208
|
-
const clearToken = () =>
|
|
2187
|
+
};
|
|
2188
|
+
const clearToken = async () => {
|
|
2209
2189
|
localStorage.removeItem("accessToken");
|
|
2210
2190
|
localStorage.removeItem("refreshToken");
|
|
2211
|
-
}
|
|
2191
|
+
};
|
|
2212
2192
|
return {
|
|
2213
2193
|
setToken,
|
|
2214
2194
|
setRefreshToken,
|
|
@@ -2220,9 +2200,9 @@ var localStorageUtils = () => {
|
|
|
2220
2200
|
|
|
2221
2201
|
// src/utils/storage/session-storage.ts
|
|
2222
2202
|
var sessionStorageUtils = () => {
|
|
2223
|
-
const getBrowserSession = () =>
|
|
2203
|
+
const getBrowserSession = async () => {
|
|
2224
2204
|
return sessionStorage.getItem("browserSession");
|
|
2225
|
-
}
|
|
2205
|
+
};
|
|
2226
2206
|
return {
|
|
2227
2207
|
getBrowserSession
|
|
2228
2208
|
};
|
|
@@ -2231,14 +2211,13 @@ var sessionStorageUtils = () => {
|
|
|
2231
2211
|
// src/configs/axios-client.ts
|
|
2232
2212
|
var axiosClient = {
|
|
2233
2213
|
init(config) {
|
|
2234
|
-
|
|
2235
|
-
const
|
|
2236
|
-
const sessionStorage2 = (_b = config.sessionStorageUtils) != null ? _b : sessionStorageUtils();
|
|
2214
|
+
const localStorage2 = config.localStorageUtils ?? localStorageUtils();
|
|
2215
|
+
const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
|
|
2237
2216
|
const db = config.db;
|
|
2238
2217
|
let isRefreshing = false;
|
|
2239
2218
|
let failedQueue = [];
|
|
2240
2219
|
const processQueue = (error, token = null) => {
|
|
2241
|
-
failedQueue
|
|
2220
|
+
failedQueue?.forEach((prom) => {
|
|
2242
2221
|
if (error) {
|
|
2243
2222
|
prom.reject(error);
|
|
2244
2223
|
} else {
|
|
@@ -2253,38 +2232,33 @@ var axiosClient = {
|
|
|
2253
2232
|
timeout: 5e4,
|
|
2254
2233
|
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
2255
2234
|
});
|
|
2256
|
-
instance.interceptors.request.use(
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
if (token) {
|
|
2261
|
-
config2.headers["Authorization"] = "Bearer " + token;
|
|
2262
|
-
}
|
|
2263
|
-
return config2;
|
|
2264
|
-
}),
|
|
2265
|
-
(error) => {
|
|
2266
|
-
Promise.reject(error);
|
|
2235
|
+
instance.interceptors.request.use(async (config2) => {
|
|
2236
|
+
const { useRefreshToken, useActionToken, actionToken } = config2;
|
|
2237
|
+
if (useActionToken && actionToken) {
|
|
2238
|
+
config2.headers["Action-Token"] = actionToken;
|
|
2267
2239
|
}
|
|
2268
|
-
|
|
2240
|
+
const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
|
|
2241
|
+
const token = await getToken?.();
|
|
2242
|
+
if (token) config2.headers["Authorization"] = `Bearer ${token}`;
|
|
2243
|
+
return config2;
|
|
2244
|
+
}, Promise.reject);
|
|
2269
2245
|
instance.interceptors.response.use(
|
|
2270
2246
|
(response) => {
|
|
2271
2247
|
return handleResponse(response);
|
|
2272
2248
|
},
|
|
2273
|
-
(error) =>
|
|
2274
|
-
|
|
2275
|
-
const handleError3 = (error2) => __async(null, null, function* () {
|
|
2276
|
-
var _a3;
|
|
2249
|
+
async (error) => {
|
|
2250
|
+
const handleError3 = async (error2) => {
|
|
2277
2251
|
if (!error2.response) {
|
|
2278
2252
|
return error2;
|
|
2279
2253
|
}
|
|
2280
2254
|
const { data } = error2.response;
|
|
2281
|
-
if (data && data.code === 400 && ["invalid_grant"].includes(
|
|
2282
|
-
|
|
2255
|
+
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
2256
|
+
await clearAuthToken();
|
|
2283
2257
|
}
|
|
2284
2258
|
return data;
|
|
2285
|
-
}
|
|
2259
|
+
};
|
|
2286
2260
|
const originalRequest = error.config;
|
|
2287
|
-
if ((
|
|
2261
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
|
|
2288
2262
|
error.response.data.code
|
|
2289
2263
|
)) {
|
|
2290
2264
|
if (isRefreshing) {
|
|
@@ -2297,19 +2271,18 @@ var axiosClient = {
|
|
|
2297
2271
|
token
|
|
2298
2272
|
);
|
|
2299
2273
|
return instance.request(originalRequest);
|
|
2300
|
-
}).catch((err) =>
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
yield clearAuthToken();
|
|
2274
|
+
}).catch(async (err) => {
|
|
2275
|
+
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
2276
|
+
await clearAuthToken();
|
|
2304
2277
|
}
|
|
2305
|
-
})
|
|
2278
|
+
});
|
|
2306
2279
|
}
|
|
2307
|
-
const browserSession =
|
|
2308
|
-
const refreshToken =
|
|
2309
|
-
const accessTokenExp =
|
|
2280
|
+
const browserSession = await sessionStorage2.getBrowserSession();
|
|
2281
|
+
const refreshToken = await localStorage2.getRefreshToken();
|
|
2282
|
+
const accessTokenExp = await localStorage2.getAccessToken();
|
|
2310
2283
|
isRefreshing = true;
|
|
2311
2284
|
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
2312
|
-
|
|
2285
|
+
await clearAuthToken();
|
|
2313
2286
|
} else {
|
|
2314
2287
|
const payload = Object.fromEntries(
|
|
2315
2288
|
Object.entries({
|
|
@@ -2320,9 +2293,8 @@ var axiosClient = {
|
|
|
2320
2293
|
}).filter(([_, value]) => !!value)
|
|
2321
2294
|
);
|
|
2322
2295
|
return new Promise(function(resolve) {
|
|
2323
|
-
var _a3;
|
|
2324
2296
|
import_axios.default.post(
|
|
2325
|
-
`${config.baseUrl}${
|
|
2297
|
+
`${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2326
2298
|
payload,
|
|
2327
2299
|
{
|
|
2328
2300
|
headers: {
|
|
@@ -2330,10 +2302,10 @@ var axiosClient = {
|
|
|
2330
2302
|
Authorization: `Bearer ${accessTokenExp}`
|
|
2331
2303
|
}
|
|
2332
2304
|
}
|
|
2333
|
-
).then((res) =>
|
|
2305
|
+
).then(async (res) => {
|
|
2334
2306
|
const data = res.data;
|
|
2335
|
-
|
|
2336
|
-
|
|
2307
|
+
await localStorage2.setToken(data.access_token);
|
|
2308
|
+
await localStorage2.setRefreshToken(data.refresh_token);
|
|
2337
2309
|
import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2338
2310
|
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2339
2311
|
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
@@ -2342,26 +2314,25 @@ var axiosClient = {
|
|
|
2342
2314
|
);
|
|
2343
2315
|
processQueue(null, data.access_token);
|
|
2344
2316
|
resolve(instance.request(originalRequest));
|
|
2345
|
-
})
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
yield clearAuthToken();
|
|
2317
|
+
}).catch(async (err) => {
|
|
2318
|
+
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") {
|
|
2319
|
+
await clearAuthToken();
|
|
2349
2320
|
}
|
|
2350
2321
|
if (err && err.response) {
|
|
2351
|
-
const { error_code } =
|
|
2322
|
+
const { error_code } = err.response?.data || {};
|
|
2352
2323
|
if (error_code === "AUTHEN_FAIL") {
|
|
2353
|
-
|
|
2324
|
+
await clearAuthToken();
|
|
2354
2325
|
}
|
|
2355
2326
|
}
|
|
2356
2327
|
processQueue(err, null);
|
|
2357
|
-
})
|
|
2328
|
+
}).finally(() => {
|
|
2358
2329
|
isRefreshing = false;
|
|
2359
2330
|
});
|
|
2360
2331
|
});
|
|
2361
2332
|
}
|
|
2362
2333
|
}
|
|
2363
|
-
return Promise.reject(
|
|
2364
|
-
}
|
|
2334
|
+
return Promise.reject(await handleError3(error));
|
|
2335
|
+
}
|
|
2365
2336
|
);
|
|
2366
2337
|
const handleResponse = (res) => {
|
|
2367
2338
|
if (res && res.data) {
|
|
@@ -2370,7 +2341,6 @@ var axiosClient = {
|
|
|
2370
2341
|
return res;
|
|
2371
2342
|
};
|
|
2372
2343
|
const handleError2 = (error) => {
|
|
2373
|
-
var _a2, _b2, _c;
|
|
2374
2344
|
if (error.isAxiosError && error.code === "ECONNABORTED") {
|
|
2375
2345
|
console.error("Request Timeout Error:", error);
|
|
2376
2346
|
return "Request Timeout Error";
|
|
@@ -2378,17 +2348,17 @@ var axiosClient = {
|
|
|
2378
2348
|
console.error("Network Error:", error);
|
|
2379
2349
|
return "Network Error";
|
|
2380
2350
|
} else {
|
|
2381
|
-
console.error("Other Error:", error
|
|
2382
|
-
const errorMessage =
|
|
2383
|
-
return { message: errorMessage, status:
|
|
2351
|
+
console.error("Other Error:", error?.response);
|
|
2352
|
+
const errorMessage = error?.response?.data?.message || "An error occurred";
|
|
2353
|
+
return { message: errorMessage, status: error?.response?.status };
|
|
2384
2354
|
}
|
|
2385
2355
|
};
|
|
2386
|
-
const clearAuthToken = () =>
|
|
2387
|
-
|
|
2356
|
+
const clearAuthToken = async () => {
|
|
2357
|
+
await localStorage2.clearToken();
|
|
2388
2358
|
if (typeof window !== "undefined") {
|
|
2389
2359
|
window.location.href = `/login`;
|
|
2390
2360
|
}
|
|
2391
|
-
}
|
|
2361
|
+
};
|
|
2392
2362
|
function formatUrl(url, db2) {
|
|
2393
2363
|
return url + (db2 ? "?db=" + db2 : "");
|
|
2394
2364
|
}
|
|
@@ -2438,6 +2408,8 @@ var initialState2 = {
|
|
|
2438
2408
|
requests: null,
|
|
2439
2409
|
companies: [],
|
|
2440
2410
|
user: {},
|
|
2411
|
+
db: "",
|
|
2412
|
+
refreshTokenEndpoint: "",
|
|
2441
2413
|
config: null,
|
|
2442
2414
|
envFile: null,
|
|
2443
2415
|
defaultCompany: {
|
|
@@ -2601,7 +2573,7 @@ var headerSlice = (0, import_toolkit5.createSlice)({
|
|
|
2601
2573
|
},
|
|
2602
2574
|
reducers: {
|
|
2603
2575
|
setHeader: (state, action) => {
|
|
2604
|
-
state.value =
|
|
2576
|
+
state.value = { ...state.value, ...action.payload };
|
|
2605
2577
|
},
|
|
2606
2578
|
setAllowedCompanyIds: (state, action) => {
|
|
2607
2579
|
state.value.allowedCompanyIds = action.payload;
|
|
@@ -3027,61 +2999,73 @@ var envStore = (0, import_toolkit11.configureStore)({
|
|
|
3027
2999
|
|
|
3028
3000
|
// src/environment/EnvStore.ts
|
|
3029
3001
|
var EnvStore = class {
|
|
3030
|
-
|
|
3031
|
-
|
|
3002
|
+
baseUrl;
|
|
3003
|
+
requests;
|
|
3004
|
+
context;
|
|
3005
|
+
defaultCompany;
|
|
3006
|
+
config;
|
|
3007
|
+
companies;
|
|
3008
|
+
user;
|
|
3009
|
+
db;
|
|
3010
|
+
localStorageUtils;
|
|
3011
|
+
sessionStorageUtils;
|
|
3012
|
+
refreshTokenEndpoint;
|
|
3013
|
+
constructor(localStorageUtils2, sessionStorageUtils2) {
|
|
3032
3014
|
this.localStorageUtils = localStorageUtils2;
|
|
3033
3015
|
this.sessionStorageUtils = sessionStorageUtils2;
|
|
3034
3016
|
this.setup();
|
|
3035
3017
|
}
|
|
3036
3018
|
setup() {
|
|
3037
|
-
const env2 =
|
|
3038
|
-
this.baseUrl = env2
|
|
3039
|
-
this.requests = env2
|
|
3040
|
-
this.context = env2
|
|
3041
|
-
this.defaultCompany = env2
|
|
3042
|
-
this.config = env2
|
|
3043
|
-
this.companies =
|
|
3044
|
-
this.user = env2
|
|
3045
|
-
this.db = env2
|
|
3046
|
-
this.refreshTokenEndpoint = env2
|
|
3019
|
+
const env2 = envStore.getState().env;
|
|
3020
|
+
this.baseUrl = env2?.baseUrl;
|
|
3021
|
+
this.requests = env2?.requests;
|
|
3022
|
+
this.context = env2?.context;
|
|
3023
|
+
this.defaultCompany = env2?.defaultCompany;
|
|
3024
|
+
this.config = env2?.config;
|
|
3025
|
+
this.companies = env2?.companies || [];
|
|
3026
|
+
this.user = env2?.user;
|
|
3027
|
+
this.db = env2?.db;
|
|
3028
|
+
this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
|
|
3029
|
+
console.log("env from interface-logic", env2);
|
|
3047
3030
|
}
|
|
3048
3031
|
setupEnv(envConfig) {
|
|
3049
|
-
const dispatch =
|
|
3050
|
-
const env2 =
|
|
3032
|
+
const dispatch = envStore.dispatch;
|
|
3033
|
+
const env2 = {
|
|
3034
|
+
...envConfig,
|
|
3051
3035
|
localStorageUtils: this.localStorageUtils,
|
|
3052
3036
|
sessionStorageUtils: this.sessionStorageUtils
|
|
3053
|
-
}
|
|
3037
|
+
};
|
|
3054
3038
|
const requests = axiosClient.init(env2);
|
|
3055
|
-
dispatch(setEnv(
|
|
3039
|
+
dispatch(setEnv({ ...env2, requests }));
|
|
3056
3040
|
this.setup();
|
|
3057
3041
|
}
|
|
3058
3042
|
setUid(uid) {
|
|
3059
|
-
const dispatch =
|
|
3043
|
+
const dispatch = envStore.dispatch;
|
|
3060
3044
|
dispatch(setUid(uid));
|
|
3061
3045
|
this.setup();
|
|
3062
3046
|
}
|
|
3063
3047
|
setLang(lang) {
|
|
3064
|
-
const dispatch =
|
|
3048
|
+
const dispatch = envStore.dispatch;
|
|
3065
3049
|
dispatch(setLang(lang));
|
|
3066
3050
|
this.setup();
|
|
3067
3051
|
}
|
|
3068
3052
|
setAllowCompanies(allowCompanies) {
|
|
3069
|
-
const dispatch =
|
|
3053
|
+
const dispatch = envStore.dispatch;
|
|
3070
3054
|
dispatch(setAllowCompanies(allowCompanies));
|
|
3071
3055
|
this.setup();
|
|
3072
3056
|
}
|
|
3073
3057
|
setCompanies(companies) {
|
|
3074
|
-
const dispatch =
|
|
3058
|
+
const dispatch = envStore.dispatch;
|
|
3075
3059
|
dispatch(setCompanies(companies));
|
|
3076
3060
|
this.setup();
|
|
3077
3061
|
}
|
|
3078
3062
|
setDefaultCompany(company) {
|
|
3079
|
-
const dispatch =
|
|
3063
|
+
const dispatch = envStore.dispatch;
|
|
3080
3064
|
dispatch(setDefaultCompany(company));
|
|
3081
3065
|
this.setup();
|
|
3082
3066
|
}
|
|
3083
3067
|
setUserInfo(userInfo) {
|
|
3084
|
-
const dispatch =
|
|
3068
|
+
const dispatch = envStore.dispatch;
|
|
3085
3069
|
dispatch(setUser(userInfo));
|
|
3086
3070
|
this.setup();
|
|
3087
3071
|
}
|
|
@@ -3091,12 +3075,11 @@ function initEnv({
|
|
|
3091
3075
|
localStorageUtils: localStorageUtils2,
|
|
3092
3076
|
sessionStorageUtils: sessionStorageUtils2
|
|
3093
3077
|
}) {
|
|
3094
|
-
env = new EnvStore(
|
|
3078
|
+
env = new EnvStore(localStorageUtils2, sessionStorageUtils2);
|
|
3095
3079
|
return env;
|
|
3096
3080
|
}
|
|
3097
3081
|
function getEnv() {
|
|
3098
|
-
if (!env)
|
|
3099
|
-
env = new EnvStore(envStore, localStorageUtils(), sessionStorageUtils());
|
|
3082
|
+
if (!env) env = new EnvStore(localStorageUtils(), sessionStorageUtils());
|
|
3100
3083
|
return env;
|
|
3101
3084
|
}
|
|
3102
3085
|
// Annotate the CommonJS export names for ESM import in node:
|