@fctc/edu-logic-lib 1.0.9 → 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/models.js CHANGED
@@ -1,26 +1,1115 @@
1
1
  'use strict';
2
2
 
3
- var chunkOADBRQ4A_js = require('./chunk-OADBRQ4A.js');
4
- var chunkFVGPSTJ7_js = require('./chunk-FVGPSTJ7.js');
5
- require('./chunk-P2IGWJDZ.js');
6
- require('./chunk-GGOFXFSX.js');
7
- require('./chunk-S7YF2I23.js');
8
- require('./chunk-4K3QAEZ6.js');
9
- require('./chunk-RZBHZYXG.js');
10
- require('./chunk-UY6GNZNB.js');
11
- require('./chunk-IXDDYGKE.js');
3
+ var toolkit = require('@reduxjs/toolkit');
4
+ var axios = require('axios');
12
5
 
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
7
 
8
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
14
9
 
15
- Object.defineProperty(exports, "CompanyModel", {
16
- enumerable: true,
17
- get: function () { return chunkOADBRQ4A_js.company_model_default; }
10
+ // src/constants/api/uri-constant.ts
11
+ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
12
+ UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
13
+ UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
14
+ UriConstants2["CALL_PATH"] = "/call";
15
+ UriConstants2["COMPANY_PATH"] = "/company";
16
+ UriConstants2["PROFILE_PATH"] = "/userinfo";
17
+ UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
18
+ UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
19
+ UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
20
+ UriConstants2["LOAD_ACTION"] = `/load_action`;
21
+ UriConstants2["REPORT_PATH"] = `/report`;
22
+ UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
23
+ UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
24
+ UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
25
+ UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
26
+ UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
27
+ UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
28
+ UriConstants2["IMAGE_PATH"] = `/web/image`;
29
+ UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
30
+ UriConstants2["TOKEN"] = `/check_token`;
31
+ UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
32
+ UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
33
+ UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
34
+ return UriConstants2;
35
+ })(UriConstants || {});
36
+
37
+ // src/constants/widget/widget-avatar-constant.ts
38
+ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
39
+ WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
40
+ WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
41
+ return WIDGETAVATAR2;
42
+ })(WIDGETAVATAR || {});
43
+
44
+ // src/models/base-model/index.ts
45
+ var BaseModel = class {
46
+ name;
47
+ view;
48
+ actContext;
49
+ fields;
50
+ constructor(init) {
51
+ this.name = init.name;
52
+ this.view = init.view;
53
+ this.actContext = init.actContext;
54
+ this.fields = init.fields;
55
+ }
56
+ getSpecificationByFields({
57
+ fields = [],
58
+ specification = {},
59
+ modelsData,
60
+ model,
61
+ modelRoot
62
+ }) {
63
+ if (Array.isArray(fields)) {
64
+ let spec = { ...specification };
65
+ fields.forEach((field) => {
66
+ if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
67
+ if (modelsData?.[model]?.[field?.name]) {
68
+ if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
69
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
70
+ const modelRelation = modelsData?.[relation];
71
+ if (modelRelation) {
72
+ spec[field?.name] = {
73
+ fields: {}
74
+ };
75
+ if (modelRoot && modelRoot === relation) {
76
+ spec[field?.name].fields = { id: {} };
77
+ } else {
78
+ spec[field?.name].fields = this.getSpecificationByFields({
79
+ fields: Object.values(modelRelation),
80
+ specification: {},
81
+ modelsData,
82
+ model: relation,
83
+ modelRoot: model
84
+ });
85
+ }
86
+ } else {
87
+ spec[field?.name] = {
88
+ fields: {
89
+ id: {},
90
+ display_name: {}
91
+ }
92
+ };
93
+ }
94
+ } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
95
+ spec[field?.name] = {
96
+ fields: {
97
+ id: {},
98
+ display_name: {},
99
+ ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
100
+ ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
101
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
102
+ }
103
+ };
104
+ } else {
105
+ spec[field?.name] = {};
106
+ }
107
+ }
108
+ } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
109
+ const specGroup = this.getSpecificationByFields({
110
+ fields: field?.fields,
111
+ specification: spec,
112
+ modelsData,
113
+ model
114
+ });
115
+ spec = { ...spec, ...specGroup };
116
+ } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
117
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
118
+ const specTreee = this.getSpecificationByFields({
119
+ fields: field?.fields,
120
+ specification: {},
121
+ modelsData,
122
+ model: relation,
123
+ modelRoot: model
124
+ });
125
+ spec = {
126
+ ...spec,
127
+ [field?.name]: {
128
+ fields: { ...spec?.[field?.name]?.fields, ...specTreee }
129
+ }
130
+ };
131
+ }
132
+ });
133
+ return spec;
134
+ } else {
135
+ console.warn("fields is not array");
136
+ }
137
+ }
138
+ getTreeProps() {
139
+ const props = this.view?.views?.list || {};
140
+ return props;
141
+ }
142
+ getTreeFields() {
143
+ const fields = this.view?.views?.list?.fields || [];
144
+ return fields;
145
+ }
146
+ getSpecification() {
147
+ const specInit = {};
148
+ const modelData = this.view?.models || {};
149
+ const specification = this.getSpecificationByFields({
150
+ fields: this.fields,
151
+ specification: specInit,
152
+ modelsData: modelData,
153
+ model: this.name,
154
+ modelRoot: ""
155
+ });
156
+ return specification;
157
+ }
158
+ };
159
+ var base_model_default = BaseModel;
160
+ var initialState = {
161
+ baseUrl: "",
162
+ requests: null,
163
+ companies: [],
164
+ user: {},
165
+ envFile: null,
166
+ defaultCompany: {
167
+ id: null,
168
+ logo: "",
169
+ secondary_color: "",
170
+ primary_color: ""
171
+ },
172
+ context: {
173
+ uid: null,
174
+ allowed_company_ids: [],
175
+ lang: "vi_VN",
176
+ tz: "Asia/Saigon"
177
+ }
178
+ };
179
+ var envSlice = toolkit.createSlice({
180
+ name: "env",
181
+ initialState,
182
+ reducers: {
183
+ setEnv: (state, action) => {
184
+ Object.assign(state, action.payload);
185
+ },
186
+ setUid: (state, action) => {
187
+ state.context.uid = action.payload;
188
+ },
189
+ setAllowCompanies: (state, action) => {
190
+ state.context.allowed_company_ids = action.payload;
191
+ },
192
+ setCompanies: (state, action) => {
193
+ state.companies = action.payload;
194
+ },
195
+ setDefaultCompany: (state, action) => {
196
+ state.defaultCompany = action.payload;
197
+ },
198
+ setLang: (state, action) => {
199
+ state.context.lang = action.payload;
200
+ },
201
+ setUser: (state, action) => {
202
+ state.user = action.payload;
203
+ },
204
+ setEnvFile: (state, action) => {
205
+ state.envFile = action.payload;
206
+ }
207
+ }
208
+ });
209
+ var {
210
+ setEnv,
211
+ setUid,
212
+ setLang,
213
+ setAllowCompanies,
214
+ setCompanies,
215
+ setDefaultCompany,
216
+ setUser,
217
+ setEnvFile
218
+ } = envSlice.actions;
219
+ var env_slice_default = envSlice.reducer;
220
+ var initialState2 = {
221
+ dataParse: null,
222
+ idFile: null,
223
+ isFileLoaded: false,
224
+ loadingImport: false,
225
+ selectedFile: null,
226
+ errorData: null
227
+ };
228
+ var excelSlice = toolkit.createSlice({
229
+ name: "excel",
230
+ initialState: initialState2,
231
+ reducers: {
232
+ setDataParse: (state, action) => {
233
+ state.dataParse = action.payload;
234
+ },
235
+ setIdFile: (state, action) => {
236
+ state.idFile = action.payload;
237
+ },
238
+ setIsFileLoaded: (state, action) => {
239
+ state.isFileLoaded = action.payload;
240
+ },
241
+ setLoadingImport: (state, action) => {
242
+ state.loadingImport = action.payload;
243
+ },
244
+ setSelectedFile: (state, action) => {
245
+ state.selectedFile = action.payload;
246
+ },
247
+ setErrorData: (state, action) => {
248
+ state.errorData = action.payload;
249
+ }
250
+ }
251
+ });
252
+ var {
253
+ setDataParse,
254
+ setIdFile,
255
+ setIsFileLoaded,
256
+ setLoadingImport,
257
+ setSelectedFile,
258
+ setErrorData
259
+ } = excelSlice.actions;
260
+ var excel_slice_default = excelSlice.reducer;
261
+ var initialState3 = {
262
+ viewDataStore: {},
263
+ isShowingModalDetail: false,
264
+ isShowModalTranslate: false,
265
+ formSubmitComponent: {},
266
+ fieldTranslation: null,
267
+ listSubject: {},
268
+ dataUser: {}
269
+ };
270
+ var formSlice = toolkit.createSlice({
271
+ name: "form",
272
+ initialState: initialState3,
273
+ reducers: {
274
+ setViewDataStore: (state, action) => {
275
+ state.viewDataStore = action.payload;
276
+ },
277
+ setIsShowingModalDetail: (state, action) => {
278
+ state.isShowingModalDetail = action.payload;
279
+ },
280
+ setIsShowModalTranslate: (state, action) => {
281
+ state.isShowModalTranslate = action.payload;
282
+ },
283
+ setFormSubmitComponent: (state, action) => {
284
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
285
+ },
286
+ setFieldTranslate: (state, action) => {
287
+ state.fieldTranslation = action.payload;
288
+ },
289
+ setListSubject: (state, action) => {
290
+ state.listSubject = action.payload;
291
+ },
292
+ setDataUser: (state, action) => {
293
+ state.dataUser = action.payload;
294
+ }
295
+ }
296
+ });
297
+ var {
298
+ setViewDataStore,
299
+ setIsShowingModalDetail,
300
+ setIsShowModalTranslate,
301
+ setFormSubmitComponent,
302
+ setFieldTranslate,
303
+ setListSubject,
304
+ setDataUser
305
+ } = formSlice.actions;
306
+ var form_slice_default = formSlice.reducer;
307
+ var initialState4 = {
308
+ pageLimit: 10,
309
+ fields: {},
310
+ order: "",
311
+ selectedRowKeys: [],
312
+ indexRowTableModal: -2,
313
+ footerGroupTable: {},
314
+ page: 0,
315
+ domainTable: []
316
+ };
317
+ var listSlice = toolkit.createSlice({
318
+ name: "list",
319
+ initialState: initialState4,
320
+ reducers: {
321
+ setPageLimit: (state, action) => {
322
+ state.pageLimit = action.payload;
323
+ },
324
+ setFields: (state, action) => {
325
+ state.fields = action.payload;
326
+ },
327
+ setOrder: (state, action) => {
328
+ state.order = action.payload;
329
+ },
330
+ setSelectedRowKeys: (state, action) => {
331
+ state.selectedRowKeys = action.payload;
332
+ },
333
+ setIndexRowTableModal: (state, action) => {
334
+ state.indexRowTableModal = action.payload;
335
+ },
336
+ setPage: (state, action) => {
337
+ state.page = action.payload;
338
+ },
339
+ setDomainTable: (state, action) => {
340
+ state.domainTable = action.payload;
341
+ }
342
+ }
343
+ });
344
+ var {
345
+ setPageLimit,
346
+ setFields,
347
+ setOrder,
348
+ setSelectedRowKeys,
349
+ setIndexRowTableModal,
350
+ setPage,
351
+ setDomainTable
352
+ } = listSlice.actions;
353
+ var list_slice_default = listSlice.reducer;
354
+ var initialState5 = {
355
+ menuList: []
356
+ };
357
+ var navbarSlice = toolkit.createSlice({
358
+ name: "navbar",
359
+ initialState: initialState5,
360
+ reducers: {
361
+ setMenuList: (state, action) => {
362
+ state.menuList = action.payload;
363
+ }
364
+ }
365
+ });
366
+ var { setMenuList } = navbarSlice.actions;
367
+ var navbar_slice_default = navbarSlice.reducer;
368
+ var initialState6 = {
369
+ profile: {}
370
+ };
371
+ var profileSlice = toolkit.createSlice({
372
+ name: "profile",
373
+ initialState: initialState6,
374
+ reducers: {
375
+ setProfile: (state, action) => {
376
+ state.profile = action.payload;
377
+ }
378
+ }
379
+ });
380
+ var { setProfile } = profileSlice.actions;
381
+ var profile_slice_default = profileSlice.reducer;
382
+ var initialState7 = {
383
+ groupByDomain: null,
384
+ tableHead: [],
385
+ searchString: "",
386
+ hoveredIndexSearchList: null,
387
+ selectedTags: [],
388
+ firstDomain: null,
389
+ searchMap: {},
390
+ typeFieldsSearch: "",
391
+ modelSearch: "",
392
+ filterBy: [],
393
+ groupBy: []
394
+ };
395
+ var searchSlice = toolkit.createSlice({
396
+ name: "search",
397
+ initialState: initialState7,
398
+ reducers: {
399
+ setGroupByDomain: (state, action) => {
400
+ state.groupByDomain = action.payload;
401
+ },
402
+ setTableHead: (state, action) => {
403
+ state.tableHead = action.payload;
404
+ },
405
+ setSearchString: (state, action) => {
406
+ state.searchString = action.payload;
407
+ },
408
+ setHoveredIndexSearchList: (state, action) => {
409
+ state.hoveredIndexSearchList = action.payload;
410
+ },
411
+ setSelectedTags: (state, action) => {
412
+ state.selectedTags = action.payload;
413
+ },
414
+ setFirstDomain: (state, action) => {
415
+ state.firstDomain = action.payload;
416
+ },
417
+ setTypeFieldsSearch: (state, action) => {
418
+ state.typeFieldsSearch = action.payload;
419
+ },
420
+ setModelSearch: (state, action) => {
421
+ state.modelSearch = action.payload;
422
+ },
423
+ setFilterBy: (state, action) => {
424
+ state.filterBy = action.payload;
425
+ },
426
+ setGroupBy: (state, action) => {
427
+ state.groupBy = action.payload;
428
+ },
429
+ setSearchMap: (state, action) => {
430
+ state.searchMap = action.payload;
431
+ },
432
+ updateSearchMap: (state, action) => {
433
+ if (!state.searchMap[action.payload.key]) {
434
+ state.searchMap[action.payload.key] = [];
435
+ }
436
+ state.searchMap[action.payload.key].push(action.payload.value);
437
+ },
438
+ removeKeyFromSearchMap: (state, action) => {
439
+ const { key, item } = action.payload;
440
+ const values = state.searchMap[key];
441
+ if (!values) return;
442
+ if (item) {
443
+ const filtered = values.filter((value) => value.name !== item.name);
444
+ if (filtered.length > 0) {
445
+ state.searchMap[key] = filtered;
446
+ } else {
447
+ delete state.searchMap[key];
448
+ }
449
+ } else {
450
+ delete state.searchMap[key];
451
+ }
452
+ },
453
+ clearSearchMap: (state) => {
454
+ state.searchMap = {};
455
+ }
456
+ }
18
457
  });
19
- Object.defineProperty(exports, "UserModel", {
20
- enumerable: true,
21
- get: function () { return chunkOADBRQ4A_js.user_model_default; }
458
+ var {
459
+ setGroupByDomain,
460
+ setSelectedTags,
461
+ setSearchString,
462
+ setHoveredIndexSearchList,
463
+ setFirstDomain,
464
+ setTableHead,
465
+ setFilterBy,
466
+ setTypeFieldsSearch,
467
+ setModelSearch,
468
+ setSearchMap,
469
+ updateSearchMap,
470
+ removeKeyFromSearchMap,
471
+ setGroupBy,
472
+ clearSearchMap
473
+ } = searchSlice.actions;
474
+ var search_slice_default = searchSlice.reducer;
475
+
476
+ // node_modules/redux/dist/redux.mjs
477
+ function formatProdErrorMessage(code) {
478
+ 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. `;
479
+ }
480
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
481
+ var ActionTypes = {
482
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
483
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
484
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
485
+ };
486
+ var actionTypes_default = ActionTypes;
487
+ function isPlainObject(obj) {
488
+ if (typeof obj !== "object" || obj === null)
489
+ return false;
490
+ let proto = obj;
491
+ while (Object.getPrototypeOf(proto) !== null) {
492
+ proto = Object.getPrototypeOf(proto);
493
+ }
494
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
495
+ }
496
+ function miniKindOf(val) {
497
+ if (val === void 0)
498
+ return "undefined";
499
+ if (val === null)
500
+ return "null";
501
+ const type = typeof val;
502
+ switch (type) {
503
+ case "boolean":
504
+ case "string":
505
+ case "number":
506
+ case "symbol":
507
+ case "function": {
508
+ return type;
509
+ }
510
+ }
511
+ if (Array.isArray(val))
512
+ return "array";
513
+ if (isDate(val))
514
+ return "date";
515
+ if (isError(val))
516
+ return "error";
517
+ const constructorName = ctorName(val);
518
+ switch (constructorName) {
519
+ case "Symbol":
520
+ case "Promise":
521
+ case "WeakMap":
522
+ case "WeakSet":
523
+ case "Map":
524
+ case "Set":
525
+ return constructorName;
526
+ }
527
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
528
+ }
529
+ function ctorName(val) {
530
+ return typeof val.constructor === "function" ? val.constructor.name : null;
531
+ }
532
+ function isError(val) {
533
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
534
+ }
535
+ function isDate(val) {
536
+ if (val instanceof Date)
537
+ return true;
538
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
539
+ }
540
+ function kindOf(val) {
541
+ let typeOfVal = typeof val;
542
+ if (process.env.NODE_ENV !== "production") {
543
+ typeOfVal = miniKindOf(val);
544
+ }
545
+ return typeOfVal;
546
+ }
547
+ function warning(message) {
548
+ if (typeof console !== "undefined" && typeof console.error === "function") {
549
+ console.error(message);
550
+ }
551
+ try {
552
+ throw new Error(message);
553
+ } catch (e) {
554
+ }
555
+ }
556
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
557
+ const reducerKeys = Object.keys(reducers);
558
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
559
+ if (reducerKeys.length === 0) {
560
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
561
+ }
562
+ if (!isPlainObject(inputState)) {
563
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
564
+ }
565
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
566
+ unexpectedKeys.forEach((key) => {
567
+ unexpectedKeyCache[key] = true;
568
+ });
569
+ if (action && action.type === actionTypes_default.REPLACE)
570
+ return;
571
+ if (unexpectedKeys.length > 0) {
572
+ 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.`;
573
+ }
574
+ }
575
+ function assertReducerShape(reducers) {
576
+ Object.keys(reducers).forEach((key) => {
577
+ const reducer = reducers[key];
578
+ const initialState8 = reducer(void 0, {
579
+ type: actionTypes_default.INIT
580
+ });
581
+ if (typeof initialState8 === "undefined") {
582
+ 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.`);
583
+ }
584
+ if (typeof reducer(void 0, {
585
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
586
+ }) === "undefined") {
587
+ 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.`);
588
+ }
589
+ });
590
+ }
591
+ function combineReducers(reducers) {
592
+ const reducerKeys = Object.keys(reducers);
593
+ const finalReducers = {};
594
+ for (let i = 0; i < reducerKeys.length; i++) {
595
+ const key = reducerKeys[i];
596
+ if (process.env.NODE_ENV !== "production") {
597
+ if (typeof reducers[key] === "undefined") {
598
+ warning(`No reducer provided for key "${key}"`);
599
+ }
600
+ }
601
+ if (typeof reducers[key] === "function") {
602
+ finalReducers[key] = reducers[key];
603
+ }
604
+ }
605
+ const finalReducerKeys = Object.keys(finalReducers);
606
+ let unexpectedKeyCache;
607
+ if (process.env.NODE_ENV !== "production") {
608
+ unexpectedKeyCache = {};
609
+ }
610
+ let shapeAssertionError;
611
+ try {
612
+ assertReducerShape(finalReducers);
613
+ } catch (e) {
614
+ shapeAssertionError = e;
615
+ }
616
+ return function combination(state = {}, action) {
617
+ if (shapeAssertionError) {
618
+ throw shapeAssertionError;
619
+ }
620
+ if (process.env.NODE_ENV !== "production") {
621
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
622
+ if (warningMessage) {
623
+ warning(warningMessage);
624
+ }
625
+ }
626
+ let hasChanged = false;
627
+ const nextState = {};
628
+ for (let i = 0; i < finalReducerKeys.length; i++) {
629
+ const key = finalReducerKeys[i];
630
+ const reducer = finalReducers[key];
631
+ const previousStateForKey = state[key];
632
+ const nextStateForKey = reducer(previousStateForKey, action);
633
+ if (typeof nextStateForKey === "undefined") {
634
+ const actionType = action && action.type;
635
+ 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.`);
636
+ }
637
+ nextState[key] = nextStateForKey;
638
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
639
+ }
640
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
641
+ return hasChanged ? nextState : state;
642
+ };
643
+ }
644
+
645
+ // src/store/store.ts
646
+ var rootReducer = combineReducers({
647
+ env: env_slice_default,
648
+ navbar: navbar_slice_default,
649
+ list: list_slice_default,
650
+ search: search_slice_default,
651
+ form: form_slice_default,
652
+ excel: excel_slice_default,
653
+ profile: profile_slice_default
22
654
  });
23
- Object.defineProperty(exports, "BaseModel", {
24
- enumerable: true,
25
- get: function () { return chunkFVGPSTJ7_js.base_model_default; }
655
+ var envStore = toolkit.configureStore({
656
+ reducer: rootReducer,
657
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
658
+ serializableCheck: false
659
+ })
26
660
  });
661
+ var MAINT_KEY = "MAINTENANCE_ACTIVE";
662
+ var MAINT_AT = "MAINTENANCE_AT";
663
+ var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
664
+ var hasRedirectedToMaintenance = false;
665
+ function setMaintenanceFlags() {
666
+ if (typeof window === "undefined") return;
667
+ const { pathname, search } = window.location;
668
+ const lastPath = pathname + (search || "");
669
+ if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
670
+ window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
671
+ }
672
+ window.localStorage.setItem(MAINT_KEY, "true");
673
+ window.localStorage.setItem(MAINT_AT, String(Date.now()));
674
+ }
675
+ async function clearMaintenanceAndExit(getToken, opts) {
676
+ if (typeof window === "undefined") return;
677
+ const forceLogin = opts?.forceLogin === true;
678
+ const clearTokenOnForce = opts?.clearTokenOnForce !== false;
679
+ window.localStorage.removeItem(MAINT_KEY);
680
+ window.localStorage.removeItem(MAINT_AT);
681
+ const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
682
+ window.localStorage.removeItem(MAINT_LAST_PATH);
683
+ try {
684
+ if (forceLogin) {
685
+ if (clearTokenOnForce) {
686
+ try {
687
+ await opts?.clearToken?.();
688
+ } catch {
689
+ }
690
+ }
691
+ window.location.replace("/login");
692
+ return;
693
+ }
694
+ const token = await getToken();
695
+ if (token) {
696
+ const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
697
+ window.location.replace(target);
698
+ } else {
699
+ window.location.replace("/login");
700
+ }
701
+ } catch {
702
+ window.location.replace("/login");
703
+ }
704
+ }
705
+ var axiosClient = {
706
+ init(config) {
707
+ const localStorage = config.localStorageUtils;
708
+ const sessionStorage = config.sessionStorageUtils;
709
+ const db = config.db;
710
+ let isRefreshing = false;
711
+ let failedQueue = [];
712
+ const processQueue = (error, token = null) => {
713
+ failedQueue?.forEach((prom) => {
714
+ if (error) {
715
+ prom.reject(error);
716
+ } else {
717
+ prom.resolve(token);
718
+ }
719
+ });
720
+ failedQueue = [];
721
+ };
722
+ const instance = axios__default.default.create({
723
+ adapter: axios__default.default.defaults.adapter,
724
+ baseURL: config.baseUrl,
725
+ timeout: 5e4,
726
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
727
+ });
728
+ if (typeof window !== "undefined") {
729
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
730
+ const onMaintenancePage = window.location.pathname === "/maintenance";
731
+ if (isMaint && !onMaintenancePage) {
732
+ hasRedirectedToMaintenance = true;
733
+ window.location.replace("/maintenance");
734
+ }
735
+ if (isMaint && onMaintenancePage) {
736
+ const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
737
+ (async () => {
738
+ try {
739
+ await axios__default.default.get(healthUrl, { timeout: 8e3 });
740
+ await clearMaintenanceAndExit(() => localStorage.getAccessToken(), {
741
+ forceLogin: true,
742
+ clearTokenOnForce: true,
743
+ clearToken: () => localStorage.clearToken()
744
+ });
745
+ } catch {
746
+ }
747
+ })();
748
+ }
749
+ }
750
+ instance.interceptors.request.use(
751
+ async (configReq) => {
752
+ const token = await localStorage.getAccessToken();
753
+ if (token) {
754
+ configReq.headers["Authorization"] = "Bearer " + token;
755
+ }
756
+ return configReq;
757
+ },
758
+ (error) => Promise.reject(error)
759
+ );
760
+ instance.interceptors.response.use(
761
+ (response) => {
762
+ if (typeof window !== "undefined") {
763
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
764
+ const onMaintenancePage = window.location.pathname === "/maintenance";
765
+ if (isMaint && onMaintenancePage) {
766
+ (async () => {
767
+ await clearMaintenanceAndExit(
768
+ () => localStorage.getAccessToken(),
769
+ {
770
+ forceLogin: true,
771
+ clearTokenOnForce: true,
772
+ clearToken: () => localStorage.clearToken()
773
+ }
774
+ );
775
+ })();
776
+ } else if (isMaint) {
777
+ window.localStorage.removeItem(MAINT_KEY);
778
+ window.localStorage.removeItem(MAINT_AT);
779
+ window.localStorage.removeItem(MAINT_LAST_PATH);
780
+ }
781
+ }
782
+ return handleResponse(response);
783
+ },
784
+ async (error) => {
785
+ const status = error?.response?.status;
786
+ if (status === 503) {
787
+ if (typeof window !== "undefined") {
788
+ setMaintenanceFlags();
789
+ if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
790
+ hasRedirectedToMaintenance = true;
791
+ window.location.replace("/maintenance");
792
+ }
793
+ }
794
+ return Promise.reject({
795
+ code: 503,
796
+ message: "SERVICE_UNAVAILABLE",
797
+ original: error?.response?.data
798
+ });
799
+ }
800
+ const handleError = async (err) => {
801
+ if (!err.response) {
802
+ return err;
803
+ }
804
+ const { data } = err.response;
805
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
806
+ await clearAuthToken();
807
+ }
808
+ return data;
809
+ };
810
+ const originalRequest = error.config;
811
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
812
+ error.response.data.code
813
+ )) {
814
+ if (isRefreshing) {
815
+ return new Promise(function(resolve, reject) {
816
+ failedQueue.push({ resolve, reject });
817
+ }).then((token) => {
818
+ originalRequest.headers["Authorization"] = "Bearer " + token;
819
+ return instance.request(originalRequest);
820
+ }).catch(async (err) => {
821
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
822
+ await clearAuthToken();
823
+ }
824
+ });
825
+ }
826
+ const browserSession = await sessionStorage.getBrowserSession();
827
+ const refreshToken = await localStorage.getRefreshToken();
828
+ const accessTokenExp = await localStorage.getAccessToken();
829
+ isRefreshing = true;
830
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
831
+ await clearAuthToken();
832
+ } else {
833
+ const payload = Object.fromEntries(
834
+ Object.entries({
835
+ refresh_token: refreshToken,
836
+ grant_type: "refresh_token",
837
+ client_id: config.config.clientId,
838
+ client_secret: config.config.clientSecret
839
+ }).filter(([_, value]) => !!value)
840
+ );
841
+ return new Promise(function(resolve) {
842
+ axios__default.default.post(
843
+ `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
844
+ payload,
845
+ {
846
+ headers: {
847
+ "Content-Type": "multipart/form-data",
848
+ Authorization: `Bearer ${accessTokenExp}`
849
+ }
850
+ }
851
+ ).then(async (res) => {
852
+ const data = res.data;
853
+ await localStorage.setToken(data.access_token);
854
+ await localStorage.setRefreshToken(data.refresh_token);
855
+ axios__default.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
856
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
857
+ processQueue(null, data.access_token);
858
+ resolve(instance.request(originalRequest));
859
+ }).catch(async (err) => {
860
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
861
+ await clearAuthToken();
862
+ }
863
+ if (err && err.response) {
864
+ const { error_code } = err.response?.data || {};
865
+ if (error_code === "AUTHEN_FAIL") {
866
+ await clearAuthToken();
867
+ }
868
+ }
869
+ processQueue(err, null);
870
+ }).finally(() => {
871
+ isRefreshing = false;
872
+ });
873
+ });
874
+ }
875
+ }
876
+ return Promise.reject(await handleError(error));
877
+ }
878
+ );
879
+ const handleResponse = (res) => {
880
+ if (res && res.data) {
881
+ return res.data;
882
+ }
883
+ return res;
884
+ };
885
+ const clearAuthToken = async () => {
886
+ await localStorage.clearToken();
887
+ if (typeof window !== "undefined") {
888
+ window.location.href = `/login`;
889
+ }
890
+ };
891
+ function formatUrl(url, db2) {
892
+ return url + (db2 ? "?db=" + db2 : "");
893
+ }
894
+ const responseBody = (response) => response;
895
+ const requests = {
896
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
897
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
898
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
899
+ responseType: "arraybuffer",
900
+ headers: {
901
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
902
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
903
+ }
904
+ }).then(responseBody),
905
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
906
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
907
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
908
+ };
909
+ return requests;
910
+ }
911
+ };
912
+
913
+ // src/environment/EnvStore.ts
914
+ var EnvStore = class {
915
+ envStore;
916
+ baseUrl;
917
+ requests;
918
+ context;
919
+ defaultCompany;
920
+ config;
921
+ companies;
922
+ user;
923
+ db;
924
+ localStorageUtils;
925
+ sessionStorageUtils;
926
+ constructor(envStore2, localStorageUtils, sessionStorageUtils) {
927
+ this.envStore = envStore2;
928
+ this.localStorageUtils = localStorageUtils;
929
+ this.sessionStorageUtils = sessionStorageUtils;
930
+ this.setup();
931
+ }
932
+ setup() {
933
+ const env2 = this.envStore.getState().env;
934
+ this.baseUrl = env2?.baseUrl;
935
+ this.requests = env2?.requests;
936
+ this.context = env2?.context;
937
+ this.defaultCompany = env2?.defaultCompany;
938
+ this.config = env2?.config;
939
+ this.companies = env2?.companies || [];
940
+ this.user = env2?.user;
941
+ this.db = env2?.db;
942
+ }
943
+ setupEnv(envConfig) {
944
+ const dispatch = this.envStore.dispatch;
945
+ const env2 = {
946
+ ...envConfig,
947
+ localStorageUtils: this.localStorageUtils,
948
+ sessionStorageUtils: this.sessionStorageUtils
949
+ };
950
+ const requests = axiosClient.init(env2);
951
+ dispatch(setEnv({ ...env2, requests }));
952
+ this.setup();
953
+ }
954
+ setUid(uid) {
955
+ const dispatch = this.envStore.dispatch;
956
+ dispatch(setUid(uid));
957
+ this.setup();
958
+ }
959
+ setLang(lang) {
960
+ const dispatch = this.envStore.dispatch;
961
+ dispatch(setLang(lang));
962
+ this.setup();
963
+ }
964
+ setAllowCompanies(allowCompanies) {
965
+ const dispatch = this.envStore.dispatch;
966
+ dispatch(setAllowCompanies(allowCompanies));
967
+ this.setup();
968
+ }
969
+ setCompanies(companies) {
970
+ const dispatch = this.envStore.dispatch;
971
+ dispatch(setCompanies(companies));
972
+ this.setup();
973
+ }
974
+ setDefaultCompany(company) {
975
+ const dispatch = this.envStore.dispatch;
976
+ dispatch(setDefaultCompany(company));
977
+ this.setup();
978
+ }
979
+ setUserInfo(userInfo) {
980
+ const dispatch = this.envStore.dispatch;
981
+ dispatch(setUser(userInfo));
982
+ this.setup();
983
+ }
984
+ };
985
+ var env = null;
986
+ function getEnv() {
987
+ if (!env) env = new EnvStore(envStore);
988
+ return env;
989
+ }
990
+
991
+ // src/services/company-service/index.ts
992
+ var CompanyService = {
993
+ async getCurrentCompany() {
994
+ const env2 = getEnv();
995
+ return await env2.requests.get("/company" /* COMPANY_PATH */, {
996
+ headers: {
997
+ "Content-Type": "application/json"
998
+ }
999
+ });
1000
+ },
1001
+ async getInfoCompany(id) {
1002
+ const env2 = getEnv();
1003
+ const jsonData = {
1004
+ ids: [id],
1005
+ model: "res.company" /* COMPANY */,
1006
+ method: "web_read" /* WEB_READ */,
1007
+ kwargs: {
1008
+ specification: {
1009
+ primary_color: {},
1010
+ secondary_color: {},
1011
+ logo: {},
1012
+ display_name: {},
1013
+ secondary_logo: {}
1014
+ }
1015
+ }
1016
+ };
1017
+ return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
1018
+ headers: {
1019
+ "Content-Type": "application/json"
1020
+ }
1021
+ });
1022
+ }
1023
+ };
1024
+ var company_service_default = CompanyService;
1025
+
1026
+ // src/services/user-service/index.ts
1027
+ var UserService = {
1028
+ async getProfile() {
1029
+ const env2 = getEnv();
1030
+ return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
1031
+ headers: {
1032
+ "Content-Type": "application/x-www-form-urlencoded"
1033
+ }
1034
+ });
1035
+ },
1036
+ async getUser({ context, id }) {
1037
+ const env2 = getEnv();
1038
+ const jsonData = {
1039
+ model: "res.users",
1040
+ method: "web_read",
1041
+ ids: [id],
1042
+ with_context: context,
1043
+ kwargs: {
1044
+ specification: {
1045
+ display_name: {},
1046
+ image_1920: {},
1047
+ name: {},
1048
+ login: {},
1049
+ email: {},
1050
+ password: {},
1051
+ visible_group_id: {
1052
+ fields: {
1053
+ id: {},
1054
+ display_name: {}
1055
+ }
1056
+ },
1057
+ company_id: {
1058
+ fields: {
1059
+ id: {},
1060
+ display_name: {}
1061
+ }
1062
+ }
1063
+ }
1064
+ }
1065
+ };
1066
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
1067
+ headers: {
1068
+ "Content-Type": "application/json"
1069
+ }
1070
+ });
1071
+ },
1072
+ switchUserLocale: async ({ id, values }) => {
1073
+ const env2 = getEnv();
1074
+ const jsonData = {
1075
+ model: "res.users",
1076
+ domain: [["id", "=", id]],
1077
+ values
1078
+ };
1079
+ return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
1080
+ headers: {
1081
+ "Content-Type": "application/json"
1082
+ }
1083
+ });
1084
+ }
1085
+ };
1086
+ var user_service_default = UserService;
1087
+
1088
+ // src/models/company-model/index.ts
1089
+ var CompanyModel = class extends base_model_default {
1090
+ constructor(init) {
1091
+ super(init);
1092
+ }
1093
+ async getCurrentCompany() {
1094
+ return await company_service_default.getCurrentCompany();
1095
+ }
1096
+ async getUserCompany(id) {
1097
+ return await company_service_default.getInfoCompany(id);
1098
+ }
1099
+ };
1100
+ var company_model_default = CompanyModel;
1101
+
1102
+ // src/models/user-model/index.ts
1103
+ var UserModel = class extends base_model_default {
1104
+ constructor(init) {
1105
+ super(init);
1106
+ }
1107
+ async getProfile() {
1108
+ return await user_service_default.getProfile();
1109
+ }
1110
+ };
1111
+ var user_model_default = UserModel;
1112
+
1113
+ exports.BaseModel = base_model_default;
1114
+ exports.CompanyModel = company_model_default;
1115
+ exports.UserModel = user_model_default;