@fctc/interface-logic 1.6.9 → 1.7.2
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} +161 -111
- package/dist/{configs.d.mts → configs.d.cts} +2 -1
- package/dist/configs.d.ts +1 -0
- package/dist/configs.js +124 -146
- package/dist/{constants.mjs → constants.cjs} +40 -2
- package/dist/constants.js +2 -41
- package/dist/{environment.mjs → environment.cjs} +2059 -1995
- package/dist/environment.d.cts +56 -0
- package/dist/environment.d.ts +24 -6
- package/dist/environment.js +2126 -2137
- package/dist/{hooks.mjs → hooks.cjs} +4023 -3773
- package/dist/{hooks.d.mts → hooks.d.cts} +2 -7
- package/dist/hooks.d.ts +1 -6
- package/dist/hooks.js +3918 -3873
- package/dist/{provider.mjs → provider.cjs} +689 -585
- package/dist/{provider.d.mts → provider.d.cts} +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +649 -619
- package/dist/{services.mjs → services.cjs} +3835 -3627
- package/dist/{services.d.mts → services.d.cts} +1 -2
- package/dist/services.d.ts +0 -1
- package/dist/services.js +3790 -3668
- package/dist/{store.mjs → store.cjs} +149 -33
- package/dist/{store.d.mts → store.d.cts} +127 -155
- package/dist/store.d.ts +127 -155
- package/dist/store.js +44 -134
- 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 +82 -81
- package/dist/environment.d.mts +0 -38
- package/dist/types.mjs +0 -0
- /package/dist/{constants.d.mts → constants.d.cts} +0 -0
- /package/dist/{view-type-BGJfDe73.d.mts → view-type-BGJfDe73.d.cts} +0 -0
package/dist/environment.js
CHANGED
|
@@ -1,761 +1,150 @@
|
|
|
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
41
|
|
|
30
|
-
// src/
|
|
31
|
-
|
|
32
|
-
__export(environment_exports, {
|
|
33
|
-
EnvStore: () => EnvStore,
|
|
34
|
-
env: () => env,
|
|
35
|
-
getEnv: () => getEnv,
|
|
36
|
-
initEnv: () => initEnv
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(environment_exports);
|
|
42
|
+
// src/configs/axios-client.ts
|
|
43
|
+
import axios from "axios";
|
|
39
44
|
|
|
40
|
-
// src/
|
|
41
|
-
|
|
45
|
+
// src/utils/format.ts
|
|
46
|
+
import moment from "moment";
|
|
42
47
|
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
|
46
|
-
}
|
|
47
|
-
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
|
48
|
-
var ActionTypes = {
|
|
49
|
-
INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
|
|
50
|
-
REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
|
|
51
|
-
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
|
48
|
+
// src/utils/domain/py_tokenizer.ts
|
|
49
|
+
var TokenizerError = class extends Error {
|
|
52
50
|
};
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case "number":
|
|
73
|
-
case "symbol":
|
|
74
|
-
case "function": {
|
|
75
|
-
return type;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (Array.isArray(val))
|
|
79
|
-
return "array";
|
|
80
|
-
if (isDate(val))
|
|
81
|
-
return "date";
|
|
82
|
-
if (isError(val))
|
|
83
|
-
return "error";
|
|
84
|
-
const constructorName = ctorName(val);
|
|
85
|
-
switch (constructorName) {
|
|
86
|
-
case "Symbol":
|
|
87
|
-
case "Promise":
|
|
88
|
-
case "WeakMap":
|
|
89
|
-
case "WeakSet":
|
|
90
|
-
case "Map":
|
|
91
|
-
case "Set":
|
|
92
|
-
return constructorName;
|
|
93
|
-
}
|
|
94
|
-
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
95
|
-
}
|
|
96
|
-
function ctorName(val) {
|
|
97
|
-
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
98
|
-
}
|
|
99
|
-
function isError(val) {
|
|
100
|
-
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
101
|
-
}
|
|
102
|
-
function isDate(val) {
|
|
103
|
-
if (val instanceof Date)
|
|
104
|
-
return true;
|
|
105
|
-
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
106
|
-
}
|
|
107
|
-
function kindOf(val) {
|
|
108
|
-
let typeOfVal = typeof val;
|
|
109
|
-
if (process.env.NODE_ENV !== "production") {
|
|
110
|
-
typeOfVal = miniKindOf(val);
|
|
111
|
-
}
|
|
112
|
-
return typeOfVal;
|
|
113
|
-
}
|
|
114
|
-
function warning(message) {
|
|
115
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
116
|
-
console.error(message);
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
throw new Error(message);
|
|
120
|
-
} catch (e) {
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
124
|
-
const reducerKeys = Object.keys(reducers);
|
|
125
|
-
const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
|
|
126
|
-
if (reducerKeys.length === 0) {
|
|
127
|
-
return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
|
|
128
|
-
}
|
|
129
|
-
if (!isPlainObject(inputState)) {
|
|
130
|
-
return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
|
|
131
|
-
}
|
|
132
|
-
const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
|
|
133
|
-
unexpectedKeys.forEach((key) => {
|
|
134
|
-
unexpectedKeyCache[key] = true;
|
|
135
|
-
});
|
|
136
|
-
if (action && action.type === actionTypes_default.REPLACE)
|
|
137
|
-
return;
|
|
138
|
-
if (unexpectedKeys.length > 0) {
|
|
139
|
-
return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function assertReducerShape(reducers) {
|
|
143
|
-
Object.keys(reducers).forEach((key) => {
|
|
144
|
-
const reducer = reducers[key];
|
|
145
|
-
const initialState10 = reducer(void 0, {
|
|
146
|
-
type: actionTypes_default.INIT
|
|
147
|
-
});
|
|
148
|
-
if (typeof initialState10 === "undefined") {
|
|
149
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
|
|
150
|
-
}
|
|
151
|
-
if (typeof reducer(void 0, {
|
|
152
|
-
type: actionTypes_default.PROBE_UNKNOWN_ACTION()
|
|
153
|
-
}) === "undefined") {
|
|
154
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
|
|
51
|
+
var directMap = {
|
|
52
|
+
"\\": "\\",
|
|
53
|
+
'"': '"',
|
|
54
|
+
"'": "'",
|
|
55
|
+
a: "\x07",
|
|
56
|
+
b: "\b",
|
|
57
|
+
f: "\f",
|
|
58
|
+
n: "\n",
|
|
59
|
+
r: "\r",
|
|
60
|
+
t: " ",
|
|
61
|
+
v: "\v"
|
|
62
|
+
};
|
|
63
|
+
function decodeStringLiteral(str, unicode) {
|
|
64
|
+
const out = [];
|
|
65
|
+
let code;
|
|
66
|
+
for (let i = 0; i < str.length; ++i) {
|
|
67
|
+
if (str[i] !== "\\") {
|
|
68
|
+
out.push(str[i]);
|
|
69
|
+
continue;
|
|
155
70
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
for (let i = 0; i < reducerKeys.length; i++) {
|
|
162
|
-
const key = reducerKeys[i];
|
|
163
|
-
if (process.env.NODE_ENV !== "production") {
|
|
164
|
-
if (typeof reducers[key] === "undefined") {
|
|
165
|
-
warning(`No reducer provided for key "${key}"`);
|
|
166
|
-
}
|
|
71
|
+
const escape = str[i + 1];
|
|
72
|
+
if (escape in directMap) {
|
|
73
|
+
out.push(directMap[escape]);
|
|
74
|
+
++i;
|
|
75
|
+
continue;
|
|
167
76
|
}
|
|
168
|
-
|
|
169
|
-
|
|
77
|
+
switch (escape) {
|
|
78
|
+
case "\n":
|
|
79
|
+
++i;
|
|
80
|
+
continue;
|
|
81
|
+
case "N":
|
|
82
|
+
if (!unicode) {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
throw new TokenizerError("SyntaxError: \\N{} escape not implemented");
|
|
86
|
+
case "u":
|
|
87
|
+
if (!unicode) {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
const uni = str.slice(i + 2, i + 6);
|
|
91
|
+
if (!/[0-9a-f]{4}/i.test(uni)) {
|
|
92
|
+
throw new TokenizerError(
|
|
93
|
+
[
|
|
94
|
+
"SyntaxError: (unicode error) 'unicodeescape' codec",
|
|
95
|
+
" can't decode bytes in position ",
|
|
96
|
+
i,
|
|
97
|
+
"-",
|
|
98
|
+
i + 4,
|
|
99
|
+
": truncated \\uXXXX escape"
|
|
100
|
+
].join("")
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
code = parseInt(uni, 16);
|
|
104
|
+
out.push(String.fromCharCode(code));
|
|
105
|
+
i += 5;
|
|
106
|
+
continue;
|
|
107
|
+
case "U":
|
|
108
|
+
if (!unicode) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
throw new TokenizerError("SyntaxError: \\U escape not implemented");
|
|
112
|
+
case "x":
|
|
113
|
+
const hex = str.slice(i + 2, i + 4);
|
|
114
|
+
if (!/[0-9a-f]{2}/i.test(hex)) {
|
|
115
|
+
if (!unicode) {
|
|
116
|
+
throw new TokenizerError("ValueError: invalid \\x escape");
|
|
117
|
+
}
|
|
118
|
+
throw new TokenizerError(
|
|
119
|
+
[
|
|
120
|
+
"SyntaxError: (unicode error) 'unicodeescape'",
|
|
121
|
+
" codec can't decode bytes in position ",
|
|
122
|
+
i,
|
|
123
|
+
"-",
|
|
124
|
+
i + 2,
|
|
125
|
+
": truncated \\xXX escape"
|
|
126
|
+
].join("")
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
code = parseInt(hex, 16);
|
|
130
|
+
out.push(String.fromCharCode(code));
|
|
131
|
+
i += 3;
|
|
132
|
+
continue;
|
|
133
|
+
default:
|
|
134
|
+
if (!/[0-8]/.test(escape)) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
const r = /[0-8]{1,3}/g;
|
|
138
|
+
r.lastIndex = i + 1;
|
|
139
|
+
const m = r.exec(str);
|
|
140
|
+
if (!m) break;
|
|
141
|
+
const oct = m[0];
|
|
142
|
+
code = parseInt(oct, 8);
|
|
143
|
+
out.push(String.fromCharCode(code));
|
|
144
|
+
i += oct.length;
|
|
145
|
+
continue;
|
|
170
146
|
}
|
|
171
|
-
|
|
172
|
-
const finalReducerKeys = Object.keys(finalReducers);
|
|
173
|
-
let unexpectedKeyCache;
|
|
174
|
-
if (process.env.NODE_ENV !== "production") {
|
|
175
|
-
unexpectedKeyCache = {};
|
|
176
|
-
}
|
|
177
|
-
let shapeAssertionError;
|
|
178
|
-
try {
|
|
179
|
-
assertReducerShape(finalReducers);
|
|
180
|
-
} catch (e) {
|
|
181
|
-
shapeAssertionError = e;
|
|
182
|
-
}
|
|
183
|
-
return function combination(state = {}, action) {
|
|
184
|
-
if (shapeAssertionError) {
|
|
185
|
-
throw shapeAssertionError;
|
|
186
|
-
}
|
|
187
|
-
if (process.env.NODE_ENV !== "production") {
|
|
188
|
-
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
|
189
|
-
if (warningMessage) {
|
|
190
|
-
warning(warningMessage);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
let hasChanged = false;
|
|
194
|
-
const nextState = {};
|
|
195
|
-
for (let i = 0; i < finalReducerKeys.length; i++) {
|
|
196
|
-
const key = finalReducerKeys[i];
|
|
197
|
-
const reducer = finalReducers[key];
|
|
198
|
-
const previousStateForKey = state[key];
|
|
199
|
-
const nextStateForKey = reducer(previousStateForKey, action);
|
|
200
|
-
if (typeof nextStateForKey === "undefined") {
|
|
201
|
-
const actionType = action && action.type;
|
|
202
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
|
|
203
|
-
}
|
|
204
|
-
nextState[key] = nextStateForKey;
|
|
205
|
-
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
206
|
-
}
|
|
207
|
-
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
208
|
-
return hasChanged ? nextState : state;
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// src/store/reducers/breadcrums-slice/index.ts
|
|
213
|
-
var import_toolkit = require("@reduxjs/toolkit");
|
|
214
|
-
var initialState = {
|
|
215
|
-
breadCrumbs: []
|
|
216
|
-
};
|
|
217
|
-
var breadcrumbsSlice = (0, import_toolkit.createSlice)({
|
|
218
|
-
name: "breadcrumbs",
|
|
219
|
-
initialState,
|
|
220
|
-
reducers: {
|
|
221
|
-
setBreadCrumbs: (state, action) => {
|
|
222
|
-
state.breadCrumbs = [...state.breadCrumbs, action.payload];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
var { setBreadCrumbs } = breadcrumbsSlice.actions;
|
|
227
|
-
var breadcrums_slice_default = breadcrumbsSlice.reducer;
|
|
228
|
-
|
|
229
|
-
// src/store/reducers/env-slice/index.ts
|
|
230
|
-
var import_toolkit2 = require("@reduxjs/toolkit");
|
|
231
|
-
var initialState2 = {
|
|
232
|
-
baseUrl: "",
|
|
233
|
-
companies: [],
|
|
234
|
-
user: {},
|
|
235
|
-
db: "",
|
|
236
|
-
refreshTokenEndpoint: "",
|
|
237
|
-
config: null,
|
|
238
|
-
envFile: null,
|
|
239
|
-
requests: null,
|
|
240
|
-
defaultCompany: {
|
|
241
|
-
id: null,
|
|
242
|
-
logo: "",
|
|
243
|
-
secondary_color: "",
|
|
244
|
-
primary_color: ""
|
|
245
|
-
},
|
|
246
|
-
context: {
|
|
247
|
-
uid: null,
|
|
248
|
-
allowed_company_ids: [],
|
|
249
|
-
lang: "vi_VN",
|
|
250
|
-
tz: "Asia/Saigon"
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
var envSlice = (0, import_toolkit2.createSlice)({
|
|
254
|
-
name: "env",
|
|
255
|
-
initialState: initialState2,
|
|
256
|
-
reducers: {
|
|
257
|
-
setEnv: (state, action) => {
|
|
258
|
-
Object.assign(state, action.payload);
|
|
259
|
-
},
|
|
260
|
-
setUid: (state, action) => {
|
|
261
|
-
state.context.uid = action.payload;
|
|
262
|
-
},
|
|
263
|
-
setAllowCompanies: (state, action) => {
|
|
264
|
-
state.context.allowed_company_ids = action.payload;
|
|
265
|
-
},
|
|
266
|
-
setCompanies: (state, action) => {
|
|
267
|
-
state.companies = action.payload;
|
|
268
|
-
},
|
|
269
|
-
setDefaultCompany: (state, action) => {
|
|
270
|
-
state.defaultCompany = action.payload;
|
|
271
|
-
},
|
|
272
|
-
setLang: (state, action) => {
|
|
273
|
-
state.context.lang = action.payload;
|
|
274
|
-
},
|
|
275
|
-
setUser: (state, action) => {
|
|
276
|
-
state.user = action.payload;
|
|
277
|
-
},
|
|
278
|
-
setConfig: (state, action) => {
|
|
279
|
-
state.config = action.payload;
|
|
280
|
-
},
|
|
281
|
-
setEnvFile: (state, action) => {
|
|
282
|
-
state.envFile = action.payload;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
var {
|
|
287
|
-
setEnv,
|
|
288
|
-
setUid,
|
|
289
|
-
setLang,
|
|
290
|
-
setAllowCompanies,
|
|
291
|
-
setCompanies,
|
|
292
|
-
setDefaultCompany,
|
|
293
|
-
setUser,
|
|
294
|
-
setConfig,
|
|
295
|
-
setEnvFile
|
|
296
|
-
} = envSlice.actions;
|
|
297
|
-
var env_slice_default = envSlice.reducer;
|
|
298
|
-
|
|
299
|
-
// src/store/reducers/excel-slice/index.ts
|
|
300
|
-
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
301
|
-
var initialState3 = {
|
|
302
|
-
dataParse: null,
|
|
303
|
-
idFile: null,
|
|
304
|
-
isFileLoaded: false,
|
|
305
|
-
loadingImport: false,
|
|
306
|
-
selectedFile: null,
|
|
307
|
-
errorData: null
|
|
308
|
-
};
|
|
309
|
-
var excelSlice = (0, import_toolkit3.createSlice)({
|
|
310
|
-
name: "excel",
|
|
311
|
-
initialState: initialState3,
|
|
312
|
-
reducers: {
|
|
313
|
-
setDataParse: (state, action) => {
|
|
314
|
-
state.dataParse = action.payload;
|
|
315
|
-
},
|
|
316
|
-
setIdFile: (state, action) => {
|
|
317
|
-
state.idFile = action.payload;
|
|
318
|
-
},
|
|
319
|
-
setIsFileLoaded: (state, action) => {
|
|
320
|
-
state.isFileLoaded = action.payload;
|
|
321
|
-
},
|
|
322
|
-
setLoadingImport: (state, action) => {
|
|
323
|
-
state.loadingImport = action.payload;
|
|
324
|
-
},
|
|
325
|
-
setSelectedFile: (state, action) => {
|
|
326
|
-
state.selectedFile = action.payload;
|
|
327
|
-
},
|
|
328
|
-
setErrorData: (state, action) => {
|
|
329
|
-
state.errorData = action.payload;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
var {
|
|
334
|
-
setDataParse,
|
|
335
|
-
setIdFile,
|
|
336
|
-
setIsFileLoaded,
|
|
337
|
-
setLoadingImport,
|
|
338
|
-
setSelectedFile,
|
|
339
|
-
setErrorData
|
|
340
|
-
} = excelSlice.actions;
|
|
341
|
-
var excel_slice_default = excelSlice.reducer;
|
|
342
|
-
|
|
343
|
-
// src/store/reducers/form-slice/index.ts
|
|
344
|
-
var import_toolkit4 = require("@reduxjs/toolkit");
|
|
345
|
-
var initialState4 = {
|
|
346
|
-
viewDataStore: {},
|
|
347
|
-
isShowingModalDetail: false,
|
|
348
|
-
isShowModalTranslate: false,
|
|
349
|
-
formSubmitComponent: {},
|
|
350
|
-
fieldTranslation: null,
|
|
351
|
-
listSubject: {},
|
|
352
|
-
dataUser: {}
|
|
353
|
-
};
|
|
354
|
-
var formSlice = (0, import_toolkit4.createSlice)({
|
|
355
|
-
name: "form",
|
|
356
|
-
initialState: initialState4,
|
|
357
|
-
reducers: {
|
|
358
|
-
setViewDataStore: (state, action) => {
|
|
359
|
-
state.viewDataStore = action.payload;
|
|
360
|
-
},
|
|
361
|
-
setIsShowingModalDetail: (state, action) => {
|
|
362
|
-
state.isShowingModalDetail = action.payload;
|
|
363
|
-
},
|
|
364
|
-
setIsShowModalTranslate: (state, action) => {
|
|
365
|
-
state.isShowModalTranslate = action.payload;
|
|
366
|
-
},
|
|
367
|
-
setFormSubmitComponent: (state, action) => {
|
|
368
|
-
state.formSubmitComponent[action.payload.key] = action.payload.component;
|
|
369
|
-
},
|
|
370
|
-
setFieldTranslate: (state, action) => {
|
|
371
|
-
state.fieldTranslation = action.payload;
|
|
372
|
-
},
|
|
373
|
-
setListSubject: (state, action) => {
|
|
374
|
-
state.listSubject = action.payload;
|
|
375
|
-
},
|
|
376
|
-
setDataUser: (state, action) => {
|
|
377
|
-
state.dataUser = action.payload;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
var {
|
|
382
|
-
setViewDataStore,
|
|
383
|
-
setIsShowingModalDetail,
|
|
384
|
-
setIsShowModalTranslate,
|
|
385
|
-
setFormSubmitComponent,
|
|
386
|
-
setFieldTranslate,
|
|
387
|
-
setListSubject,
|
|
388
|
-
setDataUser
|
|
389
|
-
} = formSlice.actions;
|
|
390
|
-
var form_slice_default = formSlice.reducer;
|
|
391
|
-
|
|
392
|
-
// src/store/reducers/header-slice/index.ts
|
|
393
|
-
var import_toolkit5 = require("@reduxjs/toolkit");
|
|
394
|
-
var headerSlice = (0, import_toolkit5.createSlice)({
|
|
395
|
-
name: "header",
|
|
396
|
-
initialState: {
|
|
397
|
-
value: { allowedCompanyIds: [] }
|
|
398
|
-
},
|
|
399
|
-
reducers: {
|
|
400
|
-
setHeader: (state, action) => {
|
|
401
|
-
state.value = { ...state.value, ...action.payload };
|
|
402
|
-
},
|
|
403
|
-
setAllowedCompanyIds: (state, action) => {
|
|
404
|
-
state.value.allowedCompanyIds = action.payload;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
|
|
409
|
-
var header_slice_default = headerSlice.reducer;
|
|
410
|
-
|
|
411
|
-
// src/store/reducers/list-slice/index.ts
|
|
412
|
-
var import_toolkit6 = require("@reduxjs/toolkit");
|
|
413
|
-
var initialState5 = {
|
|
414
|
-
pageLimit: 10,
|
|
415
|
-
fields: {},
|
|
416
|
-
order: "",
|
|
417
|
-
selectedRowKeys: [],
|
|
418
|
-
selectedRadioKey: 0,
|
|
419
|
-
indexRowTableModal: -2,
|
|
420
|
-
isUpdateTableModal: false,
|
|
421
|
-
footerGroupTable: {},
|
|
422
|
-
transferDetail: null,
|
|
423
|
-
page: 0,
|
|
424
|
-
domainTable: []
|
|
425
|
-
};
|
|
426
|
-
var listSlice = (0, import_toolkit6.createSlice)({
|
|
427
|
-
name: "list",
|
|
428
|
-
initialState: initialState5,
|
|
429
|
-
reducers: {
|
|
430
|
-
setPageLimit: (state, action) => {
|
|
431
|
-
state.pageLimit = action.payload;
|
|
432
|
-
},
|
|
433
|
-
setFields: (state, action) => {
|
|
434
|
-
state.fields = action.payload;
|
|
435
|
-
},
|
|
436
|
-
setOrder: (state, action) => {
|
|
437
|
-
state.order = action.payload;
|
|
438
|
-
},
|
|
439
|
-
setSelectedRowKeys: (state, action) => {
|
|
440
|
-
state.selectedRowKeys = action.payload;
|
|
441
|
-
},
|
|
442
|
-
setSelectedRadioKey: (state, action) => {
|
|
443
|
-
state.selectedRadioKey = action.payload;
|
|
444
|
-
},
|
|
445
|
-
setIndexRowTableModal: (state, action) => {
|
|
446
|
-
state.indexRowTableModal = action.payload;
|
|
447
|
-
},
|
|
448
|
-
setTransferDetail: (state, action) => {
|
|
449
|
-
state.transferDetail = action.payload;
|
|
450
|
-
},
|
|
451
|
-
setIsUpdateTableModal: (state, action) => {
|
|
452
|
-
state.isUpdateTableModal = action.payload;
|
|
453
|
-
},
|
|
454
|
-
setPage: (state, action) => {
|
|
455
|
-
state.page = action.payload;
|
|
456
|
-
},
|
|
457
|
-
setDomainTable: (state, action) => {
|
|
458
|
-
state.domainTable = action.payload;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
var {
|
|
463
|
-
setPageLimit,
|
|
464
|
-
setFields,
|
|
465
|
-
setOrder,
|
|
466
|
-
setSelectedRowKeys,
|
|
467
|
-
setIndexRowTableModal,
|
|
468
|
-
setIsUpdateTableModal,
|
|
469
|
-
setPage,
|
|
470
|
-
setSelectedRadioKey,
|
|
471
|
-
setTransferDetail,
|
|
472
|
-
setDomainTable
|
|
473
|
-
} = listSlice.actions;
|
|
474
|
-
var list_slice_default = listSlice.reducer;
|
|
475
|
-
|
|
476
|
-
// src/store/reducers/login-slice/index.ts
|
|
477
|
-
var import_toolkit7 = require("@reduxjs/toolkit");
|
|
478
|
-
var initialState6 = {
|
|
479
|
-
db: "",
|
|
480
|
-
redirectTo: "/",
|
|
481
|
-
forgotPasswordUrl: "/"
|
|
482
|
-
};
|
|
483
|
-
var loginSlice = (0, import_toolkit7.createSlice)({
|
|
484
|
-
name: "login",
|
|
485
|
-
initialState: initialState6,
|
|
486
|
-
reducers: {
|
|
487
|
-
setDb: (state, action) => {
|
|
488
|
-
state.db = action.payload;
|
|
489
|
-
},
|
|
490
|
-
setRedirectTo: (state, action) => {
|
|
491
|
-
state.redirectTo = action.payload;
|
|
492
|
-
},
|
|
493
|
-
setForgotPasswordUrl: (state, action) => {
|
|
494
|
-
state.forgotPasswordUrl = action.payload;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
|
|
499
|
-
var login_slice_default = loginSlice.reducer;
|
|
500
|
-
|
|
501
|
-
// src/store/reducers/navbar-slice/index.ts
|
|
502
|
-
var import_toolkit8 = require("@reduxjs/toolkit");
|
|
503
|
-
var initialState7 = {
|
|
504
|
-
menuFocus: {},
|
|
505
|
-
menuAction: {},
|
|
506
|
-
navbarWidth: 250,
|
|
507
|
-
menuList: []
|
|
508
|
-
};
|
|
509
|
-
var navbarSlice = (0, import_toolkit8.createSlice)({
|
|
510
|
-
name: "navbar",
|
|
511
|
-
initialState: initialState7,
|
|
512
|
-
reducers: {
|
|
513
|
-
setMenuFocus: (state, action) => {
|
|
514
|
-
state.menuFocus = action.payload;
|
|
515
|
-
},
|
|
516
|
-
setMenuFocusAction: (state, action) => {
|
|
517
|
-
state.menuAction = action.payload;
|
|
518
|
-
},
|
|
519
|
-
setNavbarWidth: (state, action) => {
|
|
520
|
-
state.navbarWidth = action.payload;
|
|
521
|
-
},
|
|
522
|
-
setMenuList: (state, action) => {
|
|
523
|
-
state.menuList = action.payload;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
|
|
528
|
-
var navbar_slice_default = navbarSlice.reducer;
|
|
529
|
-
|
|
530
|
-
// src/store/reducers/profile-slice/index.ts
|
|
531
|
-
var import_toolkit9 = require("@reduxjs/toolkit");
|
|
532
|
-
var initialState8 = {
|
|
533
|
-
profile: {}
|
|
534
|
-
};
|
|
535
|
-
var profileSlice = (0, import_toolkit9.createSlice)({
|
|
536
|
-
name: "profile",
|
|
537
|
-
initialState: initialState8,
|
|
538
|
-
reducers: {
|
|
539
|
-
setProfile: (state, action) => {
|
|
540
|
-
state.profile = action.payload;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
var { setProfile } = profileSlice.actions;
|
|
545
|
-
var profile_slice_default = profileSlice.reducer;
|
|
546
|
-
|
|
547
|
-
// src/store/reducers/search-slice/index.ts
|
|
548
|
-
var import_toolkit10 = require("@reduxjs/toolkit");
|
|
549
|
-
var initialState9 = {
|
|
550
|
-
groupByDomain: null,
|
|
551
|
-
searchBy: [],
|
|
552
|
-
searchString: "",
|
|
553
|
-
hoveredIndexSearchList: null,
|
|
554
|
-
selectedTags: [],
|
|
555
|
-
firstDomain: null,
|
|
556
|
-
searchMap: {},
|
|
557
|
-
filterBy: [],
|
|
558
|
-
groupBy: []
|
|
559
|
-
};
|
|
560
|
-
var searchSlice = (0, import_toolkit10.createSlice)({
|
|
561
|
-
name: "search",
|
|
562
|
-
initialState: initialState9,
|
|
563
|
-
reducers: {
|
|
564
|
-
setGroupByDomain: (state, action) => {
|
|
565
|
-
state.groupByDomain = action.payload;
|
|
566
|
-
},
|
|
567
|
-
setSearchBy: (state, action) => {
|
|
568
|
-
state.searchBy = action.payload;
|
|
569
|
-
},
|
|
570
|
-
setSearchString: (state, action) => {
|
|
571
|
-
state.searchString = action.payload;
|
|
572
|
-
},
|
|
573
|
-
setHoveredIndexSearchList: (state, action) => {
|
|
574
|
-
state.hoveredIndexSearchList = action.payload;
|
|
575
|
-
},
|
|
576
|
-
setSelectedTags: (state, action) => {
|
|
577
|
-
state.selectedTags = action.payload;
|
|
578
|
-
},
|
|
579
|
-
setFirstDomain: (state, action) => {
|
|
580
|
-
state.firstDomain = action.payload;
|
|
581
|
-
},
|
|
582
|
-
setFilterBy: (state, action) => {
|
|
583
|
-
state.filterBy = action.payload;
|
|
584
|
-
},
|
|
585
|
-
setGroupBy: (state, action) => {
|
|
586
|
-
state.groupBy = action.payload;
|
|
587
|
-
},
|
|
588
|
-
setSearchMap: (state, action) => {
|
|
589
|
-
state.searchMap = action.payload;
|
|
590
|
-
},
|
|
591
|
-
updateSearchMap: (state, action) => {
|
|
592
|
-
if (!state.searchMap[action.payload.key]) {
|
|
593
|
-
state.searchMap[action.payload.key] = [];
|
|
594
|
-
}
|
|
595
|
-
state.searchMap[action.payload.key].push(action.payload.value);
|
|
596
|
-
},
|
|
597
|
-
removeKeyFromSearchMap: (state, action) => {
|
|
598
|
-
const { key, item } = action.payload;
|
|
599
|
-
const values = state.searchMap[key];
|
|
600
|
-
if (!values) return;
|
|
601
|
-
if (item) {
|
|
602
|
-
const filtered = values.filter((value) => value.name !== item.name);
|
|
603
|
-
if (filtered.length > 0) {
|
|
604
|
-
state.searchMap[key] = filtered;
|
|
605
|
-
} else {
|
|
606
|
-
delete state.searchMap[key];
|
|
607
|
-
}
|
|
608
|
-
} else {
|
|
609
|
-
delete state.searchMap[key];
|
|
610
|
-
}
|
|
611
|
-
},
|
|
612
|
-
clearSearchMap: (state) => {
|
|
613
|
-
state.searchMap = {};
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
var {
|
|
618
|
-
setGroupByDomain,
|
|
619
|
-
setSelectedTags,
|
|
620
|
-
setSearchString,
|
|
621
|
-
setHoveredIndexSearchList,
|
|
622
|
-
setFirstDomain,
|
|
623
|
-
setSearchBy,
|
|
624
|
-
setFilterBy,
|
|
625
|
-
setSearchMap,
|
|
626
|
-
updateSearchMap,
|
|
627
|
-
removeKeyFromSearchMap,
|
|
628
|
-
setGroupBy,
|
|
629
|
-
clearSearchMap
|
|
630
|
-
} = searchSlice.actions;
|
|
631
|
-
var search_slice_default = searchSlice.reducer;
|
|
632
|
-
|
|
633
|
-
// src/store/store.ts
|
|
634
|
-
var rootReducer = combineReducers({
|
|
635
|
-
env: env_slice_default,
|
|
636
|
-
header: header_slice_default,
|
|
637
|
-
navbar: navbar_slice_default,
|
|
638
|
-
list: list_slice_default,
|
|
639
|
-
search: search_slice_default,
|
|
640
|
-
form: form_slice_default,
|
|
641
|
-
breadcrumbs: breadcrums_slice_default,
|
|
642
|
-
login: login_slice_default,
|
|
643
|
-
excel: excel_slice_default,
|
|
644
|
-
profile: profile_slice_default
|
|
645
|
-
});
|
|
646
|
-
var envStore = (0, import_toolkit11.configureStore)({
|
|
647
|
-
reducer: rootReducer,
|
|
648
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
649
|
-
serializableCheck: false
|
|
650
|
-
})
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
// src/configs/axios-client.ts
|
|
654
|
-
var import_axios = __toESM(require("axios"));
|
|
655
|
-
|
|
656
|
-
// src/utils/format.ts
|
|
657
|
-
var import_moment = __toESM(require("moment"));
|
|
658
|
-
|
|
659
|
-
// src/utils/domain/py_tokenizer.ts
|
|
660
|
-
var TokenizerError = class extends Error {
|
|
661
|
-
};
|
|
662
|
-
var directMap = {
|
|
663
|
-
"\\": "\\",
|
|
664
|
-
'"': '"',
|
|
665
|
-
"'": "'",
|
|
666
|
-
a: "\x07",
|
|
667
|
-
b: "\b",
|
|
668
|
-
f: "\f",
|
|
669
|
-
n: "\n",
|
|
670
|
-
r: "\r",
|
|
671
|
-
t: " ",
|
|
672
|
-
v: "\v"
|
|
673
|
-
};
|
|
674
|
-
function decodeStringLiteral(str, unicode) {
|
|
675
|
-
const out = [];
|
|
676
|
-
let code;
|
|
677
|
-
for (let i = 0; i < str.length; ++i) {
|
|
678
|
-
if (str[i] !== "\\") {
|
|
679
|
-
out.push(str[i]);
|
|
680
|
-
continue;
|
|
681
|
-
}
|
|
682
|
-
const escape = str[i + 1];
|
|
683
|
-
if (escape in directMap) {
|
|
684
|
-
out.push(directMap[escape]);
|
|
685
|
-
++i;
|
|
686
|
-
continue;
|
|
687
|
-
}
|
|
688
|
-
switch (escape) {
|
|
689
|
-
case "\n":
|
|
690
|
-
++i;
|
|
691
|
-
continue;
|
|
692
|
-
case "N":
|
|
693
|
-
if (!unicode) {
|
|
694
|
-
break;
|
|
695
|
-
}
|
|
696
|
-
throw new TokenizerError("SyntaxError: \\N{} escape not implemented");
|
|
697
|
-
case "u":
|
|
698
|
-
if (!unicode) {
|
|
699
|
-
break;
|
|
700
|
-
}
|
|
701
|
-
const uni = str.slice(i + 2, i + 6);
|
|
702
|
-
if (!/[0-9a-f]{4}/i.test(uni)) {
|
|
703
|
-
throw new TokenizerError(
|
|
704
|
-
[
|
|
705
|
-
"SyntaxError: (unicode error) 'unicodeescape' codec",
|
|
706
|
-
" can't decode bytes in position ",
|
|
707
|
-
i,
|
|
708
|
-
"-",
|
|
709
|
-
i + 4,
|
|
710
|
-
": truncated \\uXXXX escape"
|
|
711
|
-
].join("")
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
code = parseInt(uni, 16);
|
|
715
|
-
out.push(String.fromCharCode(code));
|
|
716
|
-
i += 5;
|
|
717
|
-
continue;
|
|
718
|
-
case "U":
|
|
719
|
-
if (!unicode) {
|
|
720
|
-
break;
|
|
721
|
-
}
|
|
722
|
-
throw new TokenizerError("SyntaxError: \\U escape not implemented");
|
|
723
|
-
case "x":
|
|
724
|
-
const hex = str.slice(i + 2, i + 4);
|
|
725
|
-
if (!/[0-9a-f]{2}/i.test(hex)) {
|
|
726
|
-
if (!unicode) {
|
|
727
|
-
throw new TokenizerError("ValueError: invalid \\x escape");
|
|
728
|
-
}
|
|
729
|
-
throw new TokenizerError(
|
|
730
|
-
[
|
|
731
|
-
"SyntaxError: (unicode error) 'unicodeescape'",
|
|
732
|
-
" codec can't decode bytes in position ",
|
|
733
|
-
i,
|
|
734
|
-
"-",
|
|
735
|
-
i + 2,
|
|
736
|
-
": truncated \\xXX escape"
|
|
737
|
-
].join("")
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
code = parseInt(hex, 16);
|
|
741
|
-
out.push(String.fromCharCode(code));
|
|
742
|
-
i += 3;
|
|
743
|
-
continue;
|
|
744
|
-
default:
|
|
745
|
-
if (!/[0-8]/.test(escape)) {
|
|
746
|
-
break;
|
|
747
|
-
}
|
|
748
|
-
const r = /[0-8]{1,3}/g;
|
|
749
|
-
r.lastIndex = i + 1;
|
|
750
|
-
const m = r.exec(str);
|
|
751
|
-
if (!m) break;
|
|
752
|
-
const oct = m[0];
|
|
753
|
-
code = parseInt(oct, 8);
|
|
754
|
-
out.push(String.fromCharCode(code));
|
|
755
|
-
i += oct.length;
|
|
756
|
-
continue;
|
|
757
|
-
}
|
|
758
|
-
out.push("\\");
|
|
147
|
+
out.push("\\");
|
|
759
148
|
}
|
|
760
149
|
return out.join("");
|
|
761
150
|
}
|
|
@@ -1506,11 +895,71 @@ var PyDateTime = class _PyDateTime {
|
|
|
1506
895
|
s.microsecond
|
|
1507
896
|
);
|
|
1508
897
|
}
|
|
1509
|
-
isEqual(other) {
|
|
1510
|
-
if (!(other instanceof _PyDateTime)) {
|
|
1511
|
-
return false;
|
|
1512
|
-
}
|
|
1513
|
-
return this.year === other.year && this.month === other.month && this.day === other.day && this.hour === other.hour && this.minute === other.minute && this.second === other.second && this.microsecond === other.microsecond;
|
|
898
|
+
isEqual(other) {
|
|
899
|
+
if (!(other instanceof _PyDateTime)) {
|
|
900
|
+
return false;
|
|
901
|
+
}
|
|
902
|
+
return this.year === other.year && this.month === other.month && this.day === other.day && this.hour === other.hour && this.minute === other.minute && this.second === other.second && this.microsecond === other.microsecond;
|
|
903
|
+
}
|
|
904
|
+
strftime(format) {
|
|
905
|
+
return format.replace(/%([A-Za-z])/g, (m, c) => {
|
|
906
|
+
switch (c) {
|
|
907
|
+
case "Y":
|
|
908
|
+
return fmt4(this.year);
|
|
909
|
+
case "m":
|
|
910
|
+
return fmt2(this.month);
|
|
911
|
+
case "d":
|
|
912
|
+
return fmt2(this.day);
|
|
913
|
+
case "H":
|
|
914
|
+
return fmt2(this.hour);
|
|
915
|
+
case "M":
|
|
916
|
+
return fmt2(this.minute);
|
|
917
|
+
case "S":
|
|
918
|
+
return fmt2(this.second);
|
|
919
|
+
default:
|
|
920
|
+
throw new ValueError(`No known conversion for ${m}`);
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
substract(timedelta) {
|
|
925
|
+
return this.add(timedelta.negate());
|
|
926
|
+
}
|
|
927
|
+
toJSON() {
|
|
928
|
+
return this.strftime("%Y-%m-%d %H:%M:%S");
|
|
929
|
+
}
|
|
930
|
+
to_utc() {
|
|
931
|
+
const d = new Date(
|
|
932
|
+
this.year,
|
|
933
|
+
this.month - 1,
|
|
934
|
+
this.day,
|
|
935
|
+
this.hour,
|
|
936
|
+
this.minute,
|
|
937
|
+
this.second
|
|
938
|
+
);
|
|
939
|
+
const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
|
|
940
|
+
return this.add(timedelta);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
var PyTime = class _PyTime extends PyDate {
|
|
944
|
+
constructor(hour, minute, second) {
|
|
945
|
+
const now = /* @__PURE__ */ new Date();
|
|
946
|
+
const year = now.getFullYear();
|
|
947
|
+
const month = now.getMonth() + 1;
|
|
948
|
+
const day = now.getDate();
|
|
949
|
+
super(year, month, day);
|
|
950
|
+
this.hour = hour;
|
|
951
|
+
this.minute = minute;
|
|
952
|
+
this.second = second;
|
|
953
|
+
this.hour = hour;
|
|
954
|
+
this.minute = minute;
|
|
955
|
+
this.second = second;
|
|
956
|
+
}
|
|
957
|
+
static create(...args) {
|
|
958
|
+
const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
|
|
959
|
+
const hour = namedArgs.hour || 0;
|
|
960
|
+
const minute = namedArgs.minute || 0;
|
|
961
|
+
const second = namedArgs.second || 0;
|
|
962
|
+
return new _PyTime(hour, minute, second);
|
|
1514
963
|
}
|
|
1515
964
|
strftime(format) {
|
|
1516
965
|
return format.replace(/%([A-Za-z])/g, (m, c) => {
|
|
@@ -1532,1564 +981,2104 @@ var PyDateTime = class _PyDateTime {
|
|
|
1532
981
|
}
|
|
1533
982
|
});
|
|
1534
983
|
}
|
|
1535
|
-
substract(timedelta) {
|
|
1536
|
-
return this.add(timedelta.negate());
|
|
1537
|
-
}
|
|
1538
984
|
toJSON() {
|
|
1539
|
-
return this.strftime("%
|
|
985
|
+
return this.strftime("%H:%M:%S");
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
var DAYS_IN_YEAR = [
|
|
989
|
+
31,
|
|
990
|
+
59,
|
|
991
|
+
90,
|
|
992
|
+
120,
|
|
993
|
+
151,
|
|
994
|
+
181,
|
|
995
|
+
212,
|
|
996
|
+
243,
|
|
997
|
+
273,
|
|
998
|
+
304,
|
|
999
|
+
334,
|
|
1000
|
+
366
|
|
1001
|
+
];
|
|
1002
|
+
var TIME_PERIODS = ["hour", "minute", "second"];
|
|
1003
|
+
var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
|
|
1004
|
+
var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
|
|
1005
|
+
" "
|
|
1006
|
+
);
|
|
1007
|
+
var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
|
|
1008
|
+
" "
|
|
1009
|
+
);
|
|
1010
|
+
var argsSpec = ["dt1", "dt2"];
|
|
1011
|
+
var PyRelativeDelta = class _PyRelativeDelta {
|
|
1012
|
+
static create(...args) {
|
|
1013
|
+
const params = parseArgs(args, argsSpec);
|
|
1014
|
+
if ("dt1" in params) {
|
|
1015
|
+
throw new Error("relativedelta(dt1, dt2) is not supported for now");
|
|
1016
|
+
}
|
|
1017
|
+
for (const period of PERIODS) {
|
|
1018
|
+
if (period in params) {
|
|
1019
|
+
const val = params[period];
|
|
1020
|
+
assert(val >= 0, `${period} ${val} is out of range`);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
for (const key of RELATIVE_KEYS) {
|
|
1024
|
+
params[key] = params[key] || 0;
|
|
1025
|
+
}
|
|
1026
|
+
for (const key of ABSOLUTE_KEYS) {
|
|
1027
|
+
params[key] = key in params ? params[key] : null;
|
|
1028
|
+
}
|
|
1029
|
+
params.days += 7 * params.weeks;
|
|
1030
|
+
let yearDay = 0;
|
|
1031
|
+
if (params.nlyearday) {
|
|
1032
|
+
yearDay = params.nlyearday;
|
|
1033
|
+
} else if (params.yearday) {
|
|
1034
|
+
yearDay = params.yearday;
|
|
1035
|
+
if (yearDay > 59) {
|
|
1036
|
+
params.leapDays = -1;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
if (yearDay) {
|
|
1040
|
+
for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
|
|
1041
|
+
if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
|
|
1042
|
+
params.month = monthIndex + 1;
|
|
1043
|
+
if (monthIndex === 0) {
|
|
1044
|
+
params.day = yearDay;
|
|
1045
|
+
} else {
|
|
1046
|
+
params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
|
|
1047
|
+
}
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return new _PyRelativeDelta(params);
|
|
1053
|
+
}
|
|
1054
|
+
static add(date, delta) {
|
|
1055
|
+
if (!(date instanceof PyDate || date instanceof PyDateTime)) {
|
|
1056
|
+
throw new NotSupportedError();
|
|
1057
|
+
}
|
|
1058
|
+
const s = tmxxx(
|
|
1059
|
+
(delta.year || date.year) + delta.years,
|
|
1060
|
+
(delta.month || date.month) + delta.months,
|
|
1061
|
+
delta.day || date.day,
|
|
1062
|
+
delta.hour || (date instanceof PyDateTime ? date.hour : 0),
|
|
1063
|
+
delta.minute || (date instanceof PyDateTime ? date.minute : 0),
|
|
1064
|
+
delta.second || (date instanceof PyDateTime ? date.second : 0),
|
|
1065
|
+
delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
|
|
1066
|
+
);
|
|
1067
|
+
const newDateTime = new PyDateTime(
|
|
1068
|
+
s.year,
|
|
1069
|
+
s.month,
|
|
1070
|
+
s.day,
|
|
1071
|
+
s.hour,
|
|
1072
|
+
s.minute,
|
|
1073
|
+
s.second,
|
|
1074
|
+
s.microsecond
|
|
1075
|
+
);
|
|
1076
|
+
let leapDays = 0;
|
|
1077
|
+
if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
|
|
1078
|
+
leapDays = delta.leapDays;
|
|
1079
|
+
}
|
|
1080
|
+
const temp = newDateTime.add(
|
|
1081
|
+
PyTimeDelta.create({
|
|
1082
|
+
days: delta.days + leapDays,
|
|
1083
|
+
hours: delta.hours,
|
|
1084
|
+
minutes: delta.minutes,
|
|
1085
|
+
seconds: delta.seconds,
|
|
1086
|
+
microseconds: delta.microseconds
|
|
1087
|
+
})
|
|
1088
|
+
);
|
|
1089
|
+
const hasTime = Boolean(
|
|
1090
|
+
temp.hour || temp.minute || temp.second || temp.microsecond
|
|
1091
|
+
);
|
|
1092
|
+
const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
|
|
1093
|
+
if (delta.weekday !== null) {
|
|
1094
|
+
const wantedDow = delta.weekday + 1;
|
|
1095
|
+
const _date = new Date(
|
|
1096
|
+
returnDate.year,
|
|
1097
|
+
returnDate.month - 1,
|
|
1098
|
+
returnDate.day
|
|
1099
|
+
);
|
|
1100
|
+
const days = (7 - _date.getDay() + wantedDow) % 7;
|
|
1101
|
+
return returnDate.add(new PyTimeDelta(days, 0, 0));
|
|
1102
|
+
}
|
|
1103
|
+
return returnDate;
|
|
1104
|
+
}
|
|
1105
|
+
static substract(date, delta) {
|
|
1106
|
+
return _PyRelativeDelta.add(date, delta.negate());
|
|
1107
|
+
}
|
|
1108
|
+
constructor(params = {}, sign = 1) {
|
|
1109
|
+
this.years = sign * params.years;
|
|
1110
|
+
this.months = sign * params.months;
|
|
1111
|
+
this.days = sign * params.days;
|
|
1112
|
+
this.hours = sign * params.hours;
|
|
1113
|
+
this.minutes = sign * params.minutes;
|
|
1114
|
+
this.seconds = sign * params.seconds;
|
|
1115
|
+
this.microseconds = sign * params.microseconds;
|
|
1116
|
+
this.leapDays = params.leapDays;
|
|
1117
|
+
this.year = params.year;
|
|
1118
|
+
this.month = params.month;
|
|
1119
|
+
this.day = params.day;
|
|
1120
|
+
this.hour = params.hour;
|
|
1121
|
+
this.minute = params.minute;
|
|
1122
|
+
this.second = params.second;
|
|
1123
|
+
this.microsecond = params.microsecond;
|
|
1124
|
+
this.weekday = params.weekday;
|
|
1125
|
+
}
|
|
1126
|
+
negate() {
|
|
1127
|
+
return new _PyRelativeDelta(this, -1);
|
|
1128
|
+
}
|
|
1129
|
+
isEqual() {
|
|
1130
|
+
throw new NotSupportedError();
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
|
|
1134
|
+
function modf(x) {
|
|
1135
|
+
const mod = x % 1;
|
|
1136
|
+
return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
|
|
1137
|
+
}
|
|
1138
|
+
var PyTimeDelta = class _PyTimeDelta {
|
|
1139
|
+
constructor(days, seconds, microseconds) {
|
|
1140
|
+
this.days = days;
|
|
1141
|
+
this.seconds = seconds;
|
|
1142
|
+
this.microseconds = microseconds;
|
|
1143
|
+
}
|
|
1144
|
+
static create(...args) {
|
|
1145
|
+
const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
|
|
1146
|
+
for (const key of TIME_DELTA_KEYS) {
|
|
1147
|
+
namedArgs[key] = namedArgs[key] || 0;
|
|
1148
|
+
}
|
|
1149
|
+
let d = 0;
|
|
1150
|
+
let s = 0;
|
|
1151
|
+
let us = 0;
|
|
1152
|
+
const days = namedArgs.days + namedArgs.weeks * 7;
|
|
1153
|
+
let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
|
|
1154
|
+
let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
|
|
1155
|
+
const [dFrac, dInt] = modf(days);
|
|
1156
|
+
d = dInt;
|
|
1157
|
+
let daysecondsfrac = 0;
|
|
1158
|
+
if (dFrac) {
|
|
1159
|
+
const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
|
|
1160
|
+
s = dsInt;
|
|
1161
|
+
daysecondsfrac = dsFrac;
|
|
1162
|
+
}
|
|
1163
|
+
const [sFrac, sInt] = modf(seconds);
|
|
1164
|
+
seconds = sInt;
|
|
1165
|
+
const secondsfrac = sFrac + daysecondsfrac;
|
|
1166
|
+
divmod(seconds, 24 * 3600, (days2, seconds2) => {
|
|
1167
|
+
d += days2;
|
|
1168
|
+
s += seconds2;
|
|
1169
|
+
});
|
|
1170
|
+
microseconds += secondsfrac * 1e6;
|
|
1171
|
+
divmod(microseconds, 1e6, (seconds2, microseconds2) => {
|
|
1172
|
+
divmod(seconds2, 24 * 3600, (days2, seconds3) => {
|
|
1173
|
+
d += days2;
|
|
1174
|
+
s += seconds3;
|
|
1175
|
+
us += Math.round(microseconds2);
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
return new _PyTimeDelta(d, s, us);
|
|
1179
|
+
}
|
|
1180
|
+
add(other) {
|
|
1181
|
+
return _PyTimeDelta.create({
|
|
1182
|
+
days: this.days + other.days,
|
|
1183
|
+
seconds: this.seconds + other.seconds,
|
|
1184
|
+
microseconds: this.microseconds + other.microseconds
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
divide(n) {
|
|
1188
|
+
const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
|
|
1189
|
+
return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
|
|
1190
|
+
}
|
|
1191
|
+
isEqual(other) {
|
|
1192
|
+
if (!(other instanceof _PyTimeDelta)) {
|
|
1193
|
+
return false;
|
|
1194
|
+
}
|
|
1195
|
+
return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
|
|
1196
|
+
}
|
|
1197
|
+
isTrue() {
|
|
1198
|
+
return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
|
|
1199
|
+
}
|
|
1200
|
+
multiply(n) {
|
|
1201
|
+
return _PyTimeDelta.create({
|
|
1202
|
+
days: n * this.days,
|
|
1203
|
+
seconds: n * this.seconds,
|
|
1204
|
+
microseconds: n * this.microseconds
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
negate() {
|
|
1208
|
+
return _PyTimeDelta.create({
|
|
1209
|
+
days: -this.days,
|
|
1210
|
+
seconds: -this.seconds,
|
|
1211
|
+
microseconds: -this.microseconds
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
substract(other) {
|
|
1215
|
+
return _PyTimeDelta.create({
|
|
1216
|
+
days: this.days - other.days,
|
|
1217
|
+
seconds: this.seconds - other.seconds,
|
|
1218
|
+
microseconds: this.microseconds - other.microseconds
|
|
1219
|
+
});
|
|
1540
1220
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
this.year,
|
|
1544
|
-
this.month - 1,
|
|
1545
|
-
this.day,
|
|
1546
|
-
this.hour,
|
|
1547
|
-
this.minute,
|
|
1548
|
-
this.second
|
|
1549
|
-
);
|
|
1550
|
-
const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
|
|
1551
|
-
return this.add(timedelta);
|
|
1221
|
+
total_seconds() {
|
|
1222
|
+
return this.days * 86400 + this.seconds + this.microseconds / 1e6;
|
|
1552
1223
|
}
|
|
1553
1224
|
};
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
super(year, month, day);
|
|
1561
|
-
this.hour = hour;
|
|
1562
|
-
this.minute = minute;
|
|
1563
|
-
this.second = second;
|
|
1564
|
-
this.hour = hour;
|
|
1565
|
-
this.minute = minute;
|
|
1566
|
-
this.second = second;
|
|
1225
|
+
|
|
1226
|
+
// src/utils/domain/py_builtin.ts
|
|
1227
|
+
var EvaluationError = class extends Error {
|
|
1228
|
+
constructor(message) {
|
|
1229
|
+
super(message);
|
|
1230
|
+
this.name = "EvaluationError";
|
|
1567
1231
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
const second = namedArgs.second || 0;
|
|
1573
|
-
return new _PyTime(hour, minute, second);
|
|
1232
|
+
};
|
|
1233
|
+
function execOnIterable(iterable, func) {
|
|
1234
|
+
if (iterable === null) {
|
|
1235
|
+
throw new EvaluationError("value not iterable");
|
|
1574
1236
|
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
switch (c) {
|
|
1578
|
-
case "Y":
|
|
1579
|
-
return fmt4(this.year);
|
|
1580
|
-
case "m":
|
|
1581
|
-
return fmt2(this.month);
|
|
1582
|
-
case "d":
|
|
1583
|
-
return fmt2(this.day);
|
|
1584
|
-
case "H":
|
|
1585
|
-
return fmt2(this.hour);
|
|
1586
|
-
case "M":
|
|
1587
|
-
return fmt2(this.minute);
|
|
1588
|
-
case "S":
|
|
1589
|
-
return fmt2(this.second);
|
|
1590
|
-
default:
|
|
1591
|
-
throw new ValueError(`No known conversion for ${m}`);
|
|
1592
|
-
}
|
|
1593
|
-
});
|
|
1237
|
+
if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
|
|
1238
|
+
iterable = Object.keys(iterable);
|
|
1594
1239
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1240
|
+
if (typeof (iterable == null ? void 0 : iterable[Symbol.iterator]) !== "function") {
|
|
1241
|
+
throw new EvaluationError("value not iterable");
|
|
1597
1242
|
}
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
)
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
)
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
if (period in params) {
|
|
1630
|
-
const val = params[period];
|
|
1631
|
-
assert(val >= 0, `${period} ${val} is out of range`);
|
|
1632
|
-
}
|
|
1243
|
+
return func(iterable);
|
|
1244
|
+
}
|
|
1245
|
+
var BUILTINS = {
|
|
1246
|
+
/**
|
|
1247
|
+
* @param {any} value
|
|
1248
|
+
* @returns {boolean}
|
|
1249
|
+
*/
|
|
1250
|
+
bool(value) {
|
|
1251
|
+
switch (typeof value) {
|
|
1252
|
+
case "number":
|
|
1253
|
+
return value !== 0;
|
|
1254
|
+
case "string":
|
|
1255
|
+
return value !== "";
|
|
1256
|
+
case "boolean":
|
|
1257
|
+
return value;
|
|
1258
|
+
case "object":
|
|
1259
|
+
if (value === null || value === void 0) {
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
if ("isTrue" in value && typeof value.isTrue === "function") {
|
|
1263
|
+
return value.isTrue();
|
|
1264
|
+
}
|
|
1265
|
+
if (value instanceof Array) {
|
|
1266
|
+
return !!value.length;
|
|
1267
|
+
}
|
|
1268
|
+
if (value instanceof Set) {
|
|
1269
|
+
return !!value.size;
|
|
1270
|
+
}
|
|
1271
|
+
return Object.keys(value).length !== 0;
|
|
1272
|
+
default:
|
|
1273
|
+
return true;
|
|
1633
1274
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1275
|
+
},
|
|
1276
|
+
set(iterable) {
|
|
1277
|
+
if (arguments.length > 2) {
|
|
1278
|
+
throw new EvaluationError(
|
|
1279
|
+
`set expected at most 1 argument, got (${arguments.length - 1})`
|
|
1280
|
+
);
|
|
1636
1281
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1282
|
+
return execOnIterable(
|
|
1283
|
+
iterable,
|
|
1284
|
+
(iterable2) => new Set(iterable2)
|
|
1285
|
+
);
|
|
1286
|
+
},
|
|
1287
|
+
time: {
|
|
1288
|
+
strftime(format) {
|
|
1289
|
+
return PyDateTime.now().strftime(format);
|
|
1639
1290
|
}
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1291
|
+
},
|
|
1292
|
+
context_today() {
|
|
1293
|
+
return PyDate.today();
|
|
1294
|
+
},
|
|
1295
|
+
get current_date() {
|
|
1296
|
+
return this.today;
|
|
1297
|
+
},
|
|
1298
|
+
get today() {
|
|
1299
|
+
return PyDate.today().strftime("%Y-%m-%d");
|
|
1300
|
+
},
|
|
1301
|
+
get now() {
|
|
1302
|
+
return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
|
|
1303
|
+
},
|
|
1304
|
+
datetime: {
|
|
1305
|
+
time: PyTime,
|
|
1306
|
+
timedelta: PyTimeDelta,
|
|
1307
|
+
datetime: PyDateTime,
|
|
1308
|
+
date: PyDate
|
|
1309
|
+
},
|
|
1310
|
+
relativedelta: PyRelativeDelta,
|
|
1311
|
+
true: true,
|
|
1312
|
+
false: false
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
// src/utils/domain/py_utils.ts
|
|
1316
|
+
function toPyValue(value) {
|
|
1317
|
+
switch (typeof value) {
|
|
1318
|
+
case "string":
|
|
1319
|
+
return { type: 1, value };
|
|
1320
|
+
case "number":
|
|
1321
|
+
return { type: 0, value };
|
|
1322
|
+
case "boolean":
|
|
1323
|
+
return { type: 2, value };
|
|
1324
|
+
case "object":
|
|
1325
|
+
if (Array.isArray(value)) {
|
|
1326
|
+
return { type: 4, value: value.map(toPyValue) };
|
|
1327
|
+
} else if (value === null) {
|
|
1328
|
+
return {
|
|
1329
|
+
type: 3
|
|
1330
|
+
/* None */
|
|
1331
|
+
};
|
|
1332
|
+
} else if (value instanceof Date) {
|
|
1333
|
+
return {
|
|
1334
|
+
type: 1,
|
|
1335
|
+
value: String(PyDateTime.convertDate(value))
|
|
1336
|
+
};
|
|
1337
|
+
} else if (value instanceof PyDate || value instanceof PyDateTime) {
|
|
1338
|
+
return { type: 1, value };
|
|
1339
|
+
} else {
|
|
1340
|
+
const content = {};
|
|
1341
|
+
for (const key in value) {
|
|
1342
|
+
content[key] = toPyValue(value[key]);
|
|
1343
|
+
}
|
|
1344
|
+
return { type: 11, value: content };
|
|
1345
|
+
}
|
|
1346
|
+
default:
|
|
1347
|
+
throw new Error("Invalid type");
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
function formatAST(ast, lbp = 0) {
|
|
1351
|
+
switch (ast.type) {
|
|
1352
|
+
case 3:
|
|
1353
|
+
return "None";
|
|
1354
|
+
case 1:
|
|
1355
|
+
return JSON.stringify(ast.value);
|
|
1356
|
+
case 0:
|
|
1357
|
+
return String(ast.value);
|
|
1358
|
+
case 2:
|
|
1359
|
+
return ast.value ? "True" : "False";
|
|
1360
|
+
case 4:
|
|
1361
|
+
return `[${ast.value.map(formatAST).join(", ")}]`;
|
|
1362
|
+
case 6:
|
|
1363
|
+
if (ast.op === "not") {
|
|
1364
|
+
return `not ${formatAST(ast.right, 50)}`;
|
|
1365
|
+
}
|
|
1366
|
+
return `${ast.op}${formatAST(ast.right, 130)}`;
|
|
1367
|
+
case 7:
|
|
1368
|
+
const abp = bp(ast.op);
|
|
1369
|
+
const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
|
|
1370
|
+
return abp < lbp ? `(${binaryStr})` : binaryStr;
|
|
1371
|
+
case 11:
|
|
1372
|
+
const pairs = [];
|
|
1373
|
+
for (const k in ast.value) {
|
|
1374
|
+
pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
|
|
1375
|
+
}
|
|
1376
|
+
return `{${pairs.join(", ")}}`;
|
|
1377
|
+
case 10:
|
|
1378
|
+
return `(${ast.value.map(formatAST).join(", ")})`;
|
|
1379
|
+
case 5:
|
|
1380
|
+
return ast.value;
|
|
1381
|
+
case 12:
|
|
1382
|
+
return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
|
|
1383
|
+
case 13:
|
|
1384
|
+
const { ifTrue, condition, ifFalse } = ast;
|
|
1385
|
+
return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
|
|
1386
|
+
case 14:
|
|
1387
|
+
const boolAbp = bp(ast.op);
|
|
1388
|
+
const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
|
|
1389
|
+
return boolAbp < lbp ? `(${boolStr})` : boolStr;
|
|
1390
|
+
case 15:
|
|
1391
|
+
return `${formatAST(ast.obj, 150)}.${ast.key}`;
|
|
1392
|
+
case 8:
|
|
1393
|
+
const args = ast.args.map(formatAST);
|
|
1394
|
+
const kwargs = [];
|
|
1395
|
+
for (const kwarg in ast.kwargs) {
|
|
1396
|
+
kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
|
|
1648
1397
|
}
|
|
1398
|
+
const argStr = args.concat(kwargs).join(", ");
|
|
1399
|
+
return `${formatAST(ast.fn)}(${argStr})`;
|
|
1400
|
+
default:
|
|
1401
|
+
throw new Error("invalid expression: " + JSON.stringify(ast));
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
var PY_DICT = /* @__PURE__ */ Object.create(null);
|
|
1405
|
+
function toPyDict(obj) {
|
|
1406
|
+
return new Proxy(obj, {
|
|
1407
|
+
getPrototypeOf() {
|
|
1408
|
+
return PY_DICT;
|
|
1649
1409
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// src/utils/domain/py_interpreter.ts
|
|
1414
|
+
var isTrue = BUILTINS.bool;
|
|
1415
|
+
function applyUnaryOp(ast, context) {
|
|
1416
|
+
const value = evaluate(ast.right, context);
|
|
1417
|
+
switch (ast.op) {
|
|
1418
|
+
case "-":
|
|
1419
|
+
if (value instanceof Object && "negate" in value) {
|
|
1420
|
+
return value.negate();
|
|
1661
1421
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1422
|
+
return -value;
|
|
1423
|
+
case "+":
|
|
1424
|
+
return value;
|
|
1425
|
+
case "not":
|
|
1426
|
+
return !isTrue(value);
|
|
1427
|
+
default:
|
|
1428
|
+
throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
|
|
1664
1429
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1430
|
+
}
|
|
1431
|
+
function pytypeIndex(val) {
|
|
1432
|
+
switch (typeof val) {
|
|
1433
|
+
case "object":
|
|
1434
|
+
return val === null ? 1 : Array.isArray(val) ? 5 : 3;
|
|
1435
|
+
case "number":
|
|
1436
|
+
return 2;
|
|
1437
|
+
case "string":
|
|
1438
|
+
return 4;
|
|
1439
|
+
default:
|
|
1440
|
+
throw new EvaluationError(`Unknown type: ${typeof val}`);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
function isLess(left, right) {
|
|
1444
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
1445
|
+
return left < right;
|
|
1446
|
+
}
|
|
1447
|
+
if (typeof left === "boolean") {
|
|
1448
|
+
left = left ? 1 : 0;
|
|
1449
|
+
}
|
|
1450
|
+
if (typeof right === "boolean") {
|
|
1451
|
+
right = right ? 1 : 0;
|
|
1452
|
+
}
|
|
1453
|
+
const leftIndex = pytypeIndex(left);
|
|
1454
|
+
const rightIndex = pytypeIndex(right);
|
|
1455
|
+
if (leftIndex === rightIndex) {
|
|
1456
|
+
return left < right;
|
|
1457
|
+
}
|
|
1458
|
+
return leftIndex < rightIndex;
|
|
1459
|
+
}
|
|
1460
|
+
function isEqual(left, right) {
|
|
1461
|
+
if (typeof left !== typeof right) {
|
|
1462
|
+
if (typeof left === "boolean" && typeof right === "number") {
|
|
1463
|
+
return right === (left ? 1 : 0);
|
|
1690
1464
|
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
days: delta.days + leapDays,
|
|
1694
|
-
hours: delta.hours,
|
|
1695
|
-
minutes: delta.minutes,
|
|
1696
|
-
seconds: delta.seconds,
|
|
1697
|
-
microseconds: delta.microseconds
|
|
1698
|
-
})
|
|
1699
|
-
);
|
|
1700
|
-
const hasTime = Boolean(
|
|
1701
|
-
temp.hour || temp.minute || temp.second || temp.microsecond
|
|
1702
|
-
);
|
|
1703
|
-
const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
|
|
1704
|
-
if (delta.weekday !== null) {
|
|
1705
|
-
const wantedDow = delta.weekday + 1;
|
|
1706
|
-
const _date = new Date(
|
|
1707
|
-
returnDate.year,
|
|
1708
|
-
returnDate.month - 1,
|
|
1709
|
-
returnDate.day
|
|
1710
|
-
);
|
|
1711
|
-
const days = (7 - _date.getDay() + wantedDow) % 7;
|
|
1712
|
-
return returnDate.add(new PyTimeDelta(days, 0, 0));
|
|
1465
|
+
if (typeof left === "number" && typeof right === "boolean") {
|
|
1466
|
+
return left === (right ? 1 : 0);
|
|
1713
1467
|
}
|
|
1714
|
-
return
|
|
1468
|
+
return false;
|
|
1715
1469
|
}
|
|
1716
|
-
|
|
1717
|
-
return
|
|
1470
|
+
if (left instanceof Object && "isEqual" in left) {
|
|
1471
|
+
return left.isEqual(right);
|
|
1718
1472
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
this.minutes = sign * params.minutes;
|
|
1725
|
-
this.seconds = sign * params.seconds;
|
|
1726
|
-
this.microseconds = sign * params.microseconds;
|
|
1727
|
-
this.leapDays = params.leapDays;
|
|
1728
|
-
this.year = params.year;
|
|
1729
|
-
this.month = params.month;
|
|
1730
|
-
this.day = params.day;
|
|
1731
|
-
this.hour = params.hour;
|
|
1732
|
-
this.minute = params.minute;
|
|
1733
|
-
this.second = params.second;
|
|
1734
|
-
this.microsecond = params.microsecond;
|
|
1735
|
-
this.weekday = params.weekday;
|
|
1473
|
+
return left === right;
|
|
1474
|
+
}
|
|
1475
|
+
function isIn(left, right) {
|
|
1476
|
+
if (Array.isArray(right)) {
|
|
1477
|
+
return right.includes(left);
|
|
1736
1478
|
}
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
days;
|
|
1740
|
-
hours;
|
|
1741
|
-
minutes;
|
|
1742
|
-
seconds;
|
|
1743
|
-
microseconds;
|
|
1744
|
-
leapDays;
|
|
1745
|
-
year;
|
|
1746
|
-
month;
|
|
1747
|
-
day;
|
|
1748
|
-
hour;
|
|
1749
|
-
minute;
|
|
1750
|
-
second;
|
|
1751
|
-
microsecond;
|
|
1752
|
-
weekday;
|
|
1753
|
-
negate() {
|
|
1754
|
-
return new _PyRelativeDelta(this, -1);
|
|
1479
|
+
if (typeof right === "string" && typeof left === "string") {
|
|
1480
|
+
return right.includes(left);
|
|
1755
1481
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1482
|
+
if (typeof right === "object") {
|
|
1483
|
+
return left in right;
|
|
1758
1484
|
}
|
|
1759
|
-
|
|
1760
|
-
var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
|
|
1761
|
-
function modf(x) {
|
|
1762
|
-
const mod = x % 1;
|
|
1763
|
-
return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
|
|
1485
|
+
return false;
|
|
1764
1486
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1487
|
+
function applyBinaryOp(ast, context) {
|
|
1488
|
+
const left = evaluate(ast.left, context);
|
|
1489
|
+
const right = evaluate(ast.right, context);
|
|
1490
|
+
switch (ast.op) {
|
|
1491
|
+
case "+": {
|
|
1492
|
+
const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
|
|
1493
|
+
const relativeDeltaOnRight = right instanceof PyRelativeDelta;
|
|
1494
|
+
if (relativeDeltaOnLeft || relativeDeltaOnRight) {
|
|
1495
|
+
const date = relativeDeltaOnLeft ? right : left;
|
|
1496
|
+
const delta = relativeDeltaOnLeft ? left : right;
|
|
1497
|
+
return PyRelativeDelta.add(date, delta);
|
|
1498
|
+
}
|
|
1499
|
+
const timeDeltaOnLeft = left instanceof PyTimeDelta;
|
|
1500
|
+
const timeDeltaOnRight = right instanceof PyTimeDelta;
|
|
1501
|
+
if (timeDeltaOnLeft && timeDeltaOnRight) {
|
|
1502
|
+
return left.add(right);
|
|
1503
|
+
}
|
|
1504
|
+
if (timeDeltaOnLeft) {
|
|
1505
|
+
if (right instanceof PyDate || right instanceof PyDateTime) {
|
|
1506
|
+
return right.add(left);
|
|
1507
|
+
} else {
|
|
1508
|
+
throw new NotSupportedError();
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
if (timeDeltaOnRight) {
|
|
1512
|
+
if (left instanceof PyDate || left instanceof PyDateTime) {
|
|
1513
|
+
return left.add(right);
|
|
1514
|
+
} else {
|
|
1515
|
+
throw new NotSupportedError();
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
if (left instanceof Array && right instanceof Array) {
|
|
1519
|
+
return [...left, ...right];
|
|
1520
|
+
}
|
|
1521
|
+
return left + right;
|
|
1775
1522
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1523
|
+
case "-": {
|
|
1524
|
+
const isRightDelta = right instanceof PyRelativeDelta;
|
|
1525
|
+
if (isRightDelta) {
|
|
1526
|
+
return PyRelativeDelta.substract(left, right);
|
|
1527
|
+
}
|
|
1528
|
+
const timeDeltaOnRight = right instanceof PyTimeDelta;
|
|
1529
|
+
if (timeDeltaOnRight) {
|
|
1530
|
+
if (left instanceof PyTimeDelta) {
|
|
1531
|
+
return left.substract(right);
|
|
1532
|
+
} else if (left instanceof PyDate || left instanceof PyDateTime) {
|
|
1533
|
+
return left.substract(right);
|
|
1534
|
+
} else {
|
|
1535
|
+
throw new NotSupportedError();
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
if (left instanceof PyDate) {
|
|
1539
|
+
return left.substract(right);
|
|
1540
|
+
}
|
|
1541
|
+
return left - right;
|
|
1789
1542
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
divmod(seconds2, 24 * 3600, (days2, seconds3) => {
|
|
1800
|
-
d += days2;
|
|
1801
|
-
s += seconds3;
|
|
1802
|
-
us += Math.round(microseconds2);
|
|
1803
|
-
});
|
|
1804
|
-
});
|
|
1805
|
-
return new _PyTimeDelta(d, s, us);
|
|
1806
|
-
}
|
|
1807
|
-
add(other) {
|
|
1808
|
-
return _PyTimeDelta.create({
|
|
1809
|
-
days: this.days + other.days,
|
|
1810
|
-
seconds: this.seconds + other.seconds,
|
|
1811
|
-
microseconds: this.microseconds + other.microseconds
|
|
1812
|
-
});
|
|
1813
|
-
}
|
|
1814
|
-
divide(n) {
|
|
1815
|
-
const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
|
|
1816
|
-
return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
|
|
1817
|
-
}
|
|
1818
|
-
isEqual(other) {
|
|
1819
|
-
if (!(other instanceof _PyTimeDelta)) {
|
|
1820
|
-
return false;
|
|
1543
|
+
case "*": {
|
|
1544
|
+
const timeDeltaOnLeft = left instanceof PyTimeDelta;
|
|
1545
|
+
const timeDeltaOnRight = right instanceof PyTimeDelta;
|
|
1546
|
+
if (timeDeltaOnLeft || timeDeltaOnRight) {
|
|
1547
|
+
const number = timeDeltaOnLeft ? right : left;
|
|
1548
|
+
const delta = timeDeltaOnLeft ? left : right;
|
|
1549
|
+
return delta.multiply(number);
|
|
1550
|
+
}
|
|
1551
|
+
return left * right;
|
|
1821
1552
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1553
|
+
case "/":
|
|
1554
|
+
return left / right;
|
|
1555
|
+
case "%":
|
|
1556
|
+
return left % right;
|
|
1557
|
+
case "//":
|
|
1558
|
+
if (left instanceof PyTimeDelta) {
|
|
1559
|
+
return left.divide(right);
|
|
1560
|
+
}
|
|
1561
|
+
return Math.floor(left / right);
|
|
1562
|
+
case "**":
|
|
1563
|
+
return __pow(left, right);
|
|
1564
|
+
case "==":
|
|
1565
|
+
return isEqual(left, right);
|
|
1566
|
+
case "<>":
|
|
1567
|
+
case "!=":
|
|
1568
|
+
return !isEqual(left, right);
|
|
1569
|
+
case "<":
|
|
1570
|
+
return isLess(left, right);
|
|
1571
|
+
case ">":
|
|
1572
|
+
return isLess(right, left);
|
|
1573
|
+
case ">=":
|
|
1574
|
+
return isEqual(left, right) || isLess(right, left);
|
|
1575
|
+
case "<=":
|
|
1576
|
+
return isEqual(left, right) || isLess(left, right);
|
|
1577
|
+
case "in":
|
|
1578
|
+
return isIn(left, right);
|
|
1579
|
+
case "not in":
|
|
1580
|
+
return !isIn(left, right);
|
|
1581
|
+
default:
|
|
1582
|
+
throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
|
|
1847
1583
|
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1584
|
+
}
|
|
1585
|
+
var DICT = {
|
|
1586
|
+
get(...args) {
|
|
1587
|
+
const { key, defValue } = parseArgs(args, ["key", "defValue"]);
|
|
1588
|
+
const self = this;
|
|
1589
|
+
if (key in self) {
|
|
1590
|
+
return self[key];
|
|
1591
|
+
} else if (defValue !== void 0) {
|
|
1592
|
+
return defValue;
|
|
1593
|
+
}
|
|
1594
|
+
return null;
|
|
1850
1595
|
}
|
|
1851
1596
|
};
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
this.
|
|
1597
|
+
var STRING = {
|
|
1598
|
+
lower() {
|
|
1599
|
+
return this.toLowerCase();
|
|
1600
|
+
},
|
|
1601
|
+
upper() {
|
|
1602
|
+
return this.toUpperCase();
|
|
1858
1603
|
}
|
|
1859
1604
|
};
|
|
1860
|
-
function
|
|
1861
|
-
if (
|
|
1862
|
-
|
|
1605
|
+
function applyFunc(key, func, set, ...args) {
|
|
1606
|
+
if (args.length === 1) {
|
|
1607
|
+
return new Set(set);
|
|
1863
1608
|
}
|
|
1864
|
-
if (
|
|
1865
|
-
|
|
1609
|
+
if (args.length > 2) {
|
|
1610
|
+
throw new EvaluationError(
|
|
1611
|
+
`${key}: py_js supports at most 1 argument, got (${args.length - 1})`
|
|
1612
|
+
);
|
|
1866
1613
|
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1614
|
+
return execOnIterable(args[0], func);
|
|
1615
|
+
}
|
|
1616
|
+
var SET = {
|
|
1617
|
+
intersection(...args) {
|
|
1618
|
+
return applyFunc(
|
|
1619
|
+
"intersection",
|
|
1620
|
+
(iterable) => {
|
|
1621
|
+
const intersection = /* @__PURE__ */ new Set();
|
|
1622
|
+
for (const i of iterable) {
|
|
1623
|
+
if (this.has(i)) {
|
|
1624
|
+
intersection.add(i);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
return intersection;
|
|
1628
|
+
},
|
|
1629
|
+
this,
|
|
1630
|
+
...args
|
|
1631
|
+
);
|
|
1632
|
+
},
|
|
1633
|
+
difference(...args) {
|
|
1634
|
+
return applyFunc(
|
|
1635
|
+
"difference",
|
|
1636
|
+
(iterable) => {
|
|
1637
|
+
iterable = new Set(iterable);
|
|
1638
|
+
const difference = /* @__PURE__ */ new Set();
|
|
1639
|
+
for (const e of this) {
|
|
1640
|
+
if (!iterable.has(e)) {
|
|
1641
|
+
difference.add(e);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
return difference;
|
|
1645
|
+
},
|
|
1646
|
+
this,
|
|
1647
|
+
...args
|
|
1648
|
+
);
|
|
1649
|
+
},
|
|
1650
|
+
union(...args) {
|
|
1651
|
+
return applyFunc(
|
|
1652
|
+
"union",
|
|
1653
|
+
(iterable) => {
|
|
1654
|
+
return /* @__PURE__ */ new Set([...this, ...iterable]);
|
|
1655
|
+
},
|
|
1656
|
+
this,
|
|
1657
|
+
...args
|
|
1658
|
+
);
|
|
1869
1659
|
}
|
|
1870
|
-
|
|
1660
|
+
};
|
|
1661
|
+
function methods(_class) {
|
|
1662
|
+
return Object.getOwnPropertyNames(_class.prototype).map(
|
|
1663
|
+
(prop) => _class.prototype[prop]
|
|
1664
|
+
);
|
|
1871
1665
|
}
|
|
1872
|
-
var
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1666
|
+
var allowedFns = /* @__PURE__ */ new Set([
|
|
1667
|
+
BUILTINS.time.strftime,
|
|
1668
|
+
BUILTINS.set,
|
|
1669
|
+
BUILTINS.bool,
|
|
1670
|
+
BUILTINS.context_today,
|
|
1671
|
+
BUILTINS.datetime.datetime.now,
|
|
1672
|
+
BUILTINS.datetime.datetime.combine,
|
|
1673
|
+
BUILTINS.datetime.date.today,
|
|
1674
|
+
...methods(BUILTINS.relativedelta),
|
|
1675
|
+
...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
|
|
1676
|
+
...Object.values(SET),
|
|
1677
|
+
...Object.values(DICT),
|
|
1678
|
+
...Object.values(STRING)
|
|
1679
|
+
]);
|
|
1680
|
+
var unboundFn = Symbol("unbound function");
|
|
1681
|
+
function evaluate(ast, context = {}) {
|
|
1682
|
+
const dicts = /* @__PURE__ */ new Set();
|
|
1683
|
+
let pyContext;
|
|
1684
|
+
const evalContext = Object.create(context);
|
|
1685
|
+
if (!(evalContext == null ? void 0 : evalContext.context)) {
|
|
1686
|
+
Object.defineProperty(evalContext, "context", {
|
|
1687
|
+
get() {
|
|
1688
|
+
if (!pyContext) {
|
|
1689
|
+
pyContext = toPyDict(context);
|
|
1690
|
+
}
|
|
1691
|
+
return pyContext;
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
function _innerEvaluate(ast2) {
|
|
1696
|
+
var _a, _b, _c;
|
|
1697
|
+
switch (ast2 == null ? void 0 : ast2.type) {
|
|
1698
|
+
case 0:
|
|
1699
|
+
// Number
|
|
1700
|
+
case 1:
|
|
1701
|
+
return ast2.value;
|
|
1702
|
+
case 5:
|
|
1703
|
+
if (ast2.value in evalContext) {
|
|
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;
|
|
1706
|
+
}
|
|
1707
|
+
return (_c = evalContext[ast2.value]) != null ? _c : false;
|
|
1708
|
+
} else if (ast2.value in BUILTINS) {
|
|
1709
|
+
return BUILTINS[ast2.value];
|
|
1710
|
+
} else {
|
|
1887
1711
|
return false;
|
|
1888
1712
|
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1713
|
+
case 3:
|
|
1714
|
+
return null;
|
|
1715
|
+
case 2:
|
|
1716
|
+
return ast2.value;
|
|
1717
|
+
case 6:
|
|
1718
|
+
return applyUnaryOp(ast2, evalContext);
|
|
1719
|
+
case 7:
|
|
1720
|
+
return applyBinaryOp(ast2, evalContext);
|
|
1721
|
+
case 14:
|
|
1722
|
+
const left = _evaluate(ast2.left);
|
|
1723
|
+
if (ast2.op === "and") {
|
|
1724
|
+
return isTrue(left) ? _evaluate(ast2.right) : left;
|
|
1725
|
+
} else {
|
|
1726
|
+
return isTrue(left) ? left : _evaluate(ast2.right);
|
|
1727
|
+
}
|
|
1728
|
+
case 4:
|
|
1729
|
+
// List
|
|
1730
|
+
case 10:
|
|
1731
|
+
return ast2.value.map(_evaluate);
|
|
1732
|
+
case 11:
|
|
1733
|
+
const dict = {};
|
|
1734
|
+
for (const key2 in ast2.value) {
|
|
1735
|
+
dict[key2] = _evaluate(ast2.value[key2]);
|
|
1736
|
+
}
|
|
1737
|
+
dicts.add(dict);
|
|
1738
|
+
return dict;
|
|
1739
|
+
case 8:
|
|
1740
|
+
const fnValue = _evaluate(ast2.fn);
|
|
1741
|
+
const args = ast2.args.map(_evaluate);
|
|
1742
|
+
const kwargs = {};
|
|
1743
|
+
for (const kwarg in ast2.kwargs) {
|
|
1744
|
+
kwargs[kwarg] = _evaluate(ast2 == null ? void 0 : ast2.kwargs[kwarg]);
|
|
1891
1745
|
}
|
|
1892
|
-
if (
|
|
1893
|
-
return
|
|
1746
|
+
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
1747
|
+
return fnValue.create(...args, kwargs);
|
|
1894
1748
|
}
|
|
1895
|
-
|
|
1896
|
-
|
|
1749
|
+
return fnValue(...args, kwargs);
|
|
1750
|
+
case 12:
|
|
1751
|
+
const dictVal = _evaluate(ast2.target);
|
|
1752
|
+
const key = _evaluate(ast2.key);
|
|
1753
|
+
return dictVal[key];
|
|
1754
|
+
case 13:
|
|
1755
|
+
if (isTrue(_evaluate(ast2.condition))) {
|
|
1756
|
+
return _evaluate(ast2.ifTrue);
|
|
1757
|
+
} else {
|
|
1758
|
+
return _evaluate(ast2.ifFalse);
|
|
1897
1759
|
}
|
|
1898
|
-
|
|
1760
|
+
case 15:
|
|
1761
|
+
let leftVal = _evaluate(ast2.obj);
|
|
1762
|
+
let result;
|
|
1763
|
+
if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
|
|
1764
|
+
result = DICT[ast2.key];
|
|
1765
|
+
} else if (typeof leftVal === "string") {
|
|
1766
|
+
result = STRING[ast2.key];
|
|
1767
|
+
} else if (leftVal instanceof Set) {
|
|
1768
|
+
result = SET[ast2.key];
|
|
1769
|
+
} else if (ast2.key === "get" && typeof leftVal === "object") {
|
|
1770
|
+
result = DICT[ast2.key];
|
|
1771
|
+
leftVal = toPyDict(leftVal);
|
|
1772
|
+
} else {
|
|
1773
|
+
result = leftVal[ast2.key];
|
|
1774
|
+
}
|
|
1775
|
+
if (typeof result === "function") {
|
|
1776
|
+
const bound = result.bind(leftVal);
|
|
1777
|
+
bound[unboundFn] = result;
|
|
1778
|
+
return bound;
|
|
1779
|
+
}
|
|
1780
|
+
return result;
|
|
1899
1781
|
default:
|
|
1900
|
-
|
|
1901
|
-
}
|
|
1902
|
-
},
|
|
1903
|
-
set(iterable) {
|
|
1904
|
-
if (arguments.length > 2) {
|
|
1905
|
-
throw new EvaluationError(
|
|
1906
|
-
`set expected at most 1 argument, got (${arguments.length - 1})`
|
|
1907
|
-
);
|
|
1908
|
-
}
|
|
1909
|
-
return execOnIterable(
|
|
1910
|
-
iterable,
|
|
1911
|
-
(iterable2) => new Set(iterable2)
|
|
1912
|
-
);
|
|
1913
|
-
},
|
|
1914
|
-
time: {
|
|
1915
|
-
strftime(format) {
|
|
1916
|
-
return PyDateTime.now().strftime(format);
|
|
1782
|
+
throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
|
|
1917
1783
|
}
|
|
1918
|
-
},
|
|
1919
|
-
context_today() {
|
|
1920
|
-
return PyDate.today();
|
|
1921
|
-
},
|
|
1922
|
-
get current_date() {
|
|
1923
|
-
return this.today;
|
|
1924
|
-
},
|
|
1925
|
-
get today() {
|
|
1926
|
-
return PyDate.today().strftime("%Y-%m-%d");
|
|
1927
|
-
},
|
|
1928
|
-
get now() {
|
|
1929
|
-
return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
|
|
1930
|
-
},
|
|
1931
|
-
datetime: {
|
|
1932
|
-
time: PyTime,
|
|
1933
|
-
timedelta: PyTimeDelta,
|
|
1934
|
-
datetime: PyDateTime,
|
|
1935
|
-
date: PyDate
|
|
1936
|
-
},
|
|
1937
|
-
relativedelta: PyRelativeDelta,
|
|
1938
|
-
true: true,
|
|
1939
|
-
false: false
|
|
1940
|
-
};
|
|
1941
|
-
|
|
1942
|
-
// src/utils/domain/py_utils.ts
|
|
1943
|
-
function toPyValue(value) {
|
|
1944
|
-
switch (typeof value) {
|
|
1945
|
-
case "string":
|
|
1946
|
-
return { type: 1, value };
|
|
1947
|
-
case "number":
|
|
1948
|
-
return { type: 0, value };
|
|
1949
|
-
case "boolean":
|
|
1950
|
-
return { type: 2, value };
|
|
1951
|
-
case "object":
|
|
1952
|
-
if (Array.isArray(value)) {
|
|
1953
|
-
return { type: 4, value: value.map(toPyValue) };
|
|
1954
|
-
} else if (value === null) {
|
|
1955
|
-
return {
|
|
1956
|
-
type: 3
|
|
1957
|
-
/* None */
|
|
1958
|
-
};
|
|
1959
|
-
} else if (value instanceof Date) {
|
|
1960
|
-
return {
|
|
1961
|
-
type: 1,
|
|
1962
|
-
value: String(PyDateTime.convertDate(value))
|
|
1963
|
-
};
|
|
1964
|
-
} else if (value instanceof PyDate || value instanceof PyDateTime) {
|
|
1965
|
-
return { type: 1, value };
|
|
1966
|
-
} else {
|
|
1967
|
-
const content = {};
|
|
1968
|
-
for (const key in value) {
|
|
1969
|
-
content[key] = toPyValue(value[key]);
|
|
1970
|
-
}
|
|
1971
|
-
return { type: 11, value: content };
|
|
1972
|
-
}
|
|
1973
|
-
default:
|
|
1974
|
-
throw new Error("Invalid type");
|
|
1975
1784
|
}
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
return JSON.stringify(ast.value);
|
|
1983
|
-
case 0:
|
|
1984
|
-
return String(ast.value);
|
|
1985
|
-
case 2:
|
|
1986
|
-
return ast.value ? "True" : "False";
|
|
1987
|
-
case 4:
|
|
1988
|
-
return `[${ast.value.map(formatAST).join(", ")}]`;
|
|
1989
|
-
case 6:
|
|
1990
|
-
if (ast.op === "not") {
|
|
1991
|
-
return `not ${formatAST(ast.right, 50)}`;
|
|
1992
|
-
}
|
|
1993
|
-
return `${ast.op}${formatAST(ast.right, 130)}`;
|
|
1994
|
-
case 7:
|
|
1995
|
-
const abp = bp(ast.op);
|
|
1996
|
-
const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
|
|
1997
|
-
return abp < lbp ? `(${binaryStr})` : binaryStr;
|
|
1998
|
-
case 11:
|
|
1999
|
-
const pairs = [];
|
|
2000
|
-
for (const k in ast.value) {
|
|
2001
|
-
pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
|
|
2002
|
-
}
|
|
2003
|
-
return `{${pairs.join(", ")}}`;
|
|
2004
|
-
case 10:
|
|
2005
|
-
return `(${ast.value.map(formatAST).join(", ")})`;
|
|
2006
|
-
case 5:
|
|
2007
|
-
return ast.value;
|
|
2008
|
-
case 12:
|
|
2009
|
-
return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
|
|
2010
|
-
case 13:
|
|
2011
|
-
const { ifTrue, condition, ifFalse } = ast;
|
|
2012
|
-
return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
|
|
2013
|
-
case 14:
|
|
2014
|
-
const boolAbp = bp(ast.op);
|
|
2015
|
-
const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
|
|
2016
|
-
return boolAbp < lbp ? `(${boolStr})` : boolStr;
|
|
2017
|
-
case 15:
|
|
2018
|
-
return `${formatAST(ast.obj, 150)}.${ast.key}`;
|
|
2019
|
-
case 8:
|
|
2020
|
-
const args = ast.args.map(formatAST);
|
|
2021
|
-
const kwargs = [];
|
|
2022
|
-
for (const kwarg in ast.kwargs) {
|
|
2023
|
-
kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
|
|
2024
|
-
}
|
|
2025
|
-
const argStr = args.concat(kwargs).join(", ");
|
|
2026
|
-
return `${formatAST(ast.fn)}(${argStr})`;
|
|
2027
|
-
default:
|
|
2028
|
-
throw new Error("invalid expression: " + JSON.stringify(ast));
|
|
1785
|
+
function _evaluate(ast2) {
|
|
1786
|
+
const val = _innerEvaluate(ast2);
|
|
1787
|
+
if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
|
|
1788
|
+
throw new Error("Invalid Function Call");
|
|
1789
|
+
}
|
|
1790
|
+
return val;
|
|
2029
1791
|
}
|
|
1792
|
+
return _evaluate(ast);
|
|
2030
1793
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
}
|
|
2037
|
-
});
|
|
1794
|
+
|
|
1795
|
+
// src/utils/domain/py.ts
|
|
1796
|
+
function parseExpr(expr) {
|
|
1797
|
+
const tokens = tokenize(expr);
|
|
1798
|
+
return parse(tokens);
|
|
2038
1799
|
}
|
|
2039
1800
|
|
|
2040
|
-
// src/utils/domain/
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
switch (ast.op) {
|
|
2045
|
-
case "-":
|
|
2046
|
-
if (value instanceof Object && "negate" in value) {
|
|
2047
|
-
return value.negate();
|
|
2048
|
-
}
|
|
2049
|
-
return -value;
|
|
2050
|
-
case "+":
|
|
2051
|
-
return value;
|
|
2052
|
-
case "not":
|
|
2053
|
-
return !isTrue(value);
|
|
2054
|
-
default:
|
|
2055
|
-
throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
|
|
1801
|
+
// src/utils/domain/objects.ts
|
|
1802
|
+
function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
|
|
1803
|
+
if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
|
|
1804
|
+
return obj1 === obj2;
|
|
2056
1805
|
}
|
|
1806
|
+
const obj1Keys = Object.keys(obj1);
|
|
1807
|
+
return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
|
|
2057
1808
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
1809
|
+
|
|
1810
|
+
// src/utils/domain/arrays.ts
|
|
1811
|
+
var shallowEqual2 = shallowEqual;
|
|
1812
|
+
|
|
1813
|
+
// src/utils/domain/strings.ts
|
|
1814
|
+
var escapeMethod = Symbol("html");
|
|
1815
|
+
function escapeRegExp(str) {
|
|
1816
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
// src/utils/domain/domain.ts
|
|
1820
|
+
var InvalidDomainError = class extends Error {
|
|
1821
|
+
};
|
|
1822
|
+
var Domain = class _Domain {
|
|
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
|
+
}
|
|
2068
1841
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
1842
|
+
static combine(domains, operator) {
|
|
1843
|
+
if (domains.length === 0) {
|
|
1844
|
+
return new _Domain([]);
|
|
1845
|
+
}
|
|
1846
|
+
const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
|
|
1847
|
+
if (domains.length === 1) {
|
|
1848
|
+
return domain1;
|
|
1849
|
+
}
|
|
1850
|
+
const domain2 = _Domain.combine(domains.slice(1), operator);
|
|
1851
|
+
const result = new _Domain([]);
|
|
1852
|
+
const astValues1 = domain1.ast.value;
|
|
1853
|
+
const astValues2 = domain2.ast.value;
|
|
1854
|
+
const op = operator === "AND" ? "&" : "|";
|
|
1855
|
+
const combinedAST = {
|
|
1856
|
+
type: 4,
|
|
1857
|
+
value: astValues1.concat(astValues2)
|
|
1858
|
+
};
|
|
1859
|
+
result.ast = normalizeDomainAST(combinedAST, op);
|
|
1860
|
+
return result;
|
|
2073
1861
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
1862
|
+
static and(domains) {
|
|
1863
|
+
return _Domain.combine(domains, "AND");
|
|
2076
1864
|
}
|
|
2077
|
-
|
|
2078
|
-
|
|
1865
|
+
static or(domains) {
|
|
1866
|
+
return _Domain.combine(domains, "OR");
|
|
2079
1867
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
return
|
|
1868
|
+
static not(domain) {
|
|
1869
|
+
const result = new _Domain(domain);
|
|
1870
|
+
result.ast.value.unshift({ type: 1, value: "!" });
|
|
1871
|
+
return result;
|
|
2084
1872
|
}
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
1873
|
+
static removeDomainLeaves(domain, keysToRemove) {
|
|
1874
|
+
function processLeaf(elements, idx, operatorCtx, newDomain2) {
|
|
1875
|
+
const leaf = elements[idx];
|
|
1876
|
+
if (leaf.type === 10) {
|
|
1877
|
+
if (keysToRemove.includes(leaf.value[0].value)) {
|
|
1878
|
+
if (operatorCtx === "&") {
|
|
1879
|
+
newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
|
|
1880
|
+
} else if (operatorCtx === "|") {
|
|
1881
|
+
newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
|
|
1882
|
+
}
|
|
1883
|
+
} else {
|
|
1884
|
+
newDomain2.ast.value.push(leaf);
|
|
1885
|
+
}
|
|
1886
|
+
return 1;
|
|
1887
|
+
} else if (leaf.type === 1) {
|
|
1888
|
+
if (leaf.value === "|" && elements[idx + 1].type === 10 && elements[idx + 2].type === 10 && keysToRemove.includes(elements[idx + 1].value[0].value) && keysToRemove.includes(elements[idx + 2].value[0].value)) {
|
|
1889
|
+
newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
|
|
1890
|
+
return 3;
|
|
1891
|
+
}
|
|
1892
|
+
newDomain2.ast.value.push(leaf);
|
|
1893
|
+
if (leaf.value === "!") {
|
|
1894
|
+
return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
|
|
1895
|
+
}
|
|
1896
|
+
const firstLeafSkip = processLeaf(
|
|
1897
|
+
elements,
|
|
1898
|
+
idx + 1,
|
|
1899
|
+
leaf.value,
|
|
1900
|
+
newDomain2
|
|
1901
|
+
);
|
|
1902
|
+
const secondLeafSkip = processLeaf(
|
|
1903
|
+
elements,
|
|
1904
|
+
idx + 1 + firstLeafSkip,
|
|
1905
|
+
leaf.value,
|
|
1906
|
+
newDomain2
|
|
1907
|
+
);
|
|
1908
|
+
return 1 + firstLeafSkip + secondLeafSkip;
|
|
1909
|
+
}
|
|
1910
|
+
return 0;
|
|
2091
1911
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
1912
|
+
const d = new _Domain(domain);
|
|
1913
|
+
if (d.ast.value.length === 0) {
|
|
1914
|
+
return d;
|
|
2094
1915
|
}
|
|
2095
|
-
|
|
1916
|
+
const newDomain = new _Domain([]);
|
|
1917
|
+
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
1918
|
+
return newDomain;
|
|
2096
1919
|
}
|
|
2097
|
-
|
|
2098
|
-
|
|
1920
|
+
contains(record) {
|
|
1921
|
+
const expr = evaluate(this.ast, record);
|
|
1922
|
+
return matchDomain(record, expr);
|
|
2099
1923
|
}
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
function isIn(left, right) {
|
|
2103
|
-
if (Array.isArray(right)) {
|
|
2104
|
-
return right.includes(left);
|
|
1924
|
+
toString() {
|
|
1925
|
+
return formatAST(this.ast);
|
|
2105
1926
|
}
|
|
2106
|
-
|
|
2107
|
-
return
|
|
1927
|
+
toList(context) {
|
|
1928
|
+
return evaluate(this.ast, context);
|
|
2108
1929
|
}
|
|
2109
|
-
|
|
2110
|
-
|
|
1930
|
+
toJson() {
|
|
1931
|
+
try {
|
|
1932
|
+
const evaluatedAsList = this.toList({});
|
|
1933
|
+
const evaluatedDomain = new _Domain(evaluatedAsList);
|
|
1934
|
+
if (evaluatedDomain.toString() === this.toString()) {
|
|
1935
|
+
return evaluatedAsList;
|
|
1936
|
+
}
|
|
1937
|
+
return this.toString();
|
|
1938
|
+
} catch (e) {
|
|
1939
|
+
return this.toString();
|
|
1940
|
+
}
|
|
2111
1941
|
}
|
|
2112
|
-
|
|
1942
|
+
};
|
|
1943
|
+
var TRUE_LEAF = [1, "=", 1];
|
|
1944
|
+
var FALSE_LEAF = [0, "=", 1];
|
|
1945
|
+
var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
|
|
1946
|
+
var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
|
|
1947
|
+
Domain.TRUE = TRUE_DOMAIN;
|
|
1948
|
+
Domain.FALSE = FALSE_DOMAIN;
|
|
1949
|
+
function toAST(domain) {
|
|
1950
|
+
const elems = domain.map((elem) => {
|
|
1951
|
+
switch (elem) {
|
|
1952
|
+
case "!":
|
|
1953
|
+
case "&":
|
|
1954
|
+
case "|":
|
|
1955
|
+
return { type: 1, value: elem };
|
|
1956
|
+
default:
|
|
1957
|
+
return {
|
|
1958
|
+
type: 10,
|
|
1959
|
+
value: elem.map(toPyValue)
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
});
|
|
1963
|
+
return { type: 4, value: elems };
|
|
2113
1964
|
}
|
|
2114
|
-
function
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
const relativeDeltaOnRight = right instanceof PyRelativeDelta;
|
|
2121
|
-
if (relativeDeltaOnLeft || relativeDeltaOnRight) {
|
|
2122
|
-
const date = relativeDeltaOnLeft ? right : left;
|
|
2123
|
-
const delta = relativeDeltaOnLeft ? left : right;
|
|
2124
|
-
return PyRelativeDelta.add(date, delta);
|
|
2125
|
-
}
|
|
2126
|
-
const timeDeltaOnLeft = left instanceof PyTimeDelta;
|
|
2127
|
-
const timeDeltaOnRight = right instanceof PyTimeDelta;
|
|
2128
|
-
if (timeDeltaOnLeft && timeDeltaOnRight) {
|
|
2129
|
-
return left.add(right);
|
|
2130
|
-
}
|
|
2131
|
-
if (timeDeltaOnLeft) {
|
|
2132
|
-
if (right instanceof PyDate || right instanceof PyDateTime) {
|
|
2133
|
-
return right.add(left);
|
|
2134
|
-
} else {
|
|
2135
|
-
throw new NotSupportedError();
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
if (timeDeltaOnRight) {
|
|
2139
|
-
if (left instanceof PyDate || left instanceof PyDateTime) {
|
|
2140
|
-
return left.add(right);
|
|
2141
|
-
} else {
|
|
2142
|
-
throw new NotSupportedError();
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
if (left instanceof Array && right instanceof Array) {
|
|
2146
|
-
return [...left, ...right];
|
|
1965
|
+
function normalizeDomainAST(domain, op = "&") {
|
|
1966
|
+
if (domain.type !== 4) {
|
|
1967
|
+
if (domain.type === 10) {
|
|
1968
|
+
const value = domain.value;
|
|
1969
|
+
if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
|
|
1970
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2147
1971
|
}
|
|
2148
|
-
|
|
1972
|
+
} else {
|
|
1973
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2149
1974
|
}
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
throw new NotSupportedError();
|
|
1975
|
+
}
|
|
1976
|
+
if (domain.value.length === 0) {
|
|
1977
|
+
return domain;
|
|
1978
|
+
}
|
|
1979
|
+
let expected = 1;
|
|
1980
|
+
for (const child of domain.value) {
|
|
1981
|
+
switch (child.type) {
|
|
1982
|
+
case 1:
|
|
1983
|
+
if (child.value === "&" || child.value === "|") {
|
|
1984
|
+
expected++;
|
|
1985
|
+
} else if (child.value !== "!") {
|
|
1986
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2163
1987
|
}
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
1988
|
+
break;
|
|
1989
|
+
case 4:
|
|
1990
|
+
/* list */
|
|
1991
|
+
case 10:
|
|
1992
|
+
if (child.value.length === 3) {
|
|
1993
|
+
expected--;
|
|
1994
|
+
break;
|
|
1995
|
+
}
|
|
1996
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
1997
|
+
default:
|
|
1998
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2169
1999
|
}
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2000
|
+
}
|
|
2001
|
+
const values = domain.value.slice();
|
|
2002
|
+
while (expected < 0) {
|
|
2003
|
+
expected++;
|
|
2004
|
+
values.unshift({ type: 1, value: op });
|
|
2005
|
+
}
|
|
2006
|
+
if (expected > 0) {
|
|
2007
|
+
throw new InvalidDomainError(
|
|
2008
|
+
`invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
return { type: 4, value: values };
|
|
2012
|
+
}
|
|
2013
|
+
function matchCondition(record, condition) {
|
|
2014
|
+
if (typeof condition === "boolean") {
|
|
2015
|
+
return condition;
|
|
2016
|
+
}
|
|
2017
|
+
const [field, operator, value] = condition;
|
|
2018
|
+
if (typeof field === "string") {
|
|
2019
|
+
const names = field.split(".");
|
|
2020
|
+
if (names.length >= 2) {
|
|
2021
|
+
return matchCondition(record[names[0]], [
|
|
2022
|
+
names.slice(1).join("."),
|
|
2023
|
+
operator,
|
|
2024
|
+
value
|
|
2025
|
+
]);
|
|
2179
2026
|
}
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2027
|
+
}
|
|
2028
|
+
let likeRegexp, ilikeRegexp;
|
|
2029
|
+
if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
|
|
2030
|
+
likeRegexp = new RegExp(
|
|
2031
|
+
`(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
|
|
2032
|
+
"g"
|
|
2033
|
+
);
|
|
2034
|
+
ilikeRegexp = new RegExp(
|
|
2035
|
+
`(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
|
|
2036
|
+
"gi"
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
2039
|
+
const fieldValue = typeof field === "number" ? field : record[field];
|
|
2040
|
+
switch (operator) {
|
|
2041
|
+
case "=?":
|
|
2042
|
+
if ([false, null].includes(value)) {
|
|
2043
|
+
return true;
|
|
2187
2044
|
}
|
|
2188
|
-
|
|
2189
|
-
case "
|
|
2190
|
-
return left ** right;
|
|
2045
|
+
// eslint-disable-next-line no-fallthrough
|
|
2046
|
+
case "=":
|
|
2191
2047
|
case "==":
|
|
2192
|
-
|
|
2193
|
-
|
|
2048
|
+
if (Array.isArray(fieldValue) && Array.isArray(value)) {
|
|
2049
|
+
return shallowEqual2(fieldValue, value);
|
|
2050
|
+
}
|
|
2051
|
+
return fieldValue === value;
|
|
2194
2052
|
case "!=":
|
|
2195
|
-
|
|
2053
|
+
case "<>":
|
|
2054
|
+
return !matchCondition(record, [field, "==", value]);
|
|
2196
2055
|
case "<":
|
|
2197
|
-
return
|
|
2056
|
+
return fieldValue < value;
|
|
2057
|
+
case "<=":
|
|
2058
|
+
return fieldValue <= value;
|
|
2198
2059
|
case ">":
|
|
2199
|
-
return
|
|
2060
|
+
return fieldValue > value;
|
|
2200
2061
|
case ">=":
|
|
2201
|
-
return
|
|
2202
|
-
case "
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
return
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2062
|
+
return fieldValue >= value;
|
|
2063
|
+
case "in": {
|
|
2064
|
+
const val = Array.isArray(value) ? value : [value];
|
|
2065
|
+
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2066
|
+
return fieldVal.some((fv) => val.includes(fv));
|
|
2067
|
+
}
|
|
2068
|
+
case "not in": {
|
|
2069
|
+
const val = Array.isArray(value) ? value : [value];
|
|
2070
|
+
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2071
|
+
return !fieldVal.some((fv) => val.includes(fv));
|
|
2072
|
+
}
|
|
2073
|
+
case "like":
|
|
2074
|
+
if (fieldValue === false) {
|
|
2075
|
+
return false;
|
|
2076
|
+
}
|
|
2077
|
+
return Boolean(fieldValue.match(likeRegexp));
|
|
2078
|
+
case "not like":
|
|
2079
|
+
if (fieldValue === false) {
|
|
2080
|
+
return false;
|
|
2081
|
+
}
|
|
2082
|
+
return Boolean(!fieldValue.match(likeRegexp));
|
|
2083
|
+
case "=like":
|
|
2084
|
+
if (fieldValue === false) {
|
|
2085
|
+
return false;
|
|
2086
|
+
}
|
|
2087
|
+
return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
|
|
2088
|
+
fieldValue
|
|
2089
|
+
);
|
|
2090
|
+
case "ilike":
|
|
2091
|
+
if (fieldValue === false) {
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
return Boolean(fieldValue.match(ilikeRegexp));
|
|
2095
|
+
case "not ilike":
|
|
2096
|
+
if (fieldValue === false) {
|
|
2097
|
+
return false;
|
|
2098
|
+
}
|
|
2099
|
+
return Boolean(!fieldValue.match(ilikeRegexp));
|
|
2100
|
+
case "=ilike":
|
|
2101
|
+
if (fieldValue === false) {
|
|
2102
|
+
return false;
|
|
2103
|
+
}
|
|
2104
|
+
return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
|
|
2105
|
+
fieldValue
|
|
2106
|
+
);
|
|
2210
2107
|
}
|
|
2108
|
+
throw new InvalidDomainError("could not match domain");
|
|
2211
2109
|
}
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2110
|
+
function makeOperators(record) {
|
|
2111
|
+
const match = matchCondition.bind(null, record);
|
|
2112
|
+
return {
|
|
2113
|
+
"!": (x) => !match(x),
|
|
2114
|
+
"&": (a, b) => match(a) && match(b),
|
|
2115
|
+
"|": (a, b) => match(a) || match(b)
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
function matchDomain(record, domain) {
|
|
2119
|
+
if (domain.length === 0) {
|
|
2120
|
+
return true;
|
|
2222
2121
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2122
|
+
const operators = makeOperators(record);
|
|
2123
|
+
const reversedDomain = Array.from(domain).reverse();
|
|
2124
|
+
const condStack = [];
|
|
2125
|
+
for (const item of reversedDomain) {
|
|
2126
|
+
const operator = typeof item === "string" && operators[item];
|
|
2127
|
+
if (operator) {
|
|
2128
|
+
const operands = condStack.splice(-operator.length);
|
|
2129
|
+
condStack.push(operator(...operands));
|
|
2130
|
+
} else {
|
|
2131
|
+
condStack.push(item);
|
|
2132
|
+
}
|
|
2230
2133
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2134
|
+
return matchCondition(record, condStack.pop());
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
// src/utils/function.ts
|
|
2138
|
+
import { useEffect, useState } from "react";
|
|
2139
|
+
var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
|
|
2140
|
+
if (!originalRequest.data) return originalRequest.data;
|
|
2141
|
+
if (typeof originalRequest.data === "string") {
|
|
2142
|
+
try {
|
|
2143
|
+
const parsedData = JSON.parse(originalRequest.data);
|
|
2144
|
+
if (parsedData.with_context && typeof parsedData.with_context === "object") {
|
|
2145
|
+
parsedData.with_context.token = newAccessToken;
|
|
2146
|
+
}
|
|
2147
|
+
return JSON.stringify(parsedData);
|
|
2148
|
+
} catch (e) {
|
|
2149
|
+
console.warn("Failed to parse originalRequest.data", e);
|
|
2150
|
+
return originalRequest.data;
|
|
2151
|
+
}
|
|
2235
2152
|
}
|
|
2236
|
-
if (
|
|
2237
|
-
|
|
2238
|
-
`${key}: py_js supports at most 1 argument, got (${args.length - 1})`
|
|
2239
|
-
);
|
|
2153
|
+
if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
|
|
2154
|
+
originalRequest.data.with_context.token = newAccessToken;
|
|
2240
2155
|
}
|
|
2241
|
-
return
|
|
2242
|
-
}
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2156
|
+
return originalRequest.data;
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
// src/utils/storage/local-storage.ts
|
|
2160
|
+
var localStorageUtils = () => {
|
|
2161
|
+
const setToken = (access_token) => __async(null, null, function* () {
|
|
2162
|
+
localStorage.setItem("accessToken", access_token);
|
|
2163
|
+
});
|
|
2164
|
+
const setRefreshToken = (refresh_token) => __async(null, null, function* () {
|
|
2165
|
+
localStorage.setItem("refreshToken", refresh_token);
|
|
2166
|
+
});
|
|
2167
|
+
const getAccessToken = () => __async(null, null, function* () {
|
|
2168
|
+
return localStorage.getItem("accessToken");
|
|
2169
|
+
});
|
|
2170
|
+
const getRefreshToken = () => __async(null, null, function* () {
|
|
2171
|
+
return localStorage.getItem("refreshToken");
|
|
2172
|
+
});
|
|
2173
|
+
const clearToken = () => __async(null, null, function* () {
|
|
2174
|
+
localStorage.removeItem("accessToken");
|
|
2175
|
+
localStorage.removeItem("refreshToken");
|
|
2176
|
+
});
|
|
2177
|
+
return {
|
|
2178
|
+
setToken,
|
|
2179
|
+
setRefreshToken,
|
|
2180
|
+
getAccessToken,
|
|
2181
|
+
getRefreshToken,
|
|
2182
|
+
clearToken
|
|
2183
|
+
};
|
|
2184
|
+
};
|
|
2185
|
+
|
|
2186
|
+
// src/utils/storage/session-storage.ts
|
|
2187
|
+
var sessionStorageUtils = () => {
|
|
2188
|
+
const getBrowserSession = () => __async(null, null, function* () {
|
|
2189
|
+
return sessionStorage.getItem("browserSession");
|
|
2190
|
+
});
|
|
2191
|
+
return {
|
|
2192
|
+
getBrowserSession
|
|
2193
|
+
};
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2196
|
+
// src/configs/axios-client.ts
|
|
2197
|
+
var axiosClient = {
|
|
2198
|
+
init(config) {
|
|
2199
|
+
var _a, _b;
|
|
2200
|
+
const localStorage2 = (_a = config.localStorageUtils) != null ? _a : localStorageUtils();
|
|
2201
|
+
const sessionStorage2 = (_b = config.sessionStorageUtils) != null ? _b : sessionStorageUtils();
|
|
2202
|
+
const db = config.db;
|
|
2203
|
+
let isRefreshing = false;
|
|
2204
|
+
let failedQueue = [];
|
|
2205
|
+
const processQueue = (error, token = null) => {
|
|
2206
|
+
failedQueue == null ? void 0 : failedQueue.forEach((prom) => {
|
|
2207
|
+
if (error) {
|
|
2208
|
+
prom.reject(error);
|
|
2209
|
+
} else {
|
|
2210
|
+
prom.resolve(token);
|
|
2253
2211
|
}
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
const
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
}
|
|
2212
|
+
});
|
|
2213
|
+
failedQueue = [];
|
|
2214
|
+
};
|
|
2215
|
+
const instance = axios.create({
|
|
2216
|
+
adapter: axios.defaults.adapter,
|
|
2217
|
+
baseURL: config.baseUrl,
|
|
2218
|
+
timeout: 5e4,
|
|
2219
|
+
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
2220
|
+
});
|
|
2221
|
+
instance.interceptors.request.use(
|
|
2222
|
+
(config2) => __async(null, null, function* () {
|
|
2223
|
+
const useRefreshToken = config2.useRefreshToken;
|
|
2224
|
+
const token = useRefreshToken ? yield localStorage2.getRefreshToken() : yield localStorage2.getAccessToken();
|
|
2225
|
+
if (token) {
|
|
2226
|
+
config2.headers["Authorization"] = "Bearer " + token;
|
|
2270
2227
|
}
|
|
2271
|
-
return
|
|
2272
|
-
},
|
|
2273
|
-
|
|
2274
|
-
|
|
2228
|
+
return config2;
|
|
2229
|
+
}),
|
|
2230
|
+
(error) => {
|
|
2231
|
+
Promise.reject(error);
|
|
2232
|
+
}
|
|
2275
2233
|
);
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
"union",
|
|
2280
|
-
(iterable) => {
|
|
2281
|
-
return /* @__PURE__ */ new Set([...this, ...iterable]);
|
|
2234
|
+
instance.interceptors.response.use(
|
|
2235
|
+
(response) => {
|
|
2236
|
+
return handleResponse(response);
|
|
2282
2237
|
},
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2238
|
+
(error) => __async(null, null, function* () {
|
|
2239
|
+
var _a2, _b2, _c;
|
|
2240
|
+
const handleError3 = (error2) => __async(null, null, function* () {
|
|
2241
|
+
var _a3;
|
|
2242
|
+
if (!error2.response) {
|
|
2243
|
+
return error2;
|
|
2244
|
+
}
|
|
2245
|
+
const { data } = error2.response;
|
|
2246
|
+
if (data && data.code === 400 && ["invalid_grant"].includes((_a3 = data.data) == null ? void 0 : _a3.error)) {
|
|
2247
|
+
yield clearAuthToken();
|
|
2248
|
+
}
|
|
2249
|
+
return data;
|
|
2250
|
+
});
|
|
2251
|
+
const originalRequest = error.config;
|
|
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(
|
|
2253
|
+
error.response.data.code
|
|
2254
|
+
)) {
|
|
2255
|
+
if (isRefreshing) {
|
|
2256
|
+
return new Promise(function(resolve, reject) {
|
|
2257
|
+
failedQueue.push({ resolve, reject });
|
|
2258
|
+
}).then((token) => {
|
|
2259
|
+
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
2260
|
+
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2261
|
+
originalRequest,
|
|
2262
|
+
token
|
|
2263
|
+
);
|
|
2264
|
+
return instance.request(originalRequest);
|
|
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();
|
|
2269
|
+
}
|
|
2270
|
+
}));
|
|
2271
|
+
}
|
|
2272
|
+
const browserSession = yield sessionStorage2.getBrowserSession();
|
|
2273
|
+
const refreshToken = yield localStorage2.getRefreshToken();
|
|
2274
|
+
const accessTokenExp = yield localStorage2.getAccessToken();
|
|
2275
|
+
isRefreshing = true;
|
|
2276
|
+
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
2277
|
+
yield clearAuthToken();
|
|
2278
|
+
} else {
|
|
2279
|
+
const payload = Object.fromEntries(
|
|
2280
|
+
Object.entries({
|
|
2281
|
+
refresh_token: refreshToken,
|
|
2282
|
+
grant_type: "refresh_token",
|
|
2283
|
+
client_id: config.config.clientId,
|
|
2284
|
+
client_secret: config.config.clientSecret
|
|
2285
|
+
}).filter(([_, value]) => !!value)
|
|
2286
|
+
);
|
|
2287
|
+
return new Promise(function(resolve) {
|
|
2288
|
+
var _a3;
|
|
2289
|
+
axios.post(
|
|
2290
|
+
`${config.baseUrl}${(_a3 = config.refreshTokenEndpoint) != null ? _a3 : "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2291
|
+
payload,
|
|
2292
|
+
{
|
|
2293
|
+
headers: {
|
|
2294
|
+
"Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
|
|
2295
|
+
Authorization: `Bearer ${accessTokenExp}`
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
).then((res) => __async(null, null, function* () {
|
|
2299
|
+
const data = res.data;
|
|
2300
|
+
yield localStorage2.setToken(data.access_token);
|
|
2301
|
+
yield localStorage2.setRefreshToken(data.refresh_token);
|
|
2302
|
+
axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2303
|
+
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2304
|
+
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2305
|
+
originalRequest,
|
|
2306
|
+
data.access_token
|
|
2307
|
+
);
|
|
2308
|
+
processQueue(null, data.access_token);
|
|
2309
|
+
resolve(instance.request(originalRequest));
|
|
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();
|
|
2314
|
+
}
|
|
2315
|
+
if (err && err.response) {
|
|
2316
|
+
const { error_code } = ((_a4 = err.response) == null ? void 0 : _a4.data) || {};
|
|
2317
|
+
if (error_code === "AUTHEN_FAIL") {
|
|
2318
|
+
yield clearAuthToken();
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
processQueue(err, null);
|
|
2322
|
+
})).finally(() => {
|
|
2323
|
+
isRefreshing = false;
|
|
2324
|
+
});
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2317
2327
|
}
|
|
2318
|
-
return
|
|
2328
|
+
return Promise.reject(yield handleError3(error));
|
|
2329
|
+
})
|
|
2330
|
+
);
|
|
2331
|
+
const handleResponse = (res) => {
|
|
2332
|
+
if (res && res.data) {
|
|
2333
|
+
return res.data;
|
|
2334
|
+
}
|
|
2335
|
+
return res;
|
|
2336
|
+
};
|
|
2337
|
+
const handleError2 = (error) => {
|
|
2338
|
+
var _a2, _b2, _c;
|
|
2339
|
+
if (error.isAxiosError && error.code === "ECONNABORTED") {
|
|
2340
|
+
console.error("Request Timeout Error:", error);
|
|
2341
|
+
return "Request Timeout Error";
|
|
2342
|
+
} else if (error.isAxiosError && !error.response) {
|
|
2343
|
+
console.error("Network Error:", error);
|
|
2344
|
+
return "Network Error";
|
|
2345
|
+
} else {
|
|
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 };
|
|
2349
|
+
}
|
|
2350
|
+
};
|
|
2351
|
+
const clearAuthToken = () => __async(null, null, function* () {
|
|
2352
|
+
yield localStorage2.clearToken();
|
|
2353
|
+
if (typeof window !== "undefined") {
|
|
2354
|
+
window.location.href = `/login`;
|
|
2319
2355
|
}
|
|
2320
2356
|
});
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
switch (ast2?.type) {
|
|
2324
|
-
case 0:
|
|
2325
|
-
// Number
|
|
2326
|
-
case 1:
|
|
2327
|
-
return ast2.value;
|
|
2328
|
-
case 5:
|
|
2329
|
-
if (ast2.value in evalContext) {
|
|
2330
|
-
if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id) {
|
|
2331
|
-
return evalContext[ast2.value]?.id;
|
|
2332
|
-
}
|
|
2333
|
-
return evalContext[ast2.value] ?? false;
|
|
2334
|
-
} else if (ast2.value in BUILTINS) {
|
|
2335
|
-
return BUILTINS[ast2.value];
|
|
2336
|
-
} else {
|
|
2337
|
-
return false;
|
|
2338
|
-
}
|
|
2339
|
-
case 3:
|
|
2340
|
-
return null;
|
|
2341
|
-
case 2:
|
|
2342
|
-
return ast2.value;
|
|
2343
|
-
case 6:
|
|
2344
|
-
return applyUnaryOp(ast2, evalContext);
|
|
2345
|
-
case 7:
|
|
2346
|
-
return applyBinaryOp(ast2, evalContext);
|
|
2347
|
-
case 14:
|
|
2348
|
-
const left = _evaluate(ast2.left);
|
|
2349
|
-
if (ast2.op === "and") {
|
|
2350
|
-
return isTrue(left) ? _evaluate(ast2.right) : left;
|
|
2351
|
-
} else {
|
|
2352
|
-
return isTrue(left) ? left : _evaluate(ast2.right);
|
|
2353
|
-
}
|
|
2354
|
-
case 4:
|
|
2355
|
-
// List
|
|
2356
|
-
case 10:
|
|
2357
|
-
return ast2.value.map(_evaluate);
|
|
2358
|
-
case 11:
|
|
2359
|
-
const dict = {};
|
|
2360
|
-
for (const key2 in ast2.value) {
|
|
2361
|
-
dict[key2] = _evaluate(ast2.value[key2]);
|
|
2362
|
-
}
|
|
2363
|
-
dicts.add(dict);
|
|
2364
|
-
return dict;
|
|
2365
|
-
case 8:
|
|
2366
|
-
const fnValue = _evaluate(ast2.fn);
|
|
2367
|
-
const args = ast2.args.map(_evaluate);
|
|
2368
|
-
const kwargs = {};
|
|
2369
|
-
for (const kwarg in ast2.kwargs) {
|
|
2370
|
-
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
2371
|
-
}
|
|
2372
|
-
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
2373
|
-
return fnValue.create(...args, kwargs);
|
|
2374
|
-
}
|
|
2375
|
-
return fnValue(...args, kwargs);
|
|
2376
|
-
case 12:
|
|
2377
|
-
const dictVal = _evaluate(ast2.target);
|
|
2378
|
-
const key = _evaluate(ast2.key);
|
|
2379
|
-
return dictVal[key];
|
|
2380
|
-
case 13:
|
|
2381
|
-
if (isTrue(_evaluate(ast2.condition))) {
|
|
2382
|
-
return _evaluate(ast2.ifTrue);
|
|
2383
|
-
} else {
|
|
2384
|
-
return _evaluate(ast2.ifFalse);
|
|
2385
|
-
}
|
|
2386
|
-
case 15:
|
|
2387
|
-
let leftVal = _evaluate(ast2.obj);
|
|
2388
|
-
let result;
|
|
2389
|
-
if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
|
|
2390
|
-
result = DICT[ast2.key];
|
|
2391
|
-
} else if (typeof leftVal === "string") {
|
|
2392
|
-
result = STRING[ast2.key];
|
|
2393
|
-
} else if (leftVal instanceof Set) {
|
|
2394
|
-
result = SET[ast2.key];
|
|
2395
|
-
} else if (ast2.key === "get" && typeof leftVal === "object") {
|
|
2396
|
-
result = DICT[ast2.key];
|
|
2397
|
-
leftVal = toPyDict(leftVal);
|
|
2398
|
-
} else {
|
|
2399
|
-
result = leftVal[ast2.key];
|
|
2400
|
-
}
|
|
2401
|
-
if (typeof result === "function") {
|
|
2402
|
-
const bound = result.bind(leftVal);
|
|
2403
|
-
bound[unboundFn] = result;
|
|
2404
|
-
return bound;
|
|
2405
|
-
}
|
|
2406
|
-
return result;
|
|
2407
|
-
default:
|
|
2408
|
-
throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2411
|
-
function _evaluate(ast2) {
|
|
2412
|
-
const val = _innerEvaluate(ast2);
|
|
2413
|
-
if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
|
|
2414
|
-
throw new Error("Invalid Function Call");
|
|
2357
|
+
function formatUrl(url, db2) {
|
|
2358
|
+
return url + (db2 ? "?db=" + db2 : "");
|
|
2415
2359
|
}
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2360
|
+
const responseBody = (response) => response;
|
|
2361
|
+
const requests = {
|
|
2362
|
+
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
|
2363
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
|
2364
|
+
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
2365
|
+
responseType: "arraybuffer",
|
|
2366
|
+
headers: {
|
|
2367
|
+
"Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
|
|
2368
|
+
Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
2369
|
+
}
|
|
2370
|
+
}).then(responseBody),
|
|
2371
|
+
put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
|
|
2372
|
+
patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
|
|
2373
|
+
delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
|
|
2374
|
+
};
|
|
2375
|
+
return requests;
|
|
2431
2376
|
}
|
|
2432
|
-
|
|
2433
|
-
return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
// src/utils/domain/arrays.ts
|
|
2437
|
-
var shallowEqual2 = shallowEqual;
|
|
2377
|
+
};
|
|
2438
2378
|
|
|
2439
|
-
// src/
|
|
2440
|
-
|
|
2441
|
-
function escapeRegExp(str) {
|
|
2442
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2443
|
-
}
|
|
2379
|
+
// src/store/index.ts
|
|
2380
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
2444
2381
|
|
|
2445
|
-
// src/
|
|
2446
|
-
|
|
2382
|
+
// src/store/reducers/breadcrums-slice/index.ts
|
|
2383
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2384
|
+
var initialState = {
|
|
2385
|
+
breadCrumbs: []
|
|
2447
2386
|
};
|
|
2448
|
-
var
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
return new _Domain([]);
|
|
2455
|
-
}
|
|
2456
|
-
const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
|
|
2457
|
-
if (domains.length === 1) {
|
|
2458
|
-
return domain1;
|
|
2387
|
+
var breadcrumbsSlice = createSlice({
|
|
2388
|
+
name: "breadcrumbs",
|
|
2389
|
+
initialState,
|
|
2390
|
+
reducers: {
|
|
2391
|
+
setBreadCrumbs: (state, action) => {
|
|
2392
|
+
state.breadCrumbs = [...state.breadCrumbs, action.payload];
|
|
2459
2393
|
}
|
|
2460
|
-
const domain2 = _Domain.combine(domains.slice(1), operator);
|
|
2461
|
-
const result = new _Domain([]);
|
|
2462
|
-
const astValues1 = domain1.ast.value;
|
|
2463
|
-
const astValues2 = domain2.ast.value;
|
|
2464
|
-
const op = operator === "AND" ? "&" : "|";
|
|
2465
|
-
const combinedAST = {
|
|
2466
|
-
type: 4,
|
|
2467
|
-
value: astValues1.concat(astValues2)
|
|
2468
|
-
};
|
|
2469
|
-
result.ast = normalizeDomainAST(combinedAST, op);
|
|
2470
|
-
return result;
|
|
2471
|
-
}
|
|
2472
|
-
static and(domains) {
|
|
2473
|
-
return _Domain.combine(domains, "AND");
|
|
2474
2394
|
}
|
|
2475
|
-
|
|
2476
|
-
|
|
2395
|
+
});
|
|
2396
|
+
var { setBreadCrumbs } = breadcrumbsSlice.actions;
|
|
2397
|
+
var breadcrums_slice_default = breadcrumbsSlice.reducer;
|
|
2398
|
+
|
|
2399
|
+
// src/store/reducers/env-slice/index.ts
|
|
2400
|
+
import { createSlice as createSlice2 } from "@reduxjs/toolkit";
|
|
2401
|
+
var initialState2 = {
|
|
2402
|
+
baseUrl: "",
|
|
2403
|
+
requests: null,
|
|
2404
|
+
companies: [],
|
|
2405
|
+
user: {},
|
|
2406
|
+
config: null,
|
|
2407
|
+
envFile: null,
|
|
2408
|
+
defaultCompany: {
|
|
2409
|
+
id: null,
|
|
2410
|
+
logo: "",
|
|
2411
|
+
secondary_color: "",
|
|
2412
|
+
primary_color: ""
|
|
2413
|
+
},
|
|
2414
|
+
context: {
|
|
2415
|
+
uid: null,
|
|
2416
|
+
allowed_company_ids: [],
|
|
2417
|
+
lang: "vi_VN",
|
|
2418
|
+
tz: "Asia/Saigon"
|
|
2477
2419
|
}
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2420
|
+
};
|
|
2421
|
+
var envSlice = createSlice2({
|
|
2422
|
+
name: "env",
|
|
2423
|
+
initialState: initialState2,
|
|
2424
|
+
reducers: {
|
|
2425
|
+
setEnv: (state, action) => {
|
|
2426
|
+
Object.assign(state, action.payload);
|
|
2427
|
+
},
|
|
2428
|
+
setUid: (state, action) => {
|
|
2429
|
+
state.context.uid = action.payload;
|
|
2430
|
+
},
|
|
2431
|
+
setAllowCompanies: (state, action) => {
|
|
2432
|
+
state.context.allowed_company_ids = action.payload;
|
|
2433
|
+
},
|
|
2434
|
+
setCompanies: (state, action) => {
|
|
2435
|
+
state.companies = action.payload;
|
|
2436
|
+
},
|
|
2437
|
+
setDefaultCompany: (state, action) => {
|
|
2438
|
+
state.defaultCompany = action.payload;
|
|
2439
|
+
},
|
|
2440
|
+
setLang: (state, action) => {
|
|
2441
|
+
state.context.lang = action.payload;
|
|
2442
|
+
},
|
|
2443
|
+
setUser: (state, action) => {
|
|
2444
|
+
state.user = action.payload;
|
|
2445
|
+
},
|
|
2446
|
+
setConfig: (state, action) => {
|
|
2447
|
+
state.config = action.payload;
|
|
2448
|
+
},
|
|
2449
|
+
setEnvFile: (state, action) => {
|
|
2450
|
+
state.envFile = action.payload;
|
|
2451
|
+
}
|
|
2482
2452
|
}
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2453
|
+
});
|
|
2454
|
+
var {
|
|
2455
|
+
setEnv,
|
|
2456
|
+
setUid,
|
|
2457
|
+
setLang,
|
|
2458
|
+
setAllowCompanies,
|
|
2459
|
+
setCompanies,
|
|
2460
|
+
setDefaultCompany,
|
|
2461
|
+
setUser,
|
|
2462
|
+
setConfig,
|
|
2463
|
+
setEnvFile
|
|
2464
|
+
} = envSlice.actions;
|
|
2465
|
+
var env_slice_default = envSlice.reducer;
|
|
2466
|
+
|
|
2467
|
+
// src/store/reducers/excel-slice/index.ts
|
|
2468
|
+
import { createSlice as createSlice3 } from "@reduxjs/toolkit";
|
|
2469
|
+
var initialState3 = {
|
|
2470
|
+
dataParse: null,
|
|
2471
|
+
idFile: null,
|
|
2472
|
+
isFileLoaded: false,
|
|
2473
|
+
loadingImport: false,
|
|
2474
|
+
selectedFile: null,
|
|
2475
|
+
errorData: null
|
|
2476
|
+
};
|
|
2477
|
+
var excelSlice = createSlice3({
|
|
2478
|
+
name: "excel",
|
|
2479
|
+
initialState: initialState3,
|
|
2480
|
+
reducers: {
|
|
2481
|
+
setDataParse: (state, action) => {
|
|
2482
|
+
state.dataParse = action.payload;
|
|
2483
|
+
},
|
|
2484
|
+
setIdFile: (state, action) => {
|
|
2485
|
+
state.idFile = action.payload;
|
|
2486
|
+
},
|
|
2487
|
+
setIsFileLoaded: (state, action) => {
|
|
2488
|
+
state.isFileLoaded = action.payload;
|
|
2489
|
+
},
|
|
2490
|
+
setLoadingImport: (state, action) => {
|
|
2491
|
+
state.loadingImport = action.payload;
|
|
2492
|
+
},
|
|
2493
|
+
setSelectedFile: (state, action) => {
|
|
2494
|
+
state.selectedFile = action.payload;
|
|
2495
|
+
},
|
|
2496
|
+
setErrorData: (state, action) => {
|
|
2497
|
+
state.errorData = action.payload;
|
|
2521
2498
|
}
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2501
|
+
var {
|
|
2502
|
+
setDataParse,
|
|
2503
|
+
setIdFile,
|
|
2504
|
+
setIsFileLoaded,
|
|
2505
|
+
setLoadingImport,
|
|
2506
|
+
setSelectedFile,
|
|
2507
|
+
setErrorData
|
|
2508
|
+
} = excelSlice.actions;
|
|
2509
|
+
var excel_slice_default = excelSlice.reducer;
|
|
2510
|
+
|
|
2511
|
+
// src/store/reducers/form-slice/index.ts
|
|
2512
|
+
import { createSlice as createSlice4 } from "@reduxjs/toolkit";
|
|
2513
|
+
var initialState4 = {
|
|
2514
|
+
viewDataStore: {},
|
|
2515
|
+
isShowingModalDetail: false,
|
|
2516
|
+
isShowModalTranslate: false,
|
|
2517
|
+
formSubmitComponent: {},
|
|
2518
|
+
fieldTranslation: null,
|
|
2519
|
+
listSubject: {},
|
|
2520
|
+
dataUser: {}
|
|
2521
|
+
};
|
|
2522
|
+
var formSlice = createSlice4({
|
|
2523
|
+
name: "form",
|
|
2524
|
+
initialState: initialState4,
|
|
2525
|
+
reducers: {
|
|
2526
|
+
setViewDataStore: (state, action) => {
|
|
2527
|
+
state.viewDataStore = action.payload;
|
|
2528
|
+
},
|
|
2529
|
+
setIsShowingModalDetail: (state, action) => {
|
|
2530
|
+
state.isShowingModalDetail = action.payload;
|
|
2531
|
+
},
|
|
2532
|
+
setIsShowModalTranslate: (state, action) => {
|
|
2533
|
+
state.isShowModalTranslate = action.payload;
|
|
2534
|
+
},
|
|
2535
|
+
setFormSubmitComponent: (state, action) => {
|
|
2536
|
+
state.formSubmitComponent[action.payload.key] = action.payload.component;
|
|
2537
|
+
},
|
|
2538
|
+
setFieldTranslate: (state, action) => {
|
|
2539
|
+
state.fieldTranslation = action.payload;
|
|
2540
|
+
},
|
|
2541
|
+
setListSubject: (state, action) => {
|
|
2542
|
+
state.listSubject = action.payload;
|
|
2543
|
+
},
|
|
2544
|
+
setDataUser: (state, action) => {
|
|
2545
|
+
state.dataUser = action.payload;
|
|
2525
2546
|
}
|
|
2526
|
-
const newDomain = new _Domain([]);
|
|
2527
|
-
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
2528
|
-
return newDomain;
|
|
2529
2547
|
}
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2548
|
+
});
|
|
2549
|
+
var {
|
|
2550
|
+
setViewDataStore,
|
|
2551
|
+
setIsShowingModalDetail,
|
|
2552
|
+
setIsShowModalTranslate,
|
|
2553
|
+
setFormSubmitComponent,
|
|
2554
|
+
setFieldTranslate,
|
|
2555
|
+
setListSubject,
|
|
2556
|
+
setDataUser
|
|
2557
|
+
} = formSlice.actions;
|
|
2558
|
+
var form_slice_default = formSlice.reducer;
|
|
2559
|
+
|
|
2560
|
+
// src/store/reducers/header-slice/index.ts
|
|
2561
|
+
import { createSlice as createSlice5 } from "@reduxjs/toolkit";
|
|
2562
|
+
var headerSlice = createSlice5({
|
|
2563
|
+
name: "header",
|
|
2564
|
+
initialState: {
|
|
2565
|
+
value: { allowedCompanyIds: [] }
|
|
2566
|
+
},
|
|
2567
|
+
reducers: {
|
|
2568
|
+
setHeader: (state, action) => {
|
|
2569
|
+
state.value = __spreadValues(__spreadValues({}, state.value), action.payload);
|
|
2570
|
+
},
|
|
2571
|
+
setAllowedCompanyIds: (state, action) => {
|
|
2572
|
+
state.value.allowedCompanyIds = action.payload;
|
|
2546
2573
|
}
|
|
2547
2574
|
}
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2575
|
+
});
|
|
2576
|
+
var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
|
|
2577
|
+
var header_slice_default = headerSlice.reducer;
|
|
2578
|
+
|
|
2579
|
+
// src/store/reducers/list-slice/index.ts
|
|
2580
|
+
import { createSlice as createSlice6 } from "@reduxjs/toolkit";
|
|
2581
|
+
var initialState5 = {
|
|
2582
|
+
pageLimit: 10,
|
|
2583
|
+
fields: {},
|
|
2584
|
+
order: "",
|
|
2585
|
+
selectedRowKeys: [],
|
|
2586
|
+
selectedRadioKey: 0,
|
|
2587
|
+
indexRowTableModal: -2,
|
|
2588
|
+
isUpdateTableModal: false,
|
|
2589
|
+
footerGroupTable: {},
|
|
2590
|
+
transferDetail: null,
|
|
2591
|
+
page: 0,
|
|
2592
|
+
domainTable: []
|
|
2593
|
+
};
|
|
2594
|
+
var listSlice = createSlice6({
|
|
2595
|
+
name: "list",
|
|
2596
|
+
initialState: initialState5,
|
|
2597
|
+
reducers: {
|
|
2598
|
+
setPageLimit: (state, action) => {
|
|
2599
|
+
state.pageLimit = action.payload;
|
|
2600
|
+
},
|
|
2601
|
+
setFields: (state, action) => {
|
|
2602
|
+
state.fields = action.payload;
|
|
2603
|
+
},
|
|
2604
|
+
setOrder: (state, action) => {
|
|
2605
|
+
state.order = action.payload;
|
|
2606
|
+
},
|
|
2607
|
+
setSelectedRowKeys: (state, action) => {
|
|
2608
|
+
state.selectedRowKeys = action.payload;
|
|
2609
|
+
},
|
|
2610
|
+
setSelectedRadioKey: (state, action) => {
|
|
2611
|
+
state.selectedRadioKey = action.payload;
|
|
2612
|
+
},
|
|
2613
|
+
setIndexRowTableModal: (state, action) => {
|
|
2614
|
+
state.indexRowTableModal = action.payload;
|
|
2615
|
+
},
|
|
2616
|
+
setTransferDetail: (state, action) => {
|
|
2617
|
+
state.transferDetail = action.payload;
|
|
2618
|
+
},
|
|
2619
|
+
setIsUpdateTableModal: (state, action) => {
|
|
2620
|
+
state.isUpdateTableModal = action.payload;
|
|
2621
|
+
},
|
|
2622
|
+
setPage: (state, action) => {
|
|
2623
|
+
state.page = action.payload;
|
|
2624
|
+
},
|
|
2625
|
+
setDomainTable: (state, action) => {
|
|
2626
|
+
state.domainTable = action.payload;
|
|
2568
2627
|
}
|
|
2569
2628
|
}
|
|
2629
|
+
});
|
|
2630
|
+
var {
|
|
2631
|
+
setPageLimit,
|
|
2632
|
+
setFields,
|
|
2633
|
+
setOrder,
|
|
2634
|
+
setSelectedRowKeys,
|
|
2635
|
+
setIndexRowTableModal,
|
|
2636
|
+
setIsUpdateTableModal,
|
|
2637
|
+
setPage,
|
|
2638
|
+
setSelectedRadioKey,
|
|
2639
|
+
setTransferDetail,
|
|
2640
|
+
setDomainTable
|
|
2641
|
+
} = listSlice.actions;
|
|
2642
|
+
var list_slice_default = listSlice.reducer;
|
|
2643
|
+
|
|
2644
|
+
// src/store/reducers/login-slice/index.ts
|
|
2645
|
+
import { createSlice as createSlice7 } from "@reduxjs/toolkit";
|
|
2646
|
+
var initialState6 = {
|
|
2647
|
+
db: "",
|
|
2648
|
+
redirectTo: "/",
|
|
2649
|
+
forgotPasswordUrl: "/"
|
|
2570
2650
|
};
|
|
2571
|
-
var
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
return { type: 1, value: elem };
|
|
2584
|
-
default:
|
|
2585
|
-
return {
|
|
2586
|
-
type: 10,
|
|
2587
|
-
value: elem.map(toPyValue)
|
|
2588
|
-
};
|
|
2651
|
+
var loginSlice = createSlice7({
|
|
2652
|
+
name: "login",
|
|
2653
|
+
initialState: initialState6,
|
|
2654
|
+
reducers: {
|
|
2655
|
+
setDb: (state, action) => {
|
|
2656
|
+
state.db = action.payload;
|
|
2657
|
+
},
|
|
2658
|
+
setRedirectTo: (state, action) => {
|
|
2659
|
+
state.redirectTo = action.payload;
|
|
2660
|
+
},
|
|
2661
|
+
setForgotPasswordUrl: (state, action) => {
|
|
2662
|
+
state.forgotPasswordUrl = action.payload;
|
|
2589
2663
|
}
|
|
2590
|
-
}
|
|
2591
|
-
|
|
2592
|
-
}
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2664
|
+
}
|
|
2665
|
+
});
|
|
2666
|
+
var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
|
|
2667
|
+
var login_slice_default = loginSlice.reducer;
|
|
2668
|
+
|
|
2669
|
+
// src/store/reducers/navbar-slice/index.ts
|
|
2670
|
+
import { createSlice as createSlice8 } from "@reduxjs/toolkit";
|
|
2671
|
+
var initialState7 = {
|
|
2672
|
+
menuFocus: {},
|
|
2673
|
+
menuAction: {},
|
|
2674
|
+
navbarWidth: 250,
|
|
2675
|
+
menuList: []
|
|
2676
|
+
};
|
|
2677
|
+
var navbarSlice = createSlice8({
|
|
2678
|
+
name: "navbar",
|
|
2679
|
+
initialState: initialState7,
|
|
2680
|
+
reducers: {
|
|
2681
|
+
setMenuFocus: (state, action) => {
|
|
2682
|
+
state.menuFocus = action.payload;
|
|
2683
|
+
},
|
|
2684
|
+
setMenuFocusAction: (state, action) => {
|
|
2685
|
+
state.menuAction = action.payload;
|
|
2686
|
+
},
|
|
2687
|
+
setNavbarWidth: (state, action) => {
|
|
2688
|
+
state.navbarWidth = action.payload;
|
|
2689
|
+
},
|
|
2690
|
+
setMenuList: (state, action) => {
|
|
2691
|
+
state.menuList = action.payload;
|
|
2602
2692
|
}
|
|
2603
2693
|
}
|
|
2604
|
-
|
|
2605
|
-
|
|
2694
|
+
});
|
|
2695
|
+
var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
|
|
2696
|
+
var navbar_slice_default = navbarSlice.reducer;
|
|
2697
|
+
|
|
2698
|
+
// src/store/reducers/profile-slice/index.ts
|
|
2699
|
+
import { createSlice as createSlice9 } from "@reduxjs/toolkit";
|
|
2700
|
+
var initialState8 = {
|
|
2701
|
+
profile: {}
|
|
2702
|
+
};
|
|
2703
|
+
var profileSlice = createSlice9({
|
|
2704
|
+
name: "profile",
|
|
2705
|
+
initialState: initialState8,
|
|
2706
|
+
reducers: {
|
|
2707
|
+
setProfile: (state, action) => {
|
|
2708
|
+
state.profile = action.payload;
|
|
2709
|
+
}
|
|
2606
2710
|
}
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2711
|
+
});
|
|
2712
|
+
var { setProfile } = profileSlice.actions;
|
|
2713
|
+
var profile_slice_default = profileSlice.reducer;
|
|
2714
|
+
|
|
2715
|
+
// src/store/reducers/search-slice/index.ts
|
|
2716
|
+
import { createSlice as createSlice10 } from "@reduxjs/toolkit";
|
|
2717
|
+
var initialState9 = {
|
|
2718
|
+
groupByDomain: null,
|
|
2719
|
+
searchBy: [],
|
|
2720
|
+
searchString: "",
|
|
2721
|
+
hoveredIndexSearchList: null,
|
|
2722
|
+
selectedTags: [],
|
|
2723
|
+
firstDomain: null,
|
|
2724
|
+
searchMap: {},
|
|
2725
|
+
filterBy: [],
|
|
2726
|
+
groupBy: []
|
|
2727
|
+
};
|
|
2728
|
+
var searchSlice = createSlice10({
|
|
2729
|
+
name: "search",
|
|
2730
|
+
initialState: initialState9,
|
|
2731
|
+
reducers: {
|
|
2732
|
+
setGroupByDomain: (state, action) => {
|
|
2733
|
+
state.groupByDomain = action.payload;
|
|
2734
|
+
},
|
|
2735
|
+
setSearchBy: (state, action) => {
|
|
2736
|
+
state.searchBy = action.payload;
|
|
2737
|
+
},
|
|
2738
|
+
setSearchString: (state, action) => {
|
|
2739
|
+
state.searchString = action.payload;
|
|
2740
|
+
},
|
|
2741
|
+
setHoveredIndexSearchList: (state, action) => {
|
|
2742
|
+
state.hoveredIndexSearchList = action.payload;
|
|
2743
|
+
},
|
|
2744
|
+
setSelectedTags: (state, action) => {
|
|
2745
|
+
state.selectedTags = action.payload;
|
|
2746
|
+
},
|
|
2747
|
+
setFirstDomain: (state, action) => {
|
|
2748
|
+
state.firstDomain = action.payload;
|
|
2749
|
+
},
|
|
2750
|
+
setFilterBy: (state, action) => {
|
|
2751
|
+
state.filterBy = action.payload;
|
|
2752
|
+
},
|
|
2753
|
+
setGroupBy: (state, action) => {
|
|
2754
|
+
state.groupBy = action.payload;
|
|
2755
|
+
},
|
|
2756
|
+
setSearchMap: (state, action) => {
|
|
2757
|
+
state.searchMap = action.payload;
|
|
2758
|
+
},
|
|
2759
|
+
updateSearchMap: (state, action) => {
|
|
2760
|
+
if (!state.searchMap[action.payload.key]) {
|
|
2761
|
+
state.searchMap[action.payload.key] = [];
|
|
2762
|
+
}
|
|
2763
|
+
state.searchMap[action.payload.key].push(action.payload.value);
|
|
2764
|
+
},
|
|
2765
|
+
removeKeyFromSearchMap: (state, action) => {
|
|
2766
|
+
const { key, item } = action.payload;
|
|
2767
|
+
const values = state.searchMap[key];
|
|
2768
|
+
if (!values) return;
|
|
2769
|
+
if (item) {
|
|
2770
|
+
const filtered = values.filter((value) => value.name !== item.name);
|
|
2771
|
+
if (filtered.length > 0) {
|
|
2772
|
+
state.searchMap[key] = filtered;
|
|
2773
|
+
} else {
|
|
2774
|
+
delete state.searchMap[key];
|
|
2623
2775
|
}
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2776
|
+
} else {
|
|
2777
|
+
delete state.searchMap[key];
|
|
2778
|
+
}
|
|
2779
|
+
},
|
|
2780
|
+
clearSearchMap: (state) => {
|
|
2781
|
+
state.searchMap = {};
|
|
2627
2782
|
}
|
|
2628
2783
|
}
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2784
|
+
});
|
|
2785
|
+
var {
|
|
2786
|
+
setGroupByDomain,
|
|
2787
|
+
setSelectedTags,
|
|
2788
|
+
setSearchString,
|
|
2789
|
+
setHoveredIndexSearchList,
|
|
2790
|
+
setFirstDomain,
|
|
2791
|
+
setSearchBy,
|
|
2792
|
+
setFilterBy,
|
|
2793
|
+
setSearchMap,
|
|
2794
|
+
updateSearchMap,
|
|
2795
|
+
removeKeyFromSearchMap,
|
|
2796
|
+
setGroupBy,
|
|
2797
|
+
clearSearchMap
|
|
2798
|
+
} = searchSlice.actions;
|
|
2799
|
+
var search_slice_default = searchSlice.reducer;
|
|
2800
|
+
|
|
2801
|
+
// src/store/store.ts
|
|
2802
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
2803
|
+
|
|
2804
|
+
// node_modules/redux/dist/redux.mjs
|
|
2805
|
+
function formatProdErrorMessage(code) {
|
|
2806
|
+
return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
|
2640
2807
|
}
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2808
|
+
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
|
2809
|
+
var ActionTypes = {
|
|
2810
|
+
INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
|
|
2811
|
+
REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
|
|
2812
|
+
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
|
2813
|
+
};
|
|
2814
|
+
var actionTypes_default = ActionTypes;
|
|
2815
|
+
function isPlainObject(obj) {
|
|
2816
|
+
if (typeof obj !== "object" || obj === null)
|
|
2817
|
+
return false;
|
|
2818
|
+
let proto = obj;
|
|
2819
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
2820
|
+
proto = Object.getPrototypeOf(proto);
|
|
2644
2821
|
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2822
|
+
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
|
|
2823
|
+
}
|
|
2824
|
+
function miniKindOf(val) {
|
|
2825
|
+
if (val === void 0)
|
|
2826
|
+
return "undefined";
|
|
2827
|
+
if (val === null)
|
|
2828
|
+
return "null";
|
|
2829
|
+
const type = typeof val;
|
|
2830
|
+
switch (type) {
|
|
2831
|
+
case "boolean":
|
|
2832
|
+
case "string":
|
|
2833
|
+
case "number":
|
|
2834
|
+
case "symbol":
|
|
2835
|
+
case "function": {
|
|
2836
|
+
return type;
|
|
2654
2837
|
}
|
|
2655
2838
|
}
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
case "
|
|
2670
|
-
|
|
2671
|
-
return true;
|
|
2672
|
-
}
|
|
2673
|
-
// eslint-disable-next-line no-fallthrough
|
|
2674
|
-
case "=":
|
|
2675
|
-
case "==":
|
|
2676
|
-
if (Array.isArray(fieldValue) && Array.isArray(value)) {
|
|
2677
|
-
return shallowEqual2(fieldValue, value);
|
|
2678
|
-
}
|
|
2679
|
-
return fieldValue === value;
|
|
2680
|
-
case "!=":
|
|
2681
|
-
case "<>":
|
|
2682
|
-
return !matchCondition(record, [field, "==", value]);
|
|
2683
|
-
case "<":
|
|
2684
|
-
return fieldValue < value;
|
|
2685
|
-
case "<=":
|
|
2686
|
-
return fieldValue <= value;
|
|
2687
|
-
case ">":
|
|
2688
|
-
return fieldValue > value;
|
|
2689
|
-
case ">=":
|
|
2690
|
-
return fieldValue >= value;
|
|
2691
|
-
case "in": {
|
|
2692
|
-
const val = Array.isArray(value) ? value : [value];
|
|
2693
|
-
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2694
|
-
return fieldVal.some((fv) => val.includes(fv));
|
|
2695
|
-
}
|
|
2696
|
-
case "not in": {
|
|
2697
|
-
const val = Array.isArray(value) ? value : [value];
|
|
2698
|
-
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2699
|
-
return !fieldVal.some((fv) => val.includes(fv));
|
|
2700
|
-
}
|
|
2701
|
-
case "like":
|
|
2702
|
-
if (fieldValue === false) {
|
|
2703
|
-
return false;
|
|
2704
|
-
}
|
|
2705
|
-
return Boolean(fieldValue.match(likeRegexp));
|
|
2706
|
-
case "not like":
|
|
2707
|
-
if (fieldValue === false) {
|
|
2708
|
-
return false;
|
|
2709
|
-
}
|
|
2710
|
-
return Boolean(!fieldValue.match(likeRegexp));
|
|
2711
|
-
case "=like":
|
|
2712
|
-
if (fieldValue === false) {
|
|
2713
|
-
return false;
|
|
2714
|
-
}
|
|
2715
|
-
return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
|
|
2716
|
-
fieldValue
|
|
2717
|
-
);
|
|
2718
|
-
case "ilike":
|
|
2719
|
-
if (fieldValue === false) {
|
|
2720
|
-
return false;
|
|
2721
|
-
}
|
|
2722
|
-
return Boolean(fieldValue.match(ilikeRegexp));
|
|
2723
|
-
case "not ilike":
|
|
2724
|
-
if (fieldValue === false) {
|
|
2725
|
-
return false;
|
|
2726
|
-
}
|
|
2727
|
-
return Boolean(!fieldValue.match(ilikeRegexp));
|
|
2728
|
-
case "=ilike":
|
|
2729
|
-
if (fieldValue === false) {
|
|
2730
|
-
return false;
|
|
2731
|
-
}
|
|
2732
|
-
return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
|
|
2733
|
-
fieldValue
|
|
2734
|
-
);
|
|
2839
|
+
if (Array.isArray(val))
|
|
2840
|
+
return "array";
|
|
2841
|
+
if (isDate(val))
|
|
2842
|
+
return "date";
|
|
2843
|
+
if (isError(val))
|
|
2844
|
+
return "error";
|
|
2845
|
+
const constructorName = ctorName(val);
|
|
2846
|
+
switch (constructorName) {
|
|
2847
|
+
case "Symbol":
|
|
2848
|
+
case "Promise":
|
|
2849
|
+
case "WeakMap":
|
|
2850
|
+
case "WeakSet":
|
|
2851
|
+
case "Map":
|
|
2852
|
+
case "Set":
|
|
2853
|
+
return constructorName;
|
|
2735
2854
|
}
|
|
2736
|
-
|
|
2855
|
+
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
2737
2856
|
}
|
|
2738
|
-
function
|
|
2739
|
-
|
|
2740
|
-
return {
|
|
2741
|
-
"!": (x) => !match(x),
|
|
2742
|
-
"&": (a, b) => match(a) && match(b),
|
|
2743
|
-
"|": (a, b) => match(a) || match(b)
|
|
2744
|
-
};
|
|
2857
|
+
function ctorName(val) {
|
|
2858
|
+
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
2745
2859
|
}
|
|
2746
|
-
function
|
|
2747
|
-
|
|
2860
|
+
function isError(val) {
|
|
2861
|
+
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
2862
|
+
}
|
|
2863
|
+
function isDate(val) {
|
|
2864
|
+
if (val instanceof Date)
|
|
2748
2865
|
return true;
|
|
2866
|
+
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
2867
|
+
}
|
|
2868
|
+
function kindOf(val) {
|
|
2869
|
+
let typeOfVal = typeof val;
|
|
2870
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2871
|
+
typeOfVal = miniKindOf(val);
|
|
2749
2872
|
}
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2873
|
+
return typeOfVal;
|
|
2874
|
+
}
|
|
2875
|
+
function warning(message) {
|
|
2876
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
2877
|
+
console.error(message);
|
|
2878
|
+
}
|
|
2879
|
+
try {
|
|
2880
|
+
throw new Error(message);
|
|
2881
|
+
} catch (e) {
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
2885
|
+
const reducerKeys = Object.keys(reducers);
|
|
2886
|
+
const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
|
|
2887
|
+
if (reducerKeys.length === 0) {
|
|
2888
|
+
return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
|
|
2889
|
+
}
|
|
2890
|
+
if (!isPlainObject(inputState)) {
|
|
2891
|
+
return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
|
|
2892
|
+
}
|
|
2893
|
+
const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
|
|
2894
|
+
unexpectedKeys.forEach((key) => {
|
|
2895
|
+
unexpectedKeyCache[key] = true;
|
|
2896
|
+
});
|
|
2897
|
+
if (action && action.type === actionTypes_default.REPLACE)
|
|
2898
|
+
return;
|
|
2899
|
+
if (unexpectedKeys.length > 0) {
|
|
2900
|
+
return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
function assertReducerShape(reducers) {
|
|
2904
|
+
Object.keys(reducers).forEach((key) => {
|
|
2905
|
+
const reducer = reducers[key];
|
|
2906
|
+
const initialState10 = reducer(void 0, {
|
|
2907
|
+
type: actionTypes_default.INIT
|
|
2908
|
+
});
|
|
2909
|
+
if (typeof initialState10 === "undefined") {
|
|
2910
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
|
|
2911
|
+
}
|
|
2912
|
+
if (typeof reducer(void 0, {
|
|
2913
|
+
type: actionTypes_default.PROBE_UNKNOWN_ACTION()
|
|
2914
|
+
}) === "undefined") {
|
|
2915
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
|
|
2760
2916
|
}
|
|
2761
|
-
}
|
|
2762
|
-
return matchCondition(record, condStack.pop());
|
|
2917
|
+
});
|
|
2763
2918
|
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
if (parsedData.with_context && typeof parsedData.with_context === "object") {
|
|
2773
|
-
parsedData.with_context.token = newAccessToken;
|
|
2919
|
+
function combineReducers(reducers) {
|
|
2920
|
+
const reducerKeys = Object.keys(reducers);
|
|
2921
|
+
const finalReducers = {};
|
|
2922
|
+
for (let i = 0; i < reducerKeys.length; i++) {
|
|
2923
|
+
const key = reducerKeys[i];
|
|
2924
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2925
|
+
if (typeof reducers[key] === "undefined") {
|
|
2926
|
+
warning(`No reducer provided for key "${key}"`);
|
|
2774
2927
|
}
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
return originalRequest.data;
|
|
2928
|
+
}
|
|
2929
|
+
if (typeof reducers[key] === "function") {
|
|
2930
|
+
finalReducers[key] = reducers[key];
|
|
2779
2931
|
}
|
|
2780
2932
|
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2933
|
+
const finalReducerKeys = Object.keys(finalReducers);
|
|
2934
|
+
let unexpectedKeyCache;
|
|
2935
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2936
|
+
unexpectedKeyCache = {};
|
|
2783
2937
|
}
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
const getRefreshToken = async () => {
|
|
2799
|
-
return localStorage.getItem("refreshToken");
|
|
2800
|
-
};
|
|
2801
|
-
const clearToken = async () => {
|
|
2802
|
-
localStorage.removeItem("accessToken");
|
|
2803
|
-
localStorage.removeItem("refreshToken");
|
|
2804
|
-
};
|
|
2805
|
-
return {
|
|
2806
|
-
setToken,
|
|
2807
|
-
setRefreshToken,
|
|
2808
|
-
getAccessToken,
|
|
2809
|
-
getRefreshToken,
|
|
2810
|
-
clearToken
|
|
2811
|
-
};
|
|
2812
|
-
};
|
|
2813
|
-
|
|
2814
|
-
// src/utils/storage/session-storage.ts
|
|
2815
|
-
var sessionStorageUtils = () => {
|
|
2816
|
-
const getBrowserSession = async () => {
|
|
2817
|
-
return sessionStorage.getItem("browserSession");
|
|
2818
|
-
};
|
|
2819
|
-
return {
|
|
2820
|
-
getBrowserSession
|
|
2821
|
-
};
|
|
2822
|
-
};
|
|
2823
|
-
|
|
2824
|
-
// src/configs/axios-client.ts
|
|
2825
|
-
var axiosClient = {
|
|
2826
|
-
init(config) {
|
|
2827
|
-
const localStorage2 = config.localStorageUtils ?? localStorageUtils();
|
|
2828
|
-
const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
|
|
2829
|
-
const db = config.db;
|
|
2830
|
-
let isRefreshing = false;
|
|
2831
|
-
let failedQueue = [];
|
|
2832
|
-
const processQueue = (error, token = null) => {
|
|
2833
|
-
failedQueue?.forEach((prom) => {
|
|
2834
|
-
if (error) {
|
|
2835
|
-
prom.reject(error);
|
|
2836
|
-
} else {
|
|
2837
|
-
prom.resolve(token);
|
|
2838
|
-
}
|
|
2839
|
-
});
|
|
2840
|
-
failedQueue = [];
|
|
2841
|
-
};
|
|
2842
|
-
const instance = import_axios.default.create({
|
|
2843
|
-
adapter: import_axios.default.defaults.adapter,
|
|
2844
|
-
baseURL: config.baseUrl,
|
|
2845
|
-
timeout: 5e4,
|
|
2846
|
-
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
2847
|
-
});
|
|
2848
|
-
instance.interceptors.request.use(async (config2) => {
|
|
2849
|
-
const { useRefreshToken, useActionToken, actionToken } = config2;
|
|
2850
|
-
if (useActionToken && actionToken) {
|
|
2851
|
-
config2.headers["Action-Token"] = actionToken;
|
|
2852
|
-
}
|
|
2853
|
-
const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
|
|
2854
|
-
const token = await getToken?.();
|
|
2855
|
-
if (token) config2.headers["Authorization"] = `Bearer ${token}`;
|
|
2856
|
-
return config2;
|
|
2857
|
-
}, Promise.reject);
|
|
2858
|
-
instance.interceptors.response.use(
|
|
2859
|
-
(response) => {
|
|
2860
|
-
return handleResponse(response);
|
|
2861
|
-
},
|
|
2862
|
-
async (error) => {
|
|
2863
|
-
const handleError3 = async (error2) => {
|
|
2864
|
-
if (!error2.response) {
|
|
2865
|
-
return error2;
|
|
2866
|
-
}
|
|
2867
|
-
const { data } = error2.response;
|
|
2868
|
-
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
2869
|
-
await clearAuthToken();
|
|
2870
|
-
}
|
|
2871
|
-
return data;
|
|
2872
|
-
};
|
|
2873
|
-
const originalRequest = error.config;
|
|
2874
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
|
|
2875
|
-
error.response.data.code
|
|
2876
|
-
)) {
|
|
2877
|
-
if (isRefreshing) {
|
|
2878
|
-
return new Promise(function(resolve, reject) {
|
|
2879
|
-
failedQueue.push({ resolve, reject });
|
|
2880
|
-
}).then((token) => {
|
|
2881
|
-
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
2882
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2883
|
-
originalRequest,
|
|
2884
|
-
token
|
|
2885
|
-
);
|
|
2886
|
-
return instance.request(originalRequest);
|
|
2887
|
-
}).catch(async (err) => {
|
|
2888
|
-
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
2889
|
-
await clearAuthToken();
|
|
2890
|
-
}
|
|
2891
|
-
});
|
|
2892
|
-
}
|
|
2893
|
-
const browserSession = await sessionStorage2.getBrowserSession();
|
|
2894
|
-
const refreshToken = await localStorage2.getRefreshToken();
|
|
2895
|
-
const accessTokenExp = await localStorage2.getAccessToken();
|
|
2896
|
-
isRefreshing = true;
|
|
2897
|
-
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
2898
|
-
await clearAuthToken();
|
|
2899
|
-
} else {
|
|
2900
|
-
const payload = Object.fromEntries(
|
|
2901
|
-
Object.entries({
|
|
2902
|
-
refresh_token: refreshToken,
|
|
2903
|
-
grant_type: "refresh_token",
|
|
2904
|
-
client_id: config.config.clientId,
|
|
2905
|
-
client_secret: config.config.clientSecret
|
|
2906
|
-
}).filter(([_, value]) => !!value)
|
|
2907
|
-
);
|
|
2908
|
-
return new Promise(function(resolve) {
|
|
2909
|
-
import_axios.default.post(
|
|
2910
|
-
`${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2911
|
-
payload,
|
|
2912
|
-
{
|
|
2913
|
-
headers: {
|
|
2914
|
-
"Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
|
|
2915
|
-
Authorization: `Bearer ${accessTokenExp}`
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
).then(async (res) => {
|
|
2919
|
-
const data = res.data;
|
|
2920
|
-
await localStorage2.setToken(data.access_token);
|
|
2921
|
-
await localStorage2.setRefreshToken(data.refresh_token);
|
|
2922
|
-
import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2923
|
-
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2924
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2925
|
-
originalRequest,
|
|
2926
|
-
data.access_token
|
|
2927
|
-
);
|
|
2928
|
-
processQueue(null, data.access_token);
|
|
2929
|
-
resolve(instance.request(originalRequest));
|
|
2930
|
-
}).catch(async (err) => {
|
|
2931
|
-
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") {
|
|
2932
|
-
await clearAuthToken();
|
|
2933
|
-
}
|
|
2934
|
-
if (err && err.response) {
|
|
2935
|
-
const { error_code } = err.response?.data || {};
|
|
2936
|
-
if (error_code === "AUTHEN_FAIL") {
|
|
2937
|
-
await clearAuthToken();
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
2940
|
-
processQueue(err, null);
|
|
2941
|
-
}).finally(() => {
|
|
2942
|
-
isRefreshing = false;
|
|
2943
|
-
});
|
|
2944
|
-
});
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
return Promise.reject(await handleError3(error));
|
|
2948
|
-
}
|
|
2949
|
-
);
|
|
2950
|
-
const handleResponse = (res) => {
|
|
2951
|
-
if (res && res.data) {
|
|
2952
|
-
return res.data;
|
|
2953
|
-
}
|
|
2954
|
-
return res;
|
|
2955
|
-
};
|
|
2956
|
-
const handleError2 = (error) => {
|
|
2957
|
-
if (error.isAxiosError && error.code === "ECONNABORTED") {
|
|
2958
|
-
console.error("Request Timeout Error:", error);
|
|
2959
|
-
return "Request Timeout Error";
|
|
2960
|
-
} else if (error.isAxiosError && !error.response) {
|
|
2961
|
-
console.error("Network Error:", error);
|
|
2962
|
-
return "Network Error";
|
|
2963
|
-
} else {
|
|
2964
|
-
console.error("Other Error:", error?.response);
|
|
2965
|
-
const errorMessage = error?.response?.data?.message || "An error occurred";
|
|
2966
|
-
return { message: errorMessage, status: error?.response?.status };
|
|
2938
|
+
let shapeAssertionError;
|
|
2939
|
+
try {
|
|
2940
|
+
assertReducerShape(finalReducers);
|
|
2941
|
+
} catch (e) {
|
|
2942
|
+
shapeAssertionError = e;
|
|
2943
|
+
}
|
|
2944
|
+
return function combination(state = {}, action) {
|
|
2945
|
+
if (shapeAssertionError) {
|
|
2946
|
+
throw shapeAssertionError;
|
|
2947
|
+
}
|
|
2948
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2949
|
+
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
|
2950
|
+
if (warningMessage) {
|
|
2951
|
+
warning(warningMessage);
|
|
2967
2952
|
}
|
|
2968
|
-
}
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2953
|
+
}
|
|
2954
|
+
let hasChanged = false;
|
|
2955
|
+
const nextState = {};
|
|
2956
|
+
for (let i = 0; i < finalReducerKeys.length; i++) {
|
|
2957
|
+
const key = finalReducerKeys[i];
|
|
2958
|
+
const reducer = finalReducers[key];
|
|
2959
|
+
const previousStateForKey = state[key];
|
|
2960
|
+
const nextStateForKey = reducer(previousStateForKey, action);
|
|
2961
|
+
if (typeof nextStateForKey === "undefined") {
|
|
2962
|
+
const actionType = action && action.type;
|
|
2963
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
|
|
2973
2964
|
}
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
return url + (db2 ? "?db=" + db2 : "");
|
|
2965
|
+
nextState[key] = nextStateForKey;
|
|
2966
|
+
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
2977
2967
|
}
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
2983
|
-
responseType: "arraybuffer",
|
|
2984
|
-
headers: {
|
|
2985
|
-
"Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
|
|
2986
|
-
Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
2987
|
-
}
|
|
2988
|
-
}).then(responseBody),
|
|
2989
|
-
put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
|
|
2990
|
-
patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
|
|
2991
|
-
delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
|
|
2992
|
-
};
|
|
2993
|
-
return requests;
|
|
2994
|
-
}
|
|
2995
|
-
};
|
|
2968
|
+
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
2969
|
+
return hasChanged ? nextState : state;
|
|
2970
|
+
};
|
|
2971
|
+
}
|
|
2996
2972
|
|
|
2997
|
-
// src/store/
|
|
2998
|
-
var
|
|
2973
|
+
// src/store/store.ts
|
|
2974
|
+
var rootReducer = combineReducers({
|
|
2975
|
+
env: env_slice_default,
|
|
2976
|
+
header: header_slice_default,
|
|
2977
|
+
navbar: navbar_slice_default,
|
|
2978
|
+
list: list_slice_default,
|
|
2979
|
+
search: search_slice_default,
|
|
2980
|
+
form: form_slice_default,
|
|
2981
|
+
breadcrumbs: breadcrums_slice_default,
|
|
2982
|
+
login: login_slice_default,
|
|
2983
|
+
excel: excel_slice_default,
|
|
2984
|
+
profile: profile_slice_default
|
|
2985
|
+
});
|
|
2986
|
+
var envStore = configureStore({
|
|
2987
|
+
reducer: rootReducer,
|
|
2988
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
2989
|
+
serializableCheck: false
|
|
2990
|
+
})
|
|
2991
|
+
});
|
|
2999
2992
|
|
|
3000
2993
|
// src/environment/EnvStore.ts
|
|
3001
|
-
var
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
context;
|
|
3005
|
-
defaultCompany;
|
|
3006
|
-
config;
|
|
3007
|
-
companies;
|
|
3008
|
-
user;
|
|
3009
|
-
db;
|
|
3010
|
-
localStorageUtils;
|
|
3011
|
-
sessionStorageUtils;
|
|
3012
|
-
refreshTokenEndpoint;
|
|
3013
|
-
constructor(localStorageUtils2, sessionStorageUtils2) {
|
|
2994
|
+
var _EnvStore = class _EnvStore {
|
|
2995
|
+
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
2996
|
+
this.envStore = envStore2;
|
|
3014
2997
|
this.localStorageUtils = localStorageUtils2;
|
|
3015
2998
|
this.sessionStorageUtils = sessionStorageUtils2;
|
|
2999
|
+
this.setup();
|
|
3000
|
+
}
|
|
3001
|
+
static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
3002
|
+
if (!_EnvStore.instance) {
|
|
3003
|
+
_EnvStore.instance = new _EnvStore(
|
|
3004
|
+
envStore2,
|
|
3005
|
+
localStorageUtils2,
|
|
3006
|
+
sessionStorageUtils2
|
|
3007
|
+
);
|
|
3008
|
+
}
|
|
3009
|
+
return _EnvStore.instance;
|
|
3016
3010
|
}
|
|
3017
3011
|
setup() {
|
|
3018
|
-
const
|
|
3019
|
-
this.baseUrl =
|
|
3020
|
-
this.
|
|
3021
|
-
this.
|
|
3022
|
-
this.
|
|
3023
|
-
this.
|
|
3024
|
-
this.
|
|
3025
|
-
this.
|
|
3026
|
-
this.
|
|
3027
|
-
this.refreshTokenEndpoint =
|
|
3012
|
+
const env = this.envStore.getState().env;
|
|
3013
|
+
this.baseUrl = env == null ? void 0 : env.baseUrl;
|
|
3014
|
+
this.requests = env == null ? void 0 : env.requests;
|
|
3015
|
+
this.context = env == null ? void 0 : env.context;
|
|
3016
|
+
this.defaultCompany = env == null ? void 0 : env.defaultCompany;
|
|
3017
|
+
this.config = env == null ? void 0 : env.config;
|
|
3018
|
+
this.companies = (env == null ? void 0 : env.companies) || [];
|
|
3019
|
+
this.user = env == null ? void 0 : env.user;
|
|
3020
|
+
this.db = env == null ? void 0 : env.db;
|
|
3021
|
+
this.refreshTokenEndpoint = env == null ? void 0 : env.refreshTokenEndpoint;
|
|
3022
|
+
console.log("Env setup:", this);
|
|
3028
3023
|
}
|
|
3029
3024
|
setupEnv(envConfig) {
|
|
3030
|
-
|
|
3031
|
-
|
|
3025
|
+
const dispatch = this.envStore.dispatch;
|
|
3026
|
+
const env = __spreadProps(__spreadValues({}, envConfig), {
|
|
3032
3027
|
localStorageUtils: this.localStorageUtils,
|
|
3033
3028
|
sessionStorageUtils: this.sessionStorageUtils
|
|
3034
|
-
};
|
|
3035
|
-
const requests = axiosClient.init(
|
|
3036
|
-
|
|
3037
|
-
dispatch(
|
|
3038
|
-
setEnv({
|
|
3039
|
-
...env2,
|
|
3040
|
-
requests
|
|
3041
|
-
})
|
|
3042
|
-
);
|
|
3029
|
+
});
|
|
3030
|
+
const requests = axiosClient.init(env);
|
|
3031
|
+
dispatch(setEnv(__spreadProps(__spreadValues({}, env), { requests })));
|
|
3043
3032
|
this.setup();
|
|
3044
|
-
return { ...env2, requests };
|
|
3045
3033
|
}
|
|
3046
3034
|
setUid(uid) {
|
|
3047
|
-
const dispatch = envStore.dispatch;
|
|
3035
|
+
const dispatch = this.envStore.dispatch;
|
|
3048
3036
|
dispatch(setUid(uid));
|
|
3049
3037
|
this.setup();
|
|
3050
3038
|
}
|
|
3051
3039
|
setLang(lang) {
|
|
3052
|
-
const dispatch = envStore.dispatch;
|
|
3040
|
+
const dispatch = this.envStore.dispatch;
|
|
3053
3041
|
dispatch(setLang(lang));
|
|
3054
3042
|
this.setup();
|
|
3055
3043
|
}
|
|
3056
3044
|
setAllowCompanies(allowCompanies) {
|
|
3057
|
-
const dispatch = envStore.dispatch;
|
|
3045
|
+
const dispatch = this.envStore.dispatch;
|
|
3058
3046
|
dispatch(setAllowCompanies(allowCompanies));
|
|
3059
3047
|
this.setup();
|
|
3060
3048
|
}
|
|
3061
3049
|
setCompanies(companies) {
|
|
3062
|
-
const dispatch = envStore.dispatch;
|
|
3050
|
+
const dispatch = this.envStore.dispatch;
|
|
3063
3051
|
dispatch(setCompanies(companies));
|
|
3064
3052
|
this.setup();
|
|
3065
3053
|
}
|
|
3066
3054
|
setDefaultCompany(company) {
|
|
3067
|
-
const dispatch = envStore.dispatch;
|
|
3055
|
+
const dispatch = this.envStore.dispatch;
|
|
3068
3056
|
dispatch(setDefaultCompany(company));
|
|
3069
3057
|
this.setup();
|
|
3070
3058
|
}
|
|
3071
3059
|
setUserInfo(userInfo) {
|
|
3072
|
-
const dispatch = envStore.dispatch;
|
|
3060
|
+
const dispatch = this.envStore.dispatch;
|
|
3073
3061
|
dispatch(setUser(userInfo));
|
|
3074
3062
|
this.setup();
|
|
3075
3063
|
}
|
|
3076
3064
|
};
|
|
3077
|
-
|
|
3065
|
+
_EnvStore.instance = null;
|
|
3066
|
+
var EnvStore = _EnvStore;
|
|
3078
3067
|
function initEnv({
|
|
3079
3068
|
localStorageUtils: localStorageUtils2,
|
|
3080
3069
|
sessionStorageUtils: sessionStorageUtils2
|
|
3081
3070
|
}) {
|
|
3082
|
-
|
|
3083
|
-
return env;
|
|
3071
|
+
return EnvStore.getInstance(envStore, localStorageUtils2, sessionStorageUtils2);
|
|
3084
3072
|
}
|
|
3085
3073
|
function getEnv() {
|
|
3086
|
-
|
|
3087
|
-
|
|
3074
|
+
const instance = EnvStore.getInstance(envStore);
|
|
3075
|
+
if (!instance) {
|
|
3076
|
+
throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
|
|
3077
|
+
}
|
|
3078
|
+
return instance;
|
|
3088
3079
|
}
|
|
3089
|
-
|
|
3090
|
-
0 && (module.exports = {
|
|
3080
|
+
export {
|
|
3091
3081
|
EnvStore,
|
|
3092
|
-
env,
|
|
3093
3082
|
getEnv,
|
|
3094
3083
|
initEnv
|
|
3095
|
-
}
|
|
3084
|
+
};
|