@fctc/interface-logic 1.7.1 → 1.7.3

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/services.js CHANGED
@@ -72,619 +72,6 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
72
72
  return UriConstants2;
73
73
  })(UriConstants || {});
74
74
 
75
- // src/store/store.ts
76
- var import_toolkit11 = require("@reduxjs/toolkit");
77
-
78
- // node_modules/redux/dist/redux.mjs
79
- function formatProdErrorMessage(code) {
80
- 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. `;
81
- }
82
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
83
- var ActionTypes = {
84
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
85
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
86
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
87
- };
88
- var actionTypes_default = ActionTypes;
89
- function isPlainObject(obj) {
90
- if (typeof obj !== "object" || obj === null)
91
- return false;
92
- let proto = obj;
93
- while (Object.getPrototypeOf(proto) !== null) {
94
- proto = Object.getPrototypeOf(proto);
95
- }
96
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
97
- }
98
- function miniKindOf(val) {
99
- if (val === void 0)
100
- return "undefined";
101
- if (val === null)
102
- return "null";
103
- const type = typeof val;
104
- switch (type) {
105
- case "boolean":
106
- case "string":
107
- case "number":
108
- case "symbol":
109
- case "function": {
110
- return type;
111
- }
112
- }
113
- if (Array.isArray(val))
114
- return "array";
115
- if (isDate(val))
116
- return "date";
117
- if (isError(val))
118
- return "error";
119
- const constructorName = ctorName(val);
120
- switch (constructorName) {
121
- case "Symbol":
122
- case "Promise":
123
- case "WeakMap":
124
- case "WeakSet":
125
- case "Map":
126
- case "Set":
127
- return constructorName;
128
- }
129
- return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
130
- }
131
- function ctorName(val) {
132
- return typeof val.constructor === "function" ? val.constructor.name : null;
133
- }
134
- function isError(val) {
135
- return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
136
- }
137
- function isDate(val) {
138
- if (val instanceof Date)
139
- return true;
140
- return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
141
- }
142
- function kindOf(val) {
143
- let typeOfVal = typeof val;
144
- if (process.env.NODE_ENV !== "production") {
145
- typeOfVal = miniKindOf(val);
146
- }
147
- return typeOfVal;
148
- }
149
- function warning(message) {
150
- if (typeof console !== "undefined" && typeof console.error === "function") {
151
- console.error(message);
152
- }
153
- try {
154
- throw new Error(message);
155
- } catch (e) {
156
- }
157
- }
158
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
159
- const reducerKeys = Object.keys(reducers);
160
- const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
161
- if (reducerKeys.length === 0) {
162
- return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
163
- }
164
- if (!isPlainObject(inputState)) {
165
- return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
166
- }
167
- const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
168
- unexpectedKeys.forEach((key) => {
169
- unexpectedKeyCache[key] = true;
170
- });
171
- if (action && action.type === actionTypes_default.REPLACE)
172
- return;
173
- if (unexpectedKeys.length > 0) {
174
- 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.`;
175
- }
176
- }
177
- function assertReducerShape(reducers) {
178
- Object.keys(reducers).forEach((key) => {
179
- const reducer = reducers[key];
180
- const initialState10 = reducer(void 0, {
181
- type: actionTypes_default.INIT
182
- });
183
- if (typeof initialState10 === "undefined") {
184
- 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.`);
185
- }
186
- if (typeof reducer(void 0, {
187
- type: actionTypes_default.PROBE_UNKNOWN_ACTION()
188
- }) === "undefined") {
189
- 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.`);
190
- }
191
- });
192
- }
193
- function combineReducers(reducers) {
194
- const reducerKeys = Object.keys(reducers);
195
- const finalReducers = {};
196
- for (let i = 0; i < reducerKeys.length; i++) {
197
- const key = reducerKeys[i];
198
- if (process.env.NODE_ENV !== "production") {
199
- if (typeof reducers[key] === "undefined") {
200
- warning(`No reducer provided for key "${key}"`);
201
- }
202
- }
203
- if (typeof reducers[key] === "function") {
204
- finalReducers[key] = reducers[key];
205
- }
206
- }
207
- const finalReducerKeys = Object.keys(finalReducers);
208
- let unexpectedKeyCache;
209
- if (process.env.NODE_ENV !== "production") {
210
- unexpectedKeyCache = {};
211
- }
212
- let shapeAssertionError;
213
- try {
214
- assertReducerShape(finalReducers);
215
- } catch (e) {
216
- shapeAssertionError = e;
217
- }
218
- return function combination(state = {}, action) {
219
- if (shapeAssertionError) {
220
- throw shapeAssertionError;
221
- }
222
- if (process.env.NODE_ENV !== "production") {
223
- const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
224
- if (warningMessage) {
225
- warning(warningMessage);
226
- }
227
- }
228
- let hasChanged = false;
229
- const nextState = {};
230
- for (let i = 0; i < finalReducerKeys.length; i++) {
231
- const key = finalReducerKeys[i];
232
- const reducer = finalReducers[key];
233
- const previousStateForKey = state[key];
234
- const nextStateForKey = reducer(previousStateForKey, action);
235
- if (typeof nextStateForKey === "undefined") {
236
- const actionType = action && action.type;
237
- 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.`);
238
- }
239
- nextState[key] = nextStateForKey;
240
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
241
- }
242
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
243
- return hasChanged ? nextState : state;
244
- };
245
- }
246
-
247
- // src/store/reducers/breadcrums-slice/index.ts
248
- var import_toolkit = require("@reduxjs/toolkit");
249
- var initialState = {
250
- breadCrumbs: []
251
- };
252
- var breadcrumbsSlice = (0, import_toolkit.createSlice)({
253
- name: "breadcrumbs",
254
- initialState,
255
- reducers: {
256
- setBreadCrumbs: (state, action) => {
257
- state.breadCrumbs = [...state.breadCrumbs, action.payload];
258
- }
259
- }
260
- });
261
- var { setBreadCrumbs } = breadcrumbsSlice.actions;
262
- var breadcrums_slice_default = breadcrumbsSlice.reducer;
263
-
264
- // src/store/reducers/env-slice/index.ts
265
- var import_toolkit2 = require("@reduxjs/toolkit");
266
- var initialState2 = {
267
- baseUrl: "",
268
- companies: [],
269
- user: {},
270
- db: "",
271
- refreshTokenEndpoint: "",
272
- config: null,
273
- envFile: null,
274
- requests: null,
275
- defaultCompany: {
276
- id: null,
277
- logo: "",
278
- secondary_color: "",
279
- primary_color: ""
280
- },
281
- context: {
282
- uid: null,
283
- allowed_company_ids: [],
284
- lang: "vi_VN",
285
- tz: "Asia/Saigon"
286
- }
287
- };
288
- var envSlice = (0, import_toolkit2.createSlice)({
289
- name: "env",
290
- initialState: initialState2,
291
- reducers: {
292
- setEnv: (state, action) => {
293
- Object.assign(state, action.payload);
294
- },
295
- setUid: (state, action) => {
296
- state.context.uid = action.payload;
297
- },
298
- setAllowCompanies: (state, action) => {
299
- state.context.allowed_company_ids = action.payload;
300
- },
301
- setCompanies: (state, action) => {
302
- state.companies = action.payload;
303
- },
304
- setDefaultCompany: (state, action) => {
305
- state.defaultCompany = action.payload;
306
- },
307
- setLang: (state, action) => {
308
- state.context.lang = action.payload;
309
- },
310
- setUser: (state, action) => {
311
- state.user = action.payload;
312
- },
313
- setConfig: (state, action) => {
314
- state.config = action.payload;
315
- },
316
- setEnvFile: (state, action) => {
317
- state.envFile = action.payload;
318
- }
319
- }
320
- });
321
- var {
322
- setEnv,
323
- setUid,
324
- setLang,
325
- setAllowCompanies,
326
- setCompanies,
327
- setDefaultCompany,
328
- setUser,
329
- setConfig,
330
- setEnvFile
331
- } = envSlice.actions;
332
- var env_slice_default = envSlice.reducer;
333
-
334
- // src/store/reducers/excel-slice/index.ts
335
- var import_toolkit3 = require("@reduxjs/toolkit");
336
- var initialState3 = {
337
- dataParse: null,
338
- idFile: null,
339
- isFileLoaded: false,
340
- loadingImport: false,
341
- selectedFile: null,
342
- errorData: null
343
- };
344
- var excelSlice = (0, import_toolkit3.createSlice)({
345
- name: "excel",
346
- initialState: initialState3,
347
- reducers: {
348
- setDataParse: (state, action) => {
349
- state.dataParse = action.payload;
350
- },
351
- setIdFile: (state, action) => {
352
- state.idFile = action.payload;
353
- },
354
- setIsFileLoaded: (state, action) => {
355
- state.isFileLoaded = action.payload;
356
- },
357
- setLoadingImport: (state, action) => {
358
- state.loadingImport = action.payload;
359
- },
360
- setSelectedFile: (state, action) => {
361
- state.selectedFile = action.payload;
362
- },
363
- setErrorData: (state, action) => {
364
- state.errorData = action.payload;
365
- }
366
- }
367
- });
368
- var {
369
- setDataParse,
370
- setIdFile,
371
- setIsFileLoaded,
372
- setLoadingImport,
373
- setSelectedFile,
374
- setErrorData
375
- } = excelSlice.actions;
376
- var excel_slice_default = excelSlice.reducer;
377
-
378
- // src/store/reducers/form-slice/index.ts
379
- var import_toolkit4 = require("@reduxjs/toolkit");
380
- var initialState4 = {
381
- viewDataStore: {},
382
- isShowingModalDetail: false,
383
- isShowModalTranslate: false,
384
- formSubmitComponent: {},
385
- fieldTranslation: null,
386
- listSubject: {},
387
- dataUser: {}
388
- };
389
- var formSlice = (0, import_toolkit4.createSlice)({
390
- name: "form",
391
- initialState: initialState4,
392
- reducers: {
393
- setViewDataStore: (state, action) => {
394
- state.viewDataStore = action.payload;
395
- },
396
- setIsShowingModalDetail: (state, action) => {
397
- state.isShowingModalDetail = action.payload;
398
- },
399
- setIsShowModalTranslate: (state, action) => {
400
- state.isShowModalTranslate = action.payload;
401
- },
402
- setFormSubmitComponent: (state, action) => {
403
- state.formSubmitComponent[action.payload.key] = action.payload.component;
404
- },
405
- setFieldTranslate: (state, action) => {
406
- state.fieldTranslation = action.payload;
407
- },
408
- setListSubject: (state, action) => {
409
- state.listSubject = action.payload;
410
- },
411
- setDataUser: (state, action) => {
412
- state.dataUser = action.payload;
413
- }
414
- }
415
- });
416
- var {
417
- setViewDataStore,
418
- setIsShowingModalDetail,
419
- setIsShowModalTranslate,
420
- setFormSubmitComponent,
421
- setFieldTranslate,
422
- setListSubject,
423
- setDataUser
424
- } = formSlice.actions;
425
- var form_slice_default = formSlice.reducer;
426
-
427
- // src/store/reducers/header-slice/index.ts
428
- var import_toolkit5 = require("@reduxjs/toolkit");
429
- var headerSlice = (0, import_toolkit5.createSlice)({
430
- name: "header",
431
- initialState: {
432
- value: { allowedCompanyIds: [] }
433
- },
434
- reducers: {
435
- setHeader: (state, action) => {
436
- state.value = { ...state.value, ...action.payload };
437
- },
438
- setAllowedCompanyIds: (state, action) => {
439
- state.value.allowedCompanyIds = action.payload;
440
- }
441
- }
442
- });
443
- var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
444
- var header_slice_default = headerSlice.reducer;
445
-
446
- // src/store/reducers/list-slice/index.ts
447
- var import_toolkit6 = require("@reduxjs/toolkit");
448
- var initialState5 = {
449
- pageLimit: 10,
450
- fields: {},
451
- order: "",
452
- selectedRowKeys: [],
453
- selectedRadioKey: 0,
454
- indexRowTableModal: -2,
455
- isUpdateTableModal: false,
456
- footerGroupTable: {},
457
- transferDetail: null,
458
- page: 0,
459
- domainTable: []
460
- };
461
- var listSlice = (0, import_toolkit6.createSlice)({
462
- name: "list",
463
- initialState: initialState5,
464
- reducers: {
465
- setPageLimit: (state, action) => {
466
- state.pageLimit = action.payload;
467
- },
468
- setFields: (state, action) => {
469
- state.fields = action.payload;
470
- },
471
- setOrder: (state, action) => {
472
- state.order = action.payload;
473
- },
474
- setSelectedRowKeys: (state, action) => {
475
- state.selectedRowKeys = action.payload;
476
- },
477
- setSelectedRadioKey: (state, action) => {
478
- state.selectedRadioKey = action.payload;
479
- },
480
- setIndexRowTableModal: (state, action) => {
481
- state.indexRowTableModal = action.payload;
482
- },
483
- setTransferDetail: (state, action) => {
484
- state.transferDetail = action.payload;
485
- },
486
- setIsUpdateTableModal: (state, action) => {
487
- state.isUpdateTableModal = action.payload;
488
- },
489
- setPage: (state, action) => {
490
- state.page = action.payload;
491
- },
492
- setDomainTable: (state, action) => {
493
- state.domainTable = action.payload;
494
- }
495
- }
496
- });
497
- var {
498
- setPageLimit,
499
- setFields,
500
- setOrder,
501
- setSelectedRowKeys,
502
- setIndexRowTableModal,
503
- setIsUpdateTableModal,
504
- setPage,
505
- setSelectedRadioKey,
506
- setTransferDetail,
507
- setDomainTable
508
- } = listSlice.actions;
509
- var list_slice_default = listSlice.reducer;
510
-
511
- // src/store/reducers/login-slice/index.ts
512
- var import_toolkit7 = require("@reduxjs/toolkit");
513
- var initialState6 = {
514
- db: "",
515
- redirectTo: "/",
516
- forgotPasswordUrl: "/"
517
- };
518
- var loginSlice = (0, import_toolkit7.createSlice)({
519
- name: "login",
520
- initialState: initialState6,
521
- reducers: {
522
- setDb: (state, action) => {
523
- state.db = action.payload;
524
- },
525
- setRedirectTo: (state, action) => {
526
- state.redirectTo = action.payload;
527
- },
528
- setForgotPasswordUrl: (state, action) => {
529
- state.forgotPasswordUrl = action.payload;
530
- }
531
- }
532
- });
533
- var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
534
- var login_slice_default = loginSlice.reducer;
535
-
536
- // src/store/reducers/navbar-slice/index.ts
537
- var import_toolkit8 = require("@reduxjs/toolkit");
538
- var initialState7 = {
539
- menuFocus: {},
540
- menuAction: {},
541
- navbarWidth: 250,
542
- menuList: []
543
- };
544
- var navbarSlice = (0, import_toolkit8.createSlice)({
545
- name: "navbar",
546
- initialState: initialState7,
547
- reducers: {
548
- setMenuFocus: (state, action) => {
549
- state.menuFocus = action.payload;
550
- },
551
- setMenuFocusAction: (state, action) => {
552
- state.menuAction = action.payload;
553
- },
554
- setNavbarWidth: (state, action) => {
555
- state.navbarWidth = action.payload;
556
- },
557
- setMenuList: (state, action) => {
558
- state.menuList = action.payload;
559
- }
560
- }
561
- });
562
- var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
563
- var navbar_slice_default = navbarSlice.reducer;
564
-
565
- // src/store/reducers/profile-slice/index.ts
566
- var import_toolkit9 = require("@reduxjs/toolkit");
567
- var initialState8 = {
568
- profile: {}
569
- };
570
- var profileSlice = (0, import_toolkit9.createSlice)({
571
- name: "profile",
572
- initialState: initialState8,
573
- reducers: {
574
- setProfile: (state, action) => {
575
- state.profile = action.payload;
576
- }
577
- }
578
- });
579
- var { setProfile } = profileSlice.actions;
580
- var profile_slice_default = profileSlice.reducer;
581
-
582
- // src/store/reducers/search-slice/index.ts
583
- var import_toolkit10 = require("@reduxjs/toolkit");
584
- var initialState9 = {
585
- groupByDomain: null,
586
- searchBy: [],
587
- searchString: "",
588
- hoveredIndexSearchList: null,
589
- selectedTags: [],
590
- firstDomain: null,
591
- searchMap: {},
592
- filterBy: [],
593
- groupBy: []
594
- };
595
- var searchSlice = (0, import_toolkit10.createSlice)({
596
- name: "search",
597
- initialState: initialState9,
598
- reducers: {
599
- setGroupByDomain: (state, action) => {
600
- state.groupByDomain = action.payload;
601
- },
602
- setSearchBy: (state, action) => {
603
- state.searchBy = action.payload;
604
- },
605
- setSearchString: (state, action) => {
606
- state.searchString = action.payload;
607
- },
608
- setHoveredIndexSearchList: (state, action) => {
609
- state.hoveredIndexSearchList = action.payload;
610
- },
611
- setSelectedTags: (state, action) => {
612
- state.selectedTags = action.payload;
613
- },
614
- setFirstDomain: (state, action) => {
615
- state.firstDomain = action.payload;
616
- },
617
- setFilterBy: (state, action) => {
618
- state.filterBy = action.payload;
619
- },
620
- setGroupBy: (state, action) => {
621
- state.groupBy = action.payload;
622
- },
623
- setSearchMap: (state, action) => {
624
- state.searchMap = action.payload;
625
- },
626
- updateSearchMap: (state, action) => {
627
- if (!state.searchMap[action.payload.key]) {
628
- state.searchMap[action.payload.key] = [];
629
- }
630
- state.searchMap[action.payload.key].push(action.payload.value);
631
- },
632
- removeKeyFromSearchMap: (state, action) => {
633
- const { key, item } = action.payload;
634
- const values = state.searchMap[key];
635
- if (!values) return;
636
- if (item) {
637
- const filtered = values.filter((value) => value.name !== item.name);
638
- if (filtered.length > 0) {
639
- state.searchMap[key] = filtered;
640
- } else {
641
- delete state.searchMap[key];
642
- }
643
- } else {
644
- delete state.searchMap[key];
645
- }
646
- },
647
- clearSearchMap: (state) => {
648
- state.searchMap = {};
649
- }
650
- }
651
- });
652
- var {
653
- setGroupByDomain,
654
- setSelectedTags,
655
- setSearchString,
656
- setHoveredIndexSearchList,
657
- setFirstDomain,
658
- setSearchBy,
659
- setFilterBy,
660
- setSearchMap,
661
- updateSearchMap,
662
- removeKeyFromSearchMap,
663
- setGroupBy,
664
- clearSearchMap
665
- } = searchSlice.actions;
666
- var search_slice_default = searchSlice.reducer;
667
-
668
- // src/store/store.ts
669
- var rootReducer = combineReducers({
670
- env: env_slice_default,
671
- header: header_slice_default,
672
- navbar: navbar_slice_default,
673
- list: list_slice_default,
674
- search: search_slice_default,
675
- form: form_slice_default,
676
- breadcrumbs: breadcrums_slice_default,
677
- login: login_slice_default,
678
- excel: excel_slice_default,
679
- profile: profile_slice_default
680
- });
681
- var envStore = (0, import_toolkit11.configureStore)({
682
- reducer: rootReducer,
683
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({
684
- serializableCheck: false
685
- })
686
- });
687
-
688
75
  // src/configs/axios-client.ts
689
76
  var import_axios = __toESM(require("axios"));
690
77
 
@@ -2433,612 +1820,1228 @@ function evaluate(ast, context = {}) {
2433
1820
  } else {
2434
1821
  result = leftVal[ast2.key];
2435
1822
  }
2436
- if (typeof result === "function") {
2437
- const bound = result.bind(leftVal);
2438
- bound[unboundFn] = result;
2439
- return bound;
1823
+ if (typeof result === "function") {
1824
+ const bound = result.bind(leftVal);
1825
+ bound[unboundFn] = result;
1826
+ return bound;
1827
+ }
1828
+ return result;
1829
+ default:
1830
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
1831
+ }
1832
+ }
1833
+ function _evaluate(ast2) {
1834
+ const val = _innerEvaluate(ast2);
1835
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
1836
+ throw new Error("Invalid Function Call");
1837
+ }
1838
+ return val;
1839
+ }
1840
+ return _evaluate(ast);
1841
+ }
1842
+
1843
+ // src/utils/domain/py.ts
1844
+ function parseExpr(expr) {
1845
+ const tokens = tokenize(expr);
1846
+ return parse(tokens);
1847
+ }
1848
+
1849
+ // src/utils/domain/objects.ts
1850
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
1851
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
1852
+ return obj1 === obj2;
1853
+ }
1854
+ const obj1Keys = Object.keys(obj1);
1855
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
1856
+ }
1857
+
1858
+ // src/utils/domain/arrays.ts
1859
+ var shallowEqual2 = shallowEqual;
1860
+
1861
+ // src/utils/domain/strings.ts
1862
+ var escapeMethod = Symbol("html");
1863
+ function escapeRegExp(str) {
1864
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1865
+ }
1866
+
1867
+ // src/utils/domain/domain.ts
1868
+ var InvalidDomainError = class extends Error {
1869
+ };
1870
+ var Domain = class _Domain {
1871
+ ast = { type: -1, value: null };
1872
+ static TRUE;
1873
+ static FALSE;
1874
+ static combine(domains, operator) {
1875
+ if (domains.length === 0) {
1876
+ return new _Domain([]);
1877
+ }
1878
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
1879
+ if (domains.length === 1) {
1880
+ return domain1;
1881
+ }
1882
+ const domain2 = _Domain.combine(domains.slice(1), operator);
1883
+ const result = new _Domain([]);
1884
+ const astValues1 = domain1.ast.value;
1885
+ const astValues2 = domain2.ast.value;
1886
+ const op = operator === "AND" ? "&" : "|";
1887
+ const combinedAST = {
1888
+ type: 4,
1889
+ value: astValues1.concat(astValues2)
1890
+ };
1891
+ result.ast = normalizeDomainAST(combinedAST, op);
1892
+ return result;
1893
+ }
1894
+ static and(domains) {
1895
+ return _Domain.combine(domains, "AND");
1896
+ }
1897
+ static or(domains) {
1898
+ return _Domain.combine(domains, "OR");
1899
+ }
1900
+ static not(domain) {
1901
+ const result = new _Domain(domain);
1902
+ result.ast.value.unshift({ type: 1, value: "!" });
1903
+ return result;
1904
+ }
1905
+ static removeDomainLeaves(domain, keysToRemove) {
1906
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
1907
+ const leaf = elements[idx];
1908
+ if (leaf.type === 10) {
1909
+ if (keysToRemove.includes(leaf.value[0].value)) {
1910
+ if (operatorCtx === "&") {
1911
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1912
+ } else if (operatorCtx === "|") {
1913
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
1914
+ }
1915
+ } else {
1916
+ newDomain2.ast.value.push(leaf);
1917
+ }
1918
+ return 1;
1919
+ } else if (leaf.type === 1) {
1920
+ 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)) {
1921
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1922
+ return 3;
1923
+ }
1924
+ newDomain2.ast.value.push(leaf);
1925
+ if (leaf.value === "!") {
1926
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
1927
+ }
1928
+ const firstLeafSkip = processLeaf(
1929
+ elements,
1930
+ idx + 1,
1931
+ leaf.value,
1932
+ newDomain2
1933
+ );
1934
+ const secondLeafSkip = processLeaf(
1935
+ elements,
1936
+ idx + 1 + firstLeafSkip,
1937
+ leaf.value,
1938
+ newDomain2
1939
+ );
1940
+ return 1 + firstLeafSkip + secondLeafSkip;
1941
+ }
1942
+ return 0;
1943
+ }
1944
+ const d = new _Domain(domain);
1945
+ if (d.ast.value.length === 0) {
1946
+ return d;
1947
+ }
1948
+ const newDomain = new _Domain([]);
1949
+ processLeaf(d.ast.value, 0, "&", newDomain);
1950
+ return newDomain;
1951
+ }
1952
+ constructor(descr = []) {
1953
+ if (descr instanceof _Domain) {
1954
+ return new _Domain(descr.toString());
1955
+ } else {
1956
+ let rawAST;
1957
+ try {
1958
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
1959
+ } catch (error) {
1960
+ throw new InvalidDomainError(
1961
+ `Invalid domain representation: ${descr}`,
1962
+ {
1963
+ cause: error
1964
+ }
1965
+ );
1966
+ }
1967
+ this.ast = normalizeDomainAST(rawAST);
1968
+ }
1969
+ }
1970
+ contains(record) {
1971
+ const expr = evaluate(this.ast, record);
1972
+ return matchDomain(record, expr);
1973
+ }
1974
+ toString() {
1975
+ return formatAST(this.ast);
1976
+ }
1977
+ toList(context) {
1978
+ return evaluate(this.ast, context);
1979
+ }
1980
+ toJson() {
1981
+ try {
1982
+ const evaluatedAsList = this.toList({});
1983
+ const evaluatedDomain = new _Domain(evaluatedAsList);
1984
+ if (evaluatedDomain.toString() === this.toString()) {
1985
+ return evaluatedAsList;
1986
+ }
1987
+ return this.toString();
1988
+ } catch {
1989
+ return this.toString();
1990
+ }
1991
+ }
1992
+ };
1993
+ var TRUE_LEAF = [1, "=", 1];
1994
+ var FALSE_LEAF = [0, "=", 1];
1995
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
1996
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
1997
+ Domain.TRUE = TRUE_DOMAIN;
1998
+ Domain.FALSE = FALSE_DOMAIN;
1999
+ function toAST(domain) {
2000
+ const elems = domain.map((elem) => {
2001
+ switch (elem) {
2002
+ case "!":
2003
+ case "&":
2004
+ case "|":
2005
+ return { type: 1, value: elem };
2006
+ default:
2007
+ return {
2008
+ type: 10,
2009
+ value: elem.map(toPyValue)
2010
+ };
2011
+ }
2012
+ });
2013
+ return { type: 4, value: elems };
2014
+ }
2015
+ function normalizeDomainAST(domain, op = "&") {
2016
+ if (domain.type !== 4) {
2017
+ if (domain.type === 10) {
2018
+ const value = domain.value;
2019
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2020
+ throw new InvalidDomainError("Invalid domain AST");
2021
+ }
2022
+ } else {
2023
+ throw new InvalidDomainError("Invalid domain AST");
2024
+ }
2025
+ }
2026
+ if (domain.value.length === 0) {
2027
+ return domain;
2028
+ }
2029
+ let expected = 1;
2030
+ for (const child of domain.value) {
2031
+ switch (child.type) {
2032
+ case 1:
2033
+ if (child.value === "&" || child.value === "|") {
2034
+ expected++;
2035
+ } else if (child.value !== "!") {
2036
+ throw new InvalidDomainError("Invalid domain AST");
2037
+ }
2038
+ break;
2039
+ case 4:
2040
+ /* list */
2041
+ case 10:
2042
+ if (child.value.length === 3) {
2043
+ expected--;
2044
+ break;
2440
2045
  }
2441
- return result;
2046
+ throw new InvalidDomainError("Invalid domain AST");
2442
2047
  default:
2443
- throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
2048
+ throw new InvalidDomainError("Invalid domain AST");
2444
2049
  }
2445
2050
  }
2446
- function _evaluate(ast2) {
2447
- const val = _innerEvaluate(ast2);
2448
- if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
2449
- throw new Error("Invalid Function Call");
2051
+ const values = domain.value.slice();
2052
+ while (expected < 0) {
2053
+ expected++;
2054
+ values.unshift({ type: 1, value: op });
2055
+ }
2056
+ if (expected > 0) {
2057
+ throw new InvalidDomainError(
2058
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2059
+ );
2060
+ }
2061
+ return { type: 4, value: values };
2062
+ }
2063
+ function matchCondition(record, condition) {
2064
+ if (typeof condition === "boolean") {
2065
+ return condition;
2066
+ }
2067
+ const [field, operator, value] = condition;
2068
+ if (typeof field === "string") {
2069
+ const names = field.split(".");
2070
+ if (names.length >= 2) {
2071
+ return matchCondition(record[names[0]], [
2072
+ names.slice(1).join("."),
2073
+ operator,
2074
+ value
2075
+ ]);
2450
2076
  }
2451
- return val;
2452
2077
  }
2453
- return _evaluate(ast);
2078
+ let likeRegexp, ilikeRegexp;
2079
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2080
+ likeRegexp = new RegExp(
2081
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2082
+ "g"
2083
+ );
2084
+ ilikeRegexp = new RegExp(
2085
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2086
+ "gi"
2087
+ );
2088
+ }
2089
+ const fieldValue = typeof field === "number" ? field : record[field];
2090
+ switch (operator) {
2091
+ case "=?":
2092
+ if ([false, null].includes(value)) {
2093
+ return true;
2094
+ }
2095
+ // eslint-disable-next-line no-fallthrough
2096
+ case "=":
2097
+ case "==":
2098
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
2099
+ return shallowEqual2(fieldValue, value);
2100
+ }
2101
+ return fieldValue === value;
2102
+ case "!=":
2103
+ case "<>":
2104
+ return !matchCondition(record, [field, "==", value]);
2105
+ case "<":
2106
+ return fieldValue < value;
2107
+ case "<=":
2108
+ return fieldValue <= value;
2109
+ case ">":
2110
+ return fieldValue > value;
2111
+ case ">=":
2112
+ return fieldValue >= value;
2113
+ case "in": {
2114
+ const val = Array.isArray(value) ? value : [value];
2115
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2116
+ return fieldVal.some((fv) => val.includes(fv));
2117
+ }
2118
+ case "not in": {
2119
+ const val = Array.isArray(value) ? value : [value];
2120
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2121
+ return !fieldVal.some((fv) => val.includes(fv));
2122
+ }
2123
+ case "like":
2124
+ if (fieldValue === false) {
2125
+ return false;
2126
+ }
2127
+ return Boolean(fieldValue.match(likeRegexp));
2128
+ case "not like":
2129
+ if (fieldValue === false) {
2130
+ return false;
2131
+ }
2132
+ return Boolean(!fieldValue.match(likeRegexp));
2133
+ case "=like":
2134
+ if (fieldValue === false) {
2135
+ return false;
2136
+ }
2137
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2138
+ fieldValue
2139
+ );
2140
+ case "ilike":
2141
+ if (fieldValue === false) {
2142
+ return false;
2143
+ }
2144
+ return Boolean(fieldValue.match(ilikeRegexp));
2145
+ case "not ilike":
2146
+ if (fieldValue === false) {
2147
+ return false;
2148
+ }
2149
+ return Boolean(!fieldValue.match(ilikeRegexp));
2150
+ case "=ilike":
2151
+ if (fieldValue === false) {
2152
+ return false;
2153
+ }
2154
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2155
+ fieldValue
2156
+ );
2157
+ }
2158
+ throw new InvalidDomainError("could not match domain");
2454
2159
  }
2455
-
2456
- // src/utils/domain/py.ts
2457
- function parseExpr(expr) {
2458
- const tokens = tokenize(expr);
2459
- return parse(tokens);
2160
+ function makeOperators(record) {
2161
+ const match = matchCondition.bind(null, record);
2162
+ return {
2163
+ "!": (x) => !match(x),
2164
+ "&": (a, b) => match(a) && match(b),
2165
+ "|": (a, b) => match(a) || match(b)
2166
+ };
2460
2167
  }
2461
-
2462
- // src/utils/domain/objects.ts
2463
- function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
2464
- if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
2465
- return obj1 === obj2;
2168
+ function matchDomain(record, domain) {
2169
+ if (domain.length === 0) {
2170
+ return true;
2466
2171
  }
2467
- const obj1Keys = Object.keys(obj1);
2468
- return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2469
- }
2470
-
2471
- // src/utils/domain/arrays.ts
2472
- var shallowEqual2 = shallowEqual;
2473
-
2474
- // src/utils/domain/strings.ts
2475
- var escapeMethod = Symbol("html");
2476
- function escapeRegExp(str) {
2477
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2172
+ const operators = makeOperators(record);
2173
+ const reversedDomain = Array.from(domain).reverse();
2174
+ const condStack = [];
2175
+ for (const item of reversedDomain) {
2176
+ const operator = typeof item === "string" && operators[item];
2177
+ if (operator) {
2178
+ const operands = condStack.splice(-operator.length);
2179
+ condStack.push(operator(...operands));
2180
+ } else {
2181
+ condStack.push(item);
2182
+ }
2183
+ }
2184
+ return matchCondition(record, condStack.pop());
2478
2185
  }
2479
2186
 
2480
- // src/utils/domain/domain.ts
2481
- var InvalidDomainError = class extends Error {
2187
+ // src/utils/function.ts
2188
+ var import_react = require("react");
2189
+ var toQueryString = (params) => {
2190
+ return Object.keys(params).map(
2191
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2192
+ ).join("&");
2482
2193
  };
2483
- var Domain = class _Domain {
2484
- ast = { type: -1, value: null };
2485
- static TRUE;
2486
- static FALSE;
2487
- static combine(domains, operator) {
2488
- if (domains.length === 0) {
2489
- return new _Domain([]);
2490
- }
2491
- const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
2492
- if (domains.length === 1) {
2493
- return domain1;
2494
- }
2495
- const domain2 = _Domain.combine(domains.slice(1), operator);
2496
- const result = new _Domain([]);
2497
- const astValues1 = domain1.ast.value;
2498
- const astValues2 = domain2.ast.value;
2499
- const op = operator === "AND" ? "&" : "|";
2500
- const combinedAST = {
2501
- type: 4,
2502
- value: astValues1.concat(astValues2)
2503
- };
2504
- result.ast = normalizeDomainAST(combinedAST, op);
2505
- return result;
2506
- }
2507
- static and(domains) {
2508
- return _Domain.combine(domains, "AND");
2509
- }
2510
- static or(domains) {
2511
- return _Domain.combine(domains, "OR");
2194
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2195
+ if (!originalRequest.data) return originalRequest.data;
2196
+ if (typeof originalRequest.data === "string") {
2197
+ try {
2198
+ const parsedData = JSON.parse(originalRequest.data);
2199
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2200
+ parsedData.with_context.token = newAccessToken;
2201
+ }
2202
+ return JSON.stringify(parsedData);
2203
+ } catch (e) {
2204
+ console.warn("Failed to parse originalRequest.data", e);
2205
+ return originalRequest.data;
2206
+ }
2512
2207
  }
2513
- static not(domain) {
2514
- const result = new _Domain(domain);
2515
- result.ast.value.unshift({ type: 1, value: "!" });
2516
- return result;
2208
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2209
+ originalRequest.data.with_context.token = newAccessToken;
2517
2210
  }
2518
- static removeDomainLeaves(domain, keysToRemove) {
2519
- function processLeaf(elements, idx, operatorCtx, newDomain2) {
2520
- const leaf = elements[idx];
2521
- if (leaf.type === 10) {
2522
- if (keysToRemove.includes(leaf.value[0].value)) {
2523
- if (operatorCtx === "&") {
2524
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2525
- } else if (operatorCtx === "|") {
2526
- newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
2527
- }
2211
+ return originalRequest.data;
2212
+ };
2213
+
2214
+ // src/utils/storage/local-storage.ts
2215
+ var localStorageUtils = () => {
2216
+ const setToken = async (access_token) => {
2217
+ localStorage.setItem("accessToken", access_token);
2218
+ };
2219
+ const setRefreshToken = async (refresh_token) => {
2220
+ localStorage.setItem("refreshToken", refresh_token);
2221
+ };
2222
+ const getAccessToken = async () => {
2223
+ return localStorage.getItem("accessToken");
2224
+ };
2225
+ const getRefreshToken = async () => {
2226
+ return localStorage.getItem("refreshToken");
2227
+ };
2228
+ const clearToken = async () => {
2229
+ localStorage.removeItem("accessToken");
2230
+ localStorage.removeItem("refreshToken");
2231
+ };
2232
+ return {
2233
+ setToken,
2234
+ setRefreshToken,
2235
+ getAccessToken,
2236
+ getRefreshToken,
2237
+ clearToken
2238
+ };
2239
+ };
2240
+
2241
+ // src/utils/storage/session-storage.ts
2242
+ var sessionStorageUtils = () => {
2243
+ const getBrowserSession = async () => {
2244
+ return sessionStorage.getItem("browserSession");
2245
+ };
2246
+ return {
2247
+ getBrowserSession
2248
+ };
2249
+ };
2250
+
2251
+ // src/configs/axios-client.ts
2252
+ var axiosClient = {
2253
+ init(config) {
2254
+ const localStorage2 = config.localStorageUtils ?? localStorageUtils();
2255
+ const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
2256
+ const db = config.db;
2257
+ let isRefreshing = false;
2258
+ let failedQueue = [];
2259
+ const processQueue = (error, token = null) => {
2260
+ failedQueue?.forEach((prom) => {
2261
+ if (error) {
2262
+ prom.reject(error);
2528
2263
  } else {
2529
- newDomain2.ast.value.push(leaf);
2530
- }
2531
- return 1;
2532
- } else if (leaf.type === 1) {
2533
- 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)) {
2534
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2535
- return 3;
2264
+ prom.resolve(token);
2536
2265
  }
2537
- newDomain2.ast.value.push(leaf);
2538
- if (leaf.value === "!") {
2539
- return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
2266
+ });
2267
+ failedQueue = [];
2268
+ };
2269
+ const instance = import_axios.default.create({
2270
+ adapter: import_axios.default.defaults.adapter,
2271
+ baseURL: config.baseUrl,
2272
+ timeout: 5e4,
2273
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
2274
+ });
2275
+ instance.interceptors.request.use(
2276
+ async (config2) => {
2277
+ const useRefreshToken = config2.useRefreshToken;
2278
+ const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2279
+ if (token) {
2280
+ config2.headers["Authorization"] = "Bearer " + token;
2540
2281
  }
2541
- const firstLeafSkip = processLeaf(
2542
- elements,
2543
- idx + 1,
2544
- leaf.value,
2545
- newDomain2
2546
- );
2547
- const secondLeafSkip = processLeaf(
2548
- elements,
2549
- idx + 1 + firstLeafSkip,
2550
- leaf.value,
2551
- newDomain2
2552
- );
2553
- return 1 + firstLeafSkip + secondLeafSkip;
2282
+ return config2;
2283
+ },
2284
+ (error) => {
2285
+ Promise.reject(error);
2554
2286
  }
2555
- return 0;
2556
- }
2557
- const d = new _Domain(domain);
2558
- if (d.ast.value.length === 0) {
2559
- return d;
2560
- }
2561
- const newDomain = new _Domain([]);
2562
- processLeaf(d.ast.value, 0, "&", newDomain);
2563
- return newDomain;
2564
- }
2565
- constructor(descr = []) {
2566
- if (descr instanceof _Domain) {
2567
- return new _Domain(descr.toString());
2568
- } else {
2569
- let rawAST;
2570
- try {
2571
- rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
2572
- } catch (error) {
2573
- throw new InvalidDomainError(
2574
- `Invalid domain representation: ${descr}`,
2575
- {
2576
- cause: error
2287
+ );
2288
+ instance.interceptors.response.use(
2289
+ (response) => {
2290
+ return handleResponse(response);
2291
+ },
2292
+ async (error) => {
2293
+ const handleError3 = async (error2) => {
2294
+ if (!error2.response) {
2295
+ return error2;
2577
2296
  }
2578
- );
2297
+ const { data } = error2.response;
2298
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2299
+ await clearAuthToken();
2300
+ }
2301
+ return data;
2302
+ };
2303
+ const originalRequest = error.config;
2304
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2305
+ error.response.data.code
2306
+ )) {
2307
+ if (isRefreshing) {
2308
+ return new Promise(function(resolve, reject) {
2309
+ failedQueue.push({ resolve, reject });
2310
+ }).then((token) => {
2311
+ originalRequest.headers["Authorization"] = "Bearer " + token;
2312
+ originalRequest.data = updateTokenParamInOriginalRequest(
2313
+ originalRequest,
2314
+ token
2315
+ );
2316
+ return instance.request(originalRequest);
2317
+ }).catch(async (err) => {
2318
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2319
+ await clearAuthToken();
2320
+ }
2321
+ });
2322
+ }
2323
+ const browserSession = await sessionStorage2.getBrowserSession();
2324
+ const refreshToken = await localStorage2.getRefreshToken();
2325
+ const accessTokenExp = await localStorage2.getAccessToken();
2326
+ isRefreshing = true;
2327
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2328
+ await clearAuthToken();
2329
+ } else {
2330
+ const payload = Object.fromEntries(
2331
+ Object.entries({
2332
+ refresh_token: refreshToken,
2333
+ grant_type: "refresh_token",
2334
+ client_id: config.config.clientId,
2335
+ client_secret: config.config.clientSecret
2336
+ }).filter(([_, value]) => !!value)
2337
+ );
2338
+ return new Promise(function(resolve) {
2339
+ import_axios.default.post(
2340
+ `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2341
+ payload,
2342
+ {
2343
+ headers: {
2344
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2345
+ Authorization: `Bearer ${accessTokenExp}`
2346
+ }
2347
+ }
2348
+ ).then(async (res) => {
2349
+ const data = res.data;
2350
+ await localStorage2.setToken(data.access_token);
2351
+ await localStorage2.setRefreshToken(data.refresh_token);
2352
+ import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2353
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2354
+ originalRequest.data = updateTokenParamInOriginalRequest(
2355
+ originalRequest,
2356
+ data.access_token
2357
+ );
2358
+ processQueue(null, data.access_token);
2359
+ resolve(instance.request(originalRequest));
2360
+ }).catch(async (err) => {
2361
+ 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") {
2362
+ await clearAuthToken();
2363
+ }
2364
+ if (err && err.response) {
2365
+ const { error_code } = err.response?.data || {};
2366
+ if (error_code === "AUTHEN_FAIL") {
2367
+ await clearAuthToken();
2368
+ }
2369
+ }
2370
+ processQueue(err, null);
2371
+ }).finally(() => {
2372
+ isRefreshing = false;
2373
+ });
2374
+ });
2375
+ }
2376
+ }
2377
+ return Promise.reject(await handleError3(error));
2579
2378
  }
2580
- this.ast = normalizeDomainAST(rawAST);
2581
- }
2582
- }
2583
- contains(record) {
2584
- const expr = evaluate(this.ast, record);
2585
- return matchDomain(record, expr);
2586
- }
2587
- toString() {
2588
- return formatAST(this.ast);
2589
- }
2590
- toList(context) {
2591
- return evaluate(this.ast, context);
2592
- }
2593
- toJson() {
2594
- try {
2595
- const evaluatedAsList = this.toList({});
2596
- const evaluatedDomain = new _Domain(evaluatedAsList);
2597
- if (evaluatedDomain.toString() === this.toString()) {
2598
- return evaluatedAsList;
2379
+ );
2380
+ const handleResponse = (res) => {
2381
+ if (res && res.data) {
2382
+ return res.data;
2383
+ }
2384
+ return res;
2385
+ };
2386
+ const handleError2 = (error) => {
2387
+ if (error.isAxiosError && error.code === "ECONNABORTED") {
2388
+ console.error("Request Timeout Error:", error);
2389
+ return "Request Timeout Error";
2390
+ } else if (error.isAxiosError && !error.response) {
2391
+ console.error("Network Error:", error);
2392
+ return "Network Error";
2393
+ } else {
2394
+ console.error("Other Error:", error?.response);
2395
+ const errorMessage = error?.response?.data?.message || "An error occurred";
2396
+ return { message: errorMessage, status: error?.response?.status };
2599
2397
  }
2600
- return this.toString();
2601
- } catch {
2602
- return this.toString();
2398
+ };
2399
+ const clearAuthToken = async () => {
2400
+ await localStorage2.clearToken();
2401
+ if (typeof window !== "undefined") {
2402
+ window.location.href = `/login`;
2403
+ }
2404
+ };
2405
+ function formatUrl(url, db2) {
2406
+ return url + (db2 ? "?db=" + db2 : "");
2603
2407
  }
2408
+ const responseBody = (response) => response;
2409
+ const requests = {
2410
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2411
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2412
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2413
+ responseType: "arraybuffer",
2414
+ headers: {
2415
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2416
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2417
+ }
2418
+ }).then(responseBody),
2419
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2420
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2421
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2422
+ };
2423
+ return requests;
2604
2424
  }
2605
2425
  };
2606
- var TRUE_LEAF = [1, "=", 1];
2607
- var FALSE_LEAF = [0, "=", 1];
2608
- var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
2609
- var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
2610
- Domain.TRUE = TRUE_DOMAIN;
2611
- Domain.FALSE = FALSE_DOMAIN;
2612
- function toAST(domain) {
2613
- const elems = domain.map((elem) => {
2614
- switch (elem) {
2615
- case "!":
2616
- case "&":
2617
- case "|":
2618
- return { type: 1, value: elem };
2619
- default:
2620
- return {
2621
- type: 10,
2622
- value: elem.map(toPyValue)
2623
- };
2624
- }
2625
- });
2626
- return { type: 4, value: elems };
2627
- }
2628
- function normalizeDomainAST(domain, op = "&") {
2629
- if (domain.type !== 4) {
2630
- if (domain.type === 10) {
2631
- const value = domain.value;
2632
- if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2633
- throw new InvalidDomainError("Invalid domain AST");
2634
- }
2635
- } else {
2636
- throw new InvalidDomainError("Invalid domain AST");
2426
+
2427
+ // src/store/index.ts
2428
+ var import_react_redux = require("react-redux");
2429
+
2430
+ // src/store/reducers/breadcrums-slice/index.ts
2431
+ var import_toolkit = require("@reduxjs/toolkit");
2432
+ var initialState = {
2433
+ breadCrumbs: []
2434
+ };
2435
+ var breadcrumbsSlice = (0, import_toolkit.createSlice)({
2436
+ name: "breadcrumbs",
2437
+ initialState,
2438
+ reducers: {
2439
+ setBreadCrumbs: (state, action) => {
2440
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
2637
2441
  }
2638
2442
  }
2639
- if (domain.value.length === 0) {
2640
- return domain;
2443
+ });
2444
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
2445
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
2446
+
2447
+ // src/store/reducers/env-slice/index.ts
2448
+ var import_toolkit2 = require("@reduxjs/toolkit");
2449
+ var initialState2 = {
2450
+ baseUrl: "",
2451
+ requests: null,
2452
+ companies: [],
2453
+ user: {},
2454
+ config: null,
2455
+ envFile: null,
2456
+ defaultCompany: {
2457
+ id: null,
2458
+ logo: "",
2459
+ secondary_color: "",
2460
+ primary_color: ""
2461
+ },
2462
+ context: {
2463
+ uid: null,
2464
+ allowed_company_ids: [],
2465
+ lang: "vi_VN",
2466
+ tz: "Asia/Saigon"
2641
2467
  }
2642
- let expected = 1;
2643
- for (const child of domain.value) {
2644
- switch (child.type) {
2645
- case 1:
2646
- if (child.value === "&" || child.value === "|") {
2647
- expected++;
2648
- } else if (child.value !== "!") {
2649
- throw new InvalidDomainError("Invalid domain AST");
2650
- }
2651
- break;
2652
- case 4:
2653
- /* list */
2654
- case 10:
2655
- if (child.value.length === 3) {
2656
- expected--;
2657
- break;
2658
- }
2659
- throw new InvalidDomainError("Invalid domain AST");
2660
- default:
2661
- throw new InvalidDomainError("Invalid domain AST");
2468
+ };
2469
+ var envSlice = (0, import_toolkit2.createSlice)({
2470
+ name: "env",
2471
+ initialState: initialState2,
2472
+ reducers: {
2473
+ setEnv: (state, action) => {
2474
+ Object.assign(state, action.payload);
2475
+ },
2476
+ setUid: (state, action) => {
2477
+ state.context.uid = action.payload;
2478
+ },
2479
+ setAllowCompanies: (state, action) => {
2480
+ state.context.allowed_company_ids = action.payload;
2481
+ },
2482
+ setCompanies: (state, action) => {
2483
+ state.companies = action.payload;
2484
+ },
2485
+ setDefaultCompany: (state, action) => {
2486
+ state.defaultCompany = action.payload;
2487
+ },
2488
+ setLang: (state, action) => {
2489
+ state.context.lang = action.payload;
2490
+ },
2491
+ setUser: (state, action) => {
2492
+ state.user = action.payload;
2493
+ },
2494
+ setConfig: (state, action) => {
2495
+ state.config = action.payload;
2496
+ },
2497
+ setEnvFile: (state, action) => {
2498
+ state.envFile = action.payload;
2662
2499
  }
2663
2500
  }
2664
- const values = domain.value.slice();
2665
- while (expected < 0) {
2666
- expected++;
2667
- values.unshift({ type: 1, value: op });
2668
- }
2669
- if (expected > 0) {
2670
- throw new InvalidDomainError(
2671
- `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2672
- );
2673
- }
2674
- return { type: 4, value: values };
2675
- }
2676
- function matchCondition(record, condition) {
2677
- if (typeof condition === "boolean") {
2678
- return condition;
2501
+ });
2502
+ var {
2503
+ setEnv,
2504
+ setUid,
2505
+ setLang,
2506
+ setAllowCompanies,
2507
+ setCompanies,
2508
+ setDefaultCompany,
2509
+ setUser,
2510
+ setConfig,
2511
+ setEnvFile
2512
+ } = envSlice.actions;
2513
+ var env_slice_default = envSlice.reducer;
2514
+
2515
+ // src/store/reducers/excel-slice/index.ts
2516
+ var import_toolkit3 = require("@reduxjs/toolkit");
2517
+ var initialState3 = {
2518
+ dataParse: null,
2519
+ idFile: null,
2520
+ isFileLoaded: false,
2521
+ loadingImport: false,
2522
+ selectedFile: null,
2523
+ errorData: null
2524
+ };
2525
+ var excelSlice = (0, import_toolkit3.createSlice)({
2526
+ name: "excel",
2527
+ initialState: initialState3,
2528
+ reducers: {
2529
+ setDataParse: (state, action) => {
2530
+ state.dataParse = action.payload;
2531
+ },
2532
+ setIdFile: (state, action) => {
2533
+ state.idFile = action.payload;
2534
+ },
2535
+ setIsFileLoaded: (state, action) => {
2536
+ state.isFileLoaded = action.payload;
2537
+ },
2538
+ setLoadingImport: (state, action) => {
2539
+ state.loadingImport = action.payload;
2540
+ },
2541
+ setSelectedFile: (state, action) => {
2542
+ state.selectedFile = action.payload;
2543
+ },
2544
+ setErrorData: (state, action) => {
2545
+ state.errorData = action.payload;
2546
+ }
2679
2547
  }
2680
- const [field, operator, value] = condition;
2681
- if (typeof field === "string") {
2682
- const names = field.split(".");
2683
- if (names.length >= 2) {
2684
- return matchCondition(record[names[0]], [
2685
- names.slice(1).join("."),
2686
- operator,
2687
- value
2688
- ]);
2548
+ });
2549
+ var {
2550
+ setDataParse,
2551
+ setIdFile,
2552
+ setIsFileLoaded,
2553
+ setLoadingImport,
2554
+ setSelectedFile,
2555
+ setErrorData
2556
+ } = excelSlice.actions;
2557
+ var excel_slice_default = excelSlice.reducer;
2558
+
2559
+ // src/store/reducers/form-slice/index.ts
2560
+ var import_toolkit4 = require("@reduxjs/toolkit");
2561
+ var initialState4 = {
2562
+ viewDataStore: {},
2563
+ isShowingModalDetail: false,
2564
+ isShowModalTranslate: false,
2565
+ formSubmitComponent: {},
2566
+ fieldTranslation: null,
2567
+ listSubject: {},
2568
+ dataUser: {}
2569
+ };
2570
+ var formSlice = (0, import_toolkit4.createSlice)({
2571
+ name: "form",
2572
+ initialState: initialState4,
2573
+ reducers: {
2574
+ setViewDataStore: (state, action) => {
2575
+ state.viewDataStore = action.payload;
2576
+ },
2577
+ setIsShowingModalDetail: (state, action) => {
2578
+ state.isShowingModalDetail = action.payload;
2579
+ },
2580
+ setIsShowModalTranslate: (state, action) => {
2581
+ state.isShowModalTranslate = action.payload;
2582
+ },
2583
+ setFormSubmitComponent: (state, action) => {
2584
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
2585
+ },
2586
+ setFieldTranslate: (state, action) => {
2587
+ state.fieldTranslation = action.payload;
2588
+ },
2589
+ setListSubject: (state, action) => {
2590
+ state.listSubject = action.payload;
2591
+ },
2592
+ setDataUser: (state, action) => {
2593
+ state.dataUser = action.payload;
2689
2594
  }
2690
2595
  }
2691
- let likeRegexp, ilikeRegexp;
2692
- if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2693
- likeRegexp = new RegExp(
2694
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2695
- "g"
2696
- );
2697
- ilikeRegexp = new RegExp(
2698
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2699
- "gi"
2700
- );
2701
- }
2702
- const fieldValue = typeof field === "number" ? field : record[field];
2703
- switch (operator) {
2704
- case "=?":
2705
- if ([false, null].includes(value)) {
2706
- return true;
2707
- }
2708
- // eslint-disable-next-line no-fallthrough
2709
- case "=":
2710
- case "==":
2711
- if (Array.isArray(fieldValue) && Array.isArray(value)) {
2712
- return shallowEqual2(fieldValue, value);
2713
- }
2714
- return fieldValue === value;
2715
- case "!=":
2716
- case "<>":
2717
- return !matchCondition(record, [field, "==", value]);
2718
- case "<":
2719
- return fieldValue < value;
2720
- case "<=":
2721
- return fieldValue <= value;
2722
- case ">":
2723
- return fieldValue > value;
2724
- case ">=":
2725
- return fieldValue >= value;
2726
- case "in": {
2727
- const val = Array.isArray(value) ? value : [value];
2728
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2729
- return fieldVal.some((fv) => val.includes(fv));
2730
- }
2731
- case "not in": {
2732
- const val = Array.isArray(value) ? value : [value];
2733
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2734
- return !fieldVal.some((fv) => val.includes(fv));
2596
+ });
2597
+ var {
2598
+ setViewDataStore,
2599
+ setIsShowingModalDetail,
2600
+ setIsShowModalTranslate,
2601
+ setFormSubmitComponent,
2602
+ setFieldTranslate,
2603
+ setListSubject,
2604
+ setDataUser
2605
+ } = formSlice.actions;
2606
+ var form_slice_default = formSlice.reducer;
2607
+
2608
+ // src/store/reducers/header-slice/index.ts
2609
+ var import_toolkit5 = require("@reduxjs/toolkit");
2610
+ var headerSlice = (0, import_toolkit5.createSlice)({
2611
+ name: "header",
2612
+ initialState: {
2613
+ value: { allowedCompanyIds: [] }
2614
+ },
2615
+ reducers: {
2616
+ setHeader: (state, action) => {
2617
+ state.value = { ...state.value, ...action.payload };
2618
+ },
2619
+ setAllowedCompanyIds: (state, action) => {
2620
+ state.value.allowedCompanyIds = action.payload;
2735
2621
  }
2736
- case "like":
2737
- if (fieldValue === false) {
2738
- return false;
2739
- }
2740
- return Boolean(fieldValue.match(likeRegexp));
2741
- case "not like":
2742
- if (fieldValue === false) {
2743
- return false;
2744
- }
2745
- return Boolean(!fieldValue.match(likeRegexp));
2746
- case "=like":
2747
- if (fieldValue === false) {
2748
- return false;
2749
- }
2750
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2751
- fieldValue
2752
- );
2753
- case "ilike":
2754
- if (fieldValue === false) {
2755
- return false;
2756
- }
2757
- return Boolean(fieldValue.match(ilikeRegexp));
2758
- case "not ilike":
2759
- if (fieldValue === false) {
2760
- return false;
2761
- }
2762
- return Boolean(!fieldValue.match(ilikeRegexp));
2763
- case "=ilike":
2764
- if (fieldValue === false) {
2765
- return false;
2766
- }
2767
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2768
- fieldValue
2769
- );
2770
2622
  }
2771
- throw new InvalidDomainError("could not match domain");
2772
- }
2773
- function makeOperators(record) {
2774
- const match = matchCondition.bind(null, record);
2775
- return {
2776
- "!": (x) => !match(x),
2777
- "&": (a, b) => match(a) && match(b),
2778
- "|": (a, b) => match(a) || match(b)
2779
- };
2780
- }
2781
- function matchDomain(record, domain) {
2782
- if (domain.length === 0) {
2783
- return true;
2623
+ });
2624
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
2625
+ var header_slice_default = headerSlice.reducer;
2626
+
2627
+ // src/store/reducers/list-slice/index.ts
2628
+ var import_toolkit6 = require("@reduxjs/toolkit");
2629
+ var initialState5 = {
2630
+ pageLimit: 10,
2631
+ fields: {},
2632
+ order: "",
2633
+ selectedRowKeys: [],
2634
+ selectedRadioKey: 0,
2635
+ indexRowTableModal: -2,
2636
+ isUpdateTableModal: false,
2637
+ footerGroupTable: {},
2638
+ transferDetail: null,
2639
+ page: 0,
2640
+ domainTable: []
2641
+ };
2642
+ var listSlice = (0, import_toolkit6.createSlice)({
2643
+ name: "list",
2644
+ initialState: initialState5,
2645
+ reducers: {
2646
+ setPageLimit: (state, action) => {
2647
+ state.pageLimit = action.payload;
2648
+ },
2649
+ setFields: (state, action) => {
2650
+ state.fields = action.payload;
2651
+ },
2652
+ setOrder: (state, action) => {
2653
+ state.order = action.payload;
2654
+ },
2655
+ setSelectedRowKeys: (state, action) => {
2656
+ state.selectedRowKeys = action.payload;
2657
+ },
2658
+ setSelectedRadioKey: (state, action) => {
2659
+ state.selectedRadioKey = action.payload;
2660
+ },
2661
+ setIndexRowTableModal: (state, action) => {
2662
+ state.indexRowTableModal = action.payload;
2663
+ },
2664
+ setTransferDetail: (state, action) => {
2665
+ state.transferDetail = action.payload;
2666
+ },
2667
+ setIsUpdateTableModal: (state, action) => {
2668
+ state.isUpdateTableModal = action.payload;
2669
+ },
2670
+ setPage: (state, action) => {
2671
+ state.page = action.payload;
2672
+ },
2673
+ setDomainTable: (state, action) => {
2674
+ state.domainTable = action.payload;
2675
+ }
2784
2676
  }
2785
- const operators = makeOperators(record);
2786
- const reversedDomain = Array.from(domain).reverse();
2787
- const condStack = [];
2788
- for (const item of reversedDomain) {
2789
- const operator = typeof item === "string" && operators[item];
2790
- if (operator) {
2791
- const operands = condStack.splice(-operator.length);
2792
- condStack.push(operator(...operands));
2793
- } else {
2794
- condStack.push(item);
2677
+ });
2678
+ var {
2679
+ setPageLimit,
2680
+ setFields,
2681
+ setOrder,
2682
+ setSelectedRowKeys,
2683
+ setIndexRowTableModal,
2684
+ setIsUpdateTableModal,
2685
+ setPage,
2686
+ setSelectedRadioKey,
2687
+ setTransferDetail,
2688
+ setDomainTable
2689
+ } = listSlice.actions;
2690
+ var list_slice_default = listSlice.reducer;
2691
+
2692
+ // src/store/reducers/login-slice/index.ts
2693
+ var import_toolkit7 = require("@reduxjs/toolkit");
2694
+ var initialState6 = {
2695
+ db: "",
2696
+ redirectTo: "/",
2697
+ forgotPasswordUrl: "/"
2698
+ };
2699
+ var loginSlice = (0, import_toolkit7.createSlice)({
2700
+ name: "login",
2701
+ initialState: initialState6,
2702
+ reducers: {
2703
+ setDb: (state, action) => {
2704
+ state.db = action.payload;
2705
+ },
2706
+ setRedirectTo: (state, action) => {
2707
+ state.redirectTo = action.payload;
2708
+ },
2709
+ setForgotPasswordUrl: (state, action) => {
2710
+ state.forgotPasswordUrl = action.payload;
2795
2711
  }
2796
2712
  }
2797
- return matchCondition(record, condStack.pop());
2798
- }
2713
+ });
2714
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
2715
+ var login_slice_default = loginSlice.reducer;
2799
2716
 
2800
- // src/utils/function.ts
2801
- var import_react = require("react");
2802
- var toQueryString = (params) => {
2803
- return Object.keys(params).map(
2804
- (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2805
- ).join("&");
2717
+ // src/store/reducers/navbar-slice/index.ts
2718
+ var import_toolkit8 = require("@reduxjs/toolkit");
2719
+ var initialState7 = {
2720
+ menuFocus: {},
2721
+ menuAction: {},
2722
+ navbarWidth: 250,
2723
+ menuList: []
2806
2724
  };
2807
- var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2808
- if (!originalRequest.data) return originalRequest.data;
2809
- if (typeof originalRequest.data === "string") {
2810
- try {
2811
- const parsedData = JSON.parse(originalRequest.data);
2812
- if (parsedData.with_context && typeof parsedData.with_context === "object") {
2813
- parsedData.with_context.token = newAccessToken;
2814
- }
2815
- return JSON.stringify(parsedData);
2816
- } catch (e) {
2817
- console.warn("Failed to parse originalRequest.data", e);
2818
- return originalRequest.data;
2725
+ var navbarSlice = (0, import_toolkit8.createSlice)({
2726
+ name: "navbar",
2727
+ initialState: initialState7,
2728
+ reducers: {
2729
+ setMenuFocus: (state, action) => {
2730
+ state.menuFocus = action.payload;
2731
+ },
2732
+ setMenuFocusAction: (state, action) => {
2733
+ state.menuAction = action.payload;
2734
+ },
2735
+ setNavbarWidth: (state, action) => {
2736
+ state.navbarWidth = action.payload;
2737
+ },
2738
+ setMenuList: (state, action) => {
2739
+ state.menuList = action.payload;
2819
2740
  }
2820
2741
  }
2821
- if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2822
- originalRequest.data.with_context.token = newAccessToken;
2823
- }
2824
- return originalRequest.data;
2825
- };
2742
+ });
2743
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
2744
+ var navbar_slice_default = navbarSlice.reducer;
2826
2745
 
2827
- // src/utils/storage/local-storage.ts
2828
- var localStorageUtils = () => {
2829
- const setToken = async (access_token) => {
2830
- localStorage.setItem("accessToken", access_token);
2831
- };
2832
- const setRefreshToken = async (refresh_token) => {
2833
- localStorage.setItem("refreshToken", refresh_token);
2834
- };
2835
- const getAccessToken = async () => {
2836
- return localStorage.getItem("accessToken");
2837
- };
2838
- const getRefreshToken = async () => {
2839
- return localStorage.getItem("refreshToken");
2840
- };
2841
- const clearToken = async () => {
2842
- localStorage.removeItem("accessToken");
2843
- localStorage.removeItem("refreshToken");
2844
- };
2845
- return {
2846
- setToken,
2847
- setRefreshToken,
2848
- getAccessToken,
2849
- getRefreshToken,
2850
- clearToken
2851
- };
2746
+ // src/store/reducers/profile-slice/index.ts
2747
+ var import_toolkit9 = require("@reduxjs/toolkit");
2748
+ var initialState8 = {
2749
+ profile: {}
2852
2750
  };
2751
+ var profileSlice = (0, import_toolkit9.createSlice)({
2752
+ name: "profile",
2753
+ initialState: initialState8,
2754
+ reducers: {
2755
+ setProfile: (state, action) => {
2756
+ state.profile = action.payload;
2757
+ }
2758
+ }
2759
+ });
2760
+ var { setProfile } = profileSlice.actions;
2761
+ var profile_slice_default = profileSlice.reducer;
2853
2762
 
2854
- // src/utils/storage/session-storage.ts
2855
- var sessionStorageUtils = () => {
2856
- const getBrowserSession = async () => {
2857
- return sessionStorage.getItem("browserSession");
2858
- };
2859
- return {
2860
- getBrowserSession
2861
- };
2763
+ // src/store/reducers/search-slice/index.ts
2764
+ var import_toolkit10 = require("@reduxjs/toolkit");
2765
+ var initialState9 = {
2766
+ groupByDomain: null,
2767
+ searchBy: [],
2768
+ searchString: "",
2769
+ hoveredIndexSearchList: null,
2770
+ selectedTags: [],
2771
+ firstDomain: null,
2772
+ searchMap: {},
2773
+ filterBy: [],
2774
+ groupBy: []
2862
2775
  };
2863
-
2864
- // src/configs/axios-client.ts
2865
- var axiosClient = {
2866
- init(config) {
2867
- const localStorage2 = config.localStorageUtils ?? localStorageUtils();
2868
- const sessionStorage2 = config.sessionStorageUtils ?? sessionStorageUtils();
2869
- const db = config.db;
2870
- let isRefreshing = false;
2871
- let failedQueue = [];
2872
- const processQueue = (error, token = null) => {
2873
- failedQueue?.forEach((prom) => {
2874
- if (error) {
2875
- prom.reject(error);
2876
- } else {
2877
- prom.resolve(token);
2878
- }
2879
- });
2880
- failedQueue = [];
2881
- };
2882
- const instance = import_axios.default.create({
2883
- adapter: import_axios.default.defaults.adapter,
2884
- baseURL: config.baseUrl,
2885
- timeout: 5e4,
2886
- paramsSerializer: (params) => new URLSearchParams(params).toString()
2887
- });
2888
- instance.interceptors.request.use(async (config2) => {
2889
- const { useRefreshToken, useActionToken, actionToken } = config2;
2890
- if (useActionToken && actionToken) {
2891
- config2.headers["Action-Token"] = actionToken;
2892
- }
2893
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2894
- const token = await getToken?.();
2895
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2896
- return config2;
2897
- }, Promise.reject);
2898
- instance.interceptors.response.use(
2899
- (response) => {
2900
- return handleResponse(response);
2901
- },
2902
- async (error) => {
2903
- const handleError3 = async (error2) => {
2904
- if (!error2.response) {
2905
- return error2;
2906
- }
2907
- const { data } = error2.response;
2908
- if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2909
- await clearAuthToken();
2910
- }
2911
- return data;
2912
- };
2913
- const originalRequest = error.config;
2914
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2915
- error.response.data.code
2916
- )) {
2917
- if (isRefreshing) {
2918
- return new Promise(function(resolve, reject) {
2919
- failedQueue.push({ resolve, reject });
2920
- }).then((token) => {
2921
- originalRequest.headers["Authorization"] = "Bearer " + token;
2922
- originalRequest.data = updateTokenParamInOriginalRequest(
2923
- originalRequest,
2924
- token
2925
- );
2926
- return instance.request(originalRequest);
2927
- }).catch(async (err) => {
2928
- if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2929
- await clearAuthToken();
2930
- }
2931
- });
2932
- }
2933
- const browserSession = await sessionStorage2.getBrowserSession();
2934
- const refreshToken = await localStorage2.getRefreshToken();
2935
- const accessTokenExp = await localStorage2.getAccessToken();
2936
- isRefreshing = true;
2937
- if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2938
- await clearAuthToken();
2939
- } else {
2940
- const payload = Object.fromEntries(
2941
- Object.entries({
2942
- refresh_token: refreshToken,
2943
- grant_type: "refresh_token",
2944
- client_id: config.config.clientId,
2945
- client_secret: config.config.clientSecret
2946
- }).filter(([_, value]) => !!value)
2947
- );
2948
- return new Promise(function(resolve) {
2949
- import_axios.default.post(
2950
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2951
- payload,
2952
- {
2953
- headers: {
2954
- "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2955
- Authorization: `Bearer ${accessTokenExp}`
2956
- }
2957
- }
2958
- ).then(async (res) => {
2959
- const data = res.data;
2960
- await localStorage2.setToken(data.access_token);
2961
- await localStorage2.setRefreshToken(data.refresh_token);
2962
- import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2963
- originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2964
- originalRequest.data = updateTokenParamInOriginalRequest(
2965
- originalRequest,
2966
- data.access_token
2967
- );
2968
- processQueue(null, data.access_token);
2969
- resolve(instance.request(originalRequest));
2970
- }).catch(async (err) => {
2971
- 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") {
2972
- await clearAuthToken();
2973
- }
2974
- if (err && err.response) {
2975
- const { error_code } = err.response?.data || {};
2976
- if (error_code === "AUTHEN_FAIL") {
2977
- await clearAuthToken();
2978
- }
2979
- }
2980
- processQueue(err, null);
2981
- }).finally(() => {
2982
- isRefreshing = false;
2983
- });
2984
- });
2985
- }
2986
- }
2987
- return Promise.reject(await handleError3(error));
2988
- }
2989
- );
2990
- const handleResponse = (res) => {
2991
- if (res && res.data) {
2992
- return res.data;
2776
+ var searchSlice = (0, import_toolkit10.createSlice)({
2777
+ name: "search",
2778
+ initialState: initialState9,
2779
+ reducers: {
2780
+ setGroupByDomain: (state, action) => {
2781
+ state.groupByDomain = action.payload;
2782
+ },
2783
+ setSearchBy: (state, action) => {
2784
+ state.searchBy = action.payload;
2785
+ },
2786
+ setSearchString: (state, action) => {
2787
+ state.searchString = action.payload;
2788
+ },
2789
+ setHoveredIndexSearchList: (state, action) => {
2790
+ state.hoveredIndexSearchList = action.payload;
2791
+ },
2792
+ setSelectedTags: (state, action) => {
2793
+ state.selectedTags = action.payload;
2794
+ },
2795
+ setFirstDomain: (state, action) => {
2796
+ state.firstDomain = action.payload;
2797
+ },
2798
+ setFilterBy: (state, action) => {
2799
+ state.filterBy = action.payload;
2800
+ },
2801
+ setGroupBy: (state, action) => {
2802
+ state.groupBy = action.payload;
2803
+ },
2804
+ setSearchMap: (state, action) => {
2805
+ state.searchMap = action.payload;
2806
+ },
2807
+ updateSearchMap: (state, action) => {
2808
+ if (!state.searchMap[action.payload.key]) {
2809
+ state.searchMap[action.payload.key] = [];
2993
2810
  }
2994
- return res;
2995
- };
2996
- const handleError2 = (error) => {
2997
- if (error.isAxiosError && error.code === "ECONNABORTED") {
2998
- console.error("Request Timeout Error:", error);
2999
- return "Request Timeout Error";
3000
- } else if (error.isAxiosError && !error.response) {
3001
- console.error("Network Error:", error);
3002
- return "Network Error";
2811
+ state.searchMap[action.payload.key].push(action.payload.value);
2812
+ },
2813
+ removeKeyFromSearchMap: (state, action) => {
2814
+ const { key, item } = action.payload;
2815
+ const values = state.searchMap[key];
2816
+ if (!values) return;
2817
+ if (item) {
2818
+ const filtered = values.filter((value) => value.name !== item.name);
2819
+ if (filtered.length > 0) {
2820
+ state.searchMap[key] = filtered;
2821
+ } else {
2822
+ delete state.searchMap[key];
2823
+ }
3003
2824
  } else {
3004
- console.error("Other Error:", error?.response);
3005
- const errorMessage = error?.response?.data?.message || "An error occurred";
3006
- return { message: errorMessage, status: error?.response?.status };
3007
- }
3008
- };
3009
- const clearAuthToken = async () => {
3010
- await localStorage2.clearToken();
3011
- if (typeof window !== "undefined") {
3012
- window.location.href = `/login`;
2825
+ delete state.searchMap[key];
3013
2826
  }
3014
- };
3015
- function formatUrl(url, db2) {
3016
- return url + (db2 ? "?db=" + db2 : "");
2827
+ },
2828
+ clearSearchMap: (state) => {
2829
+ state.searchMap = {};
3017
2830
  }
3018
- const responseBody = (response) => response;
3019
- const requests = {
3020
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
3021
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
3022
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
3023
- responseType: "arraybuffer",
3024
- headers: {
3025
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
3026
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
3027
- }
3028
- }).then(responseBody),
3029
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
3030
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
3031
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
3032
- };
3033
- return requests;
3034
2831
  }
2832
+ });
2833
+ var {
2834
+ setGroupByDomain,
2835
+ setSelectedTags,
2836
+ setSearchString,
2837
+ setHoveredIndexSearchList,
2838
+ setFirstDomain,
2839
+ setSearchBy,
2840
+ setFilterBy,
2841
+ setSearchMap,
2842
+ updateSearchMap,
2843
+ removeKeyFromSearchMap,
2844
+ setGroupBy,
2845
+ clearSearchMap
2846
+ } = searchSlice.actions;
2847
+ var search_slice_default = searchSlice.reducer;
2848
+
2849
+ // src/store/store.ts
2850
+ var import_toolkit11 = require("@reduxjs/toolkit");
2851
+
2852
+ // node_modules/redux/dist/redux.mjs
2853
+ function formatProdErrorMessage(code) {
2854
+ 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. `;
2855
+ }
2856
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
2857
+ var ActionTypes = {
2858
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
2859
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
2860
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
3035
2861
  };
2862
+ var actionTypes_default = ActionTypes;
2863
+ function isPlainObject(obj) {
2864
+ if (typeof obj !== "object" || obj === null)
2865
+ return false;
2866
+ let proto = obj;
2867
+ while (Object.getPrototypeOf(proto) !== null) {
2868
+ proto = Object.getPrototypeOf(proto);
2869
+ }
2870
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
2871
+ }
2872
+ function miniKindOf(val) {
2873
+ if (val === void 0)
2874
+ return "undefined";
2875
+ if (val === null)
2876
+ return "null";
2877
+ const type = typeof val;
2878
+ switch (type) {
2879
+ case "boolean":
2880
+ case "string":
2881
+ case "number":
2882
+ case "symbol":
2883
+ case "function": {
2884
+ return type;
2885
+ }
2886
+ }
2887
+ if (Array.isArray(val))
2888
+ return "array";
2889
+ if (isDate(val))
2890
+ return "date";
2891
+ if (isError(val))
2892
+ return "error";
2893
+ const constructorName = ctorName(val);
2894
+ switch (constructorName) {
2895
+ case "Symbol":
2896
+ case "Promise":
2897
+ case "WeakMap":
2898
+ case "WeakSet":
2899
+ case "Map":
2900
+ case "Set":
2901
+ return constructorName;
2902
+ }
2903
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
2904
+ }
2905
+ function ctorName(val) {
2906
+ return typeof val.constructor === "function" ? val.constructor.name : null;
2907
+ }
2908
+ function isError(val) {
2909
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
2910
+ }
2911
+ function isDate(val) {
2912
+ if (val instanceof Date)
2913
+ return true;
2914
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
2915
+ }
2916
+ function kindOf(val) {
2917
+ let typeOfVal = typeof val;
2918
+ if (process.env.NODE_ENV !== "production") {
2919
+ typeOfVal = miniKindOf(val);
2920
+ }
2921
+ return typeOfVal;
2922
+ }
2923
+ function warning(message) {
2924
+ if (typeof console !== "undefined" && typeof console.error === "function") {
2925
+ console.error(message);
2926
+ }
2927
+ try {
2928
+ throw new Error(message);
2929
+ } catch (e) {
2930
+ }
2931
+ }
2932
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2933
+ const reducerKeys = Object.keys(reducers);
2934
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
2935
+ if (reducerKeys.length === 0) {
2936
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
2937
+ }
2938
+ if (!isPlainObject(inputState)) {
2939
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
2940
+ }
2941
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
2942
+ unexpectedKeys.forEach((key) => {
2943
+ unexpectedKeyCache[key] = true;
2944
+ });
2945
+ if (action && action.type === actionTypes_default.REPLACE)
2946
+ return;
2947
+ if (unexpectedKeys.length > 0) {
2948
+ 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.`;
2949
+ }
2950
+ }
2951
+ function assertReducerShape(reducers) {
2952
+ Object.keys(reducers).forEach((key) => {
2953
+ const reducer = reducers[key];
2954
+ const initialState10 = reducer(void 0, {
2955
+ type: actionTypes_default.INIT
2956
+ });
2957
+ if (typeof initialState10 === "undefined") {
2958
+ 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.`);
2959
+ }
2960
+ if (typeof reducer(void 0, {
2961
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
2962
+ }) === "undefined") {
2963
+ 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.`);
2964
+ }
2965
+ });
2966
+ }
2967
+ function combineReducers(reducers) {
2968
+ const reducerKeys = Object.keys(reducers);
2969
+ const finalReducers = {};
2970
+ for (let i = 0; i < reducerKeys.length; i++) {
2971
+ const key = reducerKeys[i];
2972
+ if (process.env.NODE_ENV !== "production") {
2973
+ if (typeof reducers[key] === "undefined") {
2974
+ warning(`No reducer provided for key "${key}"`);
2975
+ }
2976
+ }
2977
+ if (typeof reducers[key] === "function") {
2978
+ finalReducers[key] = reducers[key];
2979
+ }
2980
+ }
2981
+ const finalReducerKeys = Object.keys(finalReducers);
2982
+ let unexpectedKeyCache;
2983
+ if (process.env.NODE_ENV !== "production") {
2984
+ unexpectedKeyCache = {};
2985
+ }
2986
+ let shapeAssertionError;
2987
+ try {
2988
+ assertReducerShape(finalReducers);
2989
+ } catch (e) {
2990
+ shapeAssertionError = e;
2991
+ }
2992
+ return function combination(state = {}, action) {
2993
+ if (shapeAssertionError) {
2994
+ throw shapeAssertionError;
2995
+ }
2996
+ if (process.env.NODE_ENV !== "production") {
2997
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2998
+ if (warningMessage) {
2999
+ warning(warningMessage);
3000
+ }
3001
+ }
3002
+ let hasChanged = false;
3003
+ const nextState = {};
3004
+ for (let i = 0; i < finalReducerKeys.length; i++) {
3005
+ const key = finalReducerKeys[i];
3006
+ const reducer = finalReducers[key];
3007
+ const previousStateForKey = state[key];
3008
+ const nextStateForKey = reducer(previousStateForKey, action);
3009
+ if (typeof nextStateForKey === "undefined") {
3010
+ const actionType = action && action.type;
3011
+ 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.`);
3012
+ }
3013
+ nextState[key] = nextStateForKey;
3014
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
3015
+ }
3016
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
3017
+ return hasChanged ? nextState : state;
3018
+ };
3019
+ }
3036
3020
 
3037
- // src/store/index.ts
3038
- var import_react_redux = require("react-redux");
3021
+ // src/store/store.ts
3022
+ var rootReducer = combineReducers({
3023
+ env: env_slice_default,
3024
+ header: header_slice_default,
3025
+ navbar: navbar_slice_default,
3026
+ list: list_slice_default,
3027
+ search: search_slice_default,
3028
+ form: form_slice_default,
3029
+ breadcrumbs: breadcrums_slice_default,
3030
+ login: login_slice_default,
3031
+ excel: excel_slice_default,
3032
+ profile: profile_slice_default
3033
+ });
3034
+ var envStore = (0, import_toolkit11.configureStore)({
3035
+ reducer: rootReducer,
3036
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
3037
+ serializableCheck: false
3038
+ })
3039
+ });
3039
3040
 
3040
3041
  // src/environment/EnvStore.ts
3041
- var EnvStore = class {
3042
+ var EnvStore = class _EnvStore {
3043
+ static instance = null;
3044
+ envStore;
3042
3045
  baseUrl;
3043
3046
  requests;
3044
3047
  context;
@@ -3050,76 +3053,83 @@ var EnvStore = class {
3050
3053
  localStorageUtils;
3051
3054
  sessionStorageUtils;
3052
3055
  refreshTokenEndpoint;
3053
- constructor(localStorageUtils2, sessionStorageUtils2) {
3056
+ constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3057
+ this.envStore = envStore2;
3054
3058
  this.localStorageUtils = localStorageUtils2;
3055
3059
  this.sessionStorageUtils = sessionStorageUtils2;
3056
3060
  this.setup();
3057
3061
  }
3062
+ static getInstance(envStore2, localStorageUtils2, sessionStorageUtils2) {
3063
+ if (!_EnvStore.instance) {
3064
+ _EnvStore.instance = new _EnvStore(
3065
+ envStore2,
3066
+ localStorageUtils2,
3067
+ sessionStorageUtils2
3068
+ );
3069
+ }
3070
+ return _EnvStore.instance;
3071
+ }
3058
3072
  setup() {
3059
- const env2 = envStore.getState().env;
3060
- this.baseUrl = env2?.baseUrl;
3061
- this.context = env2?.context;
3062
- this.defaultCompany = env2?.defaultCompany;
3063
- this.config = env2?.config;
3064
- this.companies = env2?.companies || [];
3065
- this.user = env2?.user;
3066
- this.db = env2?.db;
3067
- this.requests = env2?.requests;
3068
- this.refreshTokenEndpoint = env2?.refreshTokenEndpoint;
3073
+ const env = this.envStore.getState().env;
3074
+ this.baseUrl = env?.baseUrl;
3075
+ this.requests = env?.requests;
3076
+ this.context = env?.context;
3077
+ this.defaultCompany = env?.defaultCompany;
3078
+ this.config = env?.config;
3079
+ this.companies = env?.companies || [];
3080
+ this.user = env?.user;
3081
+ this.db = env?.db;
3082
+ this.refreshTokenEndpoint = env?.refreshTokenEndpoint;
3083
+ console.log("Env setup:", this);
3069
3084
  }
3070
3085
  setupEnv(envConfig) {
3071
- let env2 = {
3086
+ const dispatch = this.envStore.dispatch;
3087
+ const env = {
3072
3088
  ...envConfig,
3073
3089
  localStorageUtils: this.localStorageUtils,
3074
3090
  sessionStorageUtils: this.sessionStorageUtils
3075
3091
  };
3076
- const requests = axiosClient.init(env2);
3077
- this.requests = requests;
3078
- const dispatch = envStore.dispatch;
3079
- dispatch(
3080
- setEnv({
3081
- ...env2,
3082
- requests
3083
- })
3084
- );
3092
+ const requests = axiosClient.init(env);
3093
+ dispatch(setEnv({ ...env, requests }));
3085
3094
  this.setup();
3086
- return { ...env2, requests };
3087
3095
  }
3088
3096
  setUid(uid) {
3089
- const dispatch = envStore.dispatch;
3097
+ const dispatch = this.envStore.dispatch;
3090
3098
  dispatch(setUid(uid));
3091
3099
  this.setup();
3092
3100
  }
3093
3101
  setLang(lang) {
3094
- const dispatch = envStore.dispatch;
3102
+ const dispatch = this.envStore.dispatch;
3095
3103
  dispatch(setLang(lang));
3096
3104
  this.setup();
3097
3105
  }
3098
3106
  setAllowCompanies(allowCompanies) {
3099
- const dispatch = envStore.dispatch;
3107
+ const dispatch = this.envStore.dispatch;
3100
3108
  dispatch(setAllowCompanies(allowCompanies));
3101
3109
  this.setup();
3102
3110
  }
3103
3111
  setCompanies(companies) {
3104
- const dispatch = envStore.dispatch;
3112
+ const dispatch = this.envStore.dispatch;
3105
3113
  dispatch(setCompanies(companies));
3106
3114
  this.setup();
3107
3115
  }
3108
3116
  setDefaultCompany(company) {
3109
- const dispatch = envStore.dispatch;
3117
+ const dispatch = this.envStore.dispatch;
3110
3118
  dispatch(setDefaultCompany(company));
3111
3119
  this.setup();
3112
3120
  }
3113
3121
  setUserInfo(userInfo) {
3114
- const dispatch = envStore.dispatch;
3122
+ const dispatch = this.envStore.dispatch;
3115
3123
  dispatch(setUser(userInfo));
3116
3124
  this.setup();
3117
3125
  }
3118
3126
  };
3119
- var env = null;
3120
3127
  function getEnv() {
3121
- if (!env) env = new EnvStore(localStorageUtils(), sessionStorageUtils());
3122
- return env;
3128
+ const instance = EnvStore.getInstance(envStore);
3129
+ if (!instance) {
3130
+ throw new Error("EnvStore has not been initialized \u2014 call initEnv() first");
3131
+ }
3132
+ return instance;
3123
3133
  }
3124
3134
 
3125
3135
  // src/services/action-service/index.ts
@@ -3129,14 +3139,14 @@ var ActionService = {
3129
3139
  idAction,
3130
3140
  context
3131
3141
  }) {
3132
- const env2 = getEnv();
3142
+ const env = getEnv();
3133
3143
  const jsonData = {
3134
3144
  action_id: idAction,
3135
3145
  with_context: {
3136
3146
  ...context
3137
3147
  }
3138
3148
  };
3139
- return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
3149
+ return env.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
3140
3150
  headers: {
3141
3151
  "Content-Type": "application/json"
3142
3152
  }
@@ -3150,14 +3160,14 @@ var ActionService = {
3150
3160
  method
3151
3161
  }) {
3152
3162
  try {
3153
- const env2 = getEnv();
3163
+ const env = getEnv();
3154
3164
  const jsonData = {
3155
3165
  model,
3156
3166
  method,
3157
3167
  ids,
3158
3168
  with_context: context
3159
3169
  };
3160
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3170
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3161
3171
  headers: {
3162
3172
  "Content-Type": "application/json"
3163
3173
  }
@@ -3173,14 +3183,14 @@ var ActionService = {
3173
3183
  ids,
3174
3184
  context
3175
3185
  }) {
3176
- const env2 = getEnv();
3186
+ const env = getEnv();
3177
3187
  const jsonData = {
3178
3188
  model,
3179
3189
  method: "unlink",
3180
3190
  ids,
3181
3191
  with_context: context
3182
3192
  };
3183
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3193
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3184
3194
  headers: {
3185
3195
  "Content-Type": "application/json"
3186
3196
  }
@@ -3192,14 +3202,14 @@ var ActionService = {
3192
3202
  id,
3193
3203
  context
3194
3204
  }) {
3195
- const env2 = getEnv();
3205
+ const env = getEnv();
3196
3206
  const jsonData = {
3197
3207
  model,
3198
3208
  method: "copy",
3199
3209
  ids: id,
3200
3210
  with_context: context
3201
3211
  };
3202
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3212
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3203
3213
  headers: {
3204
3214
  "Content-Type": "application/json"
3205
3215
  }
@@ -3207,7 +3217,7 @@ var ActionService = {
3207
3217
  },
3208
3218
  // Get Print Report
3209
3219
  async getPrintReportName({ id }) {
3210
- const env2 = getEnv();
3220
+ const env = getEnv();
3211
3221
  const jsonData = {
3212
3222
  model: "ir.actions.report",
3213
3223
  method: "web_read",
@@ -3218,7 +3228,7 @@ var ActionService = {
3218
3228
  }
3219
3229
  }
3220
3230
  };
3221
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3231
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3222
3232
  headers: {
3223
3233
  "Content-Type": "application/json"
3224
3234
  }
@@ -3226,7 +3236,7 @@ var ActionService = {
3226
3236
  },
3227
3237
  //Save Print Invoice
3228
3238
  async print({ id, report, db }) {
3229
- const env2 = getEnv();
3239
+ const env = getEnv();
3230
3240
  const jsonData = {
3231
3241
  report,
3232
3242
  id,
@@ -3236,7 +3246,7 @@ var ActionService = {
3236
3246
  };
3237
3247
  const queryString = toQueryString(jsonData);
3238
3248
  const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
3239
- return env2.requests.get(urlWithParams, {
3249
+ return env.requests.get(urlWithParams, {
3240
3250
  headers: {
3241
3251
  "Content-Type": "application/json"
3242
3252
  },
@@ -3248,7 +3258,7 @@ var ActionService = {
3248
3258
  idAction,
3249
3259
  context
3250
3260
  }) {
3251
- const env2 = getEnv();
3261
+ const env = getEnv();
3252
3262
  const jsonData = {
3253
3263
  action_id: idAction,
3254
3264
  with_context: {
@@ -3264,7 +3274,7 @@ var ActionService = {
3264
3274
  // active_model: model,
3265
3275
  // },
3266
3276
  };
3267
- return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
3277
+ return env.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
3268
3278
  headers: {
3269
3279
  "Content-Type": "application/json"
3270
3280
  }
@@ -3276,30 +3286,30 @@ var action_service_default = ActionService;
3276
3286
  // src/services/auth-service/index.ts
3277
3287
  var AuthService = {
3278
3288
  async login(body) {
3279
- const env2 = getEnv();
3289
+ const env = getEnv();
3280
3290
  const payload = Object.fromEntries(
3281
3291
  Object.entries({
3282
3292
  username: body.email,
3283
3293
  password: body.password,
3284
- grant_type: env2?.config?.grantType || "",
3285
- client_id: env2?.config?.clientId || "",
3286
- client_secret: env2?.config?.clientSecret || ""
3294
+ grant_type: env?.config?.grantType || "",
3295
+ client_id: env?.config?.clientId || "",
3296
+ client_secret: env?.config?.clientSecret || ""
3287
3297
  }).filter(([_, value]) => !!value)
3288
3298
  );
3289
3299
  const encodedData = new URLSearchParams(payload).toString();
3290
- return env2?.requests?.post(body.path, encodedData, {
3300
+ return env?.requests?.post(body.path, encodedData, {
3291
3301
  headers: {
3292
3302
  "Content-Type": "application/x-www-form-urlencoded"
3293
3303
  }
3294
3304
  });
3295
3305
  },
3296
3306
  async forgotPassword(email) {
3297
- const env2 = getEnv();
3307
+ const env = getEnv();
3298
3308
  const bodyData = {
3299
3309
  login: email,
3300
3310
  url: `${window.location.origin}/reset-password`
3301
3311
  };
3302
- return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3312
+ return env?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3303
3313
  headers: {
3304
3314
  "Content-Type": "application/json"
3305
3315
  }
@@ -3310,7 +3320,7 @@ var AuthService = {
3310
3320
  with_context,
3311
3321
  method
3312
3322
  }) {
3313
- const env2 = getEnv();
3323
+ const env = getEnv();
3314
3324
  const body = {
3315
3325
  method,
3316
3326
  kwargs: {
@@ -3320,20 +3330,20 @@ var AuthService = {
3320
3330
  },
3321
3331
  with_context
3322
3332
  };
3323
- return env2?.requests?.post("/call" /* CALL_PATH */, body, {
3333
+ return env?.requests?.post("/call" /* CALL_PATH */, body, {
3324
3334
  headers: {
3325
3335
  "Content-Type": "application/json"
3326
3336
  }
3327
3337
  });
3328
3338
  },
3329
3339
  async resetPassword(data, token) {
3330
- const env2 = getEnv();
3340
+ const env = getEnv();
3331
3341
  const bodyData = {
3332
3342
  token,
3333
3343
  password: data.password,
3334
3344
  new_password: data.confirmPassword
3335
3345
  };
3336
- return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3346
+ return env?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3337
3347
  headers: {
3338
3348
  "Content-Type": "application/json"
3339
3349
  }
@@ -3344,7 +3354,7 @@ var AuthService = {
3344
3354
  password,
3345
3355
  with_context
3346
3356
  }) {
3347
- const env2 = getEnv();
3357
+ const env = getEnv();
3348
3358
  const bodyData = {
3349
3359
  method,
3350
3360
  kwargs: {
@@ -3354,57 +3364,43 @@ var AuthService = {
3354
3364
  },
3355
3365
  with_context
3356
3366
  };
3357
- return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3367
+ return env?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3358
3368
  headers: {
3359
3369
  "Content-Type": "application/json"
3360
3370
  }
3361
3371
  });
3362
3372
  },
3363
3373
  async updatePassword(data, token) {
3364
- const env2 = getEnv();
3374
+ const env = getEnv();
3365
3375
  const bodyData = {
3366
3376
  token,
3367
3377
  old_password: data.oldPassword,
3368
3378
  new_password: data.newPassword
3369
3379
  };
3370
- return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3380
+ return env?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3371
3381
  headers: {
3372
3382
  "Content-Type": "application/json"
3373
3383
  }
3374
3384
  });
3375
3385
  },
3376
3386
  async isValidToken(token) {
3377
- const env2 = getEnv();
3387
+ const env = getEnv();
3378
3388
  const bodyData = {
3379
3389
  token
3380
3390
  };
3381
- return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3391
+ return env?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3382
3392
  headers: {
3383
3393
  "Content-Type": "application/json"
3384
3394
  }
3385
3395
  });
3386
3396
  },
3387
- async isValidActionToken(actionToken, path) {
3388
- const env2 = getEnv();
3389
- return env2?.requests?.post(
3390
- path,
3391
- {},
3392
- {
3393
- headers: {
3394
- "Content-Type": "application/json"
3395
- },
3396
- useActionToken: true,
3397
- actionToken
3398
- }
3399
- );
3400
- },
3401
3397
  async loginSocial({
3402
3398
  db,
3403
3399
  state,
3404
3400
  access_token
3405
3401
  }) {
3406
- const env2 = getEnv();
3407
- return env2?.requests?.post(
3402
+ const env = getEnv();
3403
+ return env?.requests?.post(
3408
3404
  "/token/generate" /* GENTOKEN_SOCIAL */,
3409
3405
  { state, access_token },
3410
3406
  {
@@ -3415,18 +3411,18 @@ var AuthService = {
3415
3411
  );
3416
3412
  },
3417
3413
  async getProviders(db) {
3418
- const env2 = getEnv();
3419
- return env2?.requests?.get("/oauth/providers", { params: { db } });
3414
+ const env = getEnv();
3415
+ return env?.requests?.get("/oauth/providers", { params: { db } });
3420
3416
  },
3421
3417
  async getAccessByCode(code) {
3422
- const env2 = getEnv();
3418
+ const env = getEnv();
3423
3419
  const data = new URLSearchParams();
3424
3420
  data.append("code", code);
3425
3421
  data.append("grant_type", "authorization_code");
3426
- data.append("client_id", env2?.config?.clientId || "");
3427
- data.append("redirect_uri", env2?.config?.redirectUri || "");
3428
- return env2?.requests?.post(
3429
- `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3422
+ data.append("client_id", env?.config?.clientId || "");
3423
+ data.append("redirect_uri", env?.config?.redirectUri || "");
3424
+ return env?.requests?.post(
3425
+ `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3430
3426
  data,
3431
3427
  {
3432
3428
  headers: {
@@ -3436,9 +3432,9 @@ var AuthService = {
3436
3432
  );
3437
3433
  },
3438
3434
  async logout(data) {
3439
- const env2 = getEnv();
3435
+ const env = getEnv();
3440
3436
  console.log(data);
3441
- return env2?.requests?.post(
3437
+ return env?.requests?.post(
3442
3438
  "/logout" /* LOGOUT */,
3443
3439
  {},
3444
3440
  {
@@ -3456,15 +3452,15 @@ var auth_service_default = AuthService;
3456
3452
  // src/services/company-service/index.ts
3457
3453
  var CompanyService = {
3458
3454
  async getCurrentCompany() {
3459
- const env2 = getEnv();
3460
- return await env2.requests.get("/company" /* COMPANY_PATH */, {
3455
+ const env = getEnv();
3456
+ return await env.requests.get("/company" /* COMPANY_PATH */, {
3461
3457
  headers: {
3462
3458
  "Content-Type": "application/json"
3463
3459
  }
3464
3460
  });
3465
3461
  },
3466
3462
  async getInfoCompany(id) {
3467
- const env2 = getEnv();
3463
+ const env = getEnv();
3468
3464
  const jsonData = {
3469
3465
  ids: [id],
3470
3466
  model: "res.company" /* COMPANY */,
@@ -3479,7 +3475,7 @@ var CompanyService = {
3479
3475
  }
3480
3476
  }
3481
3477
  };
3482
- return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3478
+ return await env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3483
3479
  headers: {
3484
3480
  "Content-Type": "application/json"
3485
3481
  }
@@ -3491,16 +3487,16 @@ var company_service_default = CompanyService;
3491
3487
  // src/services/excel-service/index.ts
3492
3488
  var ExcelService = {
3493
3489
  async uploadFile({ formData }) {
3494
- const env2 = getEnv();
3495
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3490
+ const env = getEnv();
3491
+ return env.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3496
3492
  headers: {
3497
3493
  "Content-Type": "multipart/form-data"
3498
3494
  }
3499
3495
  });
3500
3496
  },
3501
3497
  async uploadIdFile({ formData }) {
3502
- const env2 = getEnv();
3503
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3498
+ const env = getEnv();
3499
+ return env.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3504
3500
  headers: {
3505
3501
  "Content-Type": "multipart/form-data"
3506
3502
  }
@@ -3512,7 +3508,7 @@ var ExcelService = {
3512
3508
  isHeader,
3513
3509
  context
3514
3510
  }) {
3515
- const env2 = getEnv();
3511
+ const env = getEnv();
3516
3512
  const jsonData = {
3517
3513
  model: "base_import.import" /* BASE_IMPORT */,
3518
3514
  method: "parse_preview",
@@ -3542,7 +3538,7 @@ var ExcelService = {
3542
3538
  },
3543
3539
  with_context: context
3544
3540
  };
3545
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3541
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3546
3542
  headers: {
3547
3543
  "Content-Type": "multipart/form-data"
3548
3544
  }
@@ -3556,7 +3552,7 @@ var ExcelService = {
3556
3552
  dryrun,
3557
3553
  context
3558
3554
  }) {
3559
- const env2 = getEnv();
3555
+ const env = getEnv();
3560
3556
  const jsonData = {
3561
3557
  model: "base_import.import" /* BASE_IMPORT */,
3562
3558
  method: "execute_import",
@@ -3569,20 +3565,20 @@ var ExcelService = {
3569
3565
  },
3570
3566
  with_context: context
3571
3567
  };
3572
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3568
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3573
3569
  headers: {
3574
3570
  "Content-Type": "multipart/form-data"
3575
3571
  }
3576
3572
  });
3577
3573
  },
3578
3574
  async getFileExcel({ model }) {
3579
- const env2 = getEnv();
3575
+ const env = getEnv();
3580
3576
  const jsonData = {
3581
3577
  model,
3582
3578
  method: "get_import_templates" /* GET_IMPORT */,
3583
3579
  args: []
3584
3580
  };
3585
- return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3581
+ return env.requests.post("/call" /* CALL_PATH */, jsonData);
3586
3582
  },
3587
3583
  async getFieldExport({
3588
3584
  ids,
@@ -3596,7 +3592,7 @@ var ExcelService = {
3596
3592
  context,
3597
3593
  importCompat
3598
3594
  }) {
3599
- const env2 = getEnv();
3595
+ const env = getEnv();
3600
3596
  const jsonData = {
3601
3597
  model,
3602
3598
  import_compat: importCompat,
@@ -3611,7 +3607,7 @@ var ExcelService = {
3611
3607
  jsonData.prefix = prefix;
3612
3608
  jsonData.exclude = [null];
3613
3609
  }
3614
- return env2.requests.post("/export/get_fields", jsonData);
3610
+ return env.requests.post("/export/get_fields", jsonData);
3615
3611
  },
3616
3612
  async exportExcel({
3617
3613
  model,
@@ -3623,7 +3619,7 @@ var ExcelService = {
3623
3619
  context,
3624
3620
  groupby
3625
3621
  }) {
3626
- const env2 = getEnv();
3622
+ const env = getEnv();
3627
3623
  const jsonData = {
3628
3624
  model,
3629
3625
  domain,
@@ -3633,7 +3629,7 @@ var ExcelService = {
3633
3629
  with_context: context,
3634
3630
  groupby: groupby ?? []
3635
3631
  };
3636
- return env2.requests.post_excel(`/export/${type}`, jsonData);
3632
+ return env.requests.post_excel(`/export/${type}`, jsonData);
3637
3633
  }
3638
3634
  };
3639
3635
  var excel_service_default = ExcelService;
@@ -3642,7 +3638,7 @@ var excel_service_default = ExcelService;
3642
3638
  var FormService = {
3643
3639
  async getComment({ data }) {
3644
3640
  try {
3645
- const env2 = getEnv();
3641
+ const env = getEnv();
3646
3642
  const jsonData = {
3647
3643
  thread_id: data.thread_id,
3648
3644
  thread_model: data.thread_model,
@@ -3651,7 +3647,7 @@ var FormService = {
3651
3647
  lang: data.lang
3652
3648
  }
3653
3649
  };
3654
- return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3650
+ return env.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3655
3651
  headers: {
3656
3652
  "Content-Type": "application/json"
3657
3653
  }
@@ -3663,7 +3659,7 @@ var FormService = {
3663
3659
  },
3664
3660
  async sentComment({ data }) {
3665
3661
  try {
3666
- const env2 = getEnv();
3662
+ const env = getEnv();
3667
3663
  const jsonData = {
3668
3664
  context: {
3669
3665
  tz: "Asia/Saigon",
@@ -3682,7 +3678,7 @@ var FormService = {
3682
3678
  thread_id: Number(data.thread_id),
3683
3679
  thread_model: data.thread_model
3684
3680
  };
3685
- return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3681
+ return env.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3686
3682
  headers: {
3687
3683
  "Content-Type": "application/json"
3688
3684
  }
@@ -3694,14 +3690,14 @@ var FormService = {
3694
3690
  },
3695
3691
  async deleteComment({ data }) {
3696
3692
  try {
3697
- const env2 = getEnv();
3693
+ const env = getEnv();
3698
3694
  const jsonData = {
3699
3695
  attachment_ids: [],
3700
3696
  attachment_tokens: [],
3701
3697
  body: "",
3702
3698
  message_id: data.message_id
3703
3699
  };
3704
- return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3700
+ return env.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3705
3701
  headers: {
3706
3702
  "Content-Type": "application/json"
3707
3703
  }
@@ -3713,8 +3709,8 @@ var FormService = {
3713
3709
  },
3714
3710
  async getImage({ data }) {
3715
3711
  try {
3716
- const env2 = getEnv();
3717
- return env2.requests.get(
3712
+ const env = getEnv();
3713
+ return env.requests.get(
3718
3714
  `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3719
3715
  {
3720
3716
  headers: {
@@ -3729,8 +3725,8 @@ var FormService = {
3729
3725
  },
3730
3726
  async uploadImage({ data }) {
3731
3727
  try {
3732
- const env2 = getEnv();
3733
- return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3728
+ const env = getEnv();
3729
+ return env.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3734
3730
  headers: {
3735
3731
  "Content-Type": "multipart/form-data"
3736
3732
  }
@@ -3742,14 +3738,14 @@ var FormService = {
3742
3738
  },
3743
3739
  async getFormView({ data }) {
3744
3740
  try {
3745
- const env2 = getEnv();
3741
+ const env = getEnv();
3746
3742
  const jsonData = {
3747
3743
  model: data.model,
3748
3744
  method: "get_formview_action",
3749
3745
  ids: data.id ? [data.id] : [],
3750
3746
  with_context: data.context
3751
3747
  };
3752
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3748
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3753
3749
  headers: {
3754
3750
  "Content-Type": "application/json"
3755
3751
  }
@@ -3760,7 +3756,7 @@ var FormService = {
3760
3756
  }
3761
3757
  },
3762
3758
  async changeStatus({ data }) {
3763
- const env2 = getEnv();
3759
+ const env = getEnv();
3764
3760
  const vals = {
3765
3761
  [data.name]: data.stage_id
3766
3762
  };
@@ -3780,7 +3776,7 @@ var FormService = {
3780
3776
  specification: {}
3781
3777
  }
3782
3778
  };
3783
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3779
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3784
3780
  headers: {
3785
3781
  "Content-Type": "application/json"
3786
3782
  }
@@ -3795,7 +3791,7 @@ var KanbanServices = {
3795
3791
  model,
3796
3792
  width_context
3797
3793
  }) {
3798
- const env2 = getEnv();
3794
+ const env = getEnv();
3799
3795
  const jsonDataView = {
3800
3796
  model,
3801
3797
  method: "web_read_group",
@@ -3806,7 +3802,7 @@ var KanbanServices = {
3806
3802
  },
3807
3803
  width_context
3808
3804
  };
3809
- return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3805
+ return env.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3810
3806
  headers: {
3811
3807
  "Content-Type": "application/json"
3812
3808
  }
@@ -3818,7 +3814,7 @@ var KanbanServices = {
3818
3814
  model,
3819
3815
  width_context
3820
3816
  }) {
3821
- const env2 = getEnv();
3817
+ const env = getEnv();
3822
3818
  const jsonDataView = {
3823
3819
  model,
3824
3820
  method: "read_progress_bar",
@@ -3832,7 +3828,7 @@ var KanbanServices = {
3832
3828
  },
3833
3829
  width_context
3834
3830
  };
3835
- return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3831
+ return env.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3836
3832
  headers: {
3837
3833
  "Content-Type": "application/json"
3838
3834
  }
@@ -3849,7 +3845,7 @@ var ModelService = {
3849
3845
  spectification,
3850
3846
  model
3851
3847
  }) {
3852
- const env2 = getEnv();
3848
+ const env = getEnv();
3853
3849
  const jsonData = {
3854
3850
  model,
3855
3851
  method: "web_search_read",
@@ -3860,14 +3856,14 @@ var ModelService = {
3860
3856
  offset: 0
3861
3857
  }
3862
3858
  };
3863
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3859
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3864
3860
  headers: {
3865
3861
  "Content-Type": "application/json"
3866
3862
  }
3867
3863
  });
3868
3864
  },
3869
3865
  async getCurrency() {
3870
- const env2 = getEnv();
3866
+ const env = getEnv();
3871
3867
  const jsonData = {
3872
3868
  model: "res.currency",
3873
3869
  method: "web_search_read",
@@ -3881,14 +3877,14 @@ var ModelService = {
3881
3877
  offset: 0
3882
3878
  }
3883
3879
  };
3884
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3880
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3885
3881
  headers: {
3886
3882
  "Content-Type": "application/json"
3887
3883
  }
3888
3884
  });
3889
3885
  },
3890
3886
  async getConversionRate() {
3891
- const env2 = getEnv();
3887
+ const env = getEnv();
3892
3888
  const jsonData = {
3893
3889
  model: "res.currency",
3894
3890
  method: "web_search_read",
@@ -3908,14 +3904,14 @@ var ModelService = {
3908
3904
  offset: 0
3909
3905
  }
3910
3906
  };
3911
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3907
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3912
3908
  headers: {
3913
3909
  "Content-Type": "application/json"
3914
3910
  }
3915
3911
  });
3916
3912
  },
3917
3913
  async getAll({ data }) {
3918
- const env2 = getEnv();
3914
+ const env = getEnv();
3919
3915
  const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3920
3916
  fields: data.fields,
3921
3917
  groupby: data.groupby
@@ -3936,14 +3932,14 @@ var ModelService = {
3936
3932
  ...jsonReadGroup
3937
3933
  }
3938
3934
  };
3939
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3935
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3940
3936
  headers: {
3941
3937
  "Content-Type": "application/json"
3942
3938
  }
3943
3939
  });
3944
3940
  },
3945
3941
  async getListCalendar({ data }) {
3946
- const env2 = getEnv();
3942
+ const env = getEnv();
3947
3943
  const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3948
3944
  fields: data.fields,
3949
3945
  groupby: data.groupby
@@ -3965,7 +3961,7 @@ var ModelService = {
3965
3961
  ...jsonReadGroup
3966
3962
  }
3967
3963
  };
3968
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3964
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3969
3965
  headers: {
3970
3966
  "Content-Type": "application/json"
3971
3967
  }
@@ -3981,7 +3977,7 @@ var ModelService = {
3981
3977
  context = {},
3982
3978
  limit = 10
3983
3979
  }) {
3984
- const env2 = getEnv();
3980
+ const env = getEnv();
3985
3981
  const jsonData = {
3986
3982
  model,
3987
3983
  method: "web_search_read" /* WEB_SEARCH_READ */,
@@ -3995,7 +3991,7 @@ var ModelService = {
3995
3991
  order
3996
3992
  }
3997
3993
  };
3998
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3994
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3999
3995
  headers: {
4000
3996
  "Content-Type": "application/json"
4001
3997
  }
@@ -4007,7 +4003,7 @@ var ModelService = {
4007
4003
  specification,
4008
4004
  context
4009
4005
  }) {
4010
- const env2 = getEnv();
4006
+ const env = getEnv();
4011
4007
  const jsonData = {
4012
4008
  model,
4013
4009
  method: "web_read" /* WEB_READ */,
@@ -4017,7 +4013,7 @@ var ModelService = {
4017
4013
  specification
4018
4014
  }
4019
4015
  };
4020
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4016
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4021
4017
  headers: {
4022
4018
  "Content-Type": "application/json"
4023
4019
  }
@@ -4031,7 +4027,7 @@ var ModelService = {
4031
4027
  context = {},
4032
4028
  path
4033
4029
  }) {
4034
- const env2 = getEnv();
4030
+ const env = getEnv();
4035
4031
  const jsonData = {
4036
4032
  model,
4037
4033
  method: "web_save" /* WEB_SAVE */,
@@ -4042,20 +4038,20 @@ var ModelService = {
4042
4038
  specification
4043
4039
  }
4044
4040
  };
4045
- return env2?.requests?.post(path ?? "/call" /* CALL_PATH */, jsonData, {
4041
+ return env?.requests?.post(path ?? "/call" /* CALL_PATH */, jsonData, {
4046
4042
  headers: {
4047
4043
  "Content-Type": "application/json"
4048
4044
  }
4049
4045
  });
4050
4046
  },
4051
4047
  async delete({ ids = [], model }) {
4052
- const env2 = getEnv();
4048
+ const env = getEnv();
4053
4049
  const jsonData = {
4054
4050
  model,
4055
4051
  method: "unlink" /* UNLINK */,
4056
4052
  ids
4057
4053
  };
4058
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4054
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4059
4055
  headers: {
4060
4056
  "Content-Type": "application/json"
4061
4057
  }
@@ -4069,7 +4065,7 @@ var ModelService = {
4069
4065
  context,
4070
4066
  fieldChange
4071
4067
  }) {
4072
- const env2 = getEnv();
4068
+ const env = getEnv();
4073
4069
  const jsonData = {
4074
4070
  model,
4075
4071
  method: "onchange" /* ONCHANGE */,
@@ -4081,19 +4077,19 @@ var ModelService = {
4081
4077
  specification
4082
4078
  ]
4083
4079
  };
4084
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4080
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4085
4081
  headers: {
4086
4082
  "Content-Type": "application/json"
4087
4083
  }
4088
4084
  });
4089
4085
  },
4090
4086
  async getListFieldsOnchange({ model }) {
4091
- const env2 = getEnv();
4087
+ const env = getEnv();
4092
4088
  const jsonData = {
4093
4089
  model,
4094
4090
  method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
4095
4091
  };
4096
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4092
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4097
4093
  headers: {
4098
4094
  "Content-Type": "application/json"
4099
4095
  }
@@ -4161,15 +4157,15 @@ var model_service_default = ModelService;
4161
4157
  // src/services/user-service/index.ts
4162
4158
  var UserService = {
4163
4159
  async getProfile(path) {
4164
- const env2 = getEnv();
4165
- return env2?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4160
+ const env = getEnv();
4161
+ return env.requests.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4166
4162
  headers: {
4167
4163
  "Content-Type": "application/x-www-form-urlencoded"
4168
4164
  }
4169
4165
  });
4170
4166
  },
4171
4167
  async getUser({ context, id }) {
4172
- const env2 = getEnv();
4168
+ const env = getEnv();
4173
4169
  const jsonData = {
4174
4170
  model: "res.users",
4175
4171
  method: "web_read",
@@ -4198,20 +4194,20 @@ var UserService = {
4198
4194
  }
4199
4195
  }
4200
4196
  };
4201
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4197
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
4202
4198
  headers: {
4203
4199
  "Content-Type": "application/json"
4204
4200
  }
4205
4201
  });
4206
4202
  },
4207
4203
  switchUserLocale: async ({ id, values }) => {
4208
- const env2 = getEnv();
4204
+ const env = getEnv();
4209
4205
  const jsonData = {
4210
4206
  model: "res.users",
4211
4207
  domain: [["id", "=", id]],
4212
4208
  values
4213
4209
  };
4214
- return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4210
+ return env?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4215
4211
  headers: {
4216
4212
  "Content-Type": "application/json"
4217
4213
  }
@@ -4229,7 +4225,7 @@ var ViewService = {
4229
4225
  options = {},
4230
4226
  aid
4231
4227
  }) {
4232
- const env2 = getEnv();
4228
+ const env = getEnv();
4233
4229
  const defaultOptions = {
4234
4230
  load_filters: true,
4235
4231
  toolbar: true,
@@ -4244,14 +4240,14 @@ var ViewService = {
4244
4240
  },
4245
4241
  with_context: context
4246
4242
  };
4247
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4243
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4248
4244
  headers: {
4249
4245
  "Content-Type": "application/json"
4250
4246
  }
4251
4247
  });
4252
4248
  },
4253
4249
  async getMenu(context) {
4254
- const env2 = getEnv();
4250
+ const env = getEnv();
4255
4251
  const jsonData = {
4256
4252
  model: "ir.ui.menu" /* MENU */,
4257
4253
  method: "web_search_read" /* WEB_SEARCH_READ */,
@@ -4388,14 +4384,14 @@ var ViewService = {
4388
4384
  ]
4389
4385
  }
4390
4386
  };
4391
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4387
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4392
4388
  headers: {
4393
4389
  "Content-Type": "application/json"
4394
4390
  }
4395
4391
  });
4396
4392
  },
4397
4393
  async getActionDetail(aid, context) {
4398
- const env2 = getEnv();
4394
+ const env = getEnv();
4399
4395
  const jsonData = {
4400
4396
  model: "ir.actions.act_window" /* WINDOW_ACTION */,
4401
4397
  method: "web_read" /* WEB_READ */,
@@ -4416,7 +4412,7 @@ var ViewService = {
4416
4412
  }
4417
4413
  }
4418
4414
  };
4419
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4415
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4420
4416
  headers: {
4421
4417
  "Content-Type": "application/json"
4422
4418
  }
@@ -4428,7 +4424,7 @@ var ViewService = {
4428
4424
  context,
4429
4425
  offset
4430
4426
  }) {
4431
- const env2 = getEnv();
4427
+ const env = getEnv();
4432
4428
  const jsonData = {
4433
4429
  model,
4434
4430
  with_context: context,
@@ -4436,14 +4432,14 @@ var ViewService = {
4436
4432
  field: "sequence",
4437
4433
  ...offset > 0 ? { offset } : {}
4438
4434
  };
4439
- return env2?.requests.post("/web/dataset/resequence", jsonData, {
4435
+ return env?.requests.post("/web/dataset/resequence", jsonData, {
4440
4436
  headers: {
4441
4437
  "Content-Type": "application/json"
4442
4438
  }
4443
4439
  });
4444
4440
  },
4445
4441
  async getSelectionItem({ data }) {
4446
- const env2 = getEnv();
4442
+ const env = getEnv();
4447
4443
  const jsonData = {
4448
4444
  model: data.model,
4449
4445
  ids: [],
@@ -4461,15 +4457,15 @@ var ViewService = {
4461
4457
  }
4462
4458
  }
4463
4459
  };
4464
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4460
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4465
4461
  headers: {
4466
4462
  "Content-Type": "application/json"
4467
4463
  }
4468
4464
  });
4469
4465
  },
4470
4466
  async loadMessages() {
4471
- const env2 = getEnv();
4472
- return env2.requests.post(
4467
+ const env = getEnv();
4468
+ return env.requests.post(
4473
4469
  "/load_message_failures" /* LOAD_MESSAGE */,
4474
4470
  {},
4475
4471
  {
@@ -4480,8 +4476,9 @@ var ViewService = {
4480
4476
  );
4481
4477
  },
4482
4478
  async getVersion() {
4483
- const env2 = getEnv();
4484
- return env2?.requests.get("", {
4479
+ const env = getEnv();
4480
+ console.log("env?.requests", env, env?.requests);
4481
+ return env?.requests?.get("", {
4485
4482
  headers: {
4486
4483
  "Content-Type": "application/json"
4487
4484
  }
@@ -4491,12 +4488,12 @@ var ViewService = {
4491
4488
  method,
4492
4489
  with_context
4493
4490
  }) {
4494
- const env2 = getEnv();
4491
+ const env = getEnv();
4495
4492
  const jsonData = {
4496
4493
  method,
4497
4494
  with_context
4498
4495
  };
4499
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4496
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4500
4497
  headers: {
4501
4498
  "Content-Type": "application/json"
4502
4499
  }
@@ -4509,7 +4506,7 @@ var ViewService = {
4509
4506
  device,
4510
4507
  location
4511
4508
  }) {
4512
- const env2 = getEnv();
4509
+ const env = getEnv();
4513
4510
  const jsonData = {
4514
4511
  method,
4515
4512
  kwargs: {
@@ -4521,7 +4518,7 @@ var ViewService = {
4521
4518
  },
4522
4519
  with_context
4523
4520
  };
4524
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4521
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4525
4522
  headers: {
4526
4523
  "Content-Type": "application/json"
4527
4524
  },
@@ -4535,7 +4532,7 @@ var ViewService = {
4535
4532
  response_type,
4536
4533
  path
4537
4534
  }) {
4538
- const env2 = getEnv();
4535
+ const env = getEnv();
4539
4536
  const params = new URLSearchParams({
4540
4537
  response_type,
4541
4538
  client_id,
@@ -4543,7 +4540,7 @@ var ViewService = {
4543
4540
  state
4544
4541
  });
4545
4542
  const url = `${path}?${params.toString()}`;
4546
- return env2?.requests.get(url, {
4543
+ return env?.requests.get(url, {
4547
4544
  headers: {
4548
4545
  "Content-Type": "application/json"
4549
4546
  },
@@ -4556,14 +4553,14 @@ var ViewService = {
4556
4553
  client_id,
4557
4554
  scopes
4558
4555
  }) {
4559
- const env2 = getEnv();
4556
+ const env = getEnv();
4560
4557
  const jsonData = {
4561
4558
  redirect_uri,
4562
4559
  state,
4563
4560
  client_id,
4564
4561
  scopes
4565
4562
  };
4566
- return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4563
+ return env?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4567
4564
  headers: {
4568
4565
  "Content-Type": "application/json"
4569
4566
  },
@@ -4575,7 +4572,7 @@ var ViewService = {
4575
4572
  token,
4576
4573
  views
4577
4574
  }) {
4578
- const env2 = getEnv();
4575
+ const env = getEnv();
4579
4576
  const jsonData = {
4580
4577
  method,
4581
4578
  kwargs: {
@@ -4585,7 +4582,7 @@ var ViewService = {
4585
4582
  token
4586
4583
  }
4587
4584
  };
4588
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4585
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4589
4586
  headers: {
4590
4587
  "Content-Type": "application/json"
4591
4588
  }
@@ -4597,7 +4594,7 @@ var ViewService = {
4597
4594
  kwargs,
4598
4595
  token
4599
4596
  }) {
4600
- const env2 = getEnv();
4597
+ const env = getEnv();
4601
4598
  const jsonData = {
4602
4599
  method,
4603
4600
  model,
@@ -4606,21 +4603,21 @@ var ViewService = {
4606
4603
  token
4607
4604
  }
4608
4605
  };
4609
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4606
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4610
4607
  headers: {
4611
4608
  "Content-Type": "application/json"
4612
4609
  }
4613
4610
  });
4614
4611
  },
4615
4612
  async requestSetupTotp({ method, token }) {
4616
- const env2 = getEnv();
4613
+ const env = getEnv();
4617
4614
  const jsonData = {
4618
4615
  method,
4619
4616
  with_context: {
4620
4617
  token
4621
4618
  }
4622
4619
  };
4623
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4620
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4624
4621
  headers: {
4625
4622
  "Content-Type": "application/json"
4626
4623
  }
@@ -4631,7 +4628,7 @@ var ViewService = {
4631
4628
  action_token,
4632
4629
  code
4633
4630
  }) {
4634
- const env2 = getEnv();
4631
+ const env = getEnv();
4635
4632
  const jsonData = {
4636
4633
  method,
4637
4634
  kwargs: {
@@ -4643,21 +4640,21 @@ var ViewService = {
4643
4640
  action_token
4644
4641
  }
4645
4642
  };
4646
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4643
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4647
4644
  headers: {
4648
4645
  "Content-Type": "application/json"
4649
4646
  }
4650
4647
  });
4651
4648
  },
4652
4649
  async removeTotpSetUp({ method, token }) {
4653
- const env2 = getEnv();
4650
+ const env = getEnv();
4654
4651
  const jsonData = {
4655
4652
  method,
4656
4653
  with_context: {
4657
4654
  token
4658
4655
  }
4659
4656
  };
4660
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4657
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4661
4658
  headers: {
4662
4659
  "Content-Type": "application/json"
4663
4660
  }