@fctc/interface-logic 5.1.0 → 5.1.2

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 (49) hide show
  1. package/dist/chunk-4NLKHYBY.js +131 -0
  2. package/dist/chunk-6LSKTACC.js +687 -0
  3. package/dist/chunk-B432GFRR.mjs +606 -0
  4. package/dist/chunk-BPJZ3QRN.mjs +3025 -0
  5. package/dist/chunk-BZYCE2VA.js +301 -0
  6. package/dist/chunk-FDVY2DBI.mjs +127 -0
  7. package/dist/chunk-GGNOJ77I.js +2 -0
  8. package/dist/chunk-H2VMULTO.mjs +6161 -0
  9. package/dist/chunk-IUYYGSEL.js +321 -0
  10. package/dist/chunk-IVXH2HOR.js +6321 -0
  11. package/dist/chunk-JDXUTKMX.js +3065 -0
  12. package/dist/chunk-JNLBHOL4.mjs +284 -0
  13. package/dist/chunk-MJEZ4MMQ.mjs +315 -0
  14. package/dist/chunk-WAXGOBY2.mjs +1 -0
  15. package/dist/chunk-XA7EW3ZX.mjs +114 -0
  16. package/dist/chunk-YKB32DSB.js +116 -0
  17. package/dist/configs.js +7 -2577
  18. package/dist/configs.mjs +3 -2545
  19. package/dist/constants.d.mts +4 -17
  20. package/dist/constants.d.ts +4 -17
  21. package/dist/constants.js +65 -356
  22. package/dist/constants.mjs +1 -319
  23. package/dist/environment.js +16 -2704
  24. package/dist/environment.mjs +4 -2670
  25. package/dist/hooks.d.mts +19 -95
  26. package/dist/hooks.d.ts +19 -95
  27. package/dist/hooks.js +557 -10420
  28. package/dist/hooks.mjs +6 -10238
  29. package/dist/index.d.mts +2 -1
  30. package/dist/index.d.ts +2 -1
  31. package/dist/index.js +1179 -12656
  32. package/dist/index.mjs +8 -12319
  33. package/dist/models.js +7 -143
  34. package/dist/models.mjs +2 -120
  35. package/dist/provider.d.mts +2 -15
  36. package/dist/provider.d.ts +2 -15
  37. package/dist/provider.js +37 -10968
  38. package/dist/provider.mjs +6 -10936
  39. package/dist/services.d.mts +18 -109
  40. package/dist/services.d.ts +18 -109
  41. package/dist/services.js +40 -8174
  42. package/dist/services.mjs +6 -8142
  43. package/dist/store.js +320 -817
  44. package/dist/store.mjs +1 -717
  45. package/dist/types.js +3 -17
  46. package/dist/types.mjs +1 -0
  47. package/dist/utils.js +134 -3094
  48. package/dist/utils.mjs +2 -3030
  49. package/package.json +93 -92
@@ -0,0 +1,284 @@
1
+ // src/constants/api/key-constant.ts
2
+ var KeyConstants = /* @__PURE__ */ ((KeyConstants2) => {
3
+ KeyConstants2["PROFILE"] = "userinfo";
4
+ KeyConstants2["CURRENT_COMPANY"] = "current_company";
5
+ KeyConstants2["LIST_COMPANY"] = "list_company";
6
+ KeyConstants2["COMPANY_INFO"] = "company_info";
7
+ KeyConstants2["MENU"] = "menus";
8
+ KeyConstants2["GET_VIEW_BY_ACTION"] = "get_view_by_action";
9
+ KeyConstants2["ACTION_DETAIL"] = "action_detail";
10
+ KeyConstants2["GET_DATA_SELECTION"] = "get_data_select";
11
+ KeyConstants2["WEB_SAVE"] = "web_save";
12
+ KeyConstants2["WEB_READ"] = "web_read";
13
+ KeyConstants2["GET_PROVIDER"] = "get_provider";
14
+ return KeyConstants2;
15
+ })(KeyConstants || {});
16
+
17
+ // src/constants/api/method-constant.ts
18
+ var MethodConstants = /* @__PURE__ */ ((MethodConstants2) => {
19
+ MethodConstants2["WEB_SEARCH_READ"] = "web_search_read";
20
+ MethodConstants2["WEB_READ_GROUP"] = "web_read_group";
21
+ MethodConstants2["WEB_READ"] = "web_read";
22
+ MethodConstants2["WEB_SAVE"] = "web_save";
23
+ MethodConstants2["UNLINK"] = "unlink";
24
+ MethodConstants2["ONCHANGE"] = "onchange";
25
+ MethodConstants2["GET_ONCHANGE_FIELDS"] = "get_fields_onchange";
26
+ MethodConstants2["GET_FIELD_VIEW"] = "get_fields_view_v2";
27
+ MethodConstants2["CREATE"] = "create";
28
+ MethodConstants2["LOAD_DATA"] = "load_data";
29
+ MethodConstants2["CHECK"] = "check";
30
+ MethodConstants2["GET_CLOSING_CONTROL_DATA"] = "get_closing_control_data";
31
+ MethodConstants2["GET_PREPARATION_DISPLAY_DATA"] = "get_preparation_display_data";
32
+ MethodConstants2["CHANGE_ORDER_STAGE"] = "change_order_stage";
33
+ MethodConstants2["PROCESS_ORDER"] = "process_order";
34
+ MethodConstants2["CREATE_E_INVOICE"] = "create_e_invoice";
35
+ MethodConstants2["GET_DATA_SELECT"] = "get_data_select";
36
+ MethodConstants2["COMPLETE_CURRENT_STAGE"] = "complete_current_stage";
37
+ return MethodConstants2;
38
+ })(MethodConstants || {});
39
+
40
+ // src/constants/api/uri-constant.ts
41
+ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
42
+ UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
43
+ UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
44
+ UriConstants2["CALL_PATH"] = "/call";
45
+ UriConstants2["COMPANY_PATH"] = "/company";
46
+ UriConstants2["PROFILE_PATH"] = "/userinfo";
47
+ UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
48
+ UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
49
+ UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
50
+ UriConstants2["LOAD_ACTION"] = `/load_action`;
51
+ UriConstants2["REPORT_PATH"] = `/report`;
52
+ UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
53
+ UriConstants2["UPLOAD_FILE_EXCEL_PATH"] = `/upload/file`;
54
+ UriConstants2["UPLOAD_FILE_PATH"] = `/file/upload`;
55
+ UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
56
+ UriConstants2["GET_THREAD_DATA"] = `/mail/thread/data`;
57
+ UriConstants2["GET_THREAD_MESSAGES"] = `/mail/thread/messages`;
58
+ UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
59
+ UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
60
+ UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
61
+ UriConstants2["IMAGE_PATH"] = `/web/image`;
62
+ UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
63
+ UriConstants2["TOKEN"] = `/check_token`;
64
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = `/action-token/validate`;
65
+ UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
66
+ UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
67
+ UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
68
+ UriConstants2["GRANT_ACCESS"] = "/grant-access";
69
+ UriConstants2["TOKEN_BY_CODE"] = "/token";
70
+ UriConstants2["LOGOUT"] = "/logout";
71
+ UriConstants2["CREATE_UPDATE"] = "/create_update";
72
+ UriConstants2["SEARCH_READ"] = "/search_read";
73
+ UriConstants2["CREATE_PATH"] = "/create";
74
+ UriConstants2["TENANT_MAPPING"] = "/tenant-mapping";
75
+ UriConstants2["EMENU_AUTH_TOKEN"] = "/emenu/auth/token";
76
+ UriConstants2["POS_ORDER_STATUS"] = "/pos-order/status";
77
+ UriConstants2["PAYMENT_QR"] = "/payment/qr";
78
+ UriConstants2["POS_DEVICE_PIN"] = "/pos_device/pin";
79
+ UriConstants2["GET_PIN_CODE"] = "/pos_device/get_pin_code";
80
+ UriConstants2["READ_GROUP"] = "/read_group";
81
+ UriConstants2["GET_NOTIFICATION"] = "/mail/data";
82
+ UriConstants2["PUBLIC_USER_INFO"] = "/public/user/info";
83
+ UriConstants2["FUNCTIONAL_MODULES"] = "/functional-modules";
84
+ UriConstants2["ACTION_SERVER_HOME"] = "/action_server_home";
85
+ return UriConstants2;
86
+ })(UriConstants || {});
87
+
88
+ // src/constants/field/field-type-constant.ts
89
+ var FieldTypeConstants = /* @__PURE__ */ ((FieldTypeConstants2) => {
90
+ FieldTypeConstants2["CHAR"] = "char";
91
+ FieldTypeConstants2["TEXT"] = "text";
92
+ FieldTypeConstants2["INTEGER"] = "integer";
93
+ FieldTypeConstants2["FLOAT"] = "float";
94
+ FieldTypeConstants2["BOOLEAN"] = "boolean";
95
+ FieldTypeConstants2["DATE"] = "date";
96
+ FieldTypeConstants2["DATETIME"] = "datetime";
97
+ FieldTypeConstants2["BINARY"] = "binary";
98
+ FieldTypeConstants2["SELECTION"] = "selection";
99
+ FieldTypeConstants2["HTML"] = "html";
100
+ FieldTypeConstants2["MANY2ONE"] = "many2one";
101
+ FieldTypeConstants2["ONE2MANY"] = "one2many";
102
+ FieldTypeConstants2["MANY2MANY"] = "many2many";
103
+ FieldTypeConstants2["MONETARY"] = "monetary";
104
+ FieldTypeConstants2["REFERENCE"] = "reference";
105
+ FieldTypeConstants2["FUNCTION"] = "function";
106
+ FieldTypeConstants2["PROPERTY"] = "property";
107
+ return FieldTypeConstants2;
108
+ })(FieldTypeConstants || {});
109
+
110
+ // src/constants/method/method-type-constant.ts
111
+ var MethodType = /* @__PURE__ */ ((MethodType2) => {
112
+ MethodType2[MethodType2["CREATE"] = 0] = "CREATE";
113
+ MethodType2[MethodType2["UPDATE"] = 1] = "UPDATE";
114
+ MethodType2[MethodType2["DELETE"] = 2] = "DELETE";
115
+ MethodType2[MethodType2["UNLINK"] = 3] = "UNLINK";
116
+ MethodType2[MethodType2["NO_CHANGE"] = 4] = "NO_CHANGE";
117
+ return MethodType2;
118
+ })(MethodType || {});
119
+
120
+ // src/constants/model/model-constant.ts
121
+ var ModelConstants = /* @__PURE__ */ ((ModelConstants2) => {
122
+ ModelConstants2["MENU"] = "ir.ui.menu";
123
+ ModelConstants2["USER"] = "res.users";
124
+ ModelConstants2["COMPANY"] = "res.company";
125
+ ModelConstants2["WINDOW_ACTION"] = "ir.actions.act_window";
126
+ ModelConstants2["BASE_IMPORT"] = "base_import.import";
127
+ ModelConstants2["GET_IMPORT"] = "get_import_templates";
128
+ ModelConstants2["POS_PREPARATION_DISPLAY"] = "pos_preparation_display.display";
129
+ ModelConstants2["POS_PREPARATION_ORDER"] = "pos_preparation_display.order";
130
+ ModelConstants2["POS_PREPARATION_ORDER_LINE"] = "pos_preparation_display.orderline";
131
+ ModelConstants2["POS_ORDER"] = "pos.order";
132
+ ModelConstants2["COUNTRY"] = "res.country";
133
+ ModelConstants2["COUNTRY_STATE"] = "res.country.state";
134
+ ModelConstants2["COUNTRY_WARD"] = "res.country.ward";
135
+ ModelConstants2["RES_PARTNER_TITLE"] = "res.partner.title";
136
+ return ModelConstants2;
137
+ })(ModelConstants || {});
138
+ var LoadDataModel = /* @__PURE__ */ ((LoadDataModel2) => {
139
+ LoadDataModel2["ACCOUNT_CASH_ROUNDING"] = "account.cash.rounding";
140
+ LoadDataModel2["ACCOUNT_FISCAL_POSITION"] = "account.fiscal.position";
141
+ LoadDataModel2["ACCOUNT_FISCAL_POSITION_TAX"] = "account.fiscal.position.tax";
142
+ LoadDataModel2["ACCOUNT_TAX"] = "account.tax";
143
+ LoadDataModel2["ACCOUNT_TAX_GROUP"] = "account.tax.group";
144
+ LoadDataModel2["DECIMAL_PRECISION"] = "decimal.precision";
145
+ LoadDataModel2["IR_MODULE_MODULE"] = "ir.module.module";
146
+ LoadDataModel2["IR_UI_VIEW"] = "ir.ui.view";
147
+ LoadDataModel2["POS_BILL"] = "pos.bill";
148
+ LoadDataModel2["POS_CATEGORY"] = "pos.category";
149
+ LoadDataModel2["POS_CONFIG"] = "pos.config";
150
+ LoadDataModel2["POS_NOTE"] = "pos.note";
151
+ LoadDataModel2["POS_ORDER"] = "pos.order";
152
+ LoadDataModel2["POS_ORDER_LINE"] = "pos.order.line";
153
+ LoadDataModel2["POS_PACK_OPERATION_LOT"] = "pos.pack.operation.lot";
154
+ LoadDataModel2["POS_PAYMENT"] = "pos.payment";
155
+ LoadDataModel2["POS_PAYMENT_METHOD"] = "pos.payment.method";
156
+ LoadDataModel2["POS_PRINTER"] = "pos.printer";
157
+ LoadDataModel2["POS_SESSION"] = "pos.session";
158
+ LoadDataModel2["POS_PREPARATION_DISPLAY_DISPLAY"] = "pos_preparation_display.display";
159
+ LoadDataModel2["PRODUCT_ATTRIBUTE"] = "product.attribute";
160
+ LoadDataModel2["PRODUCT_ATTRIBUTE_CUSTOM_VALUE"] = "product.attribute.custom.value";
161
+ LoadDataModel2["PRODUCT_CATEGORY"] = "product.category";
162
+ LoadDataModel2["PRODUCT_COMBO"] = "product.combo";
163
+ LoadDataModel2["PRODUCT_COMBO_ITEM"] = "product.combo.item";
164
+ LoadDataModel2["PRODUCT_PACKAGING"] = "product.packaging";
165
+ LoadDataModel2["PRODUCT_PRICELIST"] = "product.pricelist";
166
+ LoadDataModel2["PRODUCT_PRICELIST_ITEM"] = "product.pricelist.item";
167
+ LoadDataModel2["PRODUCT_PRODUCT"] = "product.product";
168
+ LoadDataModel2["PRODUCT_TAG"] = "product.tag";
169
+ LoadDataModel2["PRODUCT_TEMPLATE_ATTRIBUTE_LINE"] = "product.template.attribute.line";
170
+ LoadDataModel2["PRODUCT_TEMPLATE_ATTRIBUTE_VALUE"] = "product.template.attribute.value";
171
+ LoadDataModel2["RES_COMPANY"] = "res.company";
172
+ LoadDataModel2["RES_COUNTRY"] = "res.country";
173
+ LoadDataModel2["RES_COUNTRY_STATE"] = "res.country.state";
174
+ LoadDataModel2["RES_CURRENCY"] = "res.currency";
175
+ LoadDataModel2["RES_LANG"] = "res.lang";
176
+ LoadDataModel2["RES_PARTNER"] = "res.partner";
177
+ LoadDataModel2["RES_USERS"] = "res.users";
178
+ LoadDataModel2["STOCK_PICKING_TYPE"] = "stock.picking.type";
179
+ LoadDataModel2["UOM_CATEGORY"] = "uom.category";
180
+ LoadDataModel2["UOM_UOM"] = "uom.uom";
181
+ LoadDataModel2["LOYALTY_PROGRAM"] = "loyalty.program";
182
+ LoadDataModel2["LOYALTY_RULE"] = "loyalty.rule";
183
+ LoadDataModel2["LOYALTY_REWARD"] = "loyalty.reward";
184
+ LoadDataModel2["RESTAURANT_TABLE"] = "restaurant.table";
185
+ LoadDataModel2["RESTAURANT_FLOOR"] = "restaurant.floor";
186
+ LoadDataModel2["POS_MAKE_PAYMENT"] = "pos.make.payment";
187
+ return LoadDataModel2;
188
+ })(LoadDataModel || {});
189
+ var LoadDataModelSupa = /* @__PURE__ */ ((LoadDataModelSupa2) => {
190
+ LoadDataModelSupa2["ACCOUNT_TAXES"] = "account_taxes";
191
+ LoadDataModelSupa2["COMPANIES"] = "companies";
192
+ LoadDataModelSupa2["CUSTOMERS"] = "customers";
193
+ LoadDataModelSupa2["EMPLOYEES"] = "employees";
194
+ LoadDataModelSupa2["LOYALTY_PROGRAMS"] = "loyalty_programs";
195
+ LoadDataModelSupa2["LOYALTY_REWARDS"] = "loyalty_rewards";
196
+ LoadDataModelSupa2["LOYALTY_RULES"] = "loyalty_rules";
197
+ LoadDataModelSupa2["ORDER_LINE"] = "order_line";
198
+ LoadDataModelSupa2["ORDERS"] = "orders";
199
+ LoadDataModelSupa2["PAYMENT_METHODS"] = "payment_methods";
200
+ LoadDataModelSupa2["PAYMENTS"] = "payments";
201
+ LoadDataModelSupa2["POS_CONFIGS"] = "pos_configs";
202
+ LoadDataModelSupa2["POS_SESSIONS"] = "pos_sessions";
203
+ LoadDataModelSupa2["POS_CATEGORIES"] = "pos_categories";
204
+ LoadDataModelSupa2["PRODUCTS"] = "products";
205
+ LoadDataModelSupa2["PRODUCT_ATTRIBUTES"] = "product_attributes";
206
+ LoadDataModelSupa2["PRODUCT_ATTRIBUTE_VALUES"] = "product_attribute_values";
207
+ LoadDataModelSupa2["PRODUCT_TEMPLATES"] = "product_templates";
208
+ LoadDataModelSupa2["PRODUCT_TEMPLATE_ATTRIBUTE_LINES"] = "product_template_attribute_lines";
209
+ LoadDataModelSupa2["PRODUCT_TEMPLATE_ATTRIBUTE_VALUES"] = "product_template_attribute_values";
210
+ LoadDataModelSupa2["RESTAURANT_FLOORS"] = "restaurant_floors";
211
+ LoadDataModelSupa2["RESTAURANT_TABLES"] = "restaurant_tables";
212
+ return LoadDataModelSupa2;
213
+ })(LoadDataModelSupa || {});
214
+ var MODEL_TO_TABLE = {
215
+ ["account.tax" /* ACCOUNT_TAX */]: "account_taxes" /* ACCOUNT_TAXES */,
216
+ ["res.company" /* RES_COMPANY */]: "companies" /* COMPANIES */,
217
+ ["res.partner" /* RES_PARTNER */]: "customers" /* CUSTOMERS */,
218
+ ["res.users" /* RES_USERS */]: "employees" /* EMPLOYEES */,
219
+ ["loyalty.program" /* LOYALTY_PROGRAM */]: "loyalty_programs" /* LOYALTY_PROGRAMS */,
220
+ ["loyalty.rule" /* LOYALTY_RULE */]: "loyalty_rules" /* LOYALTY_RULES */,
221
+ ["loyalty.reward" /* LOYALTY_REWARD */]: "loyalty_rewards" /* LOYALTY_REWARDS */,
222
+ ["pos.config" /* POS_CONFIG */]: "pos_configs" /* POS_CONFIGS */,
223
+ ["pos.session" /* POS_SESSION */]: "pos_sessions" /* POS_SESSIONS */,
224
+ ["pos.order.line" /* POS_ORDER_LINE */]: "order_line" /* ORDER_LINE */,
225
+ ["pos.order" /* POS_ORDER */]: "orders" /* ORDERS */,
226
+ ["pos.payment.method" /* POS_PAYMENT_METHOD */]: "payment_methods" /* PAYMENT_METHODS */,
227
+ ["pos.payment" /* POS_PAYMENT */]: "payments" /* PAYMENTS */,
228
+ ["pos.category" /* POS_CATEGORY */]: "pos_categories" /* POS_CATEGORIES */,
229
+ ["product.product" /* PRODUCT_PRODUCT */]: "products" /* PRODUCTS */,
230
+ ["restaurant.floor" /* RESTAURANT_FLOOR */]: "restaurant_floors" /* RESTAURANT_FLOORS */,
231
+ ["restaurant.table" /* RESTAURANT_TABLE */]: "restaurant_tables" /* RESTAURANT_TABLES */
232
+ };
233
+
234
+ // src/constants/type/index.ts
235
+ var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
236
+ ComponentType2["GROUP"] = "group";
237
+ ComponentType2["FIELD"] = "field";
238
+ ComponentType2["TREE"] = "tree";
239
+ ComponentType2["DIV"] = "div";
240
+ ComponentType2["LIST"] = "list";
241
+ ComponentType2["FORM"] = "form";
242
+ ComponentType2["SETTINGS"] = "setting";
243
+ ComponentType2["SPAN"] = "span";
244
+ ComponentType2["KANBAN"] = "kanban";
245
+ ComponentType2["CALENDAR"] = "calendar";
246
+ ComponentType2["TYPE"] = "view-type";
247
+ return ComponentType2;
248
+ })(ComponentType || {});
249
+ var SearchType = {
250
+ FILTER: "filter_by",
251
+ SEARCH: "search_by",
252
+ GROUP: "group_by"
253
+ };
254
+
255
+ // src/constants/widget/widget-avatar-constant.ts
256
+ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
257
+ WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
258
+ WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
259
+ return WIDGETAVATAR2;
260
+ })(WIDGETAVATAR || {});
261
+ var WIDGETCURRENCY = /* @__PURE__ */ ((WIDGETCURRENCY2) => {
262
+ WIDGETCURRENCY2["many2one_avatar_user"] = "many2one_avatar_user";
263
+ WIDGETCURRENCY2["many2many_avatar_user"] = "many2many_avatar_user";
264
+ return WIDGETCURRENCY2;
265
+ })(WIDGETCURRENCY || {});
266
+
267
+ // src/constants/widget/widget-color-constant.ts
268
+ var WIDGETCOLOR = /* @__PURE__ */ ((WIDGETCOLOR2) => {
269
+ WIDGETCOLOR2["many2many_tags"] = "many2many_tags";
270
+ WIDGETCOLOR2["helpdesk_sla_many2many_tags"] = "helpdesk_sla_many2many_tags";
271
+ return WIDGETCOLOR2;
272
+ })(WIDGETCOLOR || {});
273
+
274
+ // src/constants/widget/widget-status-constant.ts
275
+ var WIDGETSTATUS = /* @__PURE__ */ ((WIDGETSTATUS2) => {
276
+ WIDGETSTATUS2["sla_status_ids"] = "sla_status_ids";
277
+ return WIDGETSTATUS2;
278
+ })(WIDGETSTATUS || {});
279
+ var WIDGETNOSTRING = /* @__PURE__ */ ((WIDGETNOSTRING2) => {
280
+ WIDGETNOSTRING2["sla_status_ids"] = "sla_status_ids";
281
+ return WIDGETNOSTRING2;
282
+ })(WIDGETNOSTRING || {});
283
+
284
+ export { ComponentType, FieldTypeConstants, KeyConstants, LoadDataModel, LoadDataModelSupa, MODEL_TO_TABLE, MethodConstants, MethodType, ModelConstants, SearchType, UriConstants, WIDGETAVATAR, WIDGETCOLOR, WIDGETCURRENCY, WIDGETNOSTRING, WIDGETSTATUS };
@@ -0,0 +1,315 @@
1
+ import { localStorageUtils, sessionStorageUtils, updateTokenParamInOriginalRequest } from './chunk-BPJZ3QRN.mjs';
2
+ import axios from 'axios';
3
+
4
+ function removeLanguages(acceptLang, removeList) {
5
+ return acceptLang.split(",").map((x) => x.trim()).filter((item) => !removeList?.some((lang) => item?.startsWith(lang))).join(",");
6
+ }
7
+ var axiosClient = {
8
+ init(config) {
9
+ const localStorage = config?.localStorageUtils ?? localStorageUtils();
10
+ const sessionStorage = config?.sessionStorageUtils ?? sessionStorageUtils;
11
+ const db = config?.db;
12
+ const database = config?.config?.database;
13
+ let isRefreshing = false;
14
+ let failedQueue = [];
15
+ const processQueue = (error, token = null) => {
16
+ failedQueue?.forEach((prom) => {
17
+ if (error) {
18
+ prom.reject(error);
19
+ } else {
20
+ prom.resolve(token);
21
+ }
22
+ });
23
+ failedQueue = [];
24
+ };
25
+ const instance = axios.create({
26
+ adapter: axios.defaults.adapter,
27
+ baseURL: config?.baseUrl,
28
+ timeout: 5e4,
29
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
30
+ });
31
+ instance.interceptors.request.use(async (configReq) => {
32
+ const rawLang = navigator.languages?.join(",") || navigator.language;
33
+ const useRefreshToken = configReq.headers["X-Use-Refresh-Token"] === "true";
34
+ const useActionToken = configReq.headers["X-Use-Action-Token"] === "true";
35
+ const actionToken = configReq.headers["X-Action-Token"];
36
+ const cleaned = removeLanguages(rawLang, config?.excludeLanguages);
37
+ let token = null;
38
+ if (useActionToken && actionToken) {
39
+ token = actionToken;
40
+ } else {
41
+ const getToken = useRefreshToken ? localStorage.getRefreshToken : localStorage.getAccessToken;
42
+ token = await getToken?.();
43
+ }
44
+ if (token) {
45
+ configReq.headers["Authorization"] = `Bearer ${token}`;
46
+ }
47
+ if (database) {
48
+ configReq.headers["DATABASE"] = database;
49
+ }
50
+ configReq.headers["Accept-Language"] = cleaned;
51
+ return configReq;
52
+ }, Promise.reject);
53
+ const buildRefreshUrl = () => {
54
+ if (!config.refreshTokenEndpoint) {
55
+ return `${getBaseUrl(config?.baseUrl)}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`;
56
+ }
57
+ const ep = String(config.refreshTokenEndpoint);
58
+ if (/^https?:\/\//i.test(ep)) return ep;
59
+ const cleanBase = String(config?.baseUrl || "").replace(/\/$/, "");
60
+ const cleanEp = ep.startsWith("/") ? ep : `/${ep}`;
61
+ return `${cleanBase}${cleanEp}`;
62
+ };
63
+ instance.interceptors.response.use(
64
+ (response) => handleResponse(response),
65
+ async (error) => {
66
+ const handleError2 = async (err) => {
67
+ if (!err.response) return err;
68
+ const { data } = err.response;
69
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
70
+ await clearAuthToken();
71
+ }
72
+ return data;
73
+ };
74
+ const originalRequest = error.config;
75
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
76
+ error.response.data.code
77
+ )) {
78
+ if (isRefreshing) {
79
+ return new Promise(function(resolve, reject) {
80
+ failedQueue.push({ resolve, reject });
81
+ }).then((newToken) => {
82
+ originalRequest.headers["Authorization"] = "Bearer " + newToken;
83
+ originalRequest.data = updateTokenParamInOriginalRequest(
84
+ originalRequest,
85
+ newToken
86
+ );
87
+ return instance.request(originalRequest);
88
+ }).catch(async (err) => {
89
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
90
+ await clearAuthToken();
91
+ }
92
+ });
93
+ }
94
+ const browserSession = await sessionStorage.getBrowserSession();
95
+ const refreshToken = await localStorage.getRefreshToken();
96
+ const accessTokenExp = await localStorage.getAccessToken();
97
+ isRefreshing = true;
98
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
99
+ await clearAuthToken();
100
+ } else {
101
+ const payload = Object.fromEntries(
102
+ Object.entries({
103
+ refresh_token: refreshToken,
104
+ grant_type: "refresh_token",
105
+ client_id: config.config.clientId,
106
+ client_secret: config.config.clientSecret
107
+ }).filter(([_, v]) => !!v)
108
+ );
109
+ const refreshUrl = buildRefreshUrl();
110
+ return new Promise(function(resolve) {
111
+ axios.post(refreshUrl, payload, {
112
+ headers: {
113
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
114
+ Authorization: `Bearer ${accessTokenExp}`
115
+ }
116
+ }).then(async (res) => {
117
+ const data = res.data;
118
+ await localStorage.setToken(data.access_token);
119
+ await localStorage.setRefreshToken(data.refresh_token);
120
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
121
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
122
+ originalRequest.data = updateTokenParamInOriginalRequest(
123
+ originalRequest,
124
+ data.access_token
125
+ );
126
+ processQueue(null, data.access_token);
127
+ resolve(instance.request(originalRequest));
128
+ }).catch(async (err) => {
129
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_2FA_006")) {
130
+ await clearAuthToken();
131
+ }
132
+ if (err && err.response) {
133
+ const { error_code } = err.response?.data || {};
134
+ const { code } = err;
135
+ if (error_code === "AUTHEN_FAIL" || code === "ERR_2FA_006") {
136
+ await clearAuthToken();
137
+ }
138
+ }
139
+ processQueue(err, null);
140
+ }).finally(() => {
141
+ isRefreshing = false;
142
+ });
143
+ });
144
+ }
145
+ }
146
+ return Promise.reject(await handleError2(error));
147
+ }
148
+ );
149
+ instance.interceptors.response.use(
150
+ (response) => {
151
+ return handleResponse(response);
152
+ },
153
+ async (error) => {
154
+ const handleError2 = async (error2) => {
155
+ if (!error2.response) {
156
+ return error2;
157
+ }
158
+ const { data } = error2.response;
159
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
160
+ await clearAuthToken();
161
+ }
162
+ return data;
163
+ };
164
+ const originalRequest = error.config;
165
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
166
+ error.response.data.code
167
+ )) {
168
+ if (isRefreshing) {
169
+ return new Promise(function(resolve, reject) {
170
+ failedQueue.push({ resolve, reject });
171
+ }).then((token) => {
172
+ originalRequest.headers["Authorization"] = "Bearer " + token;
173
+ originalRequest.data = updateTokenParamInOriginalRequest(
174
+ originalRequest,
175
+ token
176
+ );
177
+ return instance.request(originalRequest);
178
+ }).catch(async (err) => {
179
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
180
+ await clearAuthToken();
181
+ }
182
+ });
183
+ }
184
+ const browserSession = await sessionStorage.getBrowserSession();
185
+ const refreshToken = await localStorage.getRefreshToken();
186
+ const accessTokenExp = await localStorage.getAccessToken();
187
+ isRefreshing = true;
188
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
189
+ await clearAuthToken();
190
+ } else {
191
+ const payload = Object.fromEntries(
192
+ Object.entries({
193
+ refresh_token: refreshToken,
194
+ grant_type: "refresh_token",
195
+ client_id: config.config.clientId,
196
+ client_secret: config.config.clientSecret
197
+ }).filter(([_, value]) => !!value)
198
+ );
199
+ return new Promise(function(resolve) {
200
+ axios.post(
201
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
202
+ payload,
203
+ {
204
+ headers: {
205
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
206
+ Authorization: `Bearer ${accessTokenExp}`
207
+ }
208
+ }
209
+ ).then(async (res) => {
210
+ const data = res.data;
211
+ await localStorage.setToken(data.access_token);
212
+ await localStorage.setRefreshToken(data.refresh_token);
213
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
214
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
215
+ originalRequest.data = updateTokenParamInOriginalRequest(
216
+ originalRequest,
217
+ data.access_token
218
+ );
219
+ processQueue(null, data.access_token);
220
+ resolve(instance.request(originalRequest));
221
+ }).catch(async (err) => {
222
+ console.log("catch error: ", err);
223
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_2FA_006")) {
224
+ await clearAuthToken();
225
+ }
226
+ if (err && err.response) {
227
+ console.log("err response code: ", err);
228
+ console.log("err response: ", err.response);
229
+ const { error_code } = err.response?.data || {};
230
+ const { code } = err;
231
+ if (error_code === "AUTHEN_FAIL" || code === "ERR_2FA_006") {
232
+ await clearAuthToken();
233
+ }
234
+ }
235
+ processQueue(err, null);
236
+ }).finally(() => {
237
+ isRefreshing = false;
238
+ });
239
+ });
240
+ }
241
+ }
242
+ return Promise.reject(await handleError2(error));
243
+ }
244
+ );
245
+ const handleResponse = (res) => {
246
+ if (res && res.data) {
247
+ return res.data;
248
+ }
249
+ return res;
250
+ };
251
+ const clearAuthToken = async () => {
252
+ await localStorage.clearToken();
253
+ if (typeof window !== "undefined") {
254
+ window.location.href = `/login`;
255
+ }
256
+ };
257
+ function formatUrl(url, db2) {
258
+ return url + (db2 ? "?db=" + db2 : "");
259
+ }
260
+ const getBaseUrl = (baseUrl, hardService) => {
261
+ return `${baseUrl.replace(/\/$/, "")}/${hardService || sessionStorage.getMenuFocus().service || config?.default_service}/api/v2`;
262
+ };
263
+ const getHeaders = (header) => {
264
+ const headers = {
265
+ headers: {
266
+ ...header.headers,
267
+ ...sessionStorage.getXNode() ? { "X-Node": sessionStorage.getXNode() } : {}
268
+ }
269
+ };
270
+ return headers;
271
+ };
272
+ const responseBody = (response) => response;
273
+ const requests = {
274
+ get: (url, headers, hardService) => instance.get(
275
+ formatUrl(getBaseUrl(config?.baseUrl, hardService) + url, db),
276
+ getHeaders(headers)
277
+ ).then(responseBody),
278
+ post: async (url, body, headers, hardService) => instance.post(
279
+ formatUrl(getBaseUrl(config?.baseUrl, hardService) + url, db),
280
+ body,
281
+ getHeaders(headers)
282
+ ).then(responseBody),
283
+ post_excel: (url, body, headers, hardService) => instance.post(
284
+ formatUrl(getBaseUrl(config?.baseUrl, hardService) + url, db),
285
+ body,
286
+ {
287
+ responseType: "arraybuffer",
288
+ headers: {
289
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
290
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
291
+ ...headers,
292
+ ...sessionStorage.getXNode() ? { "X-Node": sessionStorage.getXNode() } : {}
293
+ }
294
+ }
295
+ ).then(responseBody),
296
+ put: (url, body, headers, hardService) => instance.put(
297
+ formatUrl(getBaseUrl(config?.baseUrl, hardService) + url, db),
298
+ body,
299
+ getHeaders(headers)
300
+ ).then(responseBody),
301
+ patch: (url, body, headers, hardService) => instance.patch(
302
+ formatUrl(getBaseUrl(config?.baseUrl, hardService) + url, db),
303
+ body,
304
+ getHeaders(headers)
305
+ ).then(responseBody),
306
+ delete: (url, headers, hardService) => instance.delete(
307
+ formatUrl(getBaseUrl(config?.baseUrl, hardService) + url, db),
308
+ getHeaders(headers)
309
+ ).then(responseBody)
310
+ };
311
+ return requests;
312
+ }
313
+ };
314
+
315
+ export { axiosClient };
@@ -0,0 +1 @@
1
+