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