@fctc/interface-logic 1.7.4 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs.d.mts +4 -1
- package/dist/configs.d.ts +4 -1
- package/dist/configs.js +12 -9
- package/dist/configs.mjs +12 -9
- package/dist/environment.d.mts +55 -35
- package/dist/environment.d.ts +55 -35
- package/dist/environment.js +1311 -1232
- package/dist/environment.mjs +1309 -1231
- package/dist/hooks.d.mts +2 -7
- package/dist/hooks.d.ts +2 -7
- package/dist/hooks.js +2175 -1896
- package/dist/hooks.mjs +2960 -2680
- package/dist/provider.js +329 -19
- package/dist/provider.mjs +329 -19
- package/dist/services.d.mts +1 -2
- package/dist/services.d.ts +1 -2
- package/dist/services.js +2001 -1706
- package/dist/services.mjs +2001 -1706
- package/dist/store.d.mts +28 -224
- package/dist/store.d.ts +28 -224
- package/dist/store.js +6 -20
- package/dist/store.mjs +6 -20
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{view-type-D8ukwj_2.d.mts → view-type-BGJfDe73.d.mts} +1 -1
- package/dist/{view-type-D8ukwj_2.d.ts → view-type-BGJfDe73.d.ts} +1 -1
- package/package.json +81 -81
package/dist/environment.mjs
CHANGED
|
@@ -1,631 +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
|
-
requests: {
|
|
37
|
-
get: async (url, headers) => ({}),
|
|
38
|
-
post: async (url, body, headers) => ({}),
|
|
39
|
-
post_excel: async (url, body, headers) => ({}),
|
|
40
|
-
put: async (url, body, headers) => ({}),
|
|
41
|
-
patch: async (url, body) => ({}),
|
|
42
|
-
delete: async (url, body) => ({})
|
|
43
|
-
},
|
|
44
|
-
defaultCompany: {
|
|
45
|
-
id: null,
|
|
46
|
-
logo: "",
|
|
47
|
-
secondary_color: "",
|
|
48
|
-
primary_color: ""
|
|
49
|
-
},
|
|
50
|
-
context: {
|
|
51
|
-
uid: null,
|
|
52
|
-
allowed_company_ids: [],
|
|
53
|
-
lang: "vi_VN",
|
|
54
|
-
tz: "Asia/Saigon"
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var envSlice = createSlice2({
|
|
58
|
-
name: "env",
|
|
59
|
-
initialState: initialState2,
|
|
60
|
-
reducers: {
|
|
61
|
-
setEnv: (state, action) => {
|
|
62
|
-
Object.assign(state, action.payload);
|
|
63
|
-
},
|
|
64
|
-
setUid: (state, action) => {
|
|
65
|
-
state.context.uid = action.payload;
|
|
66
|
-
},
|
|
67
|
-
setAllowCompanies: (state, action) => {
|
|
68
|
-
state.context.allowed_company_ids = action.payload;
|
|
69
|
-
},
|
|
70
|
-
setCompanies: (state, action) => {
|
|
71
|
-
state.companies = action.payload;
|
|
72
|
-
},
|
|
73
|
-
setDefaultCompany: (state, action) => {
|
|
74
|
-
state.defaultCompany = action.payload;
|
|
75
|
-
},
|
|
76
|
-
setLang: (state, action) => {
|
|
77
|
-
state.context.lang = action.payload;
|
|
78
|
-
},
|
|
79
|
-
setUser: (state, action) => {
|
|
80
|
-
state.user = action.payload;
|
|
81
|
-
},
|
|
82
|
-
setConfig: (state, action) => {
|
|
83
|
-
state.config = action.payload;
|
|
84
|
-
},
|
|
85
|
-
setEnvFile: (state, action) => {
|
|
86
|
-
state.envFile = action.payload;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
var {
|
|
91
|
-
setEnv,
|
|
92
|
-
setUid,
|
|
93
|
-
setLang,
|
|
94
|
-
setAllowCompanies,
|
|
95
|
-
setCompanies,
|
|
96
|
-
setDefaultCompany,
|
|
97
|
-
setUser,
|
|
98
|
-
setConfig,
|
|
99
|
-
setEnvFile
|
|
100
|
-
} = envSlice.actions;
|
|
101
|
-
var env_slice_default = envSlice.reducer;
|
|
102
|
-
|
|
103
|
-
// src/store/reducers/excel-slice/index.ts
|
|
104
|
-
import { createSlice as createSlice3 } from "@reduxjs/toolkit";
|
|
105
|
-
var initialState3 = {
|
|
106
|
-
dataParse: null,
|
|
107
|
-
idFile: null,
|
|
108
|
-
isFileLoaded: false,
|
|
109
|
-
loadingImport: false,
|
|
110
|
-
selectedFile: null,
|
|
111
|
-
errorData: null
|
|
112
|
-
};
|
|
113
|
-
var excelSlice = createSlice3({
|
|
114
|
-
name: "excel",
|
|
115
|
-
initialState: initialState3,
|
|
116
|
-
reducers: {
|
|
117
|
-
setDataParse: (state, action) => {
|
|
118
|
-
state.dataParse = action.payload;
|
|
119
|
-
},
|
|
120
|
-
setIdFile: (state, action) => {
|
|
121
|
-
state.idFile = action.payload;
|
|
122
|
-
},
|
|
123
|
-
setIsFileLoaded: (state, action) => {
|
|
124
|
-
state.isFileLoaded = action.payload;
|
|
125
|
-
},
|
|
126
|
-
setLoadingImport: (state, action) => {
|
|
127
|
-
state.loadingImport = action.payload;
|
|
128
|
-
},
|
|
129
|
-
setSelectedFile: (state, action) => {
|
|
130
|
-
state.selectedFile = action.payload;
|
|
131
|
-
},
|
|
132
|
-
setErrorData: (state, action) => {
|
|
133
|
-
state.errorData = action.payload;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
var {
|
|
138
|
-
setDataParse,
|
|
139
|
-
setIdFile,
|
|
140
|
-
setIsFileLoaded,
|
|
141
|
-
setLoadingImport,
|
|
142
|
-
setSelectedFile,
|
|
143
|
-
setErrorData
|
|
144
|
-
} = excelSlice.actions;
|
|
145
|
-
var excel_slice_default = excelSlice.reducer;
|
|
146
|
-
|
|
147
|
-
// src/store/reducers/form-slice/index.ts
|
|
148
|
-
import { createSlice as createSlice4 } from "@reduxjs/toolkit";
|
|
149
|
-
var initialState4 = {
|
|
150
|
-
viewDataStore: {},
|
|
151
|
-
isShowingModalDetail: false,
|
|
152
|
-
isShowModalTranslate: false,
|
|
153
|
-
formSubmitComponent: {},
|
|
154
|
-
fieldTranslation: null,
|
|
155
|
-
listSubject: {},
|
|
156
|
-
dataUser: {}
|
|
157
|
-
};
|
|
158
|
-
var formSlice = createSlice4({
|
|
159
|
-
name: "form",
|
|
160
|
-
initialState: initialState4,
|
|
161
|
-
reducers: {
|
|
162
|
-
setViewDataStore: (state, action) => {
|
|
163
|
-
state.viewDataStore = action.payload;
|
|
164
|
-
},
|
|
165
|
-
setIsShowingModalDetail: (state, action) => {
|
|
166
|
-
state.isShowingModalDetail = action.payload;
|
|
167
|
-
},
|
|
168
|
-
setIsShowModalTranslate: (state, action) => {
|
|
169
|
-
state.isShowModalTranslate = action.payload;
|
|
170
|
-
},
|
|
171
|
-
setFormSubmitComponent: (state, action) => {
|
|
172
|
-
state.formSubmitComponent[action.payload.key] = action.payload.component;
|
|
173
|
-
},
|
|
174
|
-
setFieldTranslate: (state, action) => {
|
|
175
|
-
state.fieldTranslation = action.payload;
|
|
176
|
-
},
|
|
177
|
-
setListSubject: (state, action) => {
|
|
178
|
-
state.listSubject = action.payload;
|
|
179
|
-
},
|
|
180
|
-
setDataUser: (state, action) => {
|
|
181
|
-
state.dataUser = action.payload;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
var {
|
|
186
|
-
setViewDataStore,
|
|
187
|
-
setIsShowingModalDetail,
|
|
188
|
-
setIsShowModalTranslate,
|
|
189
|
-
setFormSubmitComponent,
|
|
190
|
-
setFieldTranslate,
|
|
191
|
-
setListSubject,
|
|
192
|
-
setDataUser
|
|
193
|
-
} = formSlice.actions;
|
|
194
|
-
var form_slice_default = formSlice.reducer;
|
|
195
|
-
|
|
196
|
-
// src/store/reducers/header-slice/index.ts
|
|
197
|
-
import { createSlice as createSlice5 } from "@reduxjs/toolkit";
|
|
198
|
-
var headerSlice = createSlice5({
|
|
199
|
-
name: "header",
|
|
200
|
-
initialState: {
|
|
201
|
-
value: { allowedCompanyIds: [] }
|
|
202
|
-
},
|
|
203
|
-
reducers: {
|
|
204
|
-
setHeader: (state, action) => {
|
|
205
|
-
state.value = { ...state.value, ...action.payload };
|
|
206
|
-
},
|
|
207
|
-
setAllowedCompanyIds: (state, action) => {
|
|
208
|
-
state.value.allowedCompanyIds = action.payload;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
|
|
213
|
-
var header_slice_default = headerSlice.reducer;
|
|
214
|
-
|
|
215
|
-
// src/store/reducers/list-slice/index.ts
|
|
216
|
-
import { createSlice as createSlice6 } from "@reduxjs/toolkit";
|
|
217
|
-
var initialState5 = {
|
|
218
|
-
pageLimit: 10,
|
|
219
|
-
fields: {},
|
|
220
|
-
order: "",
|
|
221
|
-
selectedRowKeys: [],
|
|
222
|
-
selectedRadioKey: 0,
|
|
223
|
-
indexRowTableModal: -2,
|
|
224
|
-
isUpdateTableModal: false,
|
|
225
|
-
footerGroupTable: {},
|
|
226
|
-
transferDetail: null,
|
|
227
|
-
page: 0,
|
|
228
|
-
domainTable: []
|
|
229
|
-
};
|
|
230
|
-
var listSlice = createSlice6({
|
|
231
|
-
name: "list",
|
|
232
|
-
initialState: initialState5,
|
|
233
|
-
reducers: {
|
|
234
|
-
setPageLimit: (state, action) => {
|
|
235
|
-
state.pageLimit = action.payload;
|
|
236
|
-
},
|
|
237
|
-
setFields: (state, action) => {
|
|
238
|
-
state.fields = action.payload;
|
|
239
|
-
},
|
|
240
|
-
setOrder: (state, action) => {
|
|
241
|
-
state.order = action.payload;
|
|
242
|
-
},
|
|
243
|
-
setSelectedRowKeys: (state, action) => {
|
|
244
|
-
state.selectedRowKeys = action.payload;
|
|
245
|
-
},
|
|
246
|
-
setSelectedRadioKey: (state, action) => {
|
|
247
|
-
state.selectedRadioKey = action.payload;
|
|
248
|
-
},
|
|
249
|
-
setIndexRowTableModal: (state, action) => {
|
|
250
|
-
state.indexRowTableModal = action.payload;
|
|
251
|
-
},
|
|
252
|
-
setTransferDetail: (state, action) => {
|
|
253
|
-
state.transferDetail = action.payload;
|
|
254
|
-
},
|
|
255
|
-
setIsUpdateTableModal: (state, action) => {
|
|
256
|
-
state.isUpdateTableModal = action.payload;
|
|
257
|
-
},
|
|
258
|
-
setPage: (state, action) => {
|
|
259
|
-
state.page = action.payload;
|
|
260
|
-
},
|
|
261
|
-
setDomainTable: (state, action) => {
|
|
262
|
-
state.domainTable = action.payload;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
var {
|
|
267
|
-
setPageLimit,
|
|
268
|
-
setFields,
|
|
269
|
-
setOrder,
|
|
270
|
-
setSelectedRowKeys,
|
|
271
|
-
setIndexRowTableModal,
|
|
272
|
-
setIsUpdateTableModal,
|
|
273
|
-
setPage,
|
|
274
|
-
setSelectedRadioKey,
|
|
275
|
-
setTransferDetail,
|
|
276
|
-
setDomainTable
|
|
277
|
-
} = listSlice.actions;
|
|
278
|
-
var list_slice_default = listSlice.reducer;
|
|
279
|
-
|
|
280
|
-
// src/store/reducers/login-slice/index.ts
|
|
281
|
-
import { createSlice as createSlice7 } from "@reduxjs/toolkit";
|
|
282
|
-
var initialState6 = {
|
|
283
|
-
db: "",
|
|
284
|
-
redirectTo: "/",
|
|
285
|
-
forgotPasswordUrl: "/"
|
|
286
|
-
};
|
|
287
|
-
var loginSlice = createSlice7({
|
|
288
|
-
name: "login",
|
|
289
|
-
initialState: initialState6,
|
|
290
|
-
reducers: {
|
|
291
|
-
setDb: (state, action) => {
|
|
292
|
-
state.db = action.payload;
|
|
293
|
-
},
|
|
294
|
-
setRedirectTo: (state, action) => {
|
|
295
|
-
state.redirectTo = action.payload;
|
|
296
|
-
},
|
|
297
|
-
setForgotPasswordUrl: (state, action) => {
|
|
298
|
-
state.forgotPasswordUrl = action.payload;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
|
|
303
|
-
var login_slice_default = loginSlice.reducer;
|
|
304
|
-
|
|
305
|
-
// src/store/reducers/navbar-slice/index.ts
|
|
306
|
-
import { createSlice as createSlice8 } from "@reduxjs/toolkit";
|
|
307
|
-
var initialState7 = {
|
|
308
|
-
menuFocus: {},
|
|
309
|
-
menuAction: {},
|
|
310
|
-
navbarWidth: 250,
|
|
311
|
-
menuList: []
|
|
312
|
-
};
|
|
313
|
-
var navbarSlice = createSlice8({
|
|
314
|
-
name: "navbar",
|
|
315
|
-
initialState: initialState7,
|
|
316
|
-
reducers: {
|
|
317
|
-
setMenuFocus: (state, action) => {
|
|
318
|
-
state.menuFocus = action.payload;
|
|
319
|
-
},
|
|
320
|
-
setMenuFocusAction: (state, action) => {
|
|
321
|
-
state.menuAction = action.payload;
|
|
322
|
-
},
|
|
323
|
-
setNavbarWidth: (state, action) => {
|
|
324
|
-
state.navbarWidth = action.payload;
|
|
325
|
-
},
|
|
326
|
-
setMenuList: (state, action) => {
|
|
327
|
-
state.menuList = action.payload;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
|
|
332
|
-
var navbar_slice_default = navbarSlice.reducer;
|
|
333
|
-
|
|
334
|
-
// src/store/reducers/profile-slice/index.ts
|
|
335
|
-
import { createSlice as createSlice9 } from "@reduxjs/toolkit";
|
|
336
|
-
var initialState8 = {
|
|
337
|
-
profile: {}
|
|
338
|
-
};
|
|
339
|
-
var profileSlice = createSlice9({
|
|
340
|
-
name: "profile",
|
|
341
|
-
initialState: initialState8,
|
|
342
|
-
reducers: {
|
|
343
|
-
setProfile: (state, action) => {
|
|
344
|
-
state.profile = action.payload;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
var { setProfile } = profileSlice.actions;
|
|
349
|
-
var profile_slice_default = profileSlice.reducer;
|
|
350
|
-
|
|
351
|
-
// src/store/reducers/search-slice/index.ts
|
|
352
|
-
import { createSlice as createSlice10 } from "@reduxjs/toolkit";
|
|
353
|
-
var initialState9 = {
|
|
354
|
-
groupByDomain: null,
|
|
355
|
-
searchBy: [],
|
|
356
|
-
searchString: "",
|
|
357
|
-
hoveredIndexSearchList: null,
|
|
358
|
-
selectedTags: [],
|
|
359
|
-
firstDomain: null,
|
|
360
|
-
searchMap: {},
|
|
361
|
-
filterBy: [],
|
|
362
|
-
groupBy: []
|
|
363
|
-
};
|
|
364
|
-
var searchSlice = createSlice10({
|
|
365
|
-
name: "search",
|
|
366
|
-
initialState: initialState9,
|
|
367
|
-
reducers: {
|
|
368
|
-
setGroupByDomain: (state, action) => {
|
|
369
|
-
state.groupByDomain = action.payload;
|
|
370
|
-
},
|
|
371
|
-
setSearchBy: (state, action) => {
|
|
372
|
-
state.searchBy = action.payload;
|
|
373
|
-
},
|
|
374
|
-
setSearchString: (state, action) => {
|
|
375
|
-
state.searchString = action.payload;
|
|
376
|
-
},
|
|
377
|
-
setHoveredIndexSearchList: (state, action) => {
|
|
378
|
-
state.hoveredIndexSearchList = action.payload;
|
|
379
|
-
},
|
|
380
|
-
setSelectedTags: (state, action) => {
|
|
381
|
-
state.selectedTags = action.payload;
|
|
382
|
-
},
|
|
383
|
-
setFirstDomain: (state, action) => {
|
|
384
|
-
state.firstDomain = action.payload;
|
|
385
|
-
},
|
|
386
|
-
setFilterBy: (state, action) => {
|
|
387
|
-
state.filterBy = action.payload;
|
|
388
|
-
},
|
|
389
|
-
setGroupBy: (state, action) => {
|
|
390
|
-
state.groupBy = action.payload;
|
|
391
|
-
},
|
|
392
|
-
setSearchMap: (state, action) => {
|
|
393
|
-
state.searchMap = action.payload;
|
|
394
|
-
},
|
|
395
|
-
updateSearchMap: (state, action) => {
|
|
396
|
-
if (!state.searchMap[action.payload.key]) {
|
|
397
|
-
state.searchMap[action.payload.key] = [];
|
|
398
|
-
}
|
|
399
|
-
state.searchMap[action.payload.key].push(action.payload.value);
|
|
400
|
-
},
|
|
401
|
-
removeKeyFromSearchMap: (state, action) => {
|
|
402
|
-
const { key, item } = action.payload;
|
|
403
|
-
const values = state.searchMap[key];
|
|
404
|
-
if (!values) return;
|
|
405
|
-
if (item) {
|
|
406
|
-
const filtered = values.filter((value) => value.name !== item.name);
|
|
407
|
-
if (filtered.length > 0) {
|
|
408
|
-
state.searchMap[key] = filtered;
|
|
409
|
-
} else {
|
|
410
|
-
delete state.searchMap[key];
|
|
411
|
-
}
|
|
412
|
-
} else {
|
|
413
|
-
delete state.searchMap[key];
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
clearSearchMap: (state) => {
|
|
417
|
-
state.searchMap = {};
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
var {
|
|
422
|
-
setGroupByDomain,
|
|
423
|
-
setSelectedTags,
|
|
424
|
-
setSearchString,
|
|
425
|
-
setHoveredIndexSearchList,
|
|
426
|
-
setFirstDomain,
|
|
427
|
-
setSearchBy,
|
|
428
|
-
setFilterBy,
|
|
429
|
-
setSearchMap,
|
|
430
|
-
updateSearchMap,
|
|
431
|
-
removeKeyFromSearchMap,
|
|
432
|
-
setGroupBy,
|
|
433
|
-
clearSearchMap
|
|
434
|
-
} = searchSlice.actions;
|
|
435
|
-
var search_slice_default = searchSlice.reducer;
|
|
436
|
-
|
|
437
|
-
// src/store/store.ts
|
|
438
|
-
import { configureStore } from "@reduxjs/toolkit";
|
|
439
|
-
|
|
440
|
-
// node_modules/redux/dist/redux.mjs
|
|
441
|
-
function formatProdErrorMessage(code) {
|
|
442
|
-
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. `;
|
|
443
|
-
}
|
|
444
|
-
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
|
445
|
-
var ActionTypes = {
|
|
446
|
-
INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
|
|
447
|
-
REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
|
|
448
|
-
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
|
449
|
-
};
|
|
450
|
-
var actionTypes_default = ActionTypes;
|
|
451
|
-
function isPlainObject(obj) {
|
|
452
|
-
if (typeof obj !== "object" || obj === null)
|
|
453
|
-
return false;
|
|
454
|
-
let proto = obj;
|
|
455
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
456
|
-
proto = Object.getPrototypeOf(proto);
|
|
457
|
-
}
|
|
458
|
-
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
|
|
459
|
-
}
|
|
460
|
-
function miniKindOf(val) {
|
|
461
|
-
if (val === void 0)
|
|
462
|
-
return "undefined";
|
|
463
|
-
if (val === null)
|
|
464
|
-
return "null";
|
|
465
|
-
const type = typeof val;
|
|
466
|
-
switch (type) {
|
|
467
|
-
case "boolean":
|
|
468
|
-
case "string":
|
|
469
|
-
case "number":
|
|
470
|
-
case "symbol":
|
|
471
|
-
case "function": {
|
|
472
|
-
return type;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
if (Array.isArray(val))
|
|
476
|
-
return "array";
|
|
477
|
-
if (isDate(val))
|
|
478
|
-
return "date";
|
|
479
|
-
if (isError(val))
|
|
480
|
-
return "error";
|
|
481
|
-
const constructorName = ctorName(val);
|
|
482
|
-
switch (constructorName) {
|
|
483
|
-
case "Symbol":
|
|
484
|
-
case "Promise":
|
|
485
|
-
case "WeakMap":
|
|
486
|
-
case "WeakSet":
|
|
487
|
-
case "Map":
|
|
488
|
-
case "Set":
|
|
489
|
-
return constructorName;
|
|
490
|
-
}
|
|
491
|
-
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
492
|
-
}
|
|
493
|
-
function ctorName(val) {
|
|
494
|
-
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
495
|
-
}
|
|
496
|
-
function isError(val) {
|
|
497
|
-
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
498
|
-
}
|
|
499
|
-
function isDate(val) {
|
|
500
|
-
if (val instanceof Date)
|
|
501
|
-
return true;
|
|
502
|
-
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
503
|
-
}
|
|
504
|
-
function kindOf(val) {
|
|
505
|
-
let typeOfVal = typeof val;
|
|
506
|
-
if (process.env.NODE_ENV !== "production") {
|
|
507
|
-
typeOfVal = miniKindOf(val);
|
|
508
|
-
}
|
|
509
|
-
return typeOfVal;
|
|
510
|
-
}
|
|
511
|
-
function warning(message) {
|
|
512
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
513
|
-
console.error(message);
|
|
514
|
-
}
|
|
515
|
-
try {
|
|
516
|
-
throw new Error(message);
|
|
517
|
-
} catch (e) {
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
521
|
-
const reducerKeys = Object.keys(reducers);
|
|
522
|
-
const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
|
|
523
|
-
if (reducerKeys.length === 0) {
|
|
524
|
-
return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
|
|
525
|
-
}
|
|
526
|
-
if (!isPlainObject(inputState)) {
|
|
527
|
-
return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
|
|
528
|
-
}
|
|
529
|
-
const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
|
|
530
|
-
unexpectedKeys.forEach((key) => {
|
|
531
|
-
unexpectedKeyCache[key] = true;
|
|
532
|
-
});
|
|
533
|
-
if (action && action.type === actionTypes_default.REPLACE)
|
|
534
|
-
return;
|
|
535
|
-
if (unexpectedKeys.length > 0) {
|
|
536
|
-
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.`;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
function assertReducerShape(reducers) {
|
|
540
|
-
Object.keys(reducers).forEach((key) => {
|
|
541
|
-
const reducer = reducers[key];
|
|
542
|
-
const initialState10 = reducer(void 0, {
|
|
543
|
-
type: actionTypes_default.INIT
|
|
544
|
-
});
|
|
545
|
-
if (typeof initialState10 === "undefined") {
|
|
546
|
-
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.`);
|
|
547
|
-
}
|
|
548
|
-
if (typeof reducer(void 0, {
|
|
549
|
-
type: actionTypes_default.PROBE_UNKNOWN_ACTION()
|
|
550
|
-
}) === "undefined") {
|
|
551
|
-
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.`);
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
function combineReducers(reducers) {
|
|
556
|
-
const reducerKeys = Object.keys(reducers);
|
|
557
|
-
const finalReducers = {};
|
|
558
|
-
for (let i = 0; i < reducerKeys.length; i++) {
|
|
559
|
-
const key = reducerKeys[i];
|
|
560
|
-
if (process.env.NODE_ENV !== "production") {
|
|
561
|
-
if (typeof reducers[key] === "undefined") {
|
|
562
|
-
warning(`No reducer provided for key "${key}"`);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
if (typeof reducers[key] === "function") {
|
|
566
|
-
finalReducers[key] = reducers[key];
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
const finalReducerKeys = Object.keys(finalReducers);
|
|
570
|
-
let unexpectedKeyCache;
|
|
571
|
-
if (process.env.NODE_ENV !== "production") {
|
|
572
|
-
unexpectedKeyCache = {};
|
|
573
|
-
}
|
|
574
|
-
let shapeAssertionError;
|
|
575
|
-
try {
|
|
576
|
-
assertReducerShape(finalReducers);
|
|
577
|
-
} catch (e) {
|
|
578
|
-
shapeAssertionError = e;
|
|
579
|
-
}
|
|
580
|
-
return function combination(state = {}, action) {
|
|
581
|
-
if (shapeAssertionError) {
|
|
582
|
-
throw shapeAssertionError;
|
|
583
|
-
}
|
|
584
|
-
if (process.env.NODE_ENV !== "production") {
|
|
585
|
-
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
|
586
|
-
if (warningMessage) {
|
|
587
|
-
warning(warningMessage);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
let hasChanged = false;
|
|
591
|
-
const nextState = {};
|
|
592
|
-
for (let i = 0; i < finalReducerKeys.length; i++) {
|
|
593
|
-
const key = finalReducerKeys[i];
|
|
594
|
-
const reducer = finalReducers[key];
|
|
595
|
-
const previousStateForKey = state[key];
|
|
596
|
-
const nextStateForKey = reducer(previousStateForKey, action);
|
|
597
|
-
if (typeof nextStateForKey === "undefined") {
|
|
598
|
-
const actionType = action && action.type;
|
|
599
|
-
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.`);
|
|
600
|
-
}
|
|
601
|
-
nextState[key] = nextStateForKey;
|
|
602
|
-
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
603
|
-
}
|
|
604
|
-
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
605
|
-
return hasChanged ? nextState : state;
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// src/store/store.ts
|
|
610
|
-
var rootReducer = combineReducers({
|
|
611
|
-
env: env_slice_default,
|
|
612
|
-
header: header_slice_default,
|
|
613
|
-
navbar: navbar_slice_default,
|
|
614
|
-
list: list_slice_default,
|
|
615
|
-
search: search_slice_default,
|
|
616
|
-
form: form_slice_default,
|
|
617
|
-
breadcrumbs: breadcrums_slice_default,
|
|
618
|
-
login: login_slice_default,
|
|
619
|
-
excel: excel_slice_default,
|
|
620
|
-
profile: profile_slice_default
|
|
621
|
-
});
|
|
622
|
-
var envStore = configureStore({
|
|
623
|
-
reducer: rootReducer,
|
|
624
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
625
|
-
serializableCheck: false
|
|
626
|
-
})
|
|
627
|
-
});
|
|
628
|
-
|
|
629
1
|
// src/configs/axios-client.ts
|
|
630
2
|
import axios from "axios";
|
|
631
3
|
|
|
@@ -2328,663 +1700,1369 @@ function evaluate(ast, context = {}) {
|
|
|
2328
1700
|
return isTrue(left) ? left : _evaluate(ast2.right);
|
|
2329
1701
|
}
|
|
2330
1702
|
case 4:
|
|
2331
|
-
// List
|
|
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]);
|
|
1710
|
+
}
|
|
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]);
|
|
1719
|
+
}
|
|
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;
|
|
1753
|
+
}
|
|
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;
|
|
1765
|
+
}
|
|
1766
|
+
return _evaluate(ast);
|
|
1767
|
+
}
|
|
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;
|
|
1779
|
+
}
|
|
1780
|
+
const obj1Keys = Object.keys(obj1);
|
|
1781
|
+
return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
|
|
1782
|
+
}
|
|
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, "\\$&");
|
|
1791
|
+
}
|
|
1792
|
+
|
|
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;
|
|
1867
|
+
}
|
|
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;
|
|
1877
|
+
}
|
|
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
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
contains(record) {
|
|
1897
|
+
const expr = evaluate(this.ast, record);
|
|
1898
|
+
return matchDomain(record, expr);
|
|
1899
|
+
}
|
|
1900
|
+
toString() {
|
|
1901
|
+
return formatAST(this.ast);
|
|
1902
|
+
}
|
|
1903
|
+
toList(context) {
|
|
1904
|
+
return evaluate(this.ast, context);
|
|
1905
|
+
}
|
|
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
|
+
}
|
|
1917
|
+
}
|
|
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 };
|
|
1940
|
+
}
|
|
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");
|
|
1950
|
+
}
|
|
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 */
|
|
2332
1967
|
case 10:
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
for (const key2 in ast2.value) {
|
|
2337
|
-
dict[key2] = _evaluate(ast2.value[key2]);
|
|
2338
|
-
}
|
|
2339
|
-
dicts.add(dict);
|
|
2340
|
-
return dict;
|
|
2341
|
-
case 8:
|
|
2342
|
-
const fnValue = _evaluate(ast2.fn);
|
|
2343
|
-
const args = ast2.args.map(_evaluate);
|
|
2344
|
-
const kwargs = {};
|
|
2345
|
-
for (const kwarg in ast2.kwargs) {
|
|
2346
|
-
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
2347
|
-
}
|
|
2348
|
-
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
2349
|
-
return fnValue.create(...args, kwargs);
|
|
2350
|
-
}
|
|
2351
|
-
return fnValue(...args, kwargs);
|
|
2352
|
-
case 12:
|
|
2353
|
-
const dictVal = _evaluate(ast2.target);
|
|
2354
|
-
const key = _evaluate(ast2.key);
|
|
2355
|
-
return dictVal[key];
|
|
2356
|
-
case 13:
|
|
2357
|
-
if (isTrue(_evaluate(ast2.condition))) {
|
|
2358
|
-
return _evaluate(ast2.ifTrue);
|
|
2359
|
-
} else {
|
|
2360
|
-
return _evaluate(ast2.ifFalse);
|
|
2361
|
-
}
|
|
2362
|
-
case 15:
|
|
2363
|
-
let leftVal = _evaluate(ast2.obj);
|
|
2364
|
-
let result;
|
|
2365
|
-
if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
|
|
2366
|
-
result = DICT[ast2.key];
|
|
2367
|
-
} else if (typeof leftVal === "string") {
|
|
2368
|
-
result = STRING[ast2.key];
|
|
2369
|
-
} else if (leftVal instanceof Set) {
|
|
2370
|
-
result = SET[ast2.key];
|
|
2371
|
-
} else if (ast2.key === "get" && typeof leftVal === "object") {
|
|
2372
|
-
result = DICT[ast2.key];
|
|
2373
|
-
leftVal = toPyDict(leftVal);
|
|
2374
|
-
} else {
|
|
2375
|
-
result = leftVal[ast2.key];
|
|
2376
|
-
}
|
|
2377
|
-
if (typeof result === "function") {
|
|
2378
|
-
const bound = result.bind(leftVal);
|
|
2379
|
-
bound[unboundFn] = result;
|
|
2380
|
-
return bound;
|
|
1968
|
+
if (child.value.length === 3) {
|
|
1969
|
+
expected--;
|
|
1970
|
+
break;
|
|
2381
1971
|
}
|
|
2382
|
-
|
|
1972
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2383
1973
|
default:
|
|
2384
|
-
throw new
|
|
1974
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2385
1975
|
}
|
|
2386
1976
|
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
}
|
|
2392
|
-
return val;
|
|
1977
|
+
const values = domain.value.slice();
|
|
1978
|
+
while (expected < 0) {
|
|
1979
|
+
expected++;
|
|
1980
|
+
values.unshift({ type: 1, value: op });
|
|
2393
1981
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
function parseExpr(expr) {
|
|
2399
|
-
const tokens = tokenize(expr);
|
|
2400
|
-
return parse(tokens);
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
// src/utils/domain/objects.ts
|
|
2404
|
-
function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
|
|
2405
|
-
if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
|
|
2406
|
-
return obj1 === obj2;
|
|
1982
|
+
if (expected > 0) {
|
|
1983
|
+
throw new InvalidDomainError(
|
|
1984
|
+
`invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
|
|
1985
|
+
);
|
|
2407
1986
|
}
|
|
2408
|
-
|
|
2409
|
-
return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
// src/utils/domain/arrays.ts
|
|
2413
|
-
var shallowEqual2 = shallowEqual;
|
|
2414
|
-
|
|
2415
|
-
// src/utils/domain/strings.ts
|
|
2416
|
-
var escapeMethod = Symbol("html");
|
|
2417
|
-
function escapeRegExp(str) {
|
|
2418
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1987
|
+
return { type: 4, value: values };
|
|
2419
1988
|
}
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
1989
|
+
function matchCondition(record, condition) {
|
|
1990
|
+
if (typeof condition === "boolean") {
|
|
1991
|
+
return condition;
|
|
1992
|
+
}
|
|
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
|
+
]);
|
|
2431
2002
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2003
|
+
}
|
|
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
|
+
);
|
|
2014
|
+
}
|
|
2015
|
+
const fieldValue = typeof field === "number" ? field : record[field];
|
|
2016
|
+
switch (operator) {
|
|
2017
|
+
case "=?":
|
|
2018
|
+
if ([false, null].includes(value)) {
|
|
2019
|
+
return true;
|
|
2020
|
+
}
|
|
2021
|
+
// eslint-disable-next-line no-fallthrough
|
|
2022
|
+
case "=":
|
|
2023
|
+
case "==":
|
|
2024
|
+
if (Array.isArray(fieldValue) && Array.isArray(value)) {
|
|
2025
|
+
return shallowEqual2(fieldValue, value);
|
|
2026
|
+
}
|
|
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));
|
|
2435
2043
|
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
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;
|
|
2052
|
+
}
|
|
2053
|
+
return Boolean(fieldValue.match(likeRegexp));
|
|
2054
|
+
case "not like":
|
|
2055
|
+
if (fieldValue === false) {
|
|
2056
|
+
return false;
|
|
2057
|
+
}
|
|
2058
|
+
return Boolean(!fieldValue.match(likeRegexp));
|
|
2059
|
+
case "=like":
|
|
2060
|
+
if (fieldValue === false) {
|
|
2061
|
+
return false;
|
|
2062
|
+
}
|
|
2063
|
+
return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
|
|
2064
|
+
fieldValue
|
|
2065
|
+
);
|
|
2066
|
+
case "ilike":
|
|
2067
|
+
if (fieldValue === false) {
|
|
2068
|
+
return false;
|
|
2069
|
+
}
|
|
2070
|
+
return Boolean(fieldValue.match(ilikeRegexp));
|
|
2071
|
+
case "not ilike":
|
|
2072
|
+
if (fieldValue === false) {
|
|
2073
|
+
return false;
|
|
2074
|
+
}
|
|
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
|
+
);
|
|
2447
2083
|
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2084
|
+
throw new InvalidDomainError("could not match domain");
|
|
2085
|
+
}
|
|
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
|
+
};
|
|
2093
|
+
}
|
|
2094
|
+
function matchDomain(record, domain) {
|
|
2095
|
+
if (domain.length === 0) {
|
|
2096
|
+
return true;
|
|
2450
2097
|
}
|
|
2451
|
-
|
|
2452
|
-
|
|
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());
|
|
2111
|
+
}
|
|
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;
|
|
2122
|
+
}
|
|
2123
|
+
return JSON.stringify(parsedData);
|
|
2124
|
+
} catch (e) {
|
|
2125
|
+
console.warn("Failed to parse originalRequest.data", e);
|
|
2126
|
+
return originalRequest.data;
|
|
2127
|
+
}
|
|
2453
2128
|
}
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
result.ast.value.unshift({ type: 1, value: "!" });
|
|
2457
|
-
return result;
|
|
2129
|
+
if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
|
|
2130
|
+
originalRequest.data.with_context.token = newAccessToken;
|
|
2458
2131
|
}
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
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);
|
|
2469
2184
|
} else {
|
|
2470
|
-
|
|
2471
|
-
}
|
|
2472
|
-
return 1;
|
|
2473
|
-
} else if (leaf.type === 1) {
|
|
2474
|
-
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)) {
|
|
2475
|
-
newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
|
|
2476
|
-
return 3;
|
|
2185
|
+
prom.resolve(token);
|
|
2477
2186
|
}
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
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;
|
|
2481
2202
|
}
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
newDomain2
|
|
2487
|
-
);
|
|
2488
|
-
const secondLeafSkip = processLeaf(
|
|
2489
|
-
elements,
|
|
2490
|
-
idx + 1 + firstLeafSkip,
|
|
2491
|
-
leaf.value,
|
|
2492
|
-
newDomain2
|
|
2493
|
-
);
|
|
2494
|
-
return 1 + firstLeafSkip + secondLeafSkip;
|
|
2203
|
+
return config2;
|
|
2204
|
+
},
|
|
2205
|
+
(error) => {
|
|
2206
|
+
Promise.reject(error);
|
|
2495
2207
|
}
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
}
|
|
2506
|
-
constructor(descr = []) {
|
|
2507
|
-
if (descr instanceof _Domain) {
|
|
2508
|
-
return new _Domain(descr.toString());
|
|
2509
|
-
} else {
|
|
2510
|
-
let rawAST;
|
|
2511
|
-
try {
|
|
2512
|
-
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
2513
|
-
} catch (error) {
|
|
2514
|
-
throw new InvalidDomainError(
|
|
2515
|
-
`Invalid domain representation: ${descr}`,
|
|
2516
|
-
{
|
|
2517
|
-
cause: error
|
|
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;
|
|
2518
2217
|
}
|
|
2519
|
-
|
|
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
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
return Promise.reject(await handleError3(error));
|
|
2520
2299
|
}
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
return evaluatedAsList;
|
|
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 };
|
|
2540
2318
|
}
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
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 : "");
|
|
2544
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;
|
|
2545
2345
|
}
|
|
2546
2346
|
};
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
type: 10,
|
|
2563
|
-
value: elem.map(toPyValue)
|
|
2564
|
-
};
|
|
2565
|
-
}
|
|
2566
|
-
});
|
|
2567
|
-
return { type: 4, value: elems };
|
|
2568
|
-
}
|
|
2569
|
-
function normalizeDomainAST(domain, op = "&") {
|
|
2570
|
-
if (domain.type !== 4) {
|
|
2571
|
-
if (domain.type === 10) {
|
|
2572
|
-
const value = domain.value;
|
|
2573
|
-
if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
|
|
2574
|
-
throw new InvalidDomainError("Invalid domain AST");
|
|
2575
|
-
}
|
|
2576
|
-
} else {
|
|
2577
|
-
throw new InvalidDomainError("Invalid domain AST");
|
|
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];
|
|
2578
2362
|
}
|
|
2579
2363
|
}
|
|
2580
|
-
|
|
2581
|
-
|
|
2364
|
+
});
|
|
2365
|
+
var { setBreadCrumbs } = breadcrumbsSlice.actions;
|
|
2366
|
+
var breadcrums_slice_default = breadcrumbsSlice.reducer;
|
|
2367
|
+
|
|
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"
|
|
2582
2388
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
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;
|
|
2603
2420
|
}
|
|
2604
2421
|
}
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
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;
|
|
2435
|
+
|
|
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
|
+
}
|
|
2620
2468
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
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;
|
|
2479
|
+
|
|
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: {}
|
|
2490
|
+
};
|
|
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;
|
|
2630
2515
|
}
|
|
2631
2516
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
case "<>":
|
|
2658
|
-
return !matchCondition(record, [field, "==", value]);
|
|
2659
|
-
case "<":
|
|
2660
|
-
return fieldValue < value;
|
|
2661
|
-
case "<=":
|
|
2662
|
-
return fieldValue <= value;
|
|
2663
|
-
case ">":
|
|
2664
|
-
return fieldValue > value;
|
|
2665
|
-
case ">=":
|
|
2666
|
-
return fieldValue >= value;
|
|
2667
|
-
case "in": {
|
|
2668
|
-
const val = Array.isArray(value) ? value : [value];
|
|
2669
|
-
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2670
|
-
return fieldVal.some((fv) => val.includes(fv));
|
|
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;
|
|
2671
2542
|
}
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2543
|
+
}
|
|
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;
|
|
2676
2596
|
}
|
|
2677
|
-
case "like":
|
|
2678
|
-
if (fieldValue === false) {
|
|
2679
|
-
return false;
|
|
2680
|
-
}
|
|
2681
|
-
return Boolean(fieldValue.match(likeRegexp));
|
|
2682
|
-
case "not like":
|
|
2683
|
-
if (fieldValue === false) {
|
|
2684
|
-
return false;
|
|
2685
|
-
}
|
|
2686
|
-
return Boolean(!fieldValue.match(likeRegexp));
|
|
2687
|
-
case "=like":
|
|
2688
|
-
if (fieldValue === false) {
|
|
2689
|
-
return false;
|
|
2690
|
-
}
|
|
2691
|
-
return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
|
|
2692
|
-
fieldValue
|
|
2693
|
-
);
|
|
2694
|
-
case "ilike":
|
|
2695
|
-
if (fieldValue === false) {
|
|
2696
|
-
return false;
|
|
2697
|
-
}
|
|
2698
|
-
return Boolean(fieldValue.match(ilikeRegexp));
|
|
2699
|
-
case "not ilike":
|
|
2700
|
-
if (fieldValue === false) {
|
|
2701
|
-
return false;
|
|
2702
|
-
}
|
|
2703
|
-
return Boolean(!fieldValue.match(ilikeRegexp));
|
|
2704
|
-
case "=ilike":
|
|
2705
|
-
if (fieldValue === false) {
|
|
2706
|
-
return false;
|
|
2707
|
-
}
|
|
2708
|
-
return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
|
|
2709
|
-
fieldValue
|
|
2710
|
-
);
|
|
2711
2597
|
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
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
|
+
}
|
|
2725
2633
|
}
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
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;
|
|
2736
2661
|
}
|
|
2737
2662
|
}
|
|
2738
|
-
|
|
2739
|
-
}
|
|
2663
|
+
});
|
|
2664
|
+
var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
|
|
2665
|
+
var navbar_slice_default = navbarSlice.reducer;
|
|
2740
2666
|
|
|
2741
|
-
// src/
|
|
2742
|
-
import {
|
|
2743
|
-
var
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
} catch (e) {
|
|
2753
|
-
console.warn("Failed to parse originalRequest.data", e);
|
|
2754
|
-
return originalRequest.data;
|
|
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;
|
|
2755
2678
|
}
|
|
2756
2679
|
}
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
return originalRequest.data;
|
|
2761
|
-
};
|
|
2762
|
-
|
|
2763
|
-
// src/utils/storage/local-storage.ts
|
|
2764
|
-
var localStorageUtils = () => {
|
|
2765
|
-
const setToken = async (access_token) => {
|
|
2766
|
-
localStorage.setItem("accessToken", access_token);
|
|
2767
|
-
};
|
|
2768
|
-
const setRefreshToken = async (refresh_token) => {
|
|
2769
|
-
localStorage.setItem("refreshToken", refresh_token);
|
|
2770
|
-
};
|
|
2771
|
-
const getAccessToken = async () => {
|
|
2772
|
-
return localStorage.getItem("accessToken");
|
|
2773
|
-
};
|
|
2774
|
-
const getRefreshToken = async () => {
|
|
2775
|
-
return localStorage.getItem("refreshToken");
|
|
2776
|
-
};
|
|
2777
|
-
const clearToken = async () => {
|
|
2778
|
-
localStorage.removeItem("accessToken");
|
|
2779
|
-
localStorage.removeItem("refreshToken");
|
|
2780
|
-
};
|
|
2781
|
-
return {
|
|
2782
|
-
setToken,
|
|
2783
|
-
setRefreshToken,
|
|
2784
|
-
getAccessToken,
|
|
2785
|
-
getRefreshToken,
|
|
2786
|
-
clearToken
|
|
2787
|
-
};
|
|
2788
|
-
};
|
|
2680
|
+
});
|
|
2681
|
+
var { setProfile } = profileSlice.actions;
|
|
2682
|
+
var profile_slice_default = profileSlice.reducer;
|
|
2789
2683
|
|
|
2790
|
-
// src/
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
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: []
|
|
2798
2696
|
};
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
}
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
if (
|
|
2832
|
-
|
|
2833
|
-
}, Promise.reject);
|
|
2834
|
-
instance.interceptors.response.use(
|
|
2835
|
-
(response) => {
|
|
2836
|
-
return handleResponse(response);
|
|
2837
|
-
},
|
|
2838
|
-
async (error) => {
|
|
2839
|
-
const handleError3 = async (error2) => {
|
|
2840
|
-
if (!error2.response) {
|
|
2841
|
-
return error2;
|
|
2842
|
-
}
|
|
2843
|
-
const { data } = error2.response;
|
|
2844
|
-
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
2845
|
-
await clearAuthToken();
|
|
2846
|
-
}
|
|
2847
|
-
return data;
|
|
2848
|
-
};
|
|
2849
|
-
const originalRequest = error.config;
|
|
2850
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
|
|
2851
|
-
error.response.data.code
|
|
2852
|
-
)) {
|
|
2853
|
-
if (isRefreshing) {
|
|
2854
|
-
return new Promise(function(resolve, reject) {
|
|
2855
|
-
failedQueue.push({ resolve, reject });
|
|
2856
|
-
}).then((token) => {
|
|
2857
|
-
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
2858
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2859
|
-
originalRequest,
|
|
2860
|
-
token
|
|
2861
|
-
);
|
|
2862
|
-
return instance.request(originalRequest);
|
|
2863
|
-
}).catch(async (err) => {
|
|
2864
|
-
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
2865
|
-
await clearAuthToken();
|
|
2866
|
-
}
|
|
2867
|
-
});
|
|
2868
|
-
}
|
|
2869
|
-
const browserSession = await sessionStorage2.getBrowserSession();
|
|
2870
|
-
const refreshToken = await localStorage2.getRefreshToken();
|
|
2871
|
-
const accessTokenExp = await localStorage2.getAccessToken();
|
|
2872
|
-
isRefreshing = true;
|
|
2873
|
-
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
2874
|
-
await clearAuthToken();
|
|
2875
|
-
} else {
|
|
2876
|
-
const payload = Object.fromEntries(
|
|
2877
|
-
Object.entries({
|
|
2878
|
-
refresh_token: refreshToken,
|
|
2879
|
-
grant_type: "refresh_token",
|
|
2880
|
-
client_id: config.config.clientId,
|
|
2881
|
-
client_secret: config.config.clientSecret
|
|
2882
|
-
}).filter(([_, value]) => !!value)
|
|
2883
|
-
);
|
|
2884
|
-
return new Promise(function(resolve) {
|
|
2885
|
-
axios.post(
|
|
2886
|
-
`${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
2887
|
-
payload,
|
|
2888
|
-
{
|
|
2889
|
-
headers: {
|
|
2890
|
-
"Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
|
|
2891
|
-
Authorization: `Bearer ${accessTokenExp}`
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
).then(async (res) => {
|
|
2895
|
-
const data = res.data;
|
|
2896
|
-
await localStorage2.setToken(data.access_token);
|
|
2897
|
-
await localStorage2.setRefreshToken(data.refresh_token);
|
|
2898
|
-
axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
2899
|
-
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
2900
|
-
originalRequest.data = updateTokenParamInOriginalRequest(
|
|
2901
|
-
originalRequest,
|
|
2902
|
-
data.access_token
|
|
2903
|
-
);
|
|
2904
|
-
processQueue(null, data.access_token);
|
|
2905
|
-
resolve(instance.request(originalRequest));
|
|
2906
|
-
}).catch(async (err) => {
|
|
2907
|
-
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") {
|
|
2908
|
-
await clearAuthToken();
|
|
2909
|
-
}
|
|
2910
|
-
if (err && err.response) {
|
|
2911
|
-
const { error_code } = err.response?.data || {};
|
|
2912
|
-
if (error_code === "AUTHEN_FAIL") {
|
|
2913
|
-
await clearAuthToken();
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
processQueue(err, null);
|
|
2917
|
-
}).finally(() => {
|
|
2918
|
-
isRefreshing = false;
|
|
2919
|
-
});
|
|
2920
|
-
});
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
return Promise.reject(await handleError3(error));
|
|
2924
|
-
}
|
|
2925
|
-
);
|
|
2926
|
-
const handleResponse = (res) => {
|
|
2927
|
-
if (res && res.data) {
|
|
2928
|
-
return res.data;
|
|
2929
|
-
}
|
|
2930
|
-
return res;
|
|
2931
|
-
};
|
|
2932
|
-
const handleError2 = (error) => {
|
|
2933
|
-
if (error.isAxiosError && error.code === "ECONNABORTED") {
|
|
2934
|
-
console.error("Request Timeout Error:", error);
|
|
2935
|
-
return "Request Timeout Error";
|
|
2936
|
-
} else if (error.isAxiosError && !error.response) {
|
|
2937
|
-
console.error("Network Error:", error);
|
|
2938
|
-
return "Network Error";
|
|
2939
|
-
} else {
|
|
2940
|
-
console.error("Other Error:", error?.response);
|
|
2941
|
-
const errorMessage = error?.response?.data?.message || "An error occurred";
|
|
2942
|
-
return { message: errorMessage, status: error?.response?.status };
|
|
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] = [];
|
|
2943
2731
|
}
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
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];
|
|
2949
2747
|
}
|
|
2950
|
-
}
|
|
2951
|
-
|
|
2952
|
-
|
|
2748
|
+
},
|
|
2749
|
+
clearSearchMap: (state) => {
|
|
2750
|
+
state.searchMap = {};
|
|
2953
2751
|
}
|
|
2954
|
-
const responseBody = (response) => response;
|
|
2955
|
-
const requests = {
|
|
2956
|
-
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
|
2957
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
|
|
2958
|
-
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
2959
|
-
responseType: "arraybuffer",
|
|
2960
|
-
headers: {
|
|
2961
|
-
"Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
|
|
2962
|
-
Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
2963
|
-
}
|
|
2964
|
-
}).then(responseBody),
|
|
2965
|
-
put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
|
|
2966
|
-
patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
|
|
2967
|
-
delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
|
|
2968
|
-
};
|
|
2969
|
-
return requests;
|
|
2970
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()}`
|
|
2971
2782
|
};
|
|
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;
|
|
2792
|
+
}
|
|
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;
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
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;
|
|
2823
|
+
}
|
|
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);
|
|
2841
|
+
}
|
|
2842
|
+
return typeOfVal;
|
|
2843
|
+
}
|
|
2844
|
+
function warning(message) {
|
|
2845
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
2846
|
+
console.error(message);
|
|
2847
|
+
}
|
|
2848
|
+
try {
|
|
2849
|
+
throw new Error(message);
|
|
2850
|
+
} catch (e) {
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
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.";
|
|
2858
|
+
}
|
|
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('", "')}"`;
|
|
2861
|
+
}
|
|
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.`;
|
|
2870
|
+
}
|
|
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.`);
|
|
2880
|
+
}
|
|
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.`);
|
|
2885
|
+
}
|
|
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}"`);
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
if (typeof reducers[key] === "function") {
|
|
2899
|
+
finalReducers[key] = reducers[key];
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
const finalReducerKeys = Object.keys(finalReducers);
|
|
2903
|
+
let unexpectedKeyCache;
|
|
2904
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2905
|
+
unexpectedKeyCache = {};
|
|
2906
|
+
}
|
|
2907
|
+
let shapeAssertionError;
|
|
2908
|
+
try {
|
|
2909
|
+
assertReducerShape(finalReducers);
|
|
2910
|
+
} catch (e) {
|
|
2911
|
+
shapeAssertionError = e;
|
|
2912
|
+
}
|
|
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);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
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;
|
|
2939
|
+
};
|
|
2940
|
+
}
|
|
2941
|
+
|
|
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
|
+
});
|
|
2972
2961
|
|
|
2973
2962
|
// src/environment/EnvStore.ts
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
envStore
|
|
2977
|
-
|
|
2963
|
+
var EnvStore = class _EnvStore {
|
|
2964
|
+
static instance = null;
|
|
2965
|
+
envStore;
|
|
2966
|
+
baseUrl;
|
|
2967
|
+
requests;
|
|
2968
|
+
context;
|
|
2969
|
+
defaultCompany;
|
|
2970
|
+
config;
|
|
2971
|
+
companies;
|
|
2972
|
+
user;
|
|
2973
|
+
db;
|
|
2974
|
+
localStorageUtils;
|
|
2975
|
+
sessionStorageUtils;
|
|
2976
|
+
refreshTokenEndpoint;
|
|
2977
|
+
constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
2978
|
+
this.envStore = envStore2;
|
|
2979
|
+
this.localStorageUtils = localStorageUtils2;
|
|
2980
|
+
this.sessionStorageUtils = sessionStorageUtils2;
|
|
2981
|
+
this.setup();
|
|
2982
|
+
}
|
|
2983
|
+
static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
|
|
2984
|
+
if (!_EnvStore.instance) {
|
|
2985
|
+
console.log("Creating new EnvStore instance");
|
|
2986
|
+
_EnvStore.instance = new _EnvStore(envStore2, localStorageUtils2, sessionStorageUtils2);
|
|
2987
|
+
} else {
|
|
2988
|
+
console.log("Returning existing EnvStore instance");
|
|
2989
|
+
}
|
|
2990
|
+
return _EnvStore.instance;
|
|
2991
|
+
}
|
|
2992
|
+
setup() {
|
|
2993
|
+
const env = this.envStore.getState().env;
|
|
2994
|
+
console.log("Redux env state in A1:", env);
|
|
2995
|
+
this.baseUrl = env?.baseUrl;
|
|
2996
|
+
this.requests = env?.requests;
|
|
2997
|
+
this.context = env?.context;
|
|
2998
|
+
this.defaultCompany = env?.defaultCompany;
|
|
2999
|
+
this.config = env?.config;
|
|
3000
|
+
this.companies = env?.companies || [];
|
|
3001
|
+
this.user = env?.user;
|
|
3002
|
+
this.db = env?.db;
|
|
3003
|
+
this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
|
|
3004
|
+
console.log("Env setup in A1:", this);
|
|
3005
|
+
}
|
|
3006
|
+
setupEnv(envConfig) {
|
|
3007
|
+
const dispatch = this.envStore.dispatch;
|
|
3008
|
+
const env = {
|
|
2978
3009
|
...envConfig,
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
3010
|
+
localStorageUtils: this.localStorageUtils,
|
|
3011
|
+
sessionStorageUtils: this.sessionStorageUtils
|
|
3012
|
+
};
|
|
3013
|
+
console.log("Setting up env with config:", envConfig);
|
|
3014
|
+
const requests = axiosClient.init(env);
|
|
3015
|
+
console.log("axiosClient.init result:", requests);
|
|
3016
|
+
dispatch(setEnv({ ...env, requests }));
|
|
3017
|
+
this.setup();
|
|
3018
|
+
}
|
|
3019
|
+
setUid(uid) {
|
|
3020
|
+
const dispatch = this.envStore.dispatch;
|
|
3021
|
+
dispatch(setUid(uid));
|
|
3022
|
+
this.setup();
|
|
3023
|
+
}
|
|
3024
|
+
setLang(lang) {
|
|
3025
|
+
const dispatch = this.envStore.dispatch;
|
|
3026
|
+
dispatch(setLang(lang));
|
|
3027
|
+
this.setup();
|
|
3028
|
+
}
|
|
3029
|
+
setAllowCompanies(allowCompanies) {
|
|
3030
|
+
const dispatch = this.envStore.dispatch;
|
|
3031
|
+
dispatch(setAllowCompanies(allowCompanies));
|
|
3032
|
+
this.setup();
|
|
3033
|
+
}
|
|
3034
|
+
setCompanies(companies) {
|
|
3035
|
+
const dispatch = this.envStore.dispatch;
|
|
3036
|
+
dispatch(setCompanies(companies));
|
|
3037
|
+
this.setup();
|
|
3038
|
+
}
|
|
3039
|
+
setDefaultCompany(company) {
|
|
3040
|
+
const dispatch = this.envStore.dispatch;
|
|
3041
|
+
dispatch(setDefaultCompany(company));
|
|
3042
|
+
this.setup();
|
|
3043
|
+
}
|
|
3044
|
+
setUserInfo(userInfo) {
|
|
3045
|
+
const dispatch = this.envStore.dispatch;
|
|
3046
|
+
dispatch(setUser(userInfo));
|
|
3047
|
+
this.setup();
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
function initEnv({
|
|
3051
|
+
envStore: envStore2,
|
|
3052
|
+
localStorageUtils: localStorageUtils2,
|
|
3053
|
+
sessionStorageUtils: sessionStorageUtils2
|
|
3054
|
+
}) {
|
|
3055
|
+
return EnvStore.getInstance(envStore2, localStorageUtils2, sessionStorageUtils2);
|
|
2982
3056
|
}
|
|
2983
3057
|
function getEnv() {
|
|
2984
|
-
|
|
2985
|
-
|
|
3058
|
+
const instance = EnvStore.getInstance(envStore);
|
|
3059
|
+
if (!instance) {
|
|
3060
|
+
throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
|
|
3061
|
+
}
|
|
3062
|
+
return instance;
|
|
2986
3063
|
}
|
|
2987
3064
|
export {
|
|
3065
|
+
EnvStore,
|
|
2988
3066
|
getEnv,
|
|
2989
|
-
|
|
3067
|
+
initEnv
|
|
2990
3068
|
};
|