@fctc/interface-logic 1.7.4 → 1.7.6
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 -1
- package/dist/configs.d.ts +4 -1
- package/dist/configs.js +12 -9
- package/dist/configs.mjs +12 -9
- package/dist/environment.d.mts +55 -35
- package/dist/environment.d.ts +55 -35
- package/dist/environment.js +1311 -1232
- package/dist/environment.mjs +1309 -1231
- package/dist/hooks.d.mts +2 -7
- package/dist/hooks.d.ts +2 -7
- package/dist/hooks.js +2175 -1896
- package/dist/hooks.mjs +2960 -2680
- package/dist/provider.js +329 -19
- package/dist/provider.mjs +329 -19
- package/dist/services.d.mts +1 -2
- package/dist/services.d.ts +1 -2
- package/dist/services.js +2001 -1706
- package/dist/services.mjs +2001 -1706
- package/dist/store.d.mts +28 -224
- package/dist/store.d.ts +28 -224
- package/dist/store.js +6 -20
- package/dist/store.mjs +6 -20
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{view-type-D8ukwj_2.d.mts → view-type-BGJfDe73.d.mts} +1 -1
- package/dist/{view-type-D8ukwj_2.d.ts → view-type-BGJfDe73.d.ts} +1 -1
- package/package.json +81 -81
package/dist/services.mjs
CHANGED
|
@@ -28,634 +28,6 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
|
28
28
|
return UriConstants2;
|
|
29
29
|
})(UriConstants || {});
|
|
30
30
|
|
|
31
|
-
// src/store/index.ts
|
|
32
|
-
import { useDispatch, useSelector } from "react-redux";
|
|
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;
|
|
50
|
-
|
|
51
|
-
// src/store/reducers/env-slice/index.ts
|
|
52
|
-
import { createSlice as createSlice2 } from "@reduxjs/toolkit";
|
|
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
|
-
requests: {
|
|
67
|
-
get: async (url, headers) => ({}),
|
|
68
|
-
post: async (url, body, headers) => ({}),
|
|
69
|
-
post_excel: async (url, body, headers) => ({}),
|
|
70
|
-
put: async (url, body, headers) => ({}),
|
|
71
|
-
patch: async (url, body) => ({}),
|
|
72
|
-
delete: async (url, body) => ({})
|
|
73
|
-
},
|
|
74
|
-
defaultCompany: {
|
|
75
|
-
id: null,
|
|
76
|
-
logo: "",
|
|
77
|
-
secondary_color: "",
|
|
78
|
-
primary_color: ""
|
|
79
|
-
},
|
|
80
|
-
context: {
|
|
81
|
-
uid: null,
|
|
82
|
-
allowed_company_ids: [],
|
|
83
|
-
lang: "vi_VN",
|
|
84
|
-
tz: "Asia/Saigon"
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var envSlice = createSlice2({
|
|
88
|
-
name: "env",
|
|
89
|
-
initialState: initialState2,
|
|
90
|
-
reducers: {
|
|
91
|
-
setEnv: (state, action) => {
|
|
92
|
-
Object.assign(state, action.payload);
|
|
93
|
-
},
|
|
94
|
-
setUid: (state, action) => {
|
|
95
|
-
state.context.uid = action.payload;
|
|
96
|
-
},
|
|
97
|
-
setAllowCompanies: (state, action) => {
|
|
98
|
-
state.context.allowed_company_ids = action.payload;
|
|
99
|
-
},
|
|
100
|
-
setCompanies: (state, action) => {
|
|
101
|
-
state.companies = action.payload;
|
|
102
|
-
},
|
|
103
|
-
setDefaultCompany: (state, action) => {
|
|
104
|
-
state.defaultCompany = action.payload;
|
|
105
|
-
},
|
|
106
|
-
setLang: (state, action) => {
|
|
107
|
-
state.context.lang = action.payload;
|
|
108
|
-
},
|
|
109
|
-
setUser: (state, action) => {
|
|
110
|
-
state.user = action.payload;
|
|
111
|
-
},
|
|
112
|
-
setConfig: (state, action) => {
|
|
113
|
-
state.config = action.payload;
|
|
114
|
-
},
|
|
115
|
-
setEnvFile: (state, action) => {
|
|
116
|
-
state.envFile = action.payload;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
var {
|
|
121
|
-
setEnv,
|
|
122
|
-
setUid,
|
|
123
|
-
setLang,
|
|
124
|
-
setAllowCompanies,
|
|
125
|
-
setCompanies,
|
|
126
|
-
setDefaultCompany,
|
|
127
|
-
setUser,
|
|
128
|
-
setConfig,
|
|
129
|
-
setEnvFile
|
|
130
|
-
} = envSlice.actions;
|
|
131
|
-
var env_slice_default = envSlice.reducer;
|
|
132
|
-
|
|
133
|
-
// src/store/reducers/excel-slice/index.ts
|
|
134
|
-
import { createSlice as createSlice3 } from "@reduxjs/toolkit";
|
|
135
|
-
var initialState3 = {
|
|
136
|
-
dataParse: null,
|
|
137
|
-
idFile: null,
|
|
138
|
-
isFileLoaded: false,
|
|
139
|
-
loadingImport: false,
|
|
140
|
-
selectedFile: null,
|
|
141
|
-
errorData: null
|
|
142
|
-
};
|
|
143
|
-
var excelSlice = createSlice3({
|
|
144
|
-
name: "excel",
|
|
145
|
-
initialState: initialState3,
|
|
146
|
-
reducers: {
|
|
147
|
-
setDataParse: (state, action) => {
|
|
148
|
-
state.dataParse = action.payload;
|
|
149
|
-
},
|
|
150
|
-
setIdFile: (state, action) => {
|
|
151
|
-
state.idFile = action.payload;
|
|
152
|
-
},
|
|
153
|
-
setIsFileLoaded: (state, action) => {
|
|
154
|
-
state.isFileLoaded = action.payload;
|
|
155
|
-
},
|
|
156
|
-
setLoadingImport: (state, action) => {
|
|
157
|
-
state.loadingImport = action.payload;
|
|
158
|
-
},
|
|
159
|
-
setSelectedFile: (state, action) => {
|
|
160
|
-
state.selectedFile = action.payload;
|
|
161
|
-
},
|
|
162
|
-
setErrorData: (state, action) => {
|
|
163
|
-
state.errorData = action.payload;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
var {
|
|
168
|
-
setDataParse,
|
|
169
|
-
setIdFile,
|
|
170
|
-
setIsFileLoaded,
|
|
171
|
-
setLoadingImport,
|
|
172
|
-
setSelectedFile,
|
|
173
|
-
setErrorData
|
|
174
|
-
} = excelSlice.actions;
|
|
175
|
-
var excel_slice_default = excelSlice.reducer;
|
|
176
|
-
|
|
177
|
-
// src/store/reducers/form-slice/index.ts
|
|
178
|
-
import { createSlice as createSlice4 } from "@reduxjs/toolkit";
|
|
179
|
-
var initialState4 = {
|
|
180
|
-
viewDataStore: {},
|
|
181
|
-
isShowingModalDetail: false,
|
|
182
|
-
isShowModalTranslate: false,
|
|
183
|
-
formSubmitComponent: {},
|
|
184
|
-
fieldTranslation: null,
|
|
185
|
-
listSubject: {},
|
|
186
|
-
dataUser: {}
|
|
187
|
-
};
|
|
188
|
-
var formSlice = createSlice4({
|
|
189
|
-
name: "form",
|
|
190
|
-
initialState: initialState4,
|
|
191
|
-
reducers: {
|
|
192
|
-
setViewDataStore: (state, action) => {
|
|
193
|
-
state.viewDataStore = action.payload;
|
|
194
|
-
},
|
|
195
|
-
setIsShowingModalDetail: (state, action) => {
|
|
196
|
-
state.isShowingModalDetail = action.payload;
|
|
197
|
-
},
|
|
198
|
-
setIsShowModalTranslate: (state, action) => {
|
|
199
|
-
state.isShowModalTranslate = action.payload;
|
|
200
|
-
},
|
|
201
|
-
setFormSubmitComponent: (state, action) => {
|
|
202
|
-
state.formSubmitComponent[action.payload.key] = action.payload.component;
|
|
203
|
-
},
|
|
204
|
-
setFieldTranslate: (state, action) => {
|
|
205
|
-
state.fieldTranslation = action.payload;
|
|
206
|
-
},
|
|
207
|
-
setListSubject: (state, action) => {
|
|
208
|
-
state.listSubject = action.payload;
|
|
209
|
-
},
|
|
210
|
-
setDataUser: (state, action) => {
|
|
211
|
-
state.dataUser = action.payload;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
var {
|
|
216
|
-
setViewDataStore,
|
|
217
|
-
setIsShowingModalDetail,
|
|
218
|
-
setIsShowModalTranslate,
|
|
219
|
-
setFormSubmitComponent,
|
|
220
|
-
setFieldTranslate,
|
|
221
|
-
setListSubject,
|
|
222
|
-
setDataUser
|
|
223
|
-
} = formSlice.actions;
|
|
224
|
-
var form_slice_default = formSlice.reducer;
|
|
225
|
-
|
|
226
|
-
// src/store/reducers/header-slice/index.ts
|
|
227
|
-
import { createSlice as createSlice5 } from "@reduxjs/toolkit";
|
|
228
|
-
var headerSlice = createSlice5({
|
|
229
|
-
name: "header",
|
|
230
|
-
initialState: {
|
|
231
|
-
value: { allowedCompanyIds: [] }
|
|
232
|
-
},
|
|
233
|
-
reducers: {
|
|
234
|
-
setHeader: (state, action) => {
|
|
235
|
-
state.value = { ...state.value, ...action.payload };
|
|
236
|
-
},
|
|
237
|
-
setAllowedCompanyIds: (state, action) => {
|
|
238
|
-
state.value.allowedCompanyIds = action.payload;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
|
|
243
|
-
var header_slice_default = headerSlice.reducer;
|
|
244
|
-
|
|
245
|
-
// src/store/reducers/list-slice/index.ts
|
|
246
|
-
import { createSlice as createSlice6 } from "@reduxjs/toolkit";
|
|
247
|
-
var initialState5 = {
|
|
248
|
-
pageLimit: 10,
|
|
249
|
-
fields: {},
|
|
250
|
-
order: "",
|
|
251
|
-
selectedRowKeys: [],
|
|
252
|
-
selectedRadioKey: 0,
|
|
253
|
-
indexRowTableModal: -2,
|
|
254
|
-
isUpdateTableModal: false,
|
|
255
|
-
footerGroupTable: {},
|
|
256
|
-
transferDetail: null,
|
|
257
|
-
page: 0,
|
|
258
|
-
domainTable: []
|
|
259
|
-
};
|
|
260
|
-
var listSlice = createSlice6({
|
|
261
|
-
name: "list",
|
|
262
|
-
initialState: initialState5,
|
|
263
|
-
reducers: {
|
|
264
|
-
setPageLimit: (state, action) => {
|
|
265
|
-
state.pageLimit = action.payload;
|
|
266
|
-
},
|
|
267
|
-
setFields: (state, action) => {
|
|
268
|
-
state.fields = action.payload;
|
|
269
|
-
},
|
|
270
|
-
setOrder: (state, action) => {
|
|
271
|
-
state.order = action.payload;
|
|
272
|
-
},
|
|
273
|
-
setSelectedRowKeys: (state, action) => {
|
|
274
|
-
state.selectedRowKeys = action.payload;
|
|
275
|
-
},
|
|
276
|
-
setSelectedRadioKey: (state, action) => {
|
|
277
|
-
state.selectedRadioKey = action.payload;
|
|
278
|
-
},
|
|
279
|
-
setIndexRowTableModal: (state, action) => {
|
|
280
|
-
state.indexRowTableModal = action.payload;
|
|
281
|
-
},
|
|
282
|
-
setTransferDetail: (state, action) => {
|
|
283
|
-
state.transferDetail = action.payload;
|
|
284
|
-
},
|
|
285
|
-
setIsUpdateTableModal: (state, action) => {
|
|
286
|
-
state.isUpdateTableModal = action.payload;
|
|
287
|
-
},
|
|
288
|
-
setPage: (state, action) => {
|
|
289
|
-
state.page = action.payload;
|
|
290
|
-
},
|
|
291
|
-
setDomainTable: (state, action) => {
|
|
292
|
-
state.domainTable = action.payload;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
var {
|
|
297
|
-
setPageLimit,
|
|
298
|
-
setFields,
|
|
299
|
-
setOrder,
|
|
300
|
-
setSelectedRowKeys,
|
|
301
|
-
setIndexRowTableModal,
|
|
302
|
-
setIsUpdateTableModal,
|
|
303
|
-
setPage,
|
|
304
|
-
setSelectedRadioKey,
|
|
305
|
-
setTransferDetail,
|
|
306
|
-
setDomainTable
|
|
307
|
-
} = listSlice.actions;
|
|
308
|
-
var list_slice_default = listSlice.reducer;
|
|
309
|
-
|
|
310
|
-
// src/store/reducers/login-slice/index.ts
|
|
311
|
-
import { createSlice as createSlice7 } from "@reduxjs/toolkit";
|
|
312
|
-
var initialState6 = {
|
|
313
|
-
db: "",
|
|
314
|
-
redirectTo: "/",
|
|
315
|
-
forgotPasswordUrl: "/"
|
|
316
|
-
};
|
|
317
|
-
var loginSlice = createSlice7({
|
|
318
|
-
name: "login",
|
|
319
|
-
initialState: initialState6,
|
|
320
|
-
reducers: {
|
|
321
|
-
setDb: (state, action) => {
|
|
322
|
-
state.db = action.payload;
|
|
323
|
-
},
|
|
324
|
-
setRedirectTo: (state, action) => {
|
|
325
|
-
state.redirectTo = action.payload;
|
|
326
|
-
},
|
|
327
|
-
setForgotPasswordUrl: (state, action) => {
|
|
328
|
-
state.forgotPasswordUrl = action.payload;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
|
|
333
|
-
var login_slice_default = loginSlice.reducer;
|
|
334
|
-
|
|
335
|
-
// src/store/reducers/navbar-slice/index.ts
|
|
336
|
-
import { createSlice as createSlice8 } from "@reduxjs/toolkit";
|
|
337
|
-
var initialState7 = {
|
|
338
|
-
menuFocus: {},
|
|
339
|
-
menuAction: {},
|
|
340
|
-
navbarWidth: 250,
|
|
341
|
-
menuList: []
|
|
342
|
-
};
|
|
343
|
-
var navbarSlice = createSlice8({
|
|
344
|
-
name: "navbar",
|
|
345
|
-
initialState: initialState7,
|
|
346
|
-
reducers: {
|
|
347
|
-
setMenuFocus: (state, action) => {
|
|
348
|
-
state.menuFocus = action.payload;
|
|
349
|
-
},
|
|
350
|
-
setMenuFocusAction: (state, action) => {
|
|
351
|
-
state.menuAction = action.payload;
|
|
352
|
-
},
|
|
353
|
-
setNavbarWidth: (state, action) => {
|
|
354
|
-
state.navbarWidth = action.payload;
|
|
355
|
-
},
|
|
356
|
-
setMenuList: (state, action) => {
|
|
357
|
-
state.menuList = action.payload;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
|
|
362
|
-
var navbar_slice_default = navbarSlice.reducer;
|
|
363
|
-
|
|
364
|
-
// src/store/reducers/profile-slice/index.ts
|
|
365
|
-
import { createSlice as createSlice9 } from "@reduxjs/toolkit";
|
|
366
|
-
var initialState8 = {
|
|
367
|
-
profile: {}
|
|
368
|
-
};
|
|
369
|
-
var profileSlice = createSlice9({
|
|
370
|
-
name: "profile",
|
|
371
|
-
initialState: initialState8,
|
|
372
|
-
reducers: {
|
|
373
|
-
setProfile: (state, action) => {
|
|
374
|
-
state.profile = action.payload;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
var { setProfile } = profileSlice.actions;
|
|
379
|
-
var profile_slice_default = profileSlice.reducer;
|
|
380
|
-
|
|
381
|
-
// src/store/reducers/search-slice/index.ts
|
|
382
|
-
import { createSlice as createSlice10 } from "@reduxjs/toolkit";
|
|
383
|
-
var initialState9 = {
|
|
384
|
-
groupByDomain: null,
|
|
385
|
-
searchBy: [],
|
|
386
|
-
searchString: "",
|
|
387
|
-
hoveredIndexSearchList: null,
|
|
388
|
-
selectedTags: [],
|
|
389
|
-
firstDomain: null,
|
|
390
|
-
searchMap: {},
|
|
391
|
-
filterBy: [],
|
|
392
|
-
groupBy: []
|
|
393
|
-
};
|
|
394
|
-
var searchSlice = createSlice10({
|
|
395
|
-
name: "search",
|
|
396
|
-
initialState: initialState9,
|
|
397
|
-
reducers: {
|
|
398
|
-
setGroupByDomain: (state, action) => {
|
|
399
|
-
state.groupByDomain = action.payload;
|
|
400
|
-
},
|
|
401
|
-
setSearchBy: (state, action) => {
|
|
402
|
-
state.searchBy = action.payload;
|
|
403
|
-
},
|
|
404
|
-
setSearchString: (state, action) => {
|
|
405
|
-
state.searchString = action.payload;
|
|
406
|
-
},
|
|
407
|
-
setHoveredIndexSearchList: (state, action) => {
|
|
408
|
-
state.hoveredIndexSearchList = action.payload;
|
|
409
|
-
},
|
|
410
|
-
setSelectedTags: (state, action) => {
|
|
411
|
-
state.selectedTags = action.payload;
|
|
412
|
-
},
|
|
413
|
-
setFirstDomain: (state, action) => {
|
|
414
|
-
state.firstDomain = action.payload;
|
|
415
|
-
},
|
|
416
|
-
setFilterBy: (state, action) => {
|
|
417
|
-
state.filterBy = action.payload;
|
|
418
|
-
},
|
|
419
|
-
setGroupBy: (state, action) => {
|
|
420
|
-
state.groupBy = action.payload;
|
|
421
|
-
},
|
|
422
|
-
setSearchMap: (state, action) => {
|
|
423
|
-
state.searchMap = action.payload;
|
|
424
|
-
},
|
|
425
|
-
updateSearchMap: (state, action) => {
|
|
426
|
-
if (!state.searchMap[action.payload.key]) {
|
|
427
|
-
state.searchMap[action.payload.key] = [];
|
|
428
|
-
}
|
|
429
|
-
state.searchMap[action.payload.key].push(action.payload.value);
|
|
430
|
-
},
|
|
431
|
-
removeKeyFromSearchMap: (state, action) => {
|
|
432
|
-
const { key, item } = action.payload;
|
|
433
|
-
const values = state.searchMap[key];
|
|
434
|
-
if (!values) return;
|
|
435
|
-
if (item) {
|
|
436
|
-
const filtered = values.filter((value) => value.name !== item.name);
|
|
437
|
-
if (filtered.length > 0) {
|
|
438
|
-
state.searchMap[key] = filtered;
|
|
439
|
-
} else {
|
|
440
|
-
delete state.searchMap[key];
|
|
441
|
-
}
|
|
442
|
-
} else {
|
|
443
|
-
delete state.searchMap[key];
|
|
444
|
-
}
|
|
445
|
-
},
|
|
446
|
-
clearSearchMap: (state) => {
|
|
447
|
-
state.searchMap = {};
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
var {
|
|
452
|
-
setGroupByDomain,
|
|
453
|
-
setSelectedTags,
|
|
454
|
-
setSearchString,
|
|
455
|
-
setHoveredIndexSearchList,
|
|
456
|
-
setFirstDomain,
|
|
457
|
-
setSearchBy,
|
|
458
|
-
setFilterBy,
|
|
459
|
-
setSearchMap,
|
|
460
|
-
updateSearchMap,
|
|
461
|
-
removeKeyFromSearchMap,
|
|
462
|
-
setGroupBy,
|
|
463
|
-
clearSearchMap
|
|
464
|
-
} = searchSlice.actions;
|
|
465
|
-
var search_slice_default = searchSlice.reducer;
|
|
466
|
-
|
|
467
|
-
// src/store/store.ts
|
|
468
|
-
import { configureStore } from "@reduxjs/toolkit";
|
|
469
|
-
|
|
470
|
-
// node_modules/redux/dist/redux.mjs
|
|
471
|
-
function formatProdErrorMessage(code) {
|
|
472
|
-
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. `;
|
|
473
|
-
}
|
|
474
|
-
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
|
475
|
-
var ActionTypes = {
|
|
476
|
-
INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
|
|
477
|
-
REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
|
|
478
|
-
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
|
479
|
-
};
|
|
480
|
-
var actionTypes_default = ActionTypes;
|
|
481
|
-
function isPlainObject(obj) {
|
|
482
|
-
if (typeof obj !== "object" || obj === null)
|
|
483
|
-
return false;
|
|
484
|
-
let proto = obj;
|
|
485
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
486
|
-
proto = Object.getPrototypeOf(proto);
|
|
487
|
-
}
|
|
488
|
-
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
|
|
489
|
-
}
|
|
490
|
-
function miniKindOf(val) {
|
|
491
|
-
if (val === void 0)
|
|
492
|
-
return "undefined";
|
|
493
|
-
if (val === null)
|
|
494
|
-
return "null";
|
|
495
|
-
const type = typeof val;
|
|
496
|
-
switch (type) {
|
|
497
|
-
case "boolean":
|
|
498
|
-
case "string":
|
|
499
|
-
case "number":
|
|
500
|
-
case "symbol":
|
|
501
|
-
case "function": {
|
|
502
|
-
return type;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
if (Array.isArray(val))
|
|
506
|
-
return "array";
|
|
507
|
-
if (isDate(val))
|
|
508
|
-
return "date";
|
|
509
|
-
if (isError(val))
|
|
510
|
-
return "error";
|
|
511
|
-
const constructorName = ctorName(val);
|
|
512
|
-
switch (constructorName) {
|
|
513
|
-
case "Symbol":
|
|
514
|
-
case "Promise":
|
|
515
|
-
case "WeakMap":
|
|
516
|
-
case "WeakSet":
|
|
517
|
-
case "Map":
|
|
518
|
-
case "Set":
|
|
519
|
-
return constructorName;
|
|
520
|
-
}
|
|
521
|
-
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
522
|
-
}
|
|
523
|
-
function ctorName(val) {
|
|
524
|
-
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
525
|
-
}
|
|
526
|
-
function isError(val) {
|
|
527
|
-
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
528
|
-
}
|
|
529
|
-
function isDate(val) {
|
|
530
|
-
if (val instanceof Date)
|
|
531
|
-
return true;
|
|
532
|
-
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
533
|
-
}
|
|
534
|
-
function kindOf(val) {
|
|
535
|
-
let typeOfVal = typeof val;
|
|
536
|
-
if (process.env.NODE_ENV !== "production") {
|
|
537
|
-
typeOfVal = miniKindOf(val);
|
|
538
|
-
}
|
|
539
|
-
return typeOfVal;
|
|
540
|
-
}
|
|
541
|
-
function warning(message) {
|
|
542
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
543
|
-
console.error(message);
|
|
544
|
-
}
|
|
545
|
-
try {
|
|
546
|
-
throw new Error(message);
|
|
547
|
-
} catch (e) {
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
551
|
-
const reducerKeys = Object.keys(reducers);
|
|
552
|
-
const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
|
|
553
|
-
if (reducerKeys.length === 0) {
|
|
554
|
-
return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
|
|
555
|
-
}
|
|
556
|
-
if (!isPlainObject(inputState)) {
|
|
557
|
-
return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
|
|
558
|
-
}
|
|
559
|
-
const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
|
|
560
|
-
unexpectedKeys.forEach((key) => {
|
|
561
|
-
unexpectedKeyCache[key] = true;
|
|
562
|
-
});
|
|
563
|
-
if (action && action.type === actionTypes_default.REPLACE)
|
|
564
|
-
return;
|
|
565
|
-
if (unexpectedKeys.length > 0) {
|
|
566
|
-
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.`;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
function assertReducerShape(reducers) {
|
|
570
|
-
Object.keys(reducers).forEach((key) => {
|
|
571
|
-
const reducer = reducers[key];
|
|
572
|
-
const initialState10 = reducer(void 0, {
|
|
573
|
-
type: actionTypes_default.INIT
|
|
574
|
-
});
|
|
575
|
-
if (typeof initialState10 === "undefined") {
|
|
576
|
-
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.`);
|
|
577
|
-
}
|
|
578
|
-
if (typeof reducer(void 0, {
|
|
579
|
-
type: actionTypes_default.PROBE_UNKNOWN_ACTION()
|
|
580
|
-
}) === "undefined") {
|
|
581
|
-
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.`);
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
function combineReducers(reducers) {
|
|
586
|
-
const reducerKeys = Object.keys(reducers);
|
|
587
|
-
const finalReducers = {};
|
|
588
|
-
for (let i = 0; i < reducerKeys.length; i++) {
|
|
589
|
-
const key = reducerKeys[i];
|
|
590
|
-
if (process.env.NODE_ENV !== "production") {
|
|
591
|
-
if (typeof reducers[key] === "undefined") {
|
|
592
|
-
warning(`No reducer provided for key "${key}"`);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
if (typeof reducers[key] === "function") {
|
|
596
|
-
finalReducers[key] = reducers[key];
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
const finalReducerKeys = Object.keys(finalReducers);
|
|
600
|
-
let unexpectedKeyCache;
|
|
601
|
-
if (process.env.NODE_ENV !== "production") {
|
|
602
|
-
unexpectedKeyCache = {};
|
|
603
|
-
}
|
|
604
|
-
let shapeAssertionError;
|
|
605
|
-
try {
|
|
606
|
-
assertReducerShape(finalReducers);
|
|
607
|
-
} catch (e) {
|
|
608
|
-
shapeAssertionError = e;
|
|
609
|
-
}
|
|
610
|
-
return function combination(state = {}, action) {
|
|
611
|
-
if (shapeAssertionError) {
|
|
612
|
-
throw shapeAssertionError;
|
|
613
|
-
}
|
|
614
|
-
if (process.env.NODE_ENV !== "production") {
|
|
615
|
-
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
|
616
|
-
if (warningMessage) {
|
|
617
|
-
warning(warningMessage);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
let hasChanged = false;
|
|
621
|
-
const nextState = {};
|
|
622
|
-
for (let i = 0; i < finalReducerKeys.length; i++) {
|
|
623
|
-
const key = finalReducerKeys[i];
|
|
624
|
-
const reducer = finalReducers[key];
|
|
625
|
-
const previousStateForKey = state[key];
|
|
626
|
-
const nextStateForKey = reducer(previousStateForKey, action);
|
|
627
|
-
if (typeof nextStateForKey === "undefined") {
|
|
628
|
-
const actionType = action && action.type;
|
|
629
|
-
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.`);
|
|
630
|
-
}
|
|
631
|
-
nextState[key] = nextStateForKey;
|
|
632
|
-
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
633
|
-
}
|
|
634
|
-
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
635
|
-
return hasChanged ? nextState : state;
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// src/store/store.ts
|
|
640
|
-
var rootReducer = combineReducers({
|
|
641
|
-
env: env_slice_default,
|
|
642
|
-
header: header_slice_default,
|
|
643
|
-
navbar: navbar_slice_default,
|
|
644
|
-
list: list_slice_default,
|
|
645
|
-
search: search_slice_default,
|
|
646
|
-
form: form_slice_default,
|
|
647
|
-
breadcrumbs: breadcrums_slice_default,
|
|
648
|
-
login: login_slice_default,
|
|
649
|
-
excel: excel_slice_default,
|
|
650
|
-
profile: profile_slice_default
|
|
651
|
-
});
|
|
652
|
-
var envStore = configureStore({
|
|
653
|
-
reducer: rootReducer,
|
|
654
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
655
|
-
serializableCheck: false
|
|
656
|
-
})
|
|
657
|
-
});
|
|
658
|
-
|
|
659
31
|
// src/configs/axios-client.ts
|
|
660
32
|
import axios from "axios";
|
|
661
33
|
|
|
@@ -1598,1188 +970,2124 @@ var PyTime = class _PyTime extends PyDate {
|
|
|
1598
970
|
}
|
|
1599
971
|
});
|
|
1600
972
|
}
|
|
1601
|
-
toJSON() {
|
|
1602
|
-
return this.strftime("%H:%M:%S");
|
|
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
|
+
}
|
|
1047
|
+
const s = tmxxx(
|
|
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)
|
|
1055
|
+
);
|
|
1056
|
+
const newDateTime = new PyDateTime(
|
|
1057
|
+
s.year,
|
|
1058
|
+
s.month,
|
|
1059
|
+
s.day,
|
|
1060
|
+
s.hour,
|
|
1061
|
+
s.minute,
|
|
1062
|
+
s.second,
|
|
1063
|
+
s.microsecond
|
|
1064
|
+
);
|
|
1065
|
+
let leapDays = 0;
|
|
1066
|
+
if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
|
|
1067
|
+
leapDays = delta.leapDays;
|
|
1068
|
+
}
|
|
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;
|
|
1093
|
+
}
|
|
1094
|
+
static substract(date, delta) {
|
|
1095
|
+
return _PyRelativeDelta.add(date, delta.negate());
|
|
1096
|
+
}
|
|
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;
|
|
1114
|
+
}
|
|
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);
|
|
1133
|
+
}
|
|
1134
|
+
isEqual() {
|
|
1135
|
+
throw new NotSupportedError();
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
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;
|
|
1148
|
+
}
|
|
1149
|
+
static create(...args) {
|
|
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);
|
|
1184
|
+
}
|
|
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
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
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;
|
|
1603
1228
|
}
|
|
1604
1229
|
};
|
|
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
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1230
|
+
|
|
1231
|
+
// src/utils/domain/py_builtin.ts
|
|
1232
|
+
var EvaluationError = class extends Error {
|
|
1233
|
+
constructor(message) {
|
|
1234
|
+
super(message);
|
|
1235
|
+
this.name = "EvaluationError";
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
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;
|
|
1639
1279
|
}
|
|
1640
|
-
|
|
1641
|
-
|
|
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
|
+
);
|
|
1642
1286
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1287
|
+
return execOnIterable(
|
|
1288
|
+
iterable,
|
|
1289
|
+
(iterable2) => new Set(iterable2)
|
|
1290
|
+
);
|
|
1291
|
+
},
|
|
1292
|
+
time: {
|
|
1293
|
+
strftime(format) {
|
|
1294
|
+
return PyDateTime.now().strftime(format);
|
|
1645
1295
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
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]);
|
|
1348
|
+
}
|
|
1349
|
+
return { type: 11, value: content };
|
|
1350
|
+
}
|
|
1351
|
+
default:
|
|
1352
|
+
throw new Error("Invalid type");
|
|
1353
|
+
}
|
|
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)}`;
|
|
1654
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;
|
|
1655
1414
|
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
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();
|
|
1667
1426
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
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}`);
|
|
1670
1434
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
|
|
1683
|
-
);
|
|
1684
|
-
const newDateTime = new PyDateTime(
|
|
1685
|
-
s.year,
|
|
1686
|
-
s.month,
|
|
1687
|
-
s.day,
|
|
1688
|
-
s.hour,
|
|
1689
|
-
s.minute,
|
|
1690
|
-
s.second,
|
|
1691
|
-
s.microsecond
|
|
1692
|
-
);
|
|
1693
|
-
let leapDays = 0;
|
|
1694
|
-
if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
|
|
1695
|
-
leapDays = delta.leapDays;
|
|
1696
|
-
}
|
|
1697
|
-
const temp = newDateTime.add(
|
|
1698
|
-
PyTimeDelta.create({
|
|
1699
|
-
days: delta.days + leapDays,
|
|
1700
|
-
hours: delta.hours,
|
|
1701
|
-
minutes: delta.minutes,
|
|
1702
|
-
seconds: delta.seconds,
|
|
1703
|
-
microseconds: delta.microseconds
|
|
1704
|
-
})
|
|
1705
|
-
);
|
|
1706
|
-
const hasTime = Boolean(
|
|
1707
|
-
temp.hour || temp.minute || temp.second || temp.microsecond
|
|
1708
|
-
);
|
|
1709
|
-
const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
|
|
1710
|
-
if (delta.weekday !== null) {
|
|
1711
|
-
const wantedDow = delta.weekday + 1;
|
|
1712
|
-
const _date = new Date(
|
|
1713
|
-
returnDate.year,
|
|
1714
|
-
returnDate.month - 1,
|
|
1715
|
-
returnDate.day
|
|
1716
|
-
);
|
|
1717
|
-
const days = (7 - _date.getDay() + wantedDow) % 7;
|
|
1718
|
-
return returnDate.add(new PyTimeDelta(days, 0, 0));
|
|
1719
|
-
}
|
|
1720
|
-
return returnDate;
|
|
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}`);
|
|
1721
1446
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1447
|
+
}
|
|
1448
|
+
function isLess(left, right) {
|
|
1449
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
1450
|
+
return left < right;
|
|
1724
1451
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
this.months = sign * params.months;
|
|
1728
|
-
this.days = sign * params.days;
|
|
1729
|
-
this.hours = sign * params.hours;
|
|
1730
|
-
this.minutes = sign * params.minutes;
|
|
1731
|
-
this.seconds = sign * params.seconds;
|
|
1732
|
-
this.microseconds = sign * params.microseconds;
|
|
1733
|
-
this.leapDays = params.leapDays;
|
|
1734
|
-
this.year = params.year;
|
|
1735
|
-
this.month = params.month;
|
|
1736
|
-
this.day = params.day;
|
|
1737
|
-
this.hour = params.hour;
|
|
1738
|
-
this.minute = params.minute;
|
|
1739
|
-
this.second = params.second;
|
|
1740
|
-
this.microsecond = params.microsecond;
|
|
1741
|
-
this.weekday = params.weekday;
|
|
1452
|
+
if (typeof left === "boolean") {
|
|
1453
|
+
left = left ? 1 : 0;
|
|
1742
1454
|
}
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
days;
|
|
1746
|
-
hours;
|
|
1747
|
-
minutes;
|
|
1748
|
-
seconds;
|
|
1749
|
-
microseconds;
|
|
1750
|
-
leapDays;
|
|
1751
|
-
year;
|
|
1752
|
-
month;
|
|
1753
|
-
day;
|
|
1754
|
-
hour;
|
|
1755
|
-
minute;
|
|
1756
|
-
second;
|
|
1757
|
-
microsecond;
|
|
1758
|
-
weekday;
|
|
1759
|
-
negate() {
|
|
1760
|
-
return new _PyRelativeDelta(this, -1);
|
|
1455
|
+
if (typeof right === "boolean") {
|
|
1456
|
+
right = right ? 1 : 0;
|
|
1761
1457
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1458
|
+
const leftIndex = pytypeIndex(left);
|
|
1459
|
+
const rightIndex = pytypeIndex(right);
|
|
1460
|
+
if (leftIndex === rightIndex) {
|
|
1461
|
+
return left < right;
|
|
1764
1462
|
}
|
|
1765
|
-
|
|
1766
|
-
var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
|
|
1767
|
-
function modf(x) {
|
|
1768
|
-
const mod = x % 1;
|
|
1769
|
-
return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
|
|
1463
|
+
return leftIndex < rightIndex;
|
|
1770
1464
|
}
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
this.microseconds = microseconds;
|
|
1776
|
-
}
|
|
1777
|
-
static create(...args) {
|
|
1778
|
-
const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
|
|
1779
|
-
for (const key of TIME_DELTA_KEYS) {
|
|
1780
|
-
namedArgs[key] = namedArgs[key] || 0;
|
|
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);
|
|
1781
1469
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
let us = 0;
|
|
1785
|
-
const days = namedArgs.days + namedArgs.weeks * 7;
|
|
1786
|
-
let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
|
|
1787
|
-
let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
|
|
1788
|
-
const [dFrac, dInt] = modf(days);
|
|
1789
|
-
d = dInt;
|
|
1790
|
-
let daysecondsfrac = 0;
|
|
1791
|
-
if (dFrac) {
|
|
1792
|
-
const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
|
|
1793
|
-
s = dsInt;
|
|
1794
|
-
daysecondsfrac = dsFrac;
|
|
1470
|
+
if (typeof left === "number" && typeof right === "boolean") {
|
|
1471
|
+
return left === (right ? 1 : 0);
|
|
1795
1472
|
}
|
|
1796
|
-
|
|
1797
|
-
seconds = sInt;
|
|
1798
|
-
const secondsfrac = sFrac + daysecondsfrac;
|
|
1799
|
-
divmod(seconds, 24 * 3600, (days2, seconds2) => {
|
|
1800
|
-
d += days2;
|
|
1801
|
-
s += seconds2;
|
|
1802
|
-
});
|
|
1803
|
-
microseconds += secondsfrac * 1e6;
|
|
1804
|
-
divmod(microseconds, 1e6, (seconds2, microseconds2) => {
|
|
1805
|
-
divmod(seconds2, 24 * 3600, (days2, seconds3) => {
|
|
1806
|
-
d += days2;
|
|
1807
|
-
s += seconds3;
|
|
1808
|
-
us += Math.round(microseconds2);
|
|
1809
|
-
});
|
|
1810
|
-
});
|
|
1811
|
-
return new _PyTimeDelta(d, s, us);
|
|
1473
|
+
return false;
|
|
1812
1474
|
}
|
|
1813
|
-
|
|
1814
|
-
return
|
|
1815
|
-
days: this.days + other.days,
|
|
1816
|
-
seconds: this.seconds + other.seconds,
|
|
1817
|
-
microseconds: this.microseconds + other.microseconds
|
|
1818
|
-
});
|
|
1475
|
+
if (left instanceof Object && "isEqual" in left) {
|
|
1476
|
+
return left.isEqual(right);
|
|
1819
1477
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
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}`);
|
|
1823
1588
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
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;
|
|
1827
1598
|
}
|
|
1828
|
-
return
|
|
1599
|
+
return null;
|
|
1829
1600
|
}
|
|
1830
|
-
|
|
1831
|
-
|
|
1601
|
+
};
|
|
1602
|
+
var STRING = {
|
|
1603
|
+
lower() {
|
|
1604
|
+
return this.toLowerCase();
|
|
1605
|
+
},
|
|
1606
|
+
upper() {
|
|
1607
|
+
return this.toUpperCase();
|
|
1832
1608
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
microseconds: n * this.microseconds
|
|
1838
|
-
});
|
|
1609
|
+
};
|
|
1610
|
+
function applyFunc(key, func, set, ...args) {
|
|
1611
|
+
if (args.length === 1) {
|
|
1612
|
+
return new Set(set);
|
|
1839
1613
|
}
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
microseconds: -this.microseconds
|
|
1845
|
-
});
|
|
1614
|
+
if (args.length > 2) {
|
|
1615
|
+
throw new EvaluationError(
|
|
1616
|
+
`${key}: py_js supports at most 1 argument, got (${args.length - 1})`
|
|
1617
|
+
);
|
|
1846
1618
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
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
|
+
);
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
function methods(_class) {
|
|
1667
|
+
return Object.getOwnPropertyNames(_class.prototype).map(
|
|
1668
|
+
(prop) => _class.prototype[prop]
|
|
1669
|
+
);
|
|
1670
|
+
}
|
|
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
|
+
}
|
|
1852
1698
|
});
|
|
1853
1699
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
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 {
|
|
1715
|
+
return false;
|
|
1716
|
+
}
|
|
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);
|
|
1731
|
+
}
|
|
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];
|
|
1778
|
+
}
|
|
1779
|
+
if (typeof result === "function") {
|
|
1780
|
+
const bound = result.bind(leftVal);
|
|
1781
|
+
bound[unboundFn] = result;
|
|
1782
|
+
return bound;
|
|
1783
|
+
}
|
|
1784
|
+
return result;
|
|
1785
|
+
default:
|
|
1786
|
+
throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
|
|
1787
|
+
}
|
|
1856
1788
|
}
|
|
1857
|
-
|
|
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");
|
|
1793
|
+
}
|
|
1794
|
+
return val;
|
|
1795
|
+
}
|
|
1796
|
+
return _evaluate(ast);
|
|
1797
|
+
}
|
|
1858
1798
|
|
|
1859
|
-
// src/utils/domain/
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
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;
|
|
1864
1809
|
}
|
|
1810
|
+
const obj1Keys = Object.keys(obj1);
|
|
1811
|
+
return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
|
|
1812
|
+
}
|
|
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, "\\$&");
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
// src/utils/domain/domain.ts
|
|
1824
|
+
var InvalidDomainError = class extends Error {
|
|
1865
1825
|
};
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
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;
|
|
1869
1849
|
}
|
|
1870
|
-
|
|
1871
|
-
|
|
1850
|
+
static and(domains) {
|
|
1851
|
+
return _Domain.combine(domains, "AND");
|
|
1872
1852
|
}
|
|
1873
|
-
|
|
1874
|
-
|
|
1853
|
+
static or(domains) {
|
|
1854
|
+
return _Domain.combine(domains, "OR");
|
|
1875
1855
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
return false;
|
|
1894
|
-
}
|
|
1895
|
-
if ("isTrue" in value && typeof value.isTrue === "function") {
|
|
1896
|
-
return value.isTrue();
|
|
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);
|
|
1897
1873
|
}
|
|
1898
|
-
|
|
1899
|
-
|
|
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;
|
|
1900
1879
|
}
|
|
1901
|
-
|
|
1902
|
-
|
|
1880
|
+
newDomain2.ast.value.push(leaf);
|
|
1881
|
+
if (leaf.value === "!") {
|
|
1882
|
+
return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
|
|
1903
1883
|
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
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;
|
|
1897
|
+
}
|
|
1898
|
+
return 0;
|
|
1914
1899
|
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
);
|
|
1919
|
-
},
|
|
1920
|
-
time: {
|
|
1921
|
-
strftime(format) {
|
|
1922
|
-
return PyDateTime.now().strftime(format);
|
|
1900
|
+
const d = new _Domain(domain);
|
|
1901
|
+
if (d.ast.value.length === 0) {
|
|
1902
|
+
return d;
|
|
1923
1903
|
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
return
|
|
1927
|
-
},
|
|
1928
|
-
get current_date() {
|
|
1929
|
-
return this.today;
|
|
1930
|
-
},
|
|
1931
|
-
get today() {
|
|
1932
|
-
return PyDate.today().strftime("%Y-%m-%d");
|
|
1933
|
-
},
|
|
1934
|
-
get now() {
|
|
1935
|
-
return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
|
|
1936
|
-
},
|
|
1937
|
-
datetime: {
|
|
1938
|
-
time: PyTime,
|
|
1939
|
-
timedelta: PyTimeDelta,
|
|
1940
|
-
datetime: PyDateTime,
|
|
1941
|
-
date: PyDate
|
|
1942
|
-
},
|
|
1943
|
-
relativedelta: PyRelativeDelta,
|
|
1944
|
-
true: true,
|
|
1945
|
-
false: false
|
|
1946
|
-
};
|
|
1947
|
-
|
|
1948
|
-
// src/utils/domain/py_utils.ts
|
|
1949
|
-
function toPyValue(value) {
|
|
1950
|
-
switch (typeof value) {
|
|
1951
|
-
case "string":
|
|
1952
|
-
return { type: 1, value };
|
|
1953
|
-
case "number":
|
|
1954
|
-
return { type: 0, value };
|
|
1955
|
-
case "boolean":
|
|
1956
|
-
return { type: 2, value };
|
|
1957
|
-
case "object":
|
|
1958
|
-
if (Array.isArray(value)) {
|
|
1959
|
-
return { type: 4, value: value.map(toPyValue) };
|
|
1960
|
-
} else if (value === null) {
|
|
1961
|
-
return {
|
|
1962
|
-
type: 3
|
|
1963
|
-
/* None */
|
|
1964
|
-
};
|
|
1965
|
-
} else if (value instanceof Date) {
|
|
1966
|
-
return {
|
|
1967
|
-
type: 1,
|
|
1968
|
-
value: String(PyDateTime.convertDate(value))
|
|
1969
|
-
};
|
|
1970
|
-
} else if (value instanceof PyDate || value instanceof PyDateTime) {
|
|
1971
|
-
return { type: 1, value };
|
|
1972
|
-
} else {
|
|
1973
|
-
const content = {};
|
|
1974
|
-
for (const key in value) {
|
|
1975
|
-
content[key] = toPyValue(value[key]);
|
|
1976
|
-
}
|
|
1977
|
-
return { type: 11, value: content };
|
|
1978
|
-
}
|
|
1979
|
-
default:
|
|
1980
|
-
throw new Error("Invalid type");
|
|
1904
|
+
const newDomain = new _Domain([]);
|
|
1905
|
+
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
1906
|
+
return newDomain;
|
|
1981
1907
|
}
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
if (ast.op === "not") {
|
|
1997
|
-
return `not ${formatAST(ast.right, 50)}`;
|
|
1998
|
-
}
|
|
1999
|
-
return `${ast.op}${formatAST(ast.right, 130)}`;
|
|
2000
|
-
case 7:
|
|
2001
|
-
const abp = bp(ast.op);
|
|
2002
|
-
const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
|
|
2003
|
-
return abp < lbp ? `(${binaryStr})` : binaryStr;
|
|
2004
|
-
case 11:
|
|
2005
|
-
const pairs = [];
|
|
2006
|
-
for (const k in ast.value) {
|
|
2007
|
-
pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
|
|
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
|
+
);
|
|
2008
1922
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
for (const kwarg in ast.kwargs) {
|
|
2029
|
-
kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
|
|
1923
|
+
this.ast = normalizeDomainAST(rawAST);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
contains(record) {
|
|
1927
|
+
const expr = evaluate(this.ast, record);
|
|
1928
|
+
return matchDomain(record, expr);
|
|
1929
|
+
}
|
|
1930
|
+
toString() {
|
|
1931
|
+
return formatAST(this.ast);
|
|
1932
|
+
}
|
|
1933
|
+
toList(context) {
|
|
1934
|
+
return evaluate(this.ast, context);
|
|
1935
|
+
}
|
|
1936
|
+
toJson() {
|
|
1937
|
+
try {
|
|
1938
|
+
const evaluatedAsList = this.toList({});
|
|
1939
|
+
const evaluatedDomain = new _Domain(evaluatedAsList);
|
|
1940
|
+
if (evaluatedDomain.toString() === this.toString()) {
|
|
1941
|
+
return evaluatedAsList;
|
|
2030
1942
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
1943
|
+
return this.toString();
|
|
1944
|
+
} catch {
|
|
1945
|
+
return this.toString();
|
|
1946
|
+
}
|
|
2035
1947
|
}
|
|
2036
|
-
}
|
|
2037
|
-
var
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
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
|
+
};
|
|
2042
1967
|
}
|
|
2043
1968
|
});
|
|
1969
|
+
return { type: 4, value: elems };
|
|
2044
1970
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
case "-":
|
|
2052
|
-
if (value instanceof Object && "negate" in value) {
|
|
2053
|
-
return value.negate();
|
|
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");
|
|
2054
1977
|
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
case "not":
|
|
2059
|
-
return !isTrue(value);
|
|
2060
|
-
default:
|
|
2061
|
-
throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
function pytypeIndex(val) {
|
|
2065
|
-
switch (typeof val) {
|
|
2066
|
-
case "object":
|
|
2067
|
-
return val === null ? 1 : Array.isArray(val) ? 5 : 3;
|
|
2068
|
-
case "number":
|
|
2069
|
-
return 2;
|
|
2070
|
-
case "string":
|
|
2071
|
-
return 4;
|
|
2072
|
-
default:
|
|
2073
|
-
throw new EvaluationError(`Unknown type: ${typeof val}`);
|
|
1978
|
+
} else {
|
|
1979
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
1980
|
+
}
|
|
2074
1981
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
if (typeof left === "number" && typeof right === "number") {
|
|
2078
|
-
return left < right;
|
|
1982
|
+
if (domain.value.length === 0) {
|
|
1983
|
+
return domain;
|
|
2079
1984
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
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
|
+
}
|
|
2082
2006
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2007
|
+
const values = domain.value.slice();
|
|
2008
|
+
while (expected < 0) {
|
|
2009
|
+
expected++;
|
|
2010
|
+
values.unshift({ type: 1, value: op });
|
|
2085
2011
|
}
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2012
|
+
if (expected > 0) {
|
|
2013
|
+
throw new InvalidDomainError(
|
|
2014
|
+
`invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
|
|
2015
|
+
);
|
|
2090
2016
|
}
|
|
2091
|
-
return
|
|
2017
|
+
return { type: 4, value: values };
|
|
2092
2018
|
}
|
|
2093
|
-
function
|
|
2094
|
-
if (typeof
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
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
|
+
]);
|
|
2100
2032
|
}
|
|
2101
|
-
return false;
|
|
2102
2033
|
}
|
|
2103
|
-
|
|
2104
|
-
|
|
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;
|
|
2050
|
+
}
|
|
2051
|
+
// eslint-disable-next-line no-fallthrough
|
|
2052
|
+
case "=":
|
|
2053
|
+
case "==":
|
|
2054
|
+
if (Array.isArray(fieldValue) && Array.isArray(value)) {
|
|
2055
|
+
return shallowEqual2(fieldValue, value);
|
|
2056
|
+
}
|
|
2057
|
+
return fieldValue === value;
|
|
2058
|
+
case "!=":
|
|
2059
|
+
case "<>":
|
|
2060
|
+
return !matchCondition(record, [field, "==", value]);
|
|
2061
|
+
case "<":
|
|
2062
|
+
return fieldValue < value;
|
|
2063
|
+
case "<=":
|
|
2064
|
+
return fieldValue <= value;
|
|
2065
|
+
case ">":
|
|
2066
|
+
return fieldValue > value;
|
|
2067
|
+
case ">=":
|
|
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));
|
|
2073
|
+
}
|
|
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
|
+
);
|
|
2105
2113
|
}
|
|
2106
|
-
|
|
2114
|
+
throw new InvalidDomainError("could not match domain");
|
|
2107
2115
|
}
|
|
2108
|
-
function
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
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;
|
|
2114
2127
|
}
|
|
2115
|
-
|
|
2116
|
-
|
|
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
|
+
}
|
|
2117
2139
|
}
|
|
2118
|
-
return
|
|
2140
|
+
return matchCondition(record, condStack.pop());
|
|
2119
2141
|
}
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
const
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
return left.add(right);
|
|
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("&");
|
|
2149
|
+
};
|
|
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;
|
|
2136
2157
|
}
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2158
|
+
return JSON.stringify(parsedData);
|
|
2159
|
+
} catch (e) {
|
|
2160
|
+
console.warn("Failed to parse originalRequest.data", e);
|
|
2161
|
+
return originalRequest.data;
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
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);
|
|
2140
2219
|
} else {
|
|
2141
|
-
|
|
2220
|
+
prom.resolve(token);
|
|
2142
2221
|
}
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
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;
|
|
2149
2237
|
}
|
|
2238
|
+
return config2;
|
|
2239
|
+
},
|
|
2240
|
+
(error) => {
|
|
2241
|
+
Promise.reject(error);
|
|
2150
2242
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
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
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
return Promise.reject(await handleError3(error));
|
|
2153
2334
|
}
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
if (isRightDelta) {
|
|
2159
|
-
return PyRelativeDelta.substract(left, right);
|
|
2335
|
+
);
|
|
2336
|
+
const handleResponse = (res) => {
|
|
2337
|
+
if (res && res.data) {
|
|
2338
|
+
return res.data;
|
|
2160
2339
|
}
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
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 };
|
|
2170
2353
|
}
|
|
2171
|
-
|
|
2172
|
-
|
|
2354
|
+
};
|
|
2355
|
+
const clearAuthToken = async () => {
|
|
2356
|
+
await localStorage2.clearToken();
|
|
2357
|
+
if (typeof window !== "undefined") {
|
|
2358
|
+
window.location.href = `/login`;
|
|
2173
2359
|
}
|
|
2174
|
-
|
|
2360
|
+
};
|
|
2361
|
+
function formatUrl(url, db2) {
|
|
2362
|
+
return url + (db2 ? "?db=" + db2 : "");
|
|
2175
2363
|
}
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
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"
|
|
2373
|
+
}
|
|
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];
|
|
2185
2397
|
}
|
|
2186
|
-
case "/":
|
|
2187
|
-
return left / right;
|
|
2188
|
-
case "%":
|
|
2189
|
-
return left % right;
|
|
2190
|
-
case "//":
|
|
2191
|
-
if (left instanceof PyTimeDelta) {
|
|
2192
|
-
return left.divide(right);
|
|
2193
|
-
}
|
|
2194
|
-
return Math.floor(left / right);
|
|
2195
|
-
case "**":
|
|
2196
|
-
return left ** right;
|
|
2197
|
-
case "==":
|
|
2198
|
-
return isEqual(left, right);
|
|
2199
|
-
case "<>":
|
|
2200
|
-
case "!=":
|
|
2201
|
-
return !isEqual(left, right);
|
|
2202
|
-
case "<":
|
|
2203
|
-
return isLess(left, right);
|
|
2204
|
-
case ">":
|
|
2205
|
-
return isLess(right, left);
|
|
2206
|
-
case ">=":
|
|
2207
|
-
return isEqual(left, right) || isLess(right, left);
|
|
2208
|
-
case "<=":
|
|
2209
|
-
return isEqual(left, right) || isLess(left, right);
|
|
2210
|
-
case "in":
|
|
2211
|
-
return isIn(left, right);
|
|
2212
|
-
case "not in":
|
|
2213
|
-
return !isIn(left, right);
|
|
2214
|
-
default:
|
|
2215
|
-
throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
|
|
2216
2398
|
}
|
|
2217
|
-
}
|
|
2218
|
-
var
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
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;
|
|
2226
2455
|
}
|
|
2227
|
-
return null;
|
|
2228
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
|
|
2229
2480
|
};
|
|
2230
|
-
var
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
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
|
+
}
|
|
2236
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: {}
|
|
2237
2525
|
};
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
)
|
|
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;
|
|
2550
|
+
}
|
|
2246
2551
|
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
},
|
|
2266
|
-
difference(...args) {
|
|
2267
|
-
return applyFunc(
|
|
2268
|
-
"difference",
|
|
2269
|
-
(iterable) => {
|
|
2270
|
-
iterable = new Set(iterable);
|
|
2271
|
-
const difference = /* @__PURE__ */ new Set();
|
|
2272
|
-
for (const e of this) {
|
|
2273
|
-
if (!iterable.has(e)) {
|
|
2274
|
-
difference.add(e);
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2277
|
-
return difference;
|
|
2278
|
-
},
|
|
2279
|
-
this,
|
|
2280
|
-
...args
|
|
2281
|
-
);
|
|
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: [] }
|
|
2282
2570
|
},
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
...args
|
|
2291
|
-
);
|
|
2571
|
+
reducers: {
|
|
2572
|
+
setHeader: (state, action) => {
|
|
2573
|
+
state.value = { ...state.value, ...action.payload };
|
|
2574
|
+
},
|
|
2575
|
+
setAllowedCompanyIds: (state, action) => {
|
|
2576
|
+
state.value.allowedCompanyIds = action.payload;
|
|
2577
|
+
}
|
|
2292
2578
|
}
|
|
2579
|
+
});
|
|
2580
|
+
var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
|
|
2581
|
+
var header_slice_default = headerSlice.reducer;
|
|
2582
|
+
|
|
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: []
|
|
2293
2597
|
};
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
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
|
+
}
|
|
2327
2632
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
case 10:
|
|
2363
|
-
return ast2.value.map(_evaluate);
|
|
2364
|
-
case 11:
|
|
2365
|
-
const dict = {};
|
|
2366
|
-
for (const key2 in ast2.value) {
|
|
2367
|
-
dict[key2] = _evaluate(ast2.value[key2]);
|
|
2368
|
-
}
|
|
2369
|
-
dicts.add(dict);
|
|
2370
|
-
return dict;
|
|
2371
|
-
case 8:
|
|
2372
|
-
const fnValue = _evaluate(ast2.fn);
|
|
2373
|
-
const args = ast2.args.map(_evaluate);
|
|
2374
|
-
const kwargs = {};
|
|
2375
|
-
for (const kwarg in ast2.kwargs) {
|
|
2376
|
-
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
2377
|
-
}
|
|
2378
|
-
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
2379
|
-
return fnValue.create(...args, kwargs);
|
|
2380
|
-
}
|
|
2381
|
-
return fnValue(...args, kwargs);
|
|
2382
|
-
case 12:
|
|
2383
|
-
const dictVal = _evaluate(ast2.target);
|
|
2384
|
-
const key = _evaluate(ast2.key);
|
|
2385
|
-
return dictVal[key];
|
|
2386
|
-
case 13:
|
|
2387
|
-
if (isTrue(_evaluate(ast2.condition))) {
|
|
2388
|
-
return _evaluate(ast2.ifTrue);
|
|
2389
|
-
} else {
|
|
2390
|
-
return _evaluate(ast2.ifFalse);
|
|
2391
|
-
}
|
|
2392
|
-
case 15:
|
|
2393
|
-
let leftVal = _evaluate(ast2.obj);
|
|
2394
|
-
let result;
|
|
2395
|
-
if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
|
|
2396
|
-
result = DICT[ast2.key];
|
|
2397
|
-
} else if (typeof leftVal === "string") {
|
|
2398
|
-
result = STRING[ast2.key];
|
|
2399
|
-
} else if (leftVal instanceof Set) {
|
|
2400
|
-
result = SET[ast2.key];
|
|
2401
|
-
} else if (ast2.key === "get" && typeof leftVal === "object") {
|
|
2402
|
-
result = DICT[ast2.key];
|
|
2403
|
-
leftVal = toPyDict(leftVal);
|
|
2404
|
-
} else {
|
|
2405
|
-
result = leftVal[ast2.key];
|
|
2406
|
-
}
|
|
2407
|
-
if (typeof result === "function") {
|
|
2408
|
-
const bound = result.bind(leftVal);
|
|
2409
|
-
bound[unboundFn] = result;
|
|
2410
|
-
return bound;
|
|
2411
|
-
}
|
|
2412
|
-
return result;
|
|
2413
|
-
default:
|
|
2414
|
-
throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
|
|
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;
|
|
2647
|
+
|
|
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;
|
|
2415
2667
|
}
|
|
2416
2668
|
}
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
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;
|
|
2421
2696
|
}
|
|
2422
|
-
return val;
|
|
2423
2697
|
}
|
|
2424
|
-
|
|
2425
|
-
}
|
|
2698
|
+
});
|
|
2699
|
+
var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
|
|
2700
|
+
var navbar_slice_default = navbarSlice.reducer;
|
|
2426
2701
|
|
|
2427
|
-
// src/
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
}
|
|
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;
|
|
2432
2718
|
|
|
2433
|
-
// src/
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
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
|
+
}
|
|
2437
2787
|
}
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
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;
|
|
2441
2804
|
|
|
2442
|
-
// src/
|
|
2443
|
-
|
|
2805
|
+
// src/store/store.ts
|
|
2806
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
2444
2807
|
|
|
2445
|
-
//
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
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. `;
|
|
2449
2811
|
}
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
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()}`
|
|
2453
2817
|
};
|
|
2454
|
-
var
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
}
|
|
2462
|
-
const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
|
|
2463
|
-
if (domains.length === 1) {
|
|
2464
|
-
return domain1;
|
|
2465
|
-
}
|
|
2466
|
-
const domain2 = _Domain.combine(domains.slice(1), operator);
|
|
2467
|
-
const result = new _Domain([]);
|
|
2468
|
-
const astValues1 = domain1.ast.value;
|
|
2469
|
-
const astValues2 = domain2.ast.value;
|
|
2470
|
-
const op = operator === "AND" ? "&" : "|";
|
|
2471
|
-
const combinedAST = {
|
|
2472
|
-
type: 4,
|
|
2473
|
-
value: astValues1.concat(astValues2)
|
|
2474
|
-
};
|
|
2475
|
-
result.ast = normalizeDomainAST(combinedAST, op);
|
|
2476
|
-
return result;
|
|
2477
|
-
}
|
|
2478
|
-
static and(domains) {
|
|
2479
|
-
return _Domain.combine(domains, "AND");
|
|
2480
|
-
}
|
|
2481
|
-
static or(domains) {
|
|
2482
|
-
return _Domain.combine(domains, "OR");
|
|
2483
|
-
}
|
|
2484
|
-
static not(domain) {
|
|
2485
|
-
const result = new _Domain(domain);
|
|
2486
|
-
result.ast.value.unshift({ type: 1, value: "!" });
|
|
2487
|
-
return result;
|
|
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);
|
|
2488
2825
|
}
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
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)) {
|
|
2505
|
-
newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
|
|
2506
|
-
return 3;
|
|
2507
|
-
}
|
|
2508
|
-
newDomain2.ast.value.push(leaf);
|
|
2509
|
-
if (leaf.value === "!") {
|
|
2510
|
-
return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
|
|
2511
|
-
}
|
|
2512
|
-
const firstLeafSkip = processLeaf(
|
|
2513
|
-
elements,
|
|
2514
|
-
idx + 1,
|
|
2515
|
-
leaf.value,
|
|
2516
|
-
newDomain2
|
|
2517
|
-
);
|
|
2518
|
-
const secondLeafSkip = processLeaf(
|
|
2519
|
-
elements,
|
|
2520
|
-
idx + 1 + firstLeafSkip,
|
|
2521
|
-
leaf.value,
|
|
2522
|
-
newDomain2
|
|
2523
|
-
);
|
|
2524
|
-
return 1 + firstLeafSkip + secondLeafSkip;
|
|
2525
|
-
}
|
|
2526
|
-
return 0;
|
|
2527
|
-
}
|
|
2528
|
-
const d = new _Domain(domain);
|
|
2529
|
-
if (d.ast.value.length === 0) {
|
|
2530
|
-
return d;
|
|
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;
|
|
2531
2841
|
}
|
|
2532
|
-
const newDomain = new _Domain([]);
|
|
2533
|
-
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
2534
|
-
return newDomain;
|
|
2535
2842
|
}
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
this.ast = normalizeDomainAST(rawAST);
|
|
2552
|
-
}
|
|
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;
|
|
2553
2858
|
}
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
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);
|
|
2557
2876
|
}
|
|
2558
|
-
|
|
2559
|
-
|
|
2877
|
+
return typeOfVal;
|
|
2878
|
+
}
|
|
2879
|
+
function warning(message) {
|
|
2880
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
2881
|
+
console.error(message);
|
|
2560
2882
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2883
|
+
try {
|
|
2884
|
+
throw new Error(message);
|
|
2885
|
+
} catch (e) {
|
|
2563
2886
|
}
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
}
|
|
2571
|
-
return this.toString();
|
|
2572
|
-
} catch {
|
|
2573
|
-
return this.toString();
|
|
2574
|
-
}
|
|
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.";
|
|
2575
2893
|
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
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('", "')}"`;
|
|
2896
|
+
}
|
|
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.`;
|
|
2905
|
+
}
|
|
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.`);
|
|
2595
2920
|
}
|
|
2596
2921
|
});
|
|
2597
|
-
return { type: 4, value: elems };
|
|
2598
2922
|
}
|
|
2599
|
-
function
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
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}"`);
|
|
2605
2931
|
}
|
|
2606
|
-
} else {
|
|
2607
|
-
throw new InvalidDomainError("Invalid domain AST");
|
|
2608
2932
|
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
return domain;
|
|
2612
|
-
}
|
|
2613
|
-
let expected = 1;
|
|
2614
|
-
for (const child of domain.value) {
|
|
2615
|
-
switch (child.type) {
|
|
2616
|
-
case 1:
|
|
2617
|
-
if (child.value === "&" || child.value === "|") {
|
|
2618
|
-
expected++;
|
|
2619
|
-
} else if (child.value !== "!") {
|
|
2620
|
-
throw new InvalidDomainError("Invalid domain AST");
|
|
2621
|
-
}
|
|
2622
|
-
break;
|
|
2623
|
-
case 4:
|
|
2624
|
-
/* list */
|
|
2625
|
-
case 10:
|
|
2626
|
-
if (child.value.length === 3) {
|
|
2627
|
-
expected--;
|
|
2628
|
-
break;
|
|
2629
|
-
}
|
|
2630
|
-
throw new InvalidDomainError("Invalid domain AST");
|
|
2631
|
-
default:
|
|
2632
|
-
throw new InvalidDomainError("Invalid domain AST");
|
|
2933
|
+
if (typeof reducers[key] === "function") {
|
|
2934
|
+
finalReducers[key] = reducers[key];
|
|
2633
2935
|
}
|
|
2634
2936
|
}
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
}
|
|
2640
|
-
if (expected > 0) {
|
|
2641
|
-
throw new InvalidDomainError(
|
|
2642
|
-
`invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
|
|
2643
|
-
);
|
|
2937
|
+
const finalReducerKeys = Object.keys(finalReducers);
|
|
2938
|
+
let unexpectedKeyCache;
|
|
2939
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2940
|
+
unexpectedKeyCache = {};
|
|
2644
2941
|
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2942
|
+
let shapeAssertionError;
|
|
2943
|
+
try {
|
|
2944
|
+
assertReducerShape(finalReducers);
|
|
2945
|
+
} catch (e) {
|
|
2946
|
+
shapeAssertionError = e;
|
|
2650
2947
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
if (names.length >= 2) {
|
|
2655
|
-
return matchCondition(record[names[0]], [
|
|
2656
|
-
names.slice(1).join("."),
|
|
2657
|
-
operator,
|
|
2658
|
-
value
|
|
2659
|
-
]);
|
|
2948
|
+
return function combination(state = {}, action) {
|
|
2949
|
+
if (shapeAssertionError) {
|
|
2950
|
+
throw shapeAssertionError;
|
|
2660
2951
|
}
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
`(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
|
|
2666
|
-
"g"
|
|
2667
|
-
);
|
|
2668
|
-
ilikeRegexp = new RegExp(
|
|
2669
|
-
`(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
|
|
2670
|
-
"gi"
|
|
2671
|
-
);
|
|
2672
|
-
}
|
|
2673
|
-
const fieldValue = typeof field === "number" ? field : record[field];
|
|
2674
|
-
switch (operator) {
|
|
2675
|
-
case "=?":
|
|
2676
|
-
if ([false, null].includes(value)) {
|
|
2677
|
-
return true;
|
|
2678
|
-
}
|
|
2679
|
-
// eslint-disable-next-line no-fallthrough
|
|
2680
|
-
case "=":
|
|
2681
|
-
case "==":
|
|
2682
|
-
if (Array.isArray(fieldValue) && Array.isArray(value)) {
|
|
2683
|
-
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);
|
|
2684
2956
|
}
|
|
2685
|
-
return fieldValue === value;
|
|
2686
|
-
case "!=":
|
|
2687
|
-
case "<>":
|
|
2688
|
-
return !matchCondition(record, [field, "==", value]);
|
|
2689
|
-
case "<":
|
|
2690
|
-
return fieldValue < value;
|
|
2691
|
-
case "<=":
|
|
2692
|
-
return fieldValue <= value;
|
|
2693
|
-
case ">":
|
|
2694
|
-
return fieldValue > value;
|
|
2695
|
-
case ">=":
|
|
2696
|
-
return fieldValue >= value;
|
|
2697
|
-
case "in": {
|
|
2698
|
-
const val = Array.isArray(value) ? value : [value];
|
|
2699
|
-
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2700
|
-
return fieldVal.some((fv) => val.includes(fv));
|
|
2701
2957
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
case "not like":
|
|
2713
|
-
if (fieldValue === false) {
|
|
2714
|
-
return false;
|
|
2715
|
-
}
|
|
2716
|
-
return Boolean(!fieldValue.match(likeRegexp));
|
|
2717
|
-
case "=like":
|
|
2718
|
-
if (fieldValue === false) {
|
|
2719
|
-
return false;
|
|
2720
|
-
}
|
|
2721
|
-
return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
|
|
2722
|
-
fieldValue
|
|
2723
|
-
);
|
|
2724
|
-
case "ilike":
|
|
2725
|
-
if (fieldValue === false) {
|
|
2726
|
-
return false;
|
|
2727
|
-
}
|
|
2728
|
-
return Boolean(fieldValue.match(ilikeRegexp));
|
|
2729
|
-
case "not ilike":
|
|
2730
|
-
if (fieldValue === false) {
|
|
2731
|
-
return false;
|
|
2732
|
-
}
|
|
2733
|
-
return Boolean(!fieldValue.match(ilikeRegexp));
|
|
2734
|
-
case "=ilike":
|
|
2735
|
-
if (fieldValue === false) {
|
|
2736
|
-
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.`);
|
|
2737
2968
|
}
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
}
|
|
2744
|
-
function makeOperators(record) {
|
|
2745
|
-
const match = matchCondition.bind(null, record);
|
|
2746
|
-
return {
|
|
2747
|
-
"!": (x) => !match(x),
|
|
2748
|
-
"&": (a, b) => match(a) && match(b),
|
|
2749
|
-
"|": (a, b) => match(a) || match(b)
|
|
2969
|
+
nextState[key] = nextStateForKey;
|
|
2970
|
+
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
2971
|
+
}
|
|
2972
|
+
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
2973
|
+
return hasChanged ? nextState : state;
|
|
2750
2974
|
};
|
|
2751
2975
|
}
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2976
|
+
|
|
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
|
+
});
|
|
2996
|
+
|
|
2997
|
+
// src/environment/EnvStore.ts
|
|
2998
|
+
var EnvStore = class _EnvStore {
|
|
2999
|
+
static instance = null;
|
|
3000
|
+
envStore;
|
|
3001
|
+
baseUrl;
|
|
3002
|
+
requests;
|
|
3003
|
+
context;
|
|
3004
|
+
defaultCompany;
|
|
3005
|
+
config;
|
|
3006
|
+
companies;
|
|
3007
|
+
user;
|
|
3008
|
+
db;
|
|
3009
|
+
localStorageUtils;
|
|
3010
|
+
sessionStorageUtils;
|
|
3011
|
+
refreshTokenEndpoint;
|
|
3012
|
+
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
3013
|
+
this.envStore = envStore2;
|
|
3014
|
+
this.localStorageUtils = localStorageUtils2;
|
|
3015
|
+
this.sessionStorageUtils = sessionStorageUtils2;
|
|
3016
|
+
this.setup();
|
|
3017
|
+
}
|
|
3018
|
+
static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
3019
|
+
if (!_EnvStore.instance) {
|
|
3020
|
+
console.log("Creating new EnvStore instance");
|
|
3021
|
+
_EnvStore.instance = new _EnvStore(envStore2, localStorageUtils2, sessionStorageUtils2);
|
|
2764
3022
|
} else {
|
|
2765
|
-
|
|
3023
|
+
console.log("Returning existing EnvStore instance");
|
|
2766
3024
|
}
|
|
3025
|
+
return _EnvStore.instance;
|
|
3026
|
+
}
|
|
3027
|
+
setup() {
|
|
3028
|
+
const env = this.envStore.getState().env;
|
|
3029
|
+
console.log("Redux env state in A1:", env);
|
|
3030
|
+
this.baseUrl = env?.baseUrl;
|
|
3031
|
+
this.requests = env?.requests;
|
|
3032
|
+
this.context = env?.context;
|
|
3033
|
+
this.defaultCompany = env?.defaultCompany;
|
|
3034
|
+
this.config = env?.config;
|
|
3035
|
+
this.companies = env?.companies || [];
|
|
3036
|
+
this.user = env?.user;
|
|
3037
|
+
this.db = env?.db;
|
|
3038
|
+
this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
|
|
3039
|
+
console.log("Env setup in A1:", this);
|
|
3040
|
+
}
|
|
3041
|
+
setupEnv(envConfig) {
|
|
3042
|
+
const dispatch = this.envStore.dispatch;
|
|
3043
|
+
const env = {
|
|
3044
|
+
...envConfig,
|
|
3045
|
+
localStorageUtils: this.localStorageUtils,
|
|
3046
|
+
sessionStorageUtils: this.sessionStorageUtils
|
|
3047
|
+
};
|
|
3048
|
+
console.log("Setting up env with config:", envConfig);
|
|
3049
|
+
const requests = axiosClient.init(env);
|
|
3050
|
+
console.log("axiosClient.init result:", requests);
|
|
3051
|
+
dispatch(setEnv({ ...env, requests }));
|
|
3052
|
+
this.setup();
|
|
3053
|
+
}
|
|
3054
|
+
setUid(uid) {
|
|
3055
|
+
const dispatch = this.envStore.dispatch;
|
|
3056
|
+
dispatch(setUid(uid));
|
|
3057
|
+
this.setup();
|
|
3058
|
+
}
|
|
3059
|
+
setLang(lang) {
|
|
3060
|
+
const dispatch = this.envStore.dispatch;
|
|
3061
|
+
dispatch(setLang(lang));
|
|
3062
|
+
this.setup();
|
|
3063
|
+
}
|
|
3064
|
+
setAllowCompanies(allowCompanies) {
|
|
3065
|
+
const dispatch = this.envStore.dispatch;
|
|
3066
|
+
dispatch(setAllowCompanies(allowCompanies));
|
|
3067
|
+
this.setup();
|
|
3068
|
+
}
|
|
3069
|
+
setCompanies(companies) {
|
|
3070
|
+
const dispatch = this.envStore.dispatch;
|
|
3071
|
+
dispatch(setCompanies(companies));
|
|
3072
|
+
this.setup();
|
|
3073
|
+
}
|
|
3074
|
+
setDefaultCompany(company) {
|
|
3075
|
+
const dispatch = this.envStore.dispatch;
|
|
3076
|
+
dispatch(setDefaultCompany(company));
|
|
3077
|
+
this.setup();
|
|
3078
|
+
}
|
|
3079
|
+
setUserInfo(userInfo) {
|
|
3080
|
+
const dispatch = this.envStore.dispatch;
|
|
3081
|
+
dispatch(setUser(userInfo));
|
|
3082
|
+
this.setup();
|
|
2767
3083
|
}
|
|
2768
|
-
return matchCondition(record, condStack.pop());
|
|
2769
|
-
}
|
|
2770
|
-
|
|
2771
|
-
// src/utils/function.ts
|
|
2772
|
-
import { useEffect, useState } from "react";
|
|
2773
|
-
var toQueryString = (params) => {
|
|
2774
|
-
return Object.keys(params).map(
|
|
2775
|
-
(key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
|
|
2776
|
-
).join("&");
|
|
2777
3084
|
};
|
|
2778
|
-
|
|
2779
|
-
// src/environment/EnvStore.ts
|
|
2780
3085
|
function getEnv() {
|
|
2781
|
-
|
|
2782
|
-
|
|
3086
|
+
const instance = EnvStore.getInstance(envStore);
|
|
3087
|
+
if (!instance) {
|
|
3088
|
+
throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
|
|
3089
|
+
}
|
|
3090
|
+
return instance;
|
|
2783
3091
|
}
|
|
2784
3092
|
|
|
2785
3093
|
// src/services/action-service/index.ts
|
|
@@ -2947,7 +3255,7 @@ var AuthService = {
|
|
|
2947
3255
|
}).filter(([_, value]) => !!value)
|
|
2948
3256
|
);
|
|
2949
3257
|
const encodedData = new URLSearchParams(payload).toString();
|
|
2950
|
-
return env?.requests?.post(body
|
|
3258
|
+
return env?.requests?.post(body.path, encodedData, {
|
|
2951
3259
|
headers: {
|
|
2952
3260
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
2953
3261
|
}
|
|
@@ -3044,20 +3352,6 @@ var AuthService = {
|
|
|
3044
3352
|
}
|
|
3045
3353
|
});
|
|
3046
3354
|
},
|
|
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
3355
|
async loginSocial({
|
|
3062
3356
|
db,
|
|
3063
3357
|
state,
|
|
@@ -3822,7 +4116,7 @@ var model_service_default = ModelService;
|
|
|
3822
4116
|
var UserService = {
|
|
3823
4117
|
async getProfile(path) {
|
|
3824
4118
|
const env = getEnv();
|
|
3825
|
-
return env
|
|
4119
|
+
return env.requests.get(path ?? "/userinfo" /* PROFILE_PATH */, {
|
|
3826
4120
|
headers: {
|
|
3827
4121
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
3828
4122
|
}
|
|
@@ -4141,7 +4435,8 @@ var ViewService = {
|
|
|
4141
4435
|
},
|
|
4142
4436
|
async getVersion() {
|
|
4143
4437
|
const env = getEnv();
|
|
4144
|
-
|
|
4438
|
+
console.log("env?.requests", env, env?.requests);
|
|
4439
|
+
return env?.requests?.get("", {
|
|
4145
4440
|
headers: {
|
|
4146
4441
|
"Content-Type": "application/json"
|
|
4147
4442
|
}
|