@fctc/edu-logic-lib 1.0.8 → 1.0.10

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.
Files changed (47) hide show
  1. package/dist/config.js +257 -6
  2. package/dist/config.mjs +256 -2
  3. package/dist/constants.js +152 -53
  4. package/dist/constants.mjs +141 -2
  5. package/dist/environment.js +839 -16
  6. package/dist/environment.mjs +840 -4
  7. package/dist/hooks.js +4850 -180
  8. package/dist/hooks.mjs +4813 -9
  9. package/dist/index.js +5320 -626
  10. package/dist/index.mjs +5165 -12
  11. package/dist/models.js +1107 -18
  12. package/dist/models.mjs +1107 -9
  13. package/dist/provider.js +1115 -17
  14. package/dist/provider.mjs +1115 -8
  15. package/dist/services.js +1922 -31
  16. package/dist/services.mjs +1922 -7
  17. package/dist/store.js +576 -248
  18. package/dist/store.mjs +519 -1
  19. package/dist/types.js +0 -2
  20. package/dist/types.mjs +1 -1
  21. package/dist/utils.js +2355 -61
  22. package/dist/utils.mjs +2344 -1
  23. package/package.json +2 -1
  24. package/dist/chunk-4K3QAEZ6.js +0 -90
  25. package/dist/chunk-6BLY7NZ6.mjs +0 -120
  26. package/dist/chunk-6QXB3XX7.mjs +0 -256
  27. package/dist/chunk-7JD5GMIZ.js +0 -2
  28. package/dist/chunk-AYUH66EE.mjs +0 -62
  29. package/dist/chunk-CZHZLKNA.mjs +0 -585
  30. package/dist/chunk-EK43MEN4.js +0 -635
  31. package/dist/chunk-ELARQVCE.mjs +0 -2344
  32. package/dist/chunk-FVGPSTJ7.js +0 -122
  33. package/dist/chunk-GGOFXFSX.js +0 -2362
  34. package/dist/chunk-IXDDYGKE.js +0 -61
  35. package/dist/chunk-MLJQPO4Q.mjs +0 -57
  36. package/dist/chunk-OADBRQ4A.js +0 -32
  37. package/dist/chunk-OBR6UTC5.mjs +0 -1
  38. package/dist/chunk-OFUXC2LA.mjs +0 -86
  39. package/dist/chunk-P2IGWJDZ.js +0 -1068
  40. package/dist/chunk-QLUONJPQ.mjs +0 -519
  41. package/dist/chunk-RWRHCIQI.mjs +0 -1059
  42. package/dist/chunk-RZBHZYXG.js +0 -582
  43. package/dist/chunk-S7B3VKMJ.mjs +0 -85
  44. package/dist/chunk-S7YF2I23.js +0 -95
  45. package/dist/chunk-UY6GNZNB.js +0 -262
  46. package/dist/chunk-XYVK476U.mjs +0 -29
  47. package/dist/chunk-YOV6KAT2.js +0 -66
package/dist/services.mjs CHANGED
@@ -1,7 +1,1922 @@
1
- export { action_service_default as ActionService, auth_service_default as AuthService, company_service_default as CompanyService, excel_service_default as ExcelService, form_service_default as FormService, model_service_default as ModelService, user_service_default as UserService, view_service_default as ViewService } from './chunk-RWRHCIQI.mjs';
2
- import './chunk-ELARQVCE.mjs';
3
- import './chunk-S7B3VKMJ.mjs';
4
- import './chunk-OFUXC2LA.mjs';
5
- import './chunk-QLUONJPQ.mjs';
6
- import './chunk-6QXB3XX7.mjs';
7
- import './chunk-MLJQPO4Q.mjs';
1
+ import { createSlice, configureStore } from '@reduxjs/toolkit';
2
+ import axios from 'axios';
3
+
4
+ // src/constants/api/uri-constant.ts
5
+ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
6
+ UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
7
+ UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
8
+ UriConstants2["CALL_PATH"] = "/call";
9
+ UriConstants2["COMPANY_PATH"] = "/company";
10
+ UriConstants2["PROFILE_PATH"] = "/userinfo";
11
+ UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
12
+ UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
13
+ UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
14
+ UriConstants2["LOAD_ACTION"] = `/load_action`;
15
+ UriConstants2["REPORT_PATH"] = `/report`;
16
+ UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
17
+ UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
18
+ UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
19
+ UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
20
+ UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
21
+ UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
22
+ UriConstants2["IMAGE_PATH"] = `/web/image`;
23
+ UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
24
+ UriConstants2["TOKEN"] = `/check_token`;
25
+ UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
26
+ UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
27
+ UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
28
+ return UriConstants2;
29
+ })(UriConstants || {});
30
+ var initialState = {
31
+ baseUrl: "",
32
+ requests: null,
33
+ companies: [],
34
+ user: {},
35
+ envFile: null,
36
+ defaultCompany: {
37
+ id: null,
38
+ logo: "",
39
+ secondary_color: "",
40
+ primary_color: ""
41
+ },
42
+ context: {
43
+ uid: null,
44
+ allowed_company_ids: [],
45
+ lang: "vi_VN",
46
+ tz: "Asia/Saigon"
47
+ }
48
+ };
49
+ var envSlice = createSlice({
50
+ name: "env",
51
+ initialState,
52
+ reducers: {
53
+ setEnv: (state, action) => {
54
+ Object.assign(state, action.payload);
55
+ },
56
+ setUid: (state, action) => {
57
+ state.context.uid = action.payload;
58
+ },
59
+ setAllowCompanies: (state, action) => {
60
+ state.context.allowed_company_ids = action.payload;
61
+ },
62
+ setCompanies: (state, action) => {
63
+ state.companies = action.payload;
64
+ },
65
+ setDefaultCompany: (state, action) => {
66
+ state.defaultCompany = action.payload;
67
+ },
68
+ setLang: (state, action) => {
69
+ state.context.lang = action.payload;
70
+ },
71
+ setUser: (state, action) => {
72
+ state.user = action.payload;
73
+ },
74
+ setEnvFile: (state, action) => {
75
+ state.envFile = action.payload;
76
+ }
77
+ }
78
+ });
79
+ var {
80
+ setEnv,
81
+ setUid,
82
+ setLang,
83
+ setAllowCompanies,
84
+ setCompanies,
85
+ setDefaultCompany,
86
+ setUser,
87
+ setEnvFile
88
+ } = envSlice.actions;
89
+ var env_slice_default = envSlice.reducer;
90
+ var initialState2 = {
91
+ dataParse: null,
92
+ idFile: null,
93
+ isFileLoaded: false,
94
+ loadingImport: false,
95
+ selectedFile: null,
96
+ errorData: null
97
+ };
98
+ var excelSlice = createSlice({
99
+ name: "excel",
100
+ initialState: initialState2,
101
+ reducers: {
102
+ setDataParse: (state, action) => {
103
+ state.dataParse = action.payload;
104
+ },
105
+ setIdFile: (state, action) => {
106
+ state.idFile = action.payload;
107
+ },
108
+ setIsFileLoaded: (state, action) => {
109
+ state.isFileLoaded = action.payload;
110
+ },
111
+ setLoadingImport: (state, action) => {
112
+ state.loadingImport = action.payload;
113
+ },
114
+ setSelectedFile: (state, action) => {
115
+ state.selectedFile = action.payload;
116
+ },
117
+ setErrorData: (state, action) => {
118
+ state.errorData = action.payload;
119
+ }
120
+ }
121
+ });
122
+ var {
123
+ setDataParse,
124
+ setIdFile,
125
+ setIsFileLoaded,
126
+ setLoadingImport,
127
+ setSelectedFile,
128
+ setErrorData
129
+ } = excelSlice.actions;
130
+ var excel_slice_default = excelSlice.reducer;
131
+ var initialState3 = {
132
+ viewDataStore: {},
133
+ isShowingModalDetail: false,
134
+ isShowModalTranslate: false,
135
+ formSubmitComponent: {},
136
+ fieldTranslation: null,
137
+ listSubject: {},
138
+ dataUser: {}
139
+ };
140
+ var formSlice = createSlice({
141
+ name: "form",
142
+ initialState: initialState3,
143
+ reducers: {
144
+ setViewDataStore: (state, action) => {
145
+ state.viewDataStore = action.payload;
146
+ },
147
+ setIsShowingModalDetail: (state, action) => {
148
+ state.isShowingModalDetail = action.payload;
149
+ },
150
+ setIsShowModalTranslate: (state, action) => {
151
+ state.isShowModalTranslate = action.payload;
152
+ },
153
+ setFormSubmitComponent: (state, action) => {
154
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
155
+ },
156
+ setFieldTranslate: (state, action) => {
157
+ state.fieldTranslation = action.payload;
158
+ },
159
+ setListSubject: (state, action) => {
160
+ state.listSubject = action.payload;
161
+ },
162
+ setDataUser: (state, action) => {
163
+ state.dataUser = action.payload;
164
+ }
165
+ }
166
+ });
167
+ var {
168
+ setViewDataStore,
169
+ setIsShowingModalDetail,
170
+ setIsShowModalTranslate,
171
+ setFormSubmitComponent,
172
+ setFieldTranslate,
173
+ setListSubject,
174
+ setDataUser
175
+ } = formSlice.actions;
176
+ var form_slice_default = formSlice.reducer;
177
+ var initialState4 = {
178
+ pageLimit: 10,
179
+ fields: {},
180
+ order: "",
181
+ selectedRowKeys: [],
182
+ indexRowTableModal: -2,
183
+ footerGroupTable: {},
184
+ page: 0,
185
+ domainTable: []
186
+ };
187
+ var listSlice = createSlice({
188
+ name: "list",
189
+ initialState: initialState4,
190
+ reducers: {
191
+ setPageLimit: (state, action) => {
192
+ state.pageLimit = action.payload;
193
+ },
194
+ setFields: (state, action) => {
195
+ state.fields = action.payload;
196
+ },
197
+ setOrder: (state, action) => {
198
+ state.order = action.payload;
199
+ },
200
+ setSelectedRowKeys: (state, action) => {
201
+ state.selectedRowKeys = action.payload;
202
+ },
203
+ setIndexRowTableModal: (state, action) => {
204
+ state.indexRowTableModal = action.payload;
205
+ },
206
+ setPage: (state, action) => {
207
+ state.page = action.payload;
208
+ },
209
+ setDomainTable: (state, action) => {
210
+ state.domainTable = action.payload;
211
+ }
212
+ }
213
+ });
214
+ var {
215
+ setPageLimit,
216
+ setFields,
217
+ setOrder,
218
+ setSelectedRowKeys,
219
+ setIndexRowTableModal,
220
+ setPage,
221
+ setDomainTable
222
+ } = listSlice.actions;
223
+ var list_slice_default = listSlice.reducer;
224
+ var initialState5 = {
225
+ menuList: []
226
+ };
227
+ var navbarSlice = createSlice({
228
+ name: "navbar",
229
+ initialState: initialState5,
230
+ reducers: {
231
+ setMenuList: (state, action) => {
232
+ state.menuList = action.payload;
233
+ }
234
+ }
235
+ });
236
+ var { setMenuList } = navbarSlice.actions;
237
+ var navbar_slice_default = navbarSlice.reducer;
238
+ var initialState6 = {
239
+ profile: {}
240
+ };
241
+ var profileSlice = createSlice({
242
+ name: "profile",
243
+ initialState: initialState6,
244
+ reducers: {
245
+ setProfile: (state, action) => {
246
+ state.profile = action.payload;
247
+ }
248
+ }
249
+ });
250
+ var { setProfile } = profileSlice.actions;
251
+ var profile_slice_default = profileSlice.reducer;
252
+ var initialState7 = {
253
+ groupByDomain: null,
254
+ tableHead: [],
255
+ searchString: "",
256
+ hoveredIndexSearchList: null,
257
+ selectedTags: [],
258
+ firstDomain: null,
259
+ searchMap: {},
260
+ typeFieldsSearch: "",
261
+ modelSearch: "",
262
+ filterBy: [],
263
+ groupBy: []
264
+ };
265
+ var searchSlice = createSlice({
266
+ name: "search",
267
+ initialState: initialState7,
268
+ reducers: {
269
+ setGroupByDomain: (state, action) => {
270
+ state.groupByDomain = action.payload;
271
+ },
272
+ setTableHead: (state, action) => {
273
+ state.tableHead = action.payload;
274
+ },
275
+ setSearchString: (state, action) => {
276
+ state.searchString = action.payload;
277
+ },
278
+ setHoveredIndexSearchList: (state, action) => {
279
+ state.hoveredIndexSearchList = action.payload;
280
+ },
281
+ setSelectedTags: (state, action) => {
282
+ state.selectedTags = action.payload;
283
+ },
284
+ setFirstDomain: (state, action) => {
285
+ state.firstDomain = action.payload;
286
+ },
287
+ setTypeFieldsSearch: (state, action) => {
288
+ state.typeFieldsSearch = action.payload;
289
+ },
290
+ setModelSearch: (state, action) => {
291
+ state.modelSearch = action.payload;
292
+ },
293
+ setFilterBy: (state, action) => {
294
+ state.filterBy = action.payload;
295
+ },
296
+ setGroupBy: (state, action) => {
297
+ state.groupBy = action.payload;
298
+ },
299
+ setSearchMap: (state, action) => {
300
+ state.searchMap = action.payload;
301
+ },
302
+ updateSearchMap: (state, action) => {
303
+ if (!state.searchMap[action.payload.key]) {
304
+ state.searchMap[action.payload.key] = [];
305
+ }
306
+ state.searchMap[action.payload.key].push(action.payload.value);
307
+ },
308
+ removeKeyFromSearchMap: (state, action) => {
309
+ const { key, item } = action.payload;
310
+ const values = state.searchMap[key];
311
+ if (!values) return;
312
+ if (item) {
313
+ const filtered = values.filter((value) => value.name !== item.name);
314
+ if (filtered.length > 0) {
315
+ state.searchMap[key] = filtered;
316
+ } else {
317
+ delete state.searchMap[key];
318
+ }
319
+ } else {
320
+ delete state.searchMap[key];
321
+ }
322
+ },
323
+ clearSearchMap: (state) => {
324
+ state.searchMap = {};
325
+ }
326
+ }
327
+ });
328
+ var {
329
+ setGroupByDomain,
330
+ setSelectedTags,
331
+ setSearchString,
332
+ setHoveredIndexSearchList,
333
+ setFirstDomain,
334
+ setTableHead,
335
+ setFilterBy,
336
+ setTypeFieldsSearch,
337
+ setModelSearch,
338
+ setSearchMap,
339
+ updateSearchMap,
340
+ removeKeyFromSearchMap,
341
+ setGroupBy,
342
+ clearSearchMap
343
+ } = searchSlice.actions;
344
+ var search_slice_default = searchSlice.reducer;
345
+
346
+ // node_modules/redux/dist/redux.mjs
347
+ function formatProdErrorMessage(code) {
348
+ 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. `;
349
+ }
350
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
351
+ var ActionTypes = {
352
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
353
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
354
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
355
+ };
356
+ var actionTypes_default = ActionTypes;
357
+ function isPlainObject(obj) {
358
+ if (typeof obj !== "object" || obj === null)
359
+ return false;
360
+ let proto = obj;
361
+ while (Object.getPrototypeOf(proto) !== null) {
362
+ proto = Object.getPrototypeOf(proto);
363
+ }
364
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
365
+ }
366
+ function miniKindOf(val) {
367
+ if (val === void 0)
368
+ return "undefined";
369
+ if (val === null)
370
+ return "null";
371
+ const type = typeof val;
372
+ switch (type) {
373
+ case "boolean":
374
+ case "string":
375
+ case "number":
376
+ case "symbol":
377
+ case "function": {
378
+ return type;
379
+ }
380
+ }
381
+ if (Array.isArray(val))
382
+ return "array";
383
+ if (isDate(val))
384
+ return "date";
385
+ if (isError(val))
386
+ return "error";
387
+ const constructorName = ctorName(val);
388
+ switch (constructorName) {
389
+ case "Symbol":
390
+ case "Promise":
391
+ case "WeakMap":
392
+ case "WeakSet":
393
+ case "Map":
394
+ case "Set":
395
+ return constructorName;
396
+ }
397
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
398
+ }
399
+ function ctorName(val) {
400
+ return typeof val.constructor === "function" ? val.constructor.name : null;
401
+ }
402
+ function isError(val) {
403
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
404
+ }
405
+ function isDate(val) {
406
+ if (val instanceof Date)
407
+ return true;
408
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
409
+ }
410
+ function kindOf(val) {
411
+ let typeOfVal = typeof val;
412
+ if (process.env.NODE_ENV !== "production") {
413
+ typeOfVal = miniKindOf(val);
414
+ }
415
+ return typeOfVal;
416
+ }
417
+ function warning(message) {
418
+ if (typeof console !== "undefined" && typeof console.error === "function") {
419
+ console.error(message);
420
+ }
421
+ try {
422
+ throw new Error(message);
423
+ } catch (e) {
424
+ }
425
+ }
426
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
427
+ const reducerKeys = Object.keys(reducers);
428
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
429
+ if (reducerKeys.length === 0) {
430
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
431
+ }
432
+ if (!isPlainObject(inputState)) {
433
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
434
+ }
435
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
436
+ unexpectedKeys.forEach((key) => {
437
+ unexpectedKeyCache[key] = true;
438
+ });
439
+ if (action && action.type === actionTypes_default.REPLACE)
440
+ return;
441
+ if (unexpectedKeys.length > 0) {
442
+ 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.`;
443
+ }
444
+ }
445
+ function assertReducerShape(reducers) {
446
+ Object.keys(reducers).forEach((key) => {
447
+ const reducer = reducers[key];
448
+ const initialState8 = reducer(void 0, {
449
+ type: actionTypes_default.INIT
450
+ });
451
+ if (typeof initialState8 === "undefined") {
452
+ 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.`);
453
+ }
454
+ if (typeof reducer(void 0, {
455
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
456
+ }) === "undefined") {
457
+ 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.`);
458
+ }
459
+ });
460
+ }
461
+ function combineReducers(reducers) {
462
+ const reducerKeys = Object.keys(reducers);
463
+ const finalReducers = {};
464
+ for (let i = 0; i < reducerKeys.length; i++) {
465
+ const key = reducerKeys[i];
466
+ if (process.env.NODE_ENV !== "production") {
467
+ if (typeof reducers[key] === "undefined") {
468
+ warning(`No reducer provided for key "${key}"`);
469
+ }
470
+ }
471
+ if (typeof reducers[key] === "function") {
472
+ finalReducers[key] = reducers[key];
473
+ }
474
+ }
475
+ const finalReducerKeys = Object.keys(finalReducers);
476
+ let unexpectedKeyCache;
477
+ if (process.env.NODE_ENV !== "production") {
478
+ unexpectedKeyCache = {};
479
+ }
480
+ let shapeAssertionError;
481
+ try {
482
+ assertReducerShape(finalReducers);
483
+ } catch (e) {
484
+ shapeAssertionError = e;
485
+ }
486
+ return function combination(state = {}, action) {
487
+ if (shapeAssertionError) {
488
+ throw shapeAssertionError;
489
+ }
490
+ if (process.env.NODE_ENV !== "production") {
491
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
492
+ if (warningMessage) {
493
+ warning(warningMessage);
494
+ }
495
+ }
496
+ let hasChanged = false;
497
+ const nextState = {};
498
+ for (let i = 0; i < finalReducerKeys.length; i++) {
499
+ const key = finalReducerKeys[i];
500
+ const reducer = finalReducers[key];
501
+ const previousStateForKey = state[key];
502
+ const nextStateForKey = reducer(previousStateForKey, action);
503
+ if (typeof nextStateForKey === "undefined") {
504
+ const actionType = action && action.type;
505
+ 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.`);
506
+ }
507
+ nextState[key] = nextStateForKey;
508
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
509
+ }
510
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
511
+ return hasChanged ? nextState : state;
512
+ };
513
+ }
514
+
515
+ // src/store/store.ts
516
+ var rootReducer = combineReducers({
517
+ env: env_slice_default,
518
+ navbar: navbar_slice_default,
519
+ list: list_slice_default,
520
+ search: search_slice_default,
521
+ form: form_slice_default,
522
+ excel: excel_slice_default,
523
+ profile: profile_slice_default
524
+ });
525
+ var envStore = configureStore({
526
+ reducer: rootReducer,
527
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
528
+ serializableCheck: false
529
+ })
530
+ });
531
+ var MAINT_KEY = "MAINTENANCE_ACTIVE";
532
+ var MAINT_AT = "MAINTENANCE_AT";
533
+ var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
534
+ var hasRedirectedToMaintenance = false;
535
+ function setMaintenanceFlags() {
536
+ if (typeof window === "undefined") return;
537
+ const { pathname, search } = window.location;
538
+ const lastPath = pathname + (search || "");
539
+ if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
540
+ window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
541
+ }
542
+ window.localStorage.setItem(MAINT_KEY, "true");
543
+ window.localStorage.setItem(MAINT_AT, String(Date.now()));
544
+ }
545
+ async function clearMaintenanceAndExit(getToken, opts) {
546
+ if (typeof window === "undefined") return;
547
+ const forceLogin = opts?.forceLogin === true;
548
+ const clearTokenOnForce = opts?.clearTokenOnForce !== false;
549
+ window.localStorage.removeItem(MAINT_KEY);
550
+ window.localStorage.removeItem(MAINT_AT);
551
+ const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
552
+ window.localStorage.removeItem(MAINT_LAST_PATH);
553
+ try {
554
+ if (forceLogin) {
555
+ if (clearTokenOnForce) {
556
+ try {
557
+ await opts?.clearToken?.();
558
+ } catch {
559
+ }
560
+ }
561
+ window.location.replace("/login");
562
+ return;
563
+ }
564
+ const token = await getToken();
565
+ if (token) {
566
+ const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
567
+ window.location.replace(target);
568
+ } else {
569
+ window.location.replace("/login");
570
+ }
571
+ } catch {
572
+ window.location.replace("/login");
573
+ }
574
+ }
575
+ var axiosClient = {
576
+ init(config) {
577
+ const localStorage = config.localStorageUtils;
578
+ const sessionStorage = config.sessionStorageUtils;
579
+ const db = config.db;
580
+ let isRefreshing = false;
581
+ let failedQueue = [];
582
+ const processQueue = (error, token = null) => {
583
+ failedQueue?.forEach((prom) => {
584
+ if (error) {
585
+ prom.reject(error);
586
+ } else {
587
+ prom.resolve(token);
588
+ }
589
+ });
590
+ failedQueue = [];
591
+ };
592
+ const instance = axios.create({
593
+ adapter: axios.defaults.adapter,
594
+ baseURL: config.baseUrl,
595
+ timeout: 5e4,
596
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
597
+ });
598
+ if (typeof window !== "undefined") {
599
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
600
+ const onMaintenancePage = window.location.pathname === "/maintenance";
601
+ if (isMaint && !onMaintenancePage) {
602
+ hasRedirectedToMaintenance = true;
603
+ window.location.replace("/maintenance");
604
+ }
605
+ if (isMaint && onMaintenancePage) {
606
+ const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
607
+ (async () => {
608
+ try {
609
+ await axios.get(healthUrl, { timeout: 8e3 });
610
+ await clearMaintenanceAndExit(() => localStorage.getAccessToken(), {
611
+ forceLogin: true,
612
+ clearTokenOnForce: true,
613
+ clearToken: () => localStorage.clearToken()
614
+ });
615
+ } catch {
616
+ }
617
+ })();
618
+ }
619
+ }
620
+ instance.interceptors.request.use(
621
+ async (configReq) => {
622
+ const token = await localStorage.getAccessToken();
623
+ if (token) {
624
+ configReq.headers["Authorization"] = "Bearer " + token;
625
+ }
626
+ return configReq;
627
+ },
628
+ (error) => Promise.reject(error)
629
+ );
630
+ instance.interceptors.response.use(
631
+ (response) => {
632
+ if (typeof window !== "undefined") {
633
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
634
+ const onMaintenancePage = window.location.pathname === "/maintenance";
635
+ if (isMaint && onMaintenancePage) {
636
+ (async () => {
637
+ await clearMaintenanceAndExit(
638
+ () => localStorage.getAccessToken(),
639
+ {
640
+ forceLogin: true,
641
+ clearTokenOnForce: true,
642
+ clearToken: () => localStorage.clearToken()
643
+ }
644
+ );
645
+ })();
646
+ } else if (isMaint) {
647
+ window.localStorage.removeItem(MAINT_KEY);
648
+ window.localStorage.removeItem(MAINT_AT);
649
+ window.localStorage.removeItem(MAINT_LAST_PATH);
650
+ }
651
+ }
652
+ return handleResponse(response);
653
+ },
654
+ async (error) => {
655
+ const status = error?.response?.status;
656
+ if (status === 503) {
657
+ if (typeof window !== "undefined") {
658
+ setMaintenanceFlags();
659
+ if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
660
+ hasRedirectedToMaintenance = true;
661
+ window.location.replace("/maintenance");
662
+ }
663
+ }
664
+ return Promise.reject({
665
+ code: 503,
666
+ message: "SERVICE_UNAVAILABLE",
667
+ original: error?.response?.data
668
+ });
669
+ }
670
+ const handleError = async (err) => {
671
+ if (!err.response) {
672
+ return err;
673
+ }
674
+ const { data } = err.response;
675
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
676
+ await clearAuthToken();
677
+ }
678
+ return data;
679
+ };
680
+ const originalRequest = error.config;
681
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
682
+ error.response.data.code
683
+ )) {
684
+ if (isRefreshing) {
685
+ return new Promise(function(resolve, reject) {
686
+ failedQueue.push({ resolve, reject });
687
+ }).then((token) => {
688
+ originalRequest.headers["Authorization"] = "Bearer " + token;
689
+ return instance.request(originalRequest);
690
+ }).catch(async (err) => {
691
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
692
+ await clearAuthToken();
693
+ }
694
+ });
695
+ }
696
+ const browserSession = await sessionStorage.getBrowserSession();
697
+ const refreshToken = await localStorage.getRefreshToken();
698
+ const accessTokenExp = await localStorage.getAccessToken();
699
+ isRefreshing = true;
700
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
701
+ await clearAuthToken();
702
+ } else {
703
+ const payload = Object.fromEntries(
704
+ Object.entries({
705
+ refresh_token: refreshToken,
706
+ grant_type: "refresh_token",
707
+ client_id: config.config.clientId,
708
+ client_secret: config.config.clientSecret
709
+ }).filter(([_, value]) => !!value)
710
+ );
711
+ return new Promise(function(resolve) {
712
+ axios.post(
713
+ `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
714
+ payload,
715
+ {
716
+ headers: {
717
+ "Content-Type": "multipart/form-data",
718
+ Authorization: `Bearer ${accessTokenExp}`
719
+ }
720
+ }
721
+ ).then(async (res) => {
722
+ const data = res.data;
723
+ await localStorage.setToken(data.access_token);
724
+ await localStorage.setRefreshToken(data.refresh_token);
725
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
726
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
727
+ processQueue(null, data.access_token);
728
+ resolve(instance.request(originalRequest));
729
+ }).catch(async (err) => {
730
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
731
+ await clearAuthToken();
732
+ }
733
+ if (err && err.response) {
734
+ const { error_code } = err.response?.data || {};
735
+ if (error_code === "AUTHEN_FAIL") {
736
+ await clearAuthToken();
737
+ }
738
+ }
739
+ processQueue(err, null);
740
+ }).finally(() => {
741
+ isRefreshing = false;
742
+ });
743
+ });
744
+ }
745
+ }
746
+ return Promise.reject(await handleError(error));
747
+ }
748
+ );
749
+ const handleResponse = (res) => {
750
+ if (res && res.data) {
751
+ return res.data;
752
+ }
753
+ return res;
754
+ };
755
+ const clearAuthToken = async () => {
756
+ await localStorage.clearToken();
757
+ if (typeof window !== "undefined") {
758
+ window.location.href = `/login`;
759
+ }
760
+ };
761
+ function formatUrl(url, db2) {
762
+ return url + (db2 ? "?db=" + db2 : "");
763
+ }
764
+ const responseBody = (response) => response;
765
+ const requests = {
766
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
767
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
768
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
769
+ responseType: "arraybuffer",
770
+ headers: {
771
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
772
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
773
+ }
774
+ }).then(responseBody),
775
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
776
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
777
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
778
+ };
779
+ return requests;
780
+ }
781
+ };
782
+
783
+ // src/environment/EnvStore.ts
784
+ var EnvStore = class {
785
+ envStore;
786
+ baseUrl;
787
+ requests;
788
+ context;
789
+ defaultCompany;
790
+ config;
791
+ companies;
792
+ user;
793
+ db;
794
+ localStorageUtils;
795
+ sessionStorageUtils;
796
+ constructor(envStore2, localStorageUtils, sessionStorageUtils) {
797
+ this.envStore = envStore2;
798
+ this.localStorageUtils = localStorageUtils;
799
+ this.sessionStorageUtils = sessionStorageUtils;
800
+ this.setup();
801
+ }
802
+ setup() {
803
+ const env2 = this.envStore.getState().env;
804
+ this.baseUrl = env2?.baseUrl;
805
+ this.requests = env2?.requests;
806
+ this.context = env2?.context;
807
+ this.defaultCompany = env2?.defaultCompany;
808
+ this.config = env2?.config;
809
+ this.companies = env2?.companies || [];
810
+ this.user = env2?.user;
811
+ this.db = env2?.db;
812
+ }
813
+ setupEnv(envConfig) {
814
+ const dispatch = this.envStore.dispatch;
815
+ const env2 = {
816
+ ...envConfig,
817
+ localStorageUtils: this.localStorageUtils,
818
+ sessionStorageUtils: this.sessionStorageUtils
819
+ };
820
+ const requests = axiosClient.init(env2);
821
+ dispatch(setEnv({ ...env2, requests }));
822
+ this.setup();
823
+ }
824
+ setUid(uid) {
825
+ const dispatch = this.envStore.dispatch;
826
+ dispatch(setUid(uid));
827
+ this.setup();
828
+ }
829
+ setLang(lang) {
830
+ const dispatch = this.envStore.dispatch;
831
+ dispatch(setLang(lang));
832
+ this.setup();
833
+ }
834
+ setAllowCompanies(allowCompanies) {
835
+ const dispatch = this.envStore.dispatch;
836
+ dispatch(setAllowCompanies(allowCompanies));
837
+ this.setup();
838
+ }
839
+ setCompanies(companies) {
840
+ const dispatch = this.envStore.dispatch;
841
+ dispatch(setCompanies(companies));
842
+ this.setup();
843
+ }
844
+ setDefaultCompany(company) {
845
+ const dispatch = this.envStore.dispatch;
846
+ dispatch(setDefaultCompany(company));
847
+ this.setup();
848
+ }
849
+ setUserInfo(userInfo) {
850
+ const dispatch = this.envStore.dispatch;
851
+ dispatch(setUser(userInfo));
852
+ this.setup();
853
+ }
854
+ };
855
+ var env = null;
856
+ function getEnv() {
857
+ if (!env) env = new EnvStore(envStore);
858
+ return env;
859
+ }
860
+
861
+ // src/utils/function.ts
862
+ var toQueryString = (params) => {
863
+ return Object.keys(params).map(
864
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
865
+ ).join("&");
866
+ };
867
+
868
+ // src/services/action-service/index.ts
869
+ var ActionService = {
870
+ async loadAction({
871
+ idAction,
872
+ context
873
+ }) {
874
+ const env2 = getEnv();
875
+ const jsonData = {
876
+ action_id: idAction,
877
+ with_context: {
878
+ ...context
879
+ }
880
+ };
881
+ return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
882
+ headers: {
883
+ "Content-Type": "application/json"
884
+ }
885
+ });
886
+ },
887
+ async callButton({
888
+ model,
889
+ ids = [],
890
+ context,
891
+ method
892
+ }) {
893
+ try {
894
+ const env2 = getEnv();
895
+ const jsonData = {
896
+ model,
897
+ method,
898
+ ids,
899
+ with_context: context
900
+ };
901
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
902
+ headers: {
903
+ "Content-Type": "application/json"
904
+ }
905
+ });
906
+ } catch (error) {
907
+ console.error("Error when calling button action:", error);
908
+ throw error;
909
+ }
910
+ },
911
+ async removeRows({
912
+ model,
913
+ ids,
914
+ context
915
+ }) {
916
+ const env2 = getEnv();
917
+ const jsonData = {
918
+ model,
919
+ method: "unlink",
920
+ ids,
921
+ with_context: context
922
+ };
923
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
924
+ headers: {
925
+ "Content-Type": "application/json"
926
+ }
927
+ });
928
+ },
929
+ async duplicateRecord({
930
+ model,
931
+ id,
932
+ context
933
+ }) {
934
+ const env2 = getEnv();
935
+ const jsonData = {
936
+ model,
937
+ method: "copy",
938
+ ids: id,
939
+ with_context: context
940
+ };
941
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
942
+ headers: {
943
+ "Content-Type": "application/json"
944
+ }
945
+ });
946
+ },
947
+ async print({ id, report, db }) {
948
+ const env2 = getEnv();
949
+ const jsonData = {
950
+ report,
951
+ id,
952
+ type: "pdf",
953
+ file_response: true,
954
+ db
955
+ };
956
+ const queryString = toQueryString(jsonData);
957
+ const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
958
+ return env2.requests.get(urlWithParams, {
959
+ headers: {
960
+ "Content-Type": "application/json"
961
+ },
962
+ responseType: "arraybuffer"
963
+ });
964
+ },
965
+ async runAction({
966
+ idAction,
967
+ context
968
+ }) {
969
+ const env2 = getEnv();
970
+ const jsonData = {
971
+ action_id: idAction,
972
+ with_context: {
973
+ ...context
974
+ }
975
+ };
976
+ return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
977
+ headers: {
978
+ "Content-Type": "application/json"
979
+ }
980
+ });
981
+ }
982
+ };
983
+ var action_service_default = ActionService;
984
+
985
+ // src/services/auth-service/index.ts
986
+ var AuthService = {
987
+ async login(body) {
988
+ const env2 = getEnv();
989
+ const payload = Object.fromEntries(
990
+ Object.entries({
991
+ username: body.email,
992
+ password: body.password,
993
+ grant_type: env2?.config?.grantType || "",
994
+ client_id: env2?.config?.clientId || "",
995
+ client_secret: env2?.config?.clientSecret || ""
996
+ }).filter(([_, value]) => !!value)
997
+ );
998
+ const encodedData = new URLSearchParams(payload).toString();
999
+ return env2?.requests?.post(body.path, encodedData, {
1000
+ headers: {
1001
+ "Content-Type": "application/x-www-form-urlencoded"
1002
+ }
1003
+ });
1004
+ },
1005
+ async forgotPassword(email) {
1006
+ const env2 = getEnv();
1007
+ const bodyData = {
1008
+ login: email,
1009
+ url: `${window.location.origin}/reset-password`
1010
+ };
1011
+ return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
1012
+ headers: {
1013
+ "Content-Type": "application/json"
1014
+ }
1015
+ });
1016
+ },
1017
+ async resetPassword(data, token) {
1018
+ const env2 = getEnv();
1019
+ const bodyData = {
1020
+ token,
1021
+ password: data.password,
1022
+ new_password: data.confirmPassword
1023
+ };
1024
+ return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
1025
+ headers: {
1026
+ "Content-Type": "application/json"
1027
+ }
1028
+ });
1029
+ },
1030
+ async updatePassword(data, token) {
1031
+ const env2 = getEnv();
1032
+ const bodyData = {
1033
+ token,
1034
+ old_password: data.oldPassword,
1035
+ new_password: data.newPassword
1036
+ };
1037
+ return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
1038
+ headers: {
1039
+ "Content-Type": "application/json"
1040
+ }
1041
+ });
1042
+ },
1043
+ async isValidToken(token) {
1044
+ const env2 = getEnv();
1045
+ const bodyData = {
1046
+ token
1047
+ };
1048
+ return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
1049
+ headers: {
1050
+ "Content-Type": "application/json"
1051
+ }
1052
+ });
1053
+ },
1054
+ async loginSocial({
1055
+ state,
1056
+ access_token
1057
+ }) {
1058
+ const env2 = getEnv();
1059
+ return env2?.requests?.post(
1060
+ "/token/generate" /* GENTOKEN_SOCIAL */,
1061
+ { state, access_token },
1062
+ {
1063
+ headers: {
1064
+ "Content-Type": "application/json"
1065
+ }
1066
+ }
1067
+ );
1068
+ },
1069
+ async getProviders(db) {
1070
+ const env2 = getEnv();
1071
+ return env2?.requests?.get("/oauth/providers", { params: { db } });
1072
+ }
1073
+ };
1074
+ var auth_service_default = AuthService;
1075
+
1076
+ // src/services/company-service/index.ts
1077
+ var CompanyService = {
1078
+ async getCurrentCompany() {
1079
+ const env2 = getEnv();
1080
+ return await env2.requests.get("/company" /* COMPANY_PATH */, {
1081
+ headers: {
1082
+ "Content-Type": "application/json"
1083
+ }
1084
+ });
1085
+ },
1086
+ async getInfoCompany(id) {
1087
+ const env2 = getEnv();
1088
+ const jsonData = {
1089
+ ids: [id],
1090
+ model: "res.company" /* COMPANY */,
1091
+ method: "web_read" /* WEB_READ */,
1092
+ kwargs: {
1093
+ specification: {
1094
+ primary_color: {},
1095
+ secondary_color: {},
1096
+ logo: {},
1097
+ display_name: {},
1098
+ secondary_logo: {}
1099
+ }
1100
+ }
1101
+ };
1102
+ return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1103
+ headers: {
1104
+ "Content-Type": "application/json"
1105
+ }
1106
+ });
1107
+ }
1108
+ };
1109
+ var company_service_default = CompanyService;
1110
+
1111
+ // src/services/excel-service/index.ts
1112
+ var ExcelService = {
1113
+ async uploadFile({ formData }) {
1114
+ const env2 = getEnv();
1115
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
1116
+ headers: {
1117
+ "Content-Type": "multipart/form-data"
1118
+ }
1119
+ });
1120
+ },
1121
+ async uploadIdFile({ formData }) {
1122
+ const env2 = getEnv();
1123
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
1124
+ headers: {
1125
+ "Content-Type": "multipart/form-data"
1126
+ }
1127
+ });
1128
+ },
1129
+ async parsePreview({
1130
+ id,
1131
+ selectedSheet,
1132
+ isHeader,
1133
+ context
1134
+ }) {
1135
+ const env2 = getEnv();
1136
+ const jsonData = {
1137
+ model: "base_import.import" /* BASE_IMPORT */,
1138
+ method: "parse_preview",
1139
+ ids: [id],
1140
+ kwargs: {
1141
+ options: {
1142
+ import_skip_records: [],
1143
+ import_set_empty_fields: [],
1144
+ fallback_values: {},
1145
+ name_create_enabled_fields: {},
1146
+ encoding: "",
1147
+ separator: "",
1148
+ quoting: '"',
1149
+ date_format: "",
1150
+ datetime_format: "",
1151
+ float_thousand_separator: ",",
1152
+ float_decimal_separator: ".",
1153
+ advanced: true,
1154
+ has_headers: isHeader,
1155
+ keep_matches: false,
1156
+ limit: 2e3,
1157
+ sheets: [],
1158
+ sheet: selectedSheet,
1159
+ skip: 0,
1160
+ tracking_disable: true
1161
+ }
1162
+ },
1163
+ with_context: context
1164
+ };
1165
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
1166
+ headers: {
1167
+ "Content-Type": "multipart/form-data"
1168
+ }
1169
+ });
1170
+ },
1171
+ async executeImport({
1172
+ columns,
1173
+ fields,
1174
+ idFile,
1175
+ options,
1176
+ dryrun,
1177
+ context
1178
+ }) {
1179
+ const env2 = getEnv();
1180
+ const jsonData = {
1181
+ model: "base_import.import" /* BASE_IMPORT */,
1182
+ method: "execute_import",
1183
+ ids: [idFile],
1184
+ kwargs: {
1185
+ fields,
1186
+ columns,
1187
+ options,
1188
+ dryrun
1189
+ },
1190
+ with_context: context
1191
+ };
1192
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
1193
+ headers: {
1194
+ "Content-Type": "multipart/form-data"
1195
+ }
1196
+ });
1197
+ },
1198
+ async getFileExcel({ model, context }) {
1199
+ const env2 = getEnv();
1200
+ const jsonData = {
1201
+ model,
1202
+ method: "get_import_templates" /* GET_IMPORT */,
1203
+ args: [],
1204
+ with_context: context
1205
+ };
1206
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData);
1207
+ },
1208
+ async getFieldExport({
1209
+ ids,
1210
+ model,
1211
+ isShow,
1212
+ parentField,
1213
+ fieldType,
1214
+ parentName,
1215
+ prefix,
1216
+ name,
1217
+ context,
1218
+ importCompat
1219
+ }) {
1220
+ const env2 = getEnv();
1221
+ const jsonData = {
1222
+ model,
1223
+ import_compat: importCompat,
1224
+ domain: [["id", "in", ids]],
1225
+ with_context: context
1226
+ };
1227
+ if (isShow) {
1228
+ jsonData.parent_field = parentField;
1229
+ jsonData.parent_field_type = fieldType;
1230
+ jsonData.parent_name = parentName;
1231
+ jsonData.name = name;
1232
+ jsonData.prefix = prefix;
1233
+ jsonData.exclude = [null];
1234
+ }
1235
+ return env2.requests.post("/export/get_fields", jsonData);
1236
+ },
1237
+ async exportExcel({
1238
+ model,
1239
+ domain,
1240
+ ids,
1241
+ fields,
1242
+ type,
1243
+ importCompat,
1244
+ context,
1245
+ groupby
1246
+ }) {
1247
+ const env2 = getEnv();
1248
+ const jsonData = {
1249
+ model,
1250
+ domain,
1251
+ ids,
1252
+ import_compat: importCompat,
1253
+ fields,
1254
+ with_context: context,
1255
+ groupby: groupby ?? []
1256
+ };
1257
+ return env2.requests.post_excel(`/export/${type}`, jsonData);
1258
+ }
1259
+ };
1260
+ var excel_service_default = ExcelService;
1261
+
1262
+ // src/services/form-service/index.ts
1263
+ var FormService = {
1264
+ async getComment({ data }) {
1265
+ try {
1266
+ const env2 = getEnv();
1267
+ const jsonData = {
1268
+ thread_id: data.thread_id,
1269
+ thread_model: data.thread_model,
1270
+ limit: 100,
1271
+ with_context: {
1272
+ lang: data.lang
1273
+ }
1274
+ };
1275
+ return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
1276
+ headers: {
1277
+ "Content-Type": "application/json"
1278
+ }
1279
+ });
1280
+ } catch (error) {
1281
+ console.error("Error when sending message:", error);
1282
+ throw error;
1283
+ }
1284
+ },
1285
+ async sentComment({ data }) {
1286
+ try {
1287
+ const env2 = getEnv();
1288
+ const jsonData = {
1289
+ context: {
1290
+ tz: "Asia/Saigon",
1291
+ uid: 2,
1292
+ allowed_company_ids: [1],
1293
+ mail_post_autofollow: false,
1294
+ temporary_id: 142183.01
1295
+ },
1296
+ post_data: {
1297
+ body: data.message,
1298
+ message_type: "comment",
1299
+ attachment_ids: data.attachment_ids,
1300
+ attachment_tokens: [],
1301
+ subtype_xmlid: data.subtype
1302
+ },
1303
+ thread_id: Number(data.thread_id),
1304
+ thread_model: data.thread_model
1305
+ };
1306
+ return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
1307
+ headers: {
1308
+ "Content-Type": "application/json"
1309
+ }
1310
+ });
1311
+ } catch (error) {
1312
+ console.error("Error when sent message:", error);
1313
+ throw error;
1314
+ }
1315
+ },
1316
+ async deleteComment({ data }) {
1317
+ try {
1318
+ const env2 = getEnv();
1319
+ const jsonData = {
1320
+ attachment_ids: [],
1321
+ attachment_tokens: [],
1322
+ body: "",
1323
+ message_id: data.message_id
1324
+ };
1325
+ return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
1326
+ headers: {
1327
+ "Content-Type": "application/json"
1328
+ }
1329
+ });
1330
+ } catch (error) {
1331
+ console.error("Error when sent message:", error);
1332
+ throw error;
1333
+ }
1334
+ },
1335
+ async getImage({ data }) {
1336
+ try {
1337
+ const env2 = getEnv();
1338
+ return env2.requests.get(
1339
+ `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
1340
+ {
1341
+ headers: {
1342
+ "Content-Type": "application/json"
1343
+ }
1344
+ }
1345
+ );
1346
+ } catch (error) {
1347
+ console.error("Error when sent message:", error);
1348
+ throw error;
1349
+ }
1350
+ },
1351
+ async uploadImage({ data }) {
1352
+ try {
1353
+ const env2 = getEnv();
1354
+ return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
1355
+ headers: {
1356
+ "Content-Type": "multipart/form-data"
1357
+ }
1358
+ });
1359
+ } catch (error) {
1360
+ console.error("Error when sent message:", error);
1361
+ throw error;
1362
+ }
1363
+ },
1364
+ async getFormView({ data }) {
1365
+ try {
1366
+ const env2 = getEnv();
1367
+ const jsonData = {
1368
+ model: data.model,
1369
+ method: "get_formview_action",
1370
+ ids: data.id ? [data.id] : [],
1371
+ with_context: data.context
1372
+ };
1373
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
1374
+ headers: {
1375
+ "Content-Type": "application/json"
1376
+ }
1377
+ });
1378
+ } catch (error) {
1379
+ console.error("Error when fetching form view:", error);
1380
+ throw error;
1381
+ }
1382
+ },
1383
+ async changeStatus({ data }) {
1384
+ const env2 = getEnv();
1385
+ const vals = {
1386
+ [data.name]: data.stage_id
1387
+ };
1388
+ const jsonData = {
1389
+ model: data.model,
1390
+ method: "web_save",
1391
+ with_context: {
1392
+ lang: data.lang,
1393
+ allowed_company_ids: [1],
1394
+ uid: 2,
1395
+ search_default_my_ticket: true,
1396
+ search_default_is_open: true
1397
+ },
1398
+ ids: [data.id],
1399
+ kwargs: {
1400
+ vals,
1401
+ specification: {}
1402
+ }
1403
+ };
1404
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
1405
+ headers: {
1406
+ "Content-Type": "application/json"
1407
+ }
1408
+ });
1409
+ }
1410
+ };
1411
+ var form_service_default = FormService;
1412
+
1413
+ // src/services/model-service/index.ts
1414
+ var OBJECT_POSITION = 2;
1415
+ var ModelService = {
1416
+ async getAll({ data }) {
1417
+ const env2 = getEnv();
1418
+ const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
1419
+ fields: data.fields,
1420
+ groupby: data.groupby
1421
+ } : {
1422
+ count_limit: 10001,
1423
+ order: data.sort,
1424
+ specification: data.specification
1425
+ };
1426
+ const jsonData = {
1427
+ model: String(data.model),
1428
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
1429
+ ids: data.ids,
1430
+ with_context: data.context,
1431
+ kwargs: {
1432
+ domain: data.domain,
1433
+ limit: data.limit,
1434
+ offset: data.offset,
1435
+ ...jsonReadGroup
1436
+ }
1437
+ };
1438
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
1439
+ headers: {
1440
+ "Content-Type": "application/json"
1441
+ }
1442
+ });
1443
+ },
1444
+ async getList({
1445
+ model,
1446
+ ids = [],
1447
+ specification = {},
1448
+ domain = [],
1449
+ offset,
1450
+ order,
1451
+ context = {},
1452
+ limit = 10
1453
+ }) {
1454
+ const env2 = getEnv();
1455
+ const jsonData = {
1456
+ model,
1457
+ method: "web_search_read" /* WEB_SEARCH_READ */,
1458
+ ids,
1459
+ with_context: context,
1460
+ kwargs: {
1461
+ specification,
1462
+ domain,
1463
+ limit,
1464
+ offset,
1465
+ order
1466
+ }
1467
+ };
1468
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1469
+ headers: {
1470
+ "Content-Type": "application/json"
1471
+ }
1472
+ });
1473
+ },
1474
+ async getDetail({
1475
+ ids = [],
1476
+ model,
1477
+ specification,
1478
+ context
1479
+ }) {
1480
+ const env2 = getEnv();
1481
+ const jsonData = {
1482
+ model,
1483
+ method: "web_read" /* WEB_READ */,
1484
+ ids,
1485
+ with_context: context,
1486
+ kwargs: {
1487
+ specification
1488
+ }
1489
+ };
1490
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1491
+ headers: {
1492
+ "Content-Type": "application/json"
1493
+ }
1494
+ });
1495
+ },
1496
+ async save({
1497
+ model,
1498
+ ids = [],
1499
+ data = {},
1500
+ specification = {},
1501
+ context = {}
1502
+ }) {
1503
+ const env2 = getEnv();
1504
+ const jsonData = {
1505
+ model,
1506
+ method: "web_save" /* WEB_SAVE */,
1507
+ with_context: context,
1508
+ ids,
1509
+ kwargs: {
1510
+ vals: data,
1511
+ specification
1512
+ }
1513
+ };
1514
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1515
+ headers: {
1516
+ "Content-Type": "application/json"
1517
+ }
1518
+ });
1519
+ },
1520
+ async delete({ ids = [], model }) {
1521
+ const env2 = getEnv();
1522
+ const jsonData = {
1523
+ model,
1524
+ method: "unlink" /* UNLINK */,
1525
+ ids
1526
+ };
1527
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1528
+ headers: {
1529
+ "Content-Type": "application/json"
1530
+ }
1531
+ });
1532
+ },
1533
+ async onChange({
1534
+ ids = [],
1535
+ model,
1536
+ object,
1537
+ specification,
1538
+ context,
1539
+ fieldChange
1540
+ }) {
1541
+ const env2 = getEnv();
1542
+ const jsonData = {
1543
+ model,
1544
+ method: "onchange" /* ONCHANGE */,
1545
+ ids,
1546
+ with_context: context,
1547
+ args: [
1548
+ object ? object : {},
1549
+ fieldChange ? fieldChange : [],
1550
+ specification
1551
+ ]
1552
+ };
1553
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1554
+ headers: {
1555
+ "Content-Type": "application/json"
1556
+ }
1557
+ });
1558
+ },
1559
+ async getListFieldsOnchange({ model }) {
1560
+ const env2 = getEnv();
1561
+ const jsonData = {
1562
+ model,
1563
+ method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
1564
+ };
1565
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1566
+ headers: {
1567
+ "Content-Type": "application/json"
1568
+ }
1569
+ });
1570
+ },
1571
+ parseORMOdoo(data) {
1572
+ for (const key in data) {
1573
+ if (key === "display_name") {
1574
+ delete data[key];
1575
+ }
1576
+ if (!data[key] && data[key] !== 0) {
1577
+ data[key] = false;
1578
+ } else if (data[key] === "Draft") {
1579
+ data[key] = "/";
1580
+ }
1581
+ }
1582
+ return { ...data };
1583
+ },
1584
+ toDataJS(data, viewData, model) {
1585
+ for (const key in data) {
1586
+ if (data[key] === false) {
1587
+ if (viewData && model) {
1588
+ if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
1589
+ data[key] = null;
1590
+ }
1591
+ } else {
1592
+ data[key] = null;
1593
+ }
1594
+ } else if (data[key] === "/") {
1595
+ data[key] = "Draft";
1596
+ } else if (data[key] !== false) {
1597
+ if (model !== void 0) {
1598
+ if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
1599
+ data[key] = (data[key] ??= [])?.map((item, index) => {
1600
+ const relation = viewData?.models?.[model]?.[key]?.relation;
1601
+ if (relation !== void 0) {
1602
+ if (viewData?.models?.[relation]) {
1603
+ if (item?.length >= 3) {
1604
+ if (item[0] === 2 /* DELETE */) {
1605
+ delete data[key][index];
1606
+ return;
1607
+ }
1608
+ return ModelService.toDataJS(
1609
+ { ...item[OBJECT_POSITION], id: `virtual_${index}` },
1610
+ viewData,
1611
+ relation
1612
+ );
1613
+ } else {
1614
+ return ModelService.toDataJS(item, viewData, relation);
1615
+ }
1616
+ } else {
1617
+ if (item?.length >= 3) {
1618
+ if (!item[OBJECT_POSITION] || item[0] === 2 /* DELETE */) {
1619
+ delete data[key][index];
1620
+ return;
1621
+ }
1622
+ return item[OBJECT_POSITION];
1623
+ } else {
1624
+ return item;
1625
+ }
1626
+ }
1627
+ }
1628
+ });
1629
+ }
1630
+ }
1631
+ }
1632
+ }
1633
+ return { ...data };
1634
+ }
1635
+ };
1636
+ var model_service_default = ModelService;
1637
+
1638
+ // src/services/user-service/index.ts
1639
+ var UserService = {
1640
+ async getProfile() {
1641
+ const env2 = getEnv();
1642
+ return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
1643
+ headers: {
1644
+ "Content-Type": "application/x-www-form-urlencoded"
1645
+ }
1646
+ });
1647
+ },
1648
+ async getUser({ context, id }) {
1649
+ const env2 = getEnv();
1650
+ const jsonData = {
1651
+ model: "res.users",
1652
+ method: "web_read",
1653
+ ids: [id],
1654
+ with_context: context,
1655
+ kwargs: {
1656
+ specification: {
1657
+ display_name: {},
1658
+ image_1920: {},
1659
+ name: {},
1660
+ login: {},
1661
+ email: {},
1662
+ password: {},
1663
+ visible_group_id: {
1664
+ fields: {
1665
+ id: {},
1666
+ display_name: {}
1667
+ }
1668
+ },
1669
+ company_id: {
1670
+ fields: {
1671
+ id: {},
1672
+ display_name: {}
1673
+ }
1674
+ }
1675
+ }
1676
+ }
1677
+ };
1678
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
1679
+ headers: {
1680
+ "Content-Type": "application/json"
1681
+ }
1682
+ });
1683
+ },
1684
+ switchUserLocale: async ({ id, values }) => {
1685
+ const env2 = getEnv();
1686
+ const jsonData = {
1687
+ model: "res.users",
1688
+ domain: [["id", "=", id]],
1689
+ values
1690
+ };
1691
+ return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
1692
+ headers: {
1693
+ "Content-Type": "application/json"
1694
+ }
1695
+ });
1696
+ }
1697
+ };
1698
+ var user_service_default = UserService;
1699
+
1700
+ // src/services/view-service/index.ts
1701
+ var ViewService = {
1702
+ async getView({
1703
+ model,
1704
+ views,
1705
+ context = {},
1706
+ options = {},
1707
+ aid
1708
+ }) {
1709
+ const env2 = getEnv();
1710
+ const defaultOptions = {
1711
+ load_filters: true,
1712
+ toolbar: true,
1713
+ action_id: aid
1714
+ };
1715
+ const jsonDataView = {
1716
+ model,
1717
+ method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
1718
+ kwargs: {
1719
+ views,
1720
+ options: { ...options, ...defaultOptions }
1721
+ },
1722
+ with_context: context
1723
+ };
1724
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
1725
+ headers: {
1726
+ "Content-Type": "application/json"
1727
+ }
1728
+ });
1729
+ },
1730
+ async getMenu(context) {
1731
+ const env2 = getEnv();
1732
+ const jsonData = {
1733
+ model: "ir.ui.menu" /* MENU */,
1734
+ method: "web_search_read" /* WEB_SEARCH_READ */,
1735
+ ids: [],
1736
+ with_context: context,
1737
+ kwargs: {
1738
+ specification: {
1739
+ active: {},
1740
+ name: {},
1741
+ is_display: {},
1742
+ sequence: {},
1743
+ complete_name: {},
1744
+ action: {
1745
+ fields: {
1746
+ display_name: {},
1747
+ type: {},
1748
+ binding_view_types: {}
1749
+ // res_model: {},
1750
+ }
1751
+ },
1752
+ url_icon: {},
1753
+ web_icon: {},
1754
+ web_icon_data: {},
1755
+ groups_id: {
1756
+ fields: {
1757
+ full_name: {}
1758
+ },
1759
+ limit: 40,
1760
+ order: ""
1761
+ },
1762
+ display_name: {},
1763
+ child_id: {
1764
+ fields: {
1765
+ active: {},
1766
+ name: {},
1767
+ is_display: {},
1768
+ sequence: {},
1769
+ complete_name: {},
1770
+ action: {
1771
+ fields: {
1772
+ display_name: {},
1773
+ type: {},
1774
+ binding_view_types: {}
1775
+ // res_model: {},
1776
+ }
1777
+ },
1778
+ url_icon: {},
1779
+ web_icon: {},
1780
+ web_icon_data: {},
1781
+ groups_id: {
1782
+ fields: {
1783
+ full_name: {}
1784
+ },
1785
+ limit: 40,
1786
+ order: ""
1787
+ },
1788
+ display_name: {},
1789
+ child_id: {
1790
+ fields: {
1791
+ active: {},
1792
+ name: {},
1793
+ is_display: {},
1794
+ sequence: {},
1795
+ complete_name: {},
1796
+ action: {
1797
+ fields: {
1798
+ display_name: {},
1799
+ type: {},
1800
+ binding_view_types: {}
1801
+ // res_model: {},
1802
+ }
1803
+ },
1804
+ url_icon: {},
1805
+ web_icon: {},
1806
+ web_icon_data: {},
1807
+ groups_id: {
1808
+ fields: {
1809
+ full_name: {}
1810
+ },
1811
+ limit: 40,
1812
+ order: ""
1813
+ },
1814
+ display_name: {},
1815
+ child_id: {
1816
+ fields: {
1817
+ active: {},
1818
+ name: {},
1819
+ is_display: {},
1820
+ sequence: {},
1821
+ complete_name: {},
1822
+ action: {
1823
+ fields: {
1824
+ display_name: {},
1825
+ type: {},
1826
+ binding_view_types: {}
1827
+ // res_model: {},
1828
+ }
1829
+ },
1830
+ url_icon: {},
1831
+ web_icon: {},
1832
+ web_icon_data: {},
1833
+ groups_id: {
1834
+ fields: {
1835
+ full_name: {}
1836
+ },
1837
+ limit: 40,
1838
+ order: ""
1839
+ },
1840
+ display_name: {},
1841
+ child_id: {
1842
+ fields: {},
1843
+ limit: 40,
1844
+ order: ""
1845
+ }
1846
+ },
1847
+ limit: 40,
1848
+ order: ""
1849
+ }
1850
+ },
1851
+ limit: 40,
1852
+ order: ""
1853
+ }
1854
+ },
1855
+ limit: 40,
1856
+ order: ""
1857
+ }
1858
+ },
1859
+ domain: [
1860
+ "&",
1861
+ ["is_display", "=", true],
1862
+ "&",
1863
+ ["active", "=", true],
1864
+ ["parent_id", "=", false]
1865
+ ]
1866
+ }
1867
+ };
1868
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1869
+ headers: {
1870
+ "Content-Type": "application/json"
1871
+ }
1872
+ });
1873
+ },
1874
+ async getSelectionItem({ data }) {
1875
+ const env2 = getEnv();
1876
+ const jsonData = {
1877
+ model: data.model,
1878
+ ids: [],
1879
+ method: "get_data_select",
1880
+ with_context: data.context,
1881
+ kwargs: {
1882
+ count_limit: 10001,
1883
+ domain: data.domain ? data.domain : [],
1884
+ offset: 0,
1885
+ order: "",
1886
+ specification: data?.specification ?? {
1887
+ id: {},
1888
+ name: {},
1889
+ display_name: {}
1890
+ }
1891
+ }
1892
+ };
1893
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
1894
+ headers: {
1895
+ "Content-Type": "application/json"
1896
+ }
1897
+ });
1898
+ },
1899
+ async loadMessages() {
1900
+ const env2 = getEnv();
1901
+ return env2.requests.post(
1902
+ "/load_message_failures" /* LOAD_MESSAGE */,
1903
+ {},
1904
+ {
1905
+ headers: {
1906
+ "Content-Type": "application/json"
1907
+ }
1908
+ }
1909
+ );
1910
+ },
1911
+ async getVersion() {
1912
+ const env2 = getEnv();
1913
+ return env2?.requests.get("", {
1914
+ headers: {
1915
+ "Content-Type": "application/json"
1916
+ }
1917
+ });
1918
+ }
1919
+ };
1920
+ var view_service_default = ViewService;
1921
+
1922
+ export { action_service_default as ActionService, auth_service_default as AuthService, company_service_default as CompanyService, excel_service_default as ExcelService, form_service_default as FormService, model_service_default as ModelService, user_service_default as UserService, view_service_default as ViewService };