@fctc/edu-logic-lib 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hooks.mjs CHANGED
@@ -1,37 +1,10 @@
1
- import { useMutation, useQuery } from '@tanstack/react-query';
1
+ import { useMutation } from '@tanstack/react-query';
2
2
  import 'react-redux';
3
3
  import { createSlice, configureStore } from '@reduxjs/toolkit';
4
4
  import axios from 'axios';
5
- import React, { useEffect } from 'react';
5
+ import 'react';
6
6
 
7
7
  // src/hooks/auth/use-forgot-password.ts
8
-
9
- // src/constants/api/uri-constant.ts
10
- var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
11
- UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
12
- UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
13
- UriConstants2["CALL_PATH"] = "/call";
14
- UriConstants2["COMPANY_PATH"] = "/company";
15
- UriConstants2["PROFILE_PATH"] = "/userinfo";
16
- UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
17
- UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
18
- UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
19
- UriConstants2["LOAD_ACTION"] = `/load_action`;
20
- UriConstants2["REPORT_PATH"] = `/report`;
21
- UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
22
- UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
23
- UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
24
- UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
25
- UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
26
- UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
27
- UriConstants2["IMAGE_PATH"] = `/web/image`;
28
- UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
29
- UriConstants2["TOKEN"] = `/check_token`;
30
- UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
31
- UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
32
- UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
33
- return UriConstants2;
34
- })(UriConstants || {});
35
8
  var initialState = {
36
9
  baseUrl: "",
37
10
  requests: null,
@@ -2634,34 +2607,6 @@ function parseExpr(expr) {
2634
2607
  const tokens = tokenize(expr);
2635
2608
  return parse(tokens);
2636
2609
  }
2637
- function evaluateExpr(expr, context = {}) {
2638
- let ast;
2639
- try {
2640
- ast = parseExpr(expr);
2641
- } catch (error) {
2642
- throw new EvalError(
2643
- `Can not parse python expression: (${expr})
2644
- Error: ${error.message}`
2645
- );
2646
- }
2647
- try {
2648
- return evaluate(ast, context);
2649
- } catch (error) {
2650
- throw new EvalError(
2651
- `Can not evaluate python expression: (${expr})
2652
- Error: ${error.message}`
2653
- );
2654
- }
2655
- }
2656
- function evaluateBooleanExpr(expr, context = {}) {
2657
- if (!expr || expr === "False" || expr === "0") {
2658
- return false;
2659
- }
2660
- if (expr === "True" || expr === "1") {
2661
- return true;
2662
- }
2663
- return evaluateExpr(`bool(${expr})`, context);
2664
- }
2665
2610
 
2666
2611
  // src/utils/domain/objects.ts
2667
2612
  function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
@@ -2999,38 +2944,6 @@ function matchDomain(record, domain) {
2999
2944
  }
3000
2945
  return matchCondition(record, condStack.pop());
3001
2946
  }
3002
- var checkDomain = (context, domain) => {
3003
- try {
3004
- if (domain === void 0 || domain === "0" || domain === "False" || domain === false) {
3005
- return false;
3006
- } else if (domain === "1" || domain === "True" || domain === true) {
3007
- return true;
3008
- }
3009
- try {
3010
- if (context && domain) {
3011
- const d = new Domain(domain);
3012
- return d.contains(context);
3013
- }
3014
- } catch (error) {
3015
- if (context && domain) {
3016
- const domainEval = evaluateBooleanExpr(domain, context);
3017
- return domainEval;
3018
- }
3019
- return false;
3020
- }
3021
- return false;
3022
- } catch (e) {
3023
- return false;
3024
- }
3025
- };
3026
- var matchDomains = (context, domains) => {
3027
- if (Array.isArray(domains)) {
3028
- if (domains?.length > 0) {
3029
- return domains && domains.some((domain) => checkDomain(context, domain));
3030
- }
3031
- } else return checkDomain(context, domains);
3032
- return false;
3033
- };
3034
2947
 
3035
2948
  // src/utils/function.ts
3036
2949
  var toQueryString = (params) => {
@@ -3038,21 +2951,6 @@ var toQueryString = (params) => {
3038
2951
  (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
3039
2952
  ).join("&");
3040
2953
  };
3041
- var isBase64File = (str) => {
3042
- try {
3043
- const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
3044
- if (dataUriPattern.test(str)) {
3045
- return true;
3046
- }
3047
- const base64Pattern = (
3048
- // eslint-disable-next-line no-useless-escape
3049
- /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
3050
- );
3051
- return base64Pattern.test(str);
3052
- } catch (e) {
3053
- return false;
3054
- }
3055
- };
3056
2954
 
3057
2955
  // src/services/action-service/index.ts
3058
2956
  var ActionService = {
@@ -3170,1645 +3068,20 @@ var ActionService = {
3170
3068
  }
3171
3069
  };
3172
3070
  var action_service_default = ActionService;
3173
-
3174
- // src/services/auth-service/index.ts
3175
- var AuthService = {
3176
- async login(body) {
3177
- const env2 = getEnv();
3178
- const payload = Object.fromEntries(
3179
- Object.entries({
3180
- username: body.email,
3181
- password: body.password,
3182
- grant_type: env2?.config?.grantType || "",
3183
- client_id: env2?.config?.clientId || "",
3184
- client_secret: env2?.config?.clientSecret || ""
3185
- }).filter(([_, value]) => !!value)
3186
- );
3187
- const encodedData = new URLSearchParams(payload).toString();
3188
- return env2?.requests?.post(body.path, encodedData, {
3189
- headers: {
3190
- "Content-Type": "application/x-www-form-urlencoded"
3191
- }
3192
- });
3193
- },
3194
- async forgotPassword(email) {
3195
- const env2 = getEnv();
3196
- const bodyData = {
3197
- login: email,
3198
- url: `${window.location.origin}/reset-password`
3199
- };
3200
- return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3201
- headers: {
3202
- "Content-Type": "application/json"
3203
- }
3204
- });
3205
- },
3206
- async resetPassword(data, token) {
3207
- const env2 = getEnv();
3208
- const bodyData = {
3209
- token,
3210
- password: data.password,
3211
- new_password: data.confirmPassword
3212
- };
3213
- return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3214
- headers: {
3215
- "Content-Type": "application/json"
3216
- }
3217
- });
3218
- },
3219
- async updatePassword(data, token) {
3220
- const env2 = getEnv();
3221
- const bodyData = {
3222
- token,
3223
- old_password: data.oldPassword,
3224
- new_password: data.newPassword
3225
- };
3226
- return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3227
- headers: {
3228
- "Content-Type": "application/json"
3229
- }
3230
- });
3231
- },
3232
- async isValidToken(token) {
3233
- const env2 = getEnv();
3234
- const bodyData = {
3235
- token
3236
- };
3237
- return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3238
- headers: {
3239
- "Content-Type": "application/json"
3240
- }
3241
- });
3242
- },
3243
- async loginSocial({
3244
- state,
3245
- access_token
3246
- }) {
3247
- const env2 = getEnv();
3248
- return env2?.requests?.post(
3249
- "/token/generate" /* GENTOKEN_SOCIAL */,
3250
- { state, access_token },
3251
- {
3252
- headers: {
3253
- "Content-Type": "application/json"
3254
- }
3255
- }
3256
- );
3257
- },
3258
- async getProviders(db) {
3259
- const env2 = getEnv();
3260
- return env2?.requests?.get("/oauth/providers", { params: { db } });
3261
- }
3262
- };
3263
- var auth_service_default = AuthService;
3264
-
3265
- // src/constants/widget/widget-avatar-constant.ts
3266
- var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
3267
- WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
3268
- WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
3269
- return WIDGETAVATAR2;
3270
- })(WIDGETAVATAR || {});
3271
-
3272
- // src/services/company-service/index.ts
3273
- var CompanyService = {
3274
- async getCurrentCompany() {
3275
- const env2 = getEnv();
3276
- return await env2.requests.get("/company" /* COMPANY_PATH */, {
3277
- headers: {
3278
- "Content-Type": "application/json"
3279
- }
3280
- });
3281
- },
3282
- async getInfoCompany(id) {
3283
- const env2 = getEnv();
3284
- const jsonData = {
3285
- ids: [id],
3286
- model: "res.company" /* COMPANY */,
3287
- method: "web_read" /* WEB_READ */,
3288
- kwargs: {
3289
- specification: {
3290
- primary_color: {},
3291
- secondary_color: {},
3292
- logo: {},
3293
- display_name: {},
3294
- secondary_logo: {}
3295
- }
3296
- }
3297
- };
3298
- return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3299
- headers: {
3300
- "Content-Type": "application/json"
3301
- }
3302
- });
3303
- }
3304
- };
3305
- var company_service_default = CompanyService;
3306
-
3307
- // src/services/excel-service/index.ts
3308
- var ExcelService = {
3309
- async uploadFile({ formData }) {
3310
- const env2 = getEnv();
3311
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3312
- headers: {
3313
- "Content-Type": "multipart/form-data"
3314
- }
3315
- });
3316
- },
3317
- async uploadIdFile({ formData }) {
3318
- const env2 = getEnv();
3319
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3320
- headers: {
3321
- "Content-Type": "multipart/form-data"
3322
- }
3323
- });
3324
- },
3325
- async parsePreview({
3326
- id,
3327
- selectedSheet,
3328
- isHeader,
3329
- context
3330
- }) {
3331
- const env2 = getEnv();
3332
- const jsonData = {
3333
- model: "base_import.import" /* BASE_IMPORT */,
3334
- method: "parse_preview",
3335
- ids: [id],
3336
- kwargs: {
3337
- options: {
3338
- import_skip_records: [],
3339
- import_set_empty_fields: [],
3340
- fallback_values: {},
3341
- name_create_enabled_fields: {},
3342
- encoding: "",
3343
- separator: "",
3344
- quoting: '"',
3345
- date_format: "",
3346
- datetime_format: "",
3347
- float_thousand_separator: ",",
3348
- float_decimal_separator: ".",
3349
- advanced: true,
3350
- has_headers: isHeader,
3351
- keep_matches: false,
3352
- limit: 2e3,
3353
- sheets: [],
3354
- sheet: selectedSheet,
3355
- skip: 0,
3356
- tracking_disable: true
3357
- }
3358
- },
3359
- with_context: context
3360
- };
3361
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3362
- headers: {
3363
- "Content-Type": "multipart/form-data"
3364
- }
3365
- });
3366
- },
3367
- async executeImport({
3368
- columns,
3369
- fields,
3370
- idFile,
3371
- options,
3372
- dryrun,
3373
- context
3374
- }) {
3375
- const env2 = getEnv();
3376
- const jsonData = {
3377
- model: "base_import.import" /* BASE_IMPORT */,
3378
- method: "execute_import",
3379
- ids: [idFile],
3380
- kwargs: {
3381
- fields,
3382
- columns,
3383
- options,
3384
- dryrun
3385
- },
3386
- with_context: context
3387
- };
3388
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3389
- headers: {
3390
- "Content-Type": "multipart/form-data"
3391
- }
3392
- });
3393
- },
3394
- async getFileExcel({ model, context }) {
3395
- const env2 = getEnv();
3396
- const jsonData = {
3397
- model,
3398
- method: "get_import_templates" /* GET_IMPORT */,
3399
- args: [],
3400
- with_context: context
3401
- };
3402
- return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3403
- },
3404
- async getFieldExport({
3405
- ids,
3406
- model,
3407
- isShow,
3408
- parentField,
3409
- fieldType,
3410
- parentName,
3411
- prefix,
3412
- name,
3413
- context,
3414
- importCompat
3415
- }) {
3416
- const env2 = getEnv();
3417
- const jsonData = {
3071
+ function useButton() {
3072
+ return useMutation({
3073
+ mutationFn: ({
3418
3074
  model,
3419
- import_compat: importCompat,
3420
- domain: [["id", "in", ids]],
3421
- with_context: context
3422
- };
3423
- if (isShow) {
3424
- jsonData.parent_field = parentField;
3425
- jsonData.parent_field_type = fieldType;
3426
- jsonData.parent_name = parentName;
3427
- jsonData.name = name;
3428
- jsonData.prefix = prefix;
3429
- jsonData.exclude = [null];
3430
- }
3431
- return env2.requests.post("/export/get_fields", jsonData);
3432
- },
3433
- async exportExcel({
3434
- model,
3435
- domain,
3436
- ids,
3437
- fields,
3438
- type,
3439
- importCompat,
3440
- context,
3441
- groupby
3442
- }) {
3443
- const env2 = getEnv();
3444
- const jsonData = {
3445
- model,
3446
- domain,
3447
- ids,
3448
- import_compat: importCompat,
3449
- fields,
3450
- with_context: context,
3451
- groupby: groupby ?? []
3452
- };
3453
- return env2.requests.post_excel(`/export/${type}`, jsonData);
3454
- }
3455
- };
3456
- var excel_service_default = ExcelService;
3457
-
3458
- // src/services/form-service/index.ts
3459
- var FormService = {
3460
- async getComment({ data }) {
3461
- try {
3462
- const env2 = getEnv();
3463
- const jsonData = {
3464
- thread_id: data.thread_id,
3465
- thread_model: data.thread_model,
3466
- limit: 100,
3467
- with_context: {
3468
- lang: data.lang
3469
- }
3470
- };
3471
- return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3472
- headers: {
3473
- "Content-Type": "application/json"
3474
- }
3475
- });
3476
- } catch (error) {
3477
- console.error("Error when sending message:", error);
3478
- throw error;
3479
- }
3480
- },
3481
- async sentComment({ data }) {
3482
- try {
3483
- const env2 = getEnv();
3484
- const jsonData = {
3485
- context: {
3486
- tz: "Asia/Saigon",
3487
- uid: 2,
3488
- allowed_company_ids: [1],
3489
- mail_post_autofollow: false,
3490
- temporary_id: 142183.01
3491
- },
3492
- post_data: {
3493
- body: data.message,
3494
- message_type: "comment",
3495
- attachment_ids: data.attachment_ids,
3496
- attachment_tokens: [],
3497
- subtype_xmlid: data.subtype
3498
- },
3499
- thread_id: Number(data.thread_id),
3500
- thread_model: data.thread_model
3501
- };
3502
- return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3503
- headers: {
3504
- "Content-Type": "application/json"
3505
- }
3506
- });
3507
- } catch (error) {
3508
- console.error("Error when sent message:", error);
3509
- throw error;
3510
- }
3511
- },
3512
- async deleteComment({ data }) {
3513
- try {
3514
- const env2 = getEnv();
3515
- const jsonData = {
3516
- attachment_ids: [],
3517
- attachment_tokens: [],
3518
- body: "",
3519
- message_id: data.message_id
3520
- };
3521
- return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3522
- headers: {
3523
- "Content-Type": "application/json"
3524
- }
3525
- });
3526
- } catch (error) {
3527
- console.error("Error when sent message:", error);
3528
- throw error;
3529
- }
3530
- },
3531
- async getImage({ data }) {
3532
- try {
3533
- const env2 = getEnv();
3534
- return env2.requests.get(
3535
- `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3536
- {
3537
- headers: {
3538
- "Content-Type": "application/json"
3539
- }
3540
- }
3541
- );
3542
- } catch (error) {
3543
- console.error("Error when sent message:", error);
3544
- throw error;
3545
- }
3546
- },
3547
- async uploadImage({ data }) {
3548
- try {
3549
- const env2 = getEnv();
3550
- return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3551
- headers: {
3552
- "Content-Type": "multipart/form-data"
3553
- }
3554
- });
3555
- } catch (error) {
3556
- console.error("Error when sent message:", error);
3557
- throw error;
3558
- }
3559
- },
3560
- async getFormView({ data }) {
3561
- try {
3562
- const env2 = getEnv();
3563
- const jsonData = {
3564
- model: data.model,
3565
- method: "get_formview_action",
3566
- ids: data.id ? [data.id] : [],
3567
- with_context: data.context
3568
- };
3569
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3570
- headers: {
3571
- "Content-Type": "application/json"
3572
- }
3573
- });
3574
- } catch (error) {
3575
- console.error("Error when fetching form view:", error);
3576
- throw error;
3577
- }
3578
- },
3579
- async changeStatus({ data }) {
3580
- const env2 = getEnv();
3581
- const vals = {
3582
- [data.name]: data.stage_id
3583
- };
3584
- const jsonData = {
3585
- model: data.model,
3586
- method: "web_save",
3587
- with_context: {
3588
- lang: data.lang,
3589
- allowed_company_ids: [1],
3590
- uid: 2,
3591
- search_default_my_ticket: true,
3592
- search_default_is_open: true
3593
- },
3594
- ids: [data.id],
3595
- kwargs: {
3596
- vals,
3597
- specification: {}
3598
- }
3599
- };
3600
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3601
- headers: {
3602
- "Content-Type": "application/json"
3603
- }
3604
- });
3605
- }
3606
- };
3607
- var form_service_default = FormService;
3608
-
3609
- // src/services/model-service/index.ts
3610
- var OBJECT_POSITION = 2;
3611
- var ModelService = {
3612
- async getAll({ data }) {
3613
- const env2 = getEnv();
3614
- const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3615
- fields: data.fields,
3616
- groupby: data.groupby
3617
- } : {
3618
- count_limit: 10001,
3619
- order: data.sort,
3620
- specification: data.specification
3621
- };
3622
- const jsonData = {
3623
- model: String(data.model),
3624
- method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3625
- ids: data.ids,
3626
- with_context: data.context,
3627
- kwargs: {
3628
- domain: data.domain,
3629
- limit: data.limit,
3630
- offset: data.offset,
3631
- ...jsonReadGroup
3632
- }
3633
- };
3634
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3635
- headers: {
3636
- "Content-Type": "application/json"
3637
- }
3638
- });
3639
- },
3640
- async getList({
3641
- model,
3642
- ids = [],
3643
- specification = {},
3644
- domain = [],
3645
- offset,
3646
- order,
3647
- context = {},
3648
- limit = 10
3649
- }) {
3650
- const env2 = getEnv();
3651
- const jsonData = {
3652
- model,
3653
- method: "web_search_read" /* WEB_SEARCH_READ */,
3654
- ids,
3655
- with_context: context,
3656
- kwargs: {
3657
- specification,
3658
- domain,
3659
- limit,
3660
- offset,
3661
- order
3662
- }
3663
- };
3664
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3665
- headers: {
3666
- "Content-Type": "application/json"
3667
- }
3668
- });
3669
- },
3670
- async getDetail({
3671
- ids = [],
3672
- model,
3673
- specification,
3674
- context
3675
- }) {
3676
- const env2 = getEnv();
3677
- const jsonData = {
3678
- model,
3679
- method: "web_read" /* WEB_READ */,
3680
- ids,
3681
- with_context: context,
3682
- kwargs: {
3683
- specification
3684
- }
3685
- };
3686
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3687
- headers: {
3688
- "Content-Type": "application/json"
3689
- }
3690
- });
3691
- },
3692
- async save({
3693
- model,
3694
- ids = [],
3695
- data = {},
3696
- specification = {},
3697
- context = {}
3698
- }) {
3699
- const env2 = getEnv();
3700
- const jsonData = {
3701
- model,
3702
- method: "web_save" /* WEB_SAVE */,
3703
- with_context: context,
3704
- ids,
3705
- kwargs: {
3706
- vals: data,
3707
- specification
3708
- }
3709
- };
3710
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3711
- headers: {
3712
- "Content-Type": "application/json"
3713
- }
3714
- });
3715
- },
3716
- async delete({ ids = [], model }) {
3717
- const env2 = getEnv();
3718
- const jsonData = {
3719
- model,
3720
- method: "unlink" /* UNLINK */,
3721
- ids
3722
- };
3723
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3724
- headers: {
3725
- "Content-Type": "application/json"
3726
- }
3727
- });
3728
- },
3729
- async onChange({
3730
- ids = [],
3731
- model,
3732
- object,
3733
- specification,
3734
- context,
3735
- fieldChange
3736
- }) {
3737
- const env2 = getEnv();
3738
- const jsonData = {
3739
- model,
3740
- method: "onchange" /* ONCHANGE */,
3741
- ids,
3742
- with_context: context,
3743
- args: [
3744
- object ? object : {},
3745
- fieldChange ? fieldChange : [],
3746
- specification
3747
- ]
3748
- };
3749
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3750
- headers: {
3751
- "Content-Type": "application/json"
3752
- }
3753
- });
3754
- },
3755
- async getListFieldsOnchange({ model }) {
3756
- const env2 = getEnv();
3757
- const jsonData = {
3758
- model,
3759
- method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3760
- };
3761
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3762
- headers: {
3763
- "Content-Type": "application/json"
3764
- }
3765
- });
3766
- },
3767
- parseORMOdoo(data) {
3768
- for (const key in data) {
3769
- if (key === "display_name") {
3770
- delete data[key];
3771
- }
3772
- if (!data[key] && data[key] !== 0) {
3773
- data[key] = false;
3774
- } else if (data[key] === "Draft") {
3775
- data[key] = "/";
3776
- }
3777
- }
3778
- return { ...data };
3779
- },
3780
- toDataJS(data, viewData, model) {
3781
- for (const key in data) {
3782
- if (data[key] === false) {
3783
- if (viewData && model) {
3784
- if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
3785
- data[key] = null;
3786
- }
3787
- } else {
3788
- data[key] = null;
3789
- }
3790
- } else if (data[key] === "/") {
3791
- data[key] = "Draft";
3792
- } else if (data[key] !== false) {
3793
- if (model !== void 0) {
3794
- if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
3795
- data[key] = (data[key] ??= [])?.map((item, index) => {
3796
- const relation = viewData?.models?.[model]?.[key]?.relation;
3797
- if (relation !== void 0) {
3798
- if (viewData?.models?.[relation]) {
3799
- if (item?.length >= 3) {
3800
- if (item[0] === 2 /* DELETE */) {
3801
- delete data[key][index];
3802
- return;
3803
- }
3804
- return ModelService.toDataJS(
3805
- { ...item[OBJECT_POSITION], id: `virtual_${index}` },
3806
- viewData,
3807
- relation
3808
- );
3809
- } else {
3810
- return ModelService.toDataJS(item, viewData, relation);
3811
- }
3812
- } else {
3813
- if (item?.length >= 3) {
3814
- if (!item[OBJECT_POSITION] || item[0] === 2 /* DELETE */) {
3815
- delete data[key][index];
3816
- return;
3817
- }
3818
- return item[OBJECT_POSITION];
3819
- } else {
3820
- return item;
3821
- }
3822
- }
3823
- }
3824
- });
3825
- }
3826
- }
3827
- }
3828
- }
3829
- return { ...data };
3830
- }
3831
- };
3832
- var model_service_default = ModelService;
3833
-
3834
- // src/services/user-service/index.ts
3835
- var UserService = {
3836
- async getProfile() {
3837
- const env2 = getEnv();
3838
- return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
3839
- headers: {
3840
- "Content-Type": "application/x-www-form-urlencoded"
3841
- }
3842
- });
3843
- },
3844
- async getUser({ context, id }) {
3845
- const env2 = getEnv();
3846
- const jsonData = {
3847
- model: "res.users",
3848
- method: "web_read",
3849
- ids: [id],
3850
- with_context: context,
3851
- kwargs: {
3852
- specification: {
3853
- display_name: {},
3854
- image_1920: {},
3855
- name: {},
3856
- login: {},
3857
- email: {},
3858
- password: {},
3859
- visible_group_id: {
3860
- fields: {
3861
- id: {},
3862
- display_name: {}
3863
- }
3864
- },
3865
- company_id: {
3866
- fields: {
3867
- id: {},
3868
- display_name: {}
3869
- }
3870
- }
3871
- }
3872
- }
3873
- };
3874
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3875
- headers: {
3876
- "Content-Type": "application/json"
3877
- }
3878
- });
3879
- },
3880
- switchUserLocale: async ({ id, values }) => {
3881
- const env2 = getEnv();
3882
- const jsonData = {
3883
- model: "res.users",
3884
- domain: [["id", "=", id]],
3885
- values
3886
- };
3887
- return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
3888
- headers: {
3889
- "Content-Type": "application/json"
3890
- }
3891
- });
3892
- }
3893
- };
3894
- var user_service_default = UserService;
3895
-
3896
- // src/services/view-service/index.ts
3897
- var ViewService = {
3898
- async getView({
3899
- model,
3900
- views,
3901
- context = {},
3902
- options = {},
3903
- aid
3904
- }) {
3905
- const env2 = getEnv();
3906
- const defaultOptions = {
3907
- load_filters: true,
3908
- toolbar: true,
3909
- action_id: aid
3910
- };
3911
- const jsonDataView = {
3912
- model,
3913
- method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
3914
- kwargs: {
3915
- views,
3916
- options: { ...options, ...defaultOptions }
3917
- },
3918
- with_context: context
3919
- };
3920
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3921
- headers: {
3922
- "Content-Type": "application/json"
3923
- }
3924
- });
3925
- },
3926
- async getMenu(context) {
3927
- const env2 = getEnv();
3928
- const jsonData = {
3929
- model: "ir.ui.menu" /* MENU */,
3930
- method: "web_search_read" /* WEB_SEARCH_READ */,
3931
- ids: [],
3932
- with_context: context,
3933
- kwargs: {
3934
- specification: {
3935
- active: {},
3936
- name: {},
3937
- is_display: {},
3938
- sequence: {},
3939
- complete_name: {},
3940
- action: {
3941
- fields: {
3942
- display_name: {},
3943
- type: {},
3944
- binding_view_types: {}
3945
- // res_model: {},
3946
- }
3947
- },
3948
- url_icon: {},
3949
- web_icon: {},
3950
- web_icon_data: {},
3951
- groups_id: {
3952
- fields: {
3953
- full_name: {}
3954
- },
3955
- limit: 40,
3956
- order: ""
3957
- },
3958
- display_name: {},
3959
- child_id: {
3960
- fields: {
3961
- active: {},
3962
- name: {},
3963
- is_display: {},
3964
- sequence: {},
3965
- complete_name: {},
3966
- action: {
3967
- fields: {
3968
- display_name: {},
3969
- type: {},
3970
- binding_view_types: {}
3971
- // res_model: {},
3972
- }
3973
- },
3974
- url_icon: {},
3975
- web_icon: {},
3976
- web_icon_data: {},
3977
- groups_id: {
3978
- fields: {
3979
- full_name: {}
3980
- },
3981
- limit: 40,
3982
- order: ""
3983
- },
3984
- display_name: {},
3985
- child_id: {
3986
- fields: {
3987
- active: {},
3988
- name: {},
3989
- is_display: {},
3990
- sequence: {},
3991
- complete_name: {},
3992
- action: {
3993
- fields: {
3994
- display_name: {},
3995
- type: {},
3996
- binding_view_types: {}
3997
- // res_model: {},
3998
- }
3999
- },
4000
- url_icon: {},
4001
- web_icon: {},
4002
- web_icon_data: {},
4003
- groups_id: {
4004
- fields: {
4005
- full_name: {}
4006
- },
4007
- limit: 40,
4008
- order: ""
4009
- },
4010
- display_name: {},
4011
- child_id: {
4012
- fields: {
4013
- active: {},
4014
- name: {},
4015
- is_display: {},
4016
- sequence: {},
4017
- complete_name: {},
4018
- action: {
4019
- fields: {
4020
- display_name: {},
4021
- type: {},
4022
- binding_view_types: {}
4023
- // res_model: {},
4024
- }
4025
- },
4026
- url_icon: {},
4027
- web_icon: {},
4028
- web_icon_data: {},
4029
- groups_id: {
4030
- fields: {
4031
- full_name: {}
4032
- },
4033
- limit: 40,
4034
- order: ""
4035
- },
4036
- display_name: {},
4037
- child_id: {
4038
- fields: {},
4039
- limit: 40,
4040
- order: ""
4041
- }
4042
- },
4043
- limit: 40,
4044
- order: ""
4045
- }
4046
- },
4047
- limit: 40,
4048
- order: ""
4049
- }
4050
- },
4051
- limit: 40,
4052
- order: ""
4053
- }
4054
- },
4055
- domain: [
4056
- "&",
4057
- ["is_display", "=", true],
4058
- "&",
4059
- ["active", "=", true],
4060
- ["parent_id", "=", false]
4061
- ]
4062
- }
4063
- };
4064
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4065
- headers: {
4066
- "Content-Type": "application/json"
4067
- }
4068
- });
4069
- },
4070
- async getSelectionItem({ data }) {
4071
- const env2 = getEnv();
4072
- const jsonData = {
4073
- model: data.model,
4074
- ids: [],
4075
- method: "get_data_select",
4076
- with_context: data.context,
4077
- kwargs: {
4078
- count_limit: 10001,
4079
- domain: data.domain ? data.domain : [],
4080
- offset: 0,
4081
- order: "",
4082
- specification: data?.specification ?? {
4083
- id: {},
4084
- name: {},
4085
- display_name: {}
4086
- }
4087
- }
4088
- };
4089
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4090
- headers: {
4091
- "Content-Type": "application/json"
4092
- }
4093
- });
4094
- },
4095
- async loadMessages() {
4096
- const env2 = getEnv();
4097
- return env2.requests.post(
4098
- "/load_message_failures" /* LOAD_MESSAGE */,
4099
- {},
4100
- {
4101
- headers: {
4102
- "Content-Type": "application/json"
4103
- }
4104
- }
4105
- );
4106
- },
4107
- async getVersion() {
4108
- const env2 = getEnv();
4109
- return env2?.requests.get("", {
4110
- headers: {
4111
- "Content-Type": "application/json"
4112
- }
4113
- });
4114
- }
4115
- };
4116
- var view_service_default = ViewService;
4117
-
4118
- // src/hooks/auth/use-forgot-password.ts
4119
- var useForgotPassword = () => {
4120
- return useMutation({
4121
- mutationFn: (email) => {
4122
- return auth_service_default.forgotPassword(email);
4123
- }
4124
- });
4125
- };
4126
- var use_forgot_password_default = useForgotPassword;
4127
- var useGetProvider = () => {
4128
- return useMutation({
4129
- mutationFn: (data) => {
4130
- return auth_service_default.getProviders(data?.db);
4131
- }
4132
- });
4133
- };
4134
- var use_get_provider_default = useGetProvider;
4135
- var useIsValidToken = () => {
4136
- return useMutation({
4137
- mutationFn: (token) => {
4138
- return auth_service_default.isValidToken(token);
4139
- }
4140
- });
4141
- };
4142
- var use_isvalid_token_default = useIsValidToken;
4143
- var useLoginCredential = () => {
4144
- return useMutation({
4145
- mutationFn: (data) => {
4146
- return auth_service_default.login(data);
4147
- }
4148
- });
4149
- };
4150
- var use_login_credential_default = useLoginCredential;
4151
- var useLoginSocial = () => {
4152
- return useMutation({
4153
- mutationFn: (data) => {
4154
- return auth_service_default.loginSocial(data);
4155
- }
4156
- });
4157
- };
4158
- var use_login_socical_default = useLoginSocial;
4159
- var useResetPassword = () => {
4160
- return useMutation({
4161
- mutationFn: (request) => {
4162
- return auth_service_default.resetPassword(request.data, request.token);
4163
- }
4164
- });
4165
- };
4166
- var use_reset_password_default = useResetPassword;
4167
- var useUpdatePassword = () => {
4168
- return useMutation({
4169
- mutationFn: (request) => {
4170
- return auth_service_default.updatePassword(request.data, request.token);
4171
- }
4172
- });
4173
- };
4174
- var use_update_password_default = useUpdatePassword;
4175
- var useField = (props) => {
4176
- const [invisible, setInvisible] = React.useState(true);
4177
- const [required, setRequired] = React.useState(false);
4178
- const [readonly, setReadOnly] = React.useState(false);
4179
- const {
4180
- invisible: inv,
4181
- required: req,
4182
- readonly: rea,
4183
- onchangeData,
4184
- rootField,
4185
- index,
4186
- name
4187
- } = props;
4188
- const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
4189
- useEffect(() => {
4190
- if (onchangeData && Object.keys(onchangeData).length > 0) {
4191
- setRequired(
4192
- typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
4193
- );
4194
- setInvisible(matchDomains(onchangeData, inv));
4195
- setReadOnly(
4196
- typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
4197
- );
4198
- }
4199
- }, [onchangeData]);
4200
- return {
4201
- invisible,
4202
- required,
4203
- readonly,
4204
- nameField
4205
- };
4206
- };
4207
- var use_field_default = useField;
4208
- var useGetCompanyInfo = () => {
4209
- return useMutation({
4210
- mutationFn: (id) => company_service_default.getInfoCompany(id)
4211
- });
4212
- };
4213
- var use_get_company_info_default = useGetCompanyInfo;
4214
- var useGetCurrentCompany = () => {
4215
- return useMutation({
4216
- mutationFn: () => company_service_default.getCurrentCompany()
4217
- });
4218
- };
4219
- var use_get_current_company_default = useGetCurrentCompany;
4220
- var useChangeStatus = () => {
4221
- return useMutation({
4222
- mutationFn: ({ data }) => {
4223
- return form_service_default.changeStatus({
4224
- data
4225
- });
4226
- }
4227
- });
4228
- };
4229
- var use_change_status_default = useChangeStatus;
4230
- var useDeleteComment = () => {
4231
- return useMutation({
4232
- mutationFn: ({ data }) => form_service_default.deleteComment({
4233
- data
4234
- })
4235
- });
4236
- };
4237
- var use_delete_comment_default = useDeleteComment;
4238
- var useGetComment = ({ data, queryKey }) => {
4239
- return useQuery({
4240
- queryKey,
4241
- queryFn: () => form_service_default.getComment({ data }).then((res) => {
4242
- if (res) {
4243
- return res;
4244
- }
4245
- }),
4246
- enabled: !!data.thread_id && !isNaN(data.thread_id),
4247
- refetchOnWindowFocus: false
4248
- });
4249
- };
4250
- var use_get_comment_default = useGetComment;
4251
- var useGetFormView = ({
4252
- data,
4253
- queryKey,
4254
- enabled
4255
- }) => {
4256
- return useQuery({
4257
- queryKey,
4258
- queryFn: () => form_service_default.getFormView({ data }).then((res) => {
4259
- if (res) {
4260
- return res;
4261
- }
4262
- }),
4263
- enabled,
4264
- refetchOnWindowFocus: false
4265
- });
4266
- };
4267
- var use_get_form_view_default = useGetFormView;
4268
- var useGetImage = ({
4269
- data,
4270
- queryKey,
4271
- src
4272
- }) => {
4273
- return useQuery({
4274
- queryKey,
4275
- queryFn: () => form_service_default.getImage({ data }).then((res) => {
4276
- if (res) {
4277
- return res;
4278
- }
4279
- }),
4280
- enabled: !src && !isBase64File(src),
4281
- refetchOnWindowFocus: false
4282
- });
4283
- };
4284
- var use_get_image_default = useGetImage;
4285
- var useSendComment = () => {
4286
- return useMutation({
4287
- mutationFn: ({ data }) => form_service_default.sentComment({
4288
- data
4289
- })
4290
- });
4291
- };
4292
- var use_send_comment_default = useSendComment;
4293
- var useUploadImage = () => {
4294
- return useMutation({
4295
- mutationFn: ({ data }) => form_service_default.uploadImage({
4296
- data
4297
- })
4298
- });
4299
- };
4300
- var use_upload_image_default = useUploadImage;
4301
- var useExportExcel = () => {
4302
- return useMutation({
4303
- mutationFn: ({
4304
- model,
4305
- domain,
4306
- ids,
4307
- fields,
4308
- type,
4309
- importCompat,
4310
- context,
4311
- groupby
4312
- }) => excel_service_default.exportExcel({
4313
- model,
4314
- domain,
4315
- ids,
4316
- fields,
4317
- type,
4318
- importCompat,
4319
- context,
4320
- groupby
4321
- })
4322
- });
4323
- };
4324
- var use_export_excel_default = useExportExcel;
4325
- var useGetFieldExport = () => {
4326
- return useMutation({
4327
- mutationFn: ({
4328
- ids,
4329
- model,
4330
- isShow,
4331
- parentField,
4332
- fieldType,
4333
- parentName,
4334
- prefix,
4335
- name,
4336
- context,
4337
- importCompat
4338
- }) => excel_service_default.getFieldExport({
4339
- ids,
4340
- model,
4341
- isShow,
4342
- parentField,
4343
- fieldType,
4344
- parentName,
4345
- prefix,
4346
- name,
4347
- context,
4348
- importCompat
4349
- })
4350
- });
4351
- };
4352
- var use_get_field_export_default = useGetFieldExport;
4353
- var useGetFileExcel = ({
4354
- model,
4355
- context
4356
- }) => {
4357
- return useQuery({
4358
- queryKey: [],
4359
- queryFn: () => excel_service_default.getFileExcel({
4360
- model,
4361
- context
4362
- }).then((res) => {
4363
- if (res) {
4364
- return res;
4365
- }
4366
- return [];
4367
- }),
4368
- refetchOnWindowFocus: false
4369
- });
4370
- };
4371
- var use_get_file_excel_default = useGetFileExcel;
4372
- var useParsePreview = () => {
4373
- return useMutation({
4374
- mutationFn: ({
4375
- id,
4376
- selectedSheet,
4377
- isHeader,
4378
- context
4379
- }) => excel_service_default.parsePreview({
4380
- id,
4381
- selectedSheet,
4382
- isHeader,
4383
- context
4384
- })
4385
- });
4386
- };
4387
- var use_parse_preview_default = useParsePreview;
4388
- var useUploadFile = () => {
4389
- return useMutation({
4390
- mutationFn: ({ formData }) => excel_service_default.uploadFile({
4391
- formData
4392
- })
4393
- });
4394
- };
4395
- var use_upload_file_default = useUploadFile;
4396
- var useUploadIdFile = () => {
4397
- return useMutation({
4398
- mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
4399
- formData
4400
- })
4401
- });
4402
- };
4403
- var use_upload_id_file_default = useUploadIdFile;
4404
- var useExecuteImport = () => {
4405
- return useMutation({
4406
- mutationFn: ({
4407
- fields,
4408
- columns,
4409
- idFile,
4410
- options,
4411
- dryrun,
4412
- context
4413
- }) => excel_service_default.executeImport({
4414
- fields,
4415
- columns,
4416
- idFile,
4417
- options,
4418
- dryrun,
4419
- context
4420
- })
4421
- });
4422
- };
4423
- var uss_execute_import_default = useExecuteImport;
4424
- var useDelete = () => {
4425
- return useMutation({
4426
- mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
4427
- });
4428
- };
4429
- var use_delete_default = useDelete;
4430
- var useGetAll = ({ data, queryKey, viewResponse }) => {
4431
- return useQuery({
4432
- queryKey,
4433
- queryFn: () => model_service_default.getAll({ data }).then((res) => {
4434
- if (res) {
4435
- return res;
4436
- }
4437
- }),
4438
- enabled: !!data.specification && !!data.model && !!data.domain && !!viewResponse,
4439
- refetchOnWindowFocus: false
4440
- // placeholderData: keepPreviousData,
4441
- });
4442
- };
4443
- var use_get_all_default = useGetAll;
4444
- var useGetDetail = () => {
4445
- return useMutation({
4446
- mutationFn: ({
4447
- model,
4448
- ids,
4449
- specification,
4450
- context
4451
- }) => model_service_default.getDetail({
4452
- model,
4453
- ids,
4454
- specification,
4455
- context
4456
- })
4457
- });
4458
- };
4459
- var use_get_detail_default = useGetDetail;
4460
- var useGetFieldOnChange = ({ model }) => {
4461
- return useQuery({
4462
- queryKey: [`field-onchange-${model}`, model],
4463
- queryFn: () => model_service_default.getListFieldsOnchange({
4464
- model
4465
- }).then((res) => {
4466
- if (res) {
4467
- return res;
4468
- }
4469
- }),
4470
- refetchOnWindowFocus: false,
4471
- staleTime: Infinity
4472
- });
4473
- };
4474
- var use_get_field_onchange_default = useGetFieldOnChange;
4475
-
4476
- // src/models/base-model/index.ts
4477
- var BaseModel = class {
4478
- name;
4479
- view;
4480
- actContext;
4481
- fields;
4482
- constructor(init) {
4483
- this.name = init.name;
4484
- this.view = init.view;
4485
- this.actContext = init.actContext;
4486
- this.fields = init.fields;
4487
- }
4488
- getSpecificationByFields({
4489
- fields = [],
4490
- specification = {},
4491
- modelsData,
4492
- model,
4493
- modelRoot
4494
- }) {
4495
- if (Array.isArray(fields)) {
4496
- let spec = { ...specification };
4497
- fields.forEach((field) => {
4498
- if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
4499
- if (modelsData?.[model]?.[field?.name]) {
4500
- if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
4501
- const relation = modelsData?.[model]?.[field?.name]?.relation;
4502
- const modelRelation = modelsData?.[relation];
4503
- if (modelRelation) {
4504
- spec[field?.name] = {
4505
- fields: {}
4506
- };
4507
- if (modelRoot && modelRoot === relation) {
4508
- spec[field?.name].fields = { id: {} };
4509
- } else {
4510
- spec[field?.name].fields = this.getSpecificationByFields({
4511
- fields: Object.values(modelRelation),
4512
- specification: {},
4513
- modelsData,
4514
- model: relation,
4515
- modelRoot: model
4516
- });
4517
- }
4518
- } else {
4519
- spec[field?.name] = {
4520
- fields: {
4521
- id: {},
4522
- display_name: {}
4523
- }
4524
- };
4525
- }
4526
- } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
4527
- spec[field?.name] = {
4528
- fields: {
4529
- id: {},
4530
- display_name: {},
4531
- ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
4532
- ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
4533
- ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
4534
- }
4535
- };
4536
- } else {
4537
- spec[field?.name] = {};
4538
- }
4539
- }
4540
- } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
4541
- const specGroup = this.getSpecificationByFields({
4542
- fields: field?.fields,
4543
- specification: spec,
4544
- modelsData,
4545
- model
4546
- });
4547
- spec = { ...spec, ...specGroup };
4548
- } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
4549
- const relation = modelsData?.[model]?.[field?.name]?.relation;
4550
- const specTreee = this.getSpecificationByFields({
4551
- fields: field?.fields,
4552
- specification: {},
4553
- modelsData,
4554
- model: relation,
4555
- modelRoot: model
4556
- });
4557
- spec = {
4558
- ...spec,
4559
- [field?.name]: {
4560
- fields: { ...spec?.[field?.name]?.fields, ...specTreee }
4561
- }
4562
- };
4563
- }
4564
- });
4565
- return spec;
4566
- } else {
4567
- console.warn("fields is not array");
4568
- }
4569
- }
4570
- getTreeProps() {
4571
- const props = this.view?.views?.list || {};
4572
- return props;
4573
- }
4574
- getTreeFields() {
4575
- const fields = this.view?.views?.list?.fields || [];
4576
- return fields;
4577
- }
4578
- getSpecification() {
4579
- const specInit = {};
4580
- const modelData = this.view?.models || {};
4581
- const specification = this.getSpecificationByFields({
4582
- fields: this.fields,
4583
- specification: specInit,
4584
- modelsData: modelData,
4585
- model: this.name,
4586
- modelRoot: ""
4587
- });
4588
- return specification;
4589
- }
4590
- };
4591
- var base_model_default = BaseModel;
4592
-
4593
- // src/hooks/model/use-model.ts
4594
- var useModel = () => {
4595
- const initModel = (modelData) => {
4596
- switch (modelData?.name) {
4597
- default:
4598
- return new base_model_default(modelData);
4599
- }
4600
- };
4601
- return {
4602
- initModel
4603
- };
4604
- };
4605
- var use_model_default = useModel;
4606
-
4607
- // src/hooks/model/use-odoo-data-transform.ts
4608
- var useOdooDataTransform = () => {
4609
- return {
4610
- toDataJS: model_service_default.toDataJS,
4611
- parseORM: model_service_default.parseORMOdoo
4612
- };
4613
- };
4614
- var use_odoo_data_transform_default = useOdooDataTransform;
4615
- var useOnChangeForm = () => {
4616
- return useMutation({
4617
- mutationFn: ({
4618
- ids,
4619
- model,
4620
- specification,
4621
- context,
4622
- object,
4623
- fieldChange
4624
- }) => model_service_default.onChange({
4625
- ids,
4626
- model,
4627
- specification,
4628
- context,
4629
- object,
4630
- fieldChange
4631
- })
4632
- });
4633
- };
4634
- var use_onchange_form_default = useOnChangeForm;
4635
- var useSave = () => {
4636
- return useMutation({
4637
- mutationFn: ({
4638
- ids,
4639
- model,
4640
- data,
4641
- specification,
4642
- context
4643
- }) => model_service_default.save({ ids, model, data, specification, context })
4644
- });
4645
- };
4646
- var use_save_default = useSave;
4647
- var useGetProfile = () => {
4648
- return useMutation({
4649
- mutationFn: () => user_service_default.getProfile()
4650
- });
4651
- };
4652
- var use_get_profile_default = useGetProfile;
4653
- var useGetUser = () => {
4654
- return useMutation({
4655
- mutationFn: ({ id, context }) => user_service_default.getUser({
4656
- id,
4657
- context
4658
- })
4659
- });
4660
- };
4661
- var use_get_user_default = useGetUser;
4662
- var useSwitchLocale = () => {
4663
- return useMutation({
4664
- mutationFn: ({ data }) => {
4665
- return user_service_default.switchUserLocale({
4666
- id: data.id,
4667
- values: data.values
4668
- });
4669
- }
4670
- });
4671
- };
4672
- var use_switch_locale_default = useSwitchLocale;
4673
- var useButton = () => {
4674
- return useMutation({
4675
- mutationFn: ({
4676
- model,
4677
- ids,
4678
- context,
4679
- method
4680
- }) => action_service_default.callButton({
3075
+ ids,
3076
+ context,
3077
+ method
3078
+ }) => action_service_default.callButton({
4681
3079
  model,
4682
3080
  ids,
4683
3081
  context,
4684
3082
  method
4685
- }),
4686
- onSuccess: (response) => {
4687
- return response;
4688
- }
4689
- });
4690
- };
4691
- var use_button_default = useButton;
4692
- var useDuplicateRecord = () => {
4693
- return useMutation({
4694
- mutationFn: ({
4695
- id,
4696
- model,
4697
- context
4698
- }) => action_service_default.duplicateRecord({
4699
- id,
4700
- model,
4701
- context
4702
3083
  })
4703
3084
  });
4704
- };
4705
- var use_duplicate_record_default = useDuplicateRecord;
4706
- var useGetListData = (listDataProps, queryKey, enabled) => {
4707
- return useQuery({
4708
- queryKey,
4709
- queryFn: () => model_service_default.getAll({ data: listDataProps }).then((res) => {
4710
- if (res) {
4711
- return res;
4712
- }
4713
- return [];
4714
- }),
4715
- enabled,
4716
- refetchOnWindowFocus: false,
4717
- staleTime: 0
4718
- });
4719
- };
4720
- var use_get_list_data_default = useGetListData;
4721
- var useGetMenu = ({ context, enabled, queryKey }) => {
4722
- return useQuery({
4723
- queryKey,
4724
- queryFn: async () => {
4725
- const res = await view_service_default.getMenu(context);
4726
- if (res?.records && Array.isArray(res.records) && res.records.length > 0) {
4727
- return res.records;
4728
- }
4729
- return [];
4730
- },
4731
- refetchOnWindowFocus: false,
4732
- staleTime: Infinity,
4733
- enabled
4734
- });
4735
- };
4736
- var use_get_menu_default = useGetMenu;
4737
- var useGetSelection = ({
4738
- data,
4739
- queryKey,
4740
- enabled
4741
- }) => {
4742
- return useQuery({
4743
- queryKey,
4744
- queryFn: () => view_service_default.getSelectionItem({ data }),
4745
- enabled,
4746
- refetchOnWindowFocus: false
4747
- });
4748
- };
4749
- var use_get_selection_default = useGetSelection;
4750
- var useGetView = (viewParams, actData) => {
4751
- return useQuery({
4752
- queryKey: ["get_view_by_action" /* GET_VIEW_BY_ACTION */, viewParams],
4753
- queryFn: () => view_service_default.getView(viewParams),
4754
- enabled: !!actData,
4755
- refetchOnWindowFocus: false,
4756
- staleTime: Infinity
4757
- });
4758
- };
4759
- var use_get_view_default = useGetView;
4760
- var useLoadAction = ({
4761
- idAction,
4762
- context
4763
- }) => {
4764
- return useQuery({
4765
- queryKey: ["load_action", idAction],
4766
- queryFn: () => action_service_default.loadAction({
4767
- idAction,
4768
- context
4769
- }),
4770
- enabled: false,
4771
- staleTime: Infinity,
4772
- gcTime: Infinity
4773
- });
4774
- };
4775
- var use_load_action_default = useLoadAction;
4776
- var usePrint = () => {
4777
- return useMutation({
4778
- mutationFn: ({ id, report, db }) => action_service_default.print({
4779
- id,
4780
- report,
4781
- db
4782
- })
4783
- });
4784
- };
4785
- var use_print_default = usePrint;
4786
- var useRemoveRow = () => {
4787
- return useMutation({
4788
- mutationFn: ({
4789
- model,
4790
- ids,
4791
- context
4792
- }) => action_service_default.removeRows({
4793
- model,
4794
- ids,
4795
- context
4796
- })
4797
- });
4798
- };
4799
- var use_remove_row_default = useRemoveRow;
4800
- var useRunAction = ({ idAction, context }) => {
4801
- return useQuery({
4802
- queryKey: ["run_action", idAction],
4803
- queryFn: () => action_service_default.runAction({
4804
- idAction,
4805
- context
4806
- }),
4807
- enabled: false,
4808
- staleTime: Infinity,
4809
- gcTime: Infinity
4810
- });
4811
- };
4812
- var use_run_action_default = useRunAction;
3085
+ }
4813
3086
 
4814
- export { use_button_default as useButton, use_change_status_default as useChangeStatus, use_delete_default as useDelete, use_delete_comment_default as useDeleteComment, use_duplicate_record_default as useDuplicateRecord, uss_execute_import_default as useExecuteImport, use_export_excel_default as useExportExcel, use_field_default as useField, use_forgot_password_default as useForgotPassword, use_get_all_default as useGetAll, use_get_comment_default as useGetComment, use_get_company_info_default as useGetCompanyInfo, use_get_current_company_default as useGetCurrentCompany, use_get_detail_default as useGetDetail, use_get_field_export_default as useGetFieldExport, use_get_field_onchange_default as useGetFieldOnChange, use_get_file_excel_default as useGetFileExcel, use_get_form_view_default as useGetFormView, use_get_image_default as useGetImage, use_get_list_data_default as useGetListData, use_get_menu_default as useGetMenu, use_get_profile_default as useGetProfile, use_get_provider_default as useGetProvider, use_get_selection_default as useGetSelection, use_get_user_default as useGetUser, use_get_view_default as useGetView, use_isvalid_token_default as useIsValidToken, use_load_action_default as useLoadAction, use_login_credential_default as useLoginCredential, use_login_socical_default as useLoginSocial, use_model_default as useModel, use_odoo_data_transform_default as useOdooDataTransform, use_onchange_form_default as useOnChangeForm, use_parse_preview_default as useParsePreview, use_print_default as usePrint, use_remove_row_default as useRemoveRow, use_reset_password_default as useResetPassword, use_run_action_default as useRunAction, use_save_default as useSave, use_send_comment_default as useSendComment, use_switch_locale_default as useSwitchLocale, use_update_password_default as useUpdatePassword, use_upload_file_default as useUploadFile, use_upload_id_file_default as useUploadIdFile, use_upload_image_default as useUploadImage };
3087
+ export { useButton };