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