@fctc/interface-logic 1.10.6 → 1.10.7

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/provider.js CHANGED
@@ -33,8 +33,10 @@ __export(provider_exports, {
33
33
  EnvProvider: () => EnvProvider,
34
34
  MainProvider: () => MainProvider,
35
35
  ReactQueryProvider: () => ReactQueryProvider,
36
+ ServiceProvider: () => ServiceProvider,
36
37
  VersionGate: () => VersionGate,
37
- useEnv: () => useEnv
38
+ useEnv: () => useEnv,
39
+ useService: () => useService
38
40
  });
39
41
  module.exports = __toCommonJS(provider_exports);
40
42
 
@@ -693,8 +695,47 @@ var import_react_query69 = require("@tanstack/react-query");
693
695
 
694
696
  // src/services/view-service/backup.ts
695
697
  var import_react = require("react");
698
+
699
+ // src/constants/api/uri-constant.ts
700
+ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
701
+ UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
702
+ UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
703
+ UriConstants2["CALL_PATH"] = "/call";
704
+ UriConstants2["COMPANY_PATH"] = "/company";
705
+ UriConstants2["PROFILE_PATH"] = "/userinfo";
706
+ UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
707
+ UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
708
+ UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
709
+ UriConstants2["LOAD_ACTION"] = `/load_action`;
710
+ UriConstants2["REPORT_PATH"] = `/report`;
711
+ UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
712
+ UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
713
+ UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
714
+ UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
715
+ UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
716
+ UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
717
+ UriConstants2["IMAGE_PATH"] = `/web/image`;
718
+ UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
719
+ UriConstants2["TOKEN"] = `/check_token`;
720
+ UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
721
+ UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
722
+ UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
723
+ UriConstants2["GRANT_ACCESS"] = "/grant-access";
724
+ UriConstants2["TOKEN_BY_CODE"] = "/token";
725
+ UriConstants2["LOGOUT"] = "/logout";
726
+ return UriConstants2;
727
+ })(UriConstants || {});
728
+
729
+ // src/constants/widget/widget-avatar-constant.ts
730
+ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
731
+ WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
732
+ WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
733
+ return WIDGETAVATAR2;
734
+ })(WIDGETAVATAR || {});
735
+
736
+ // src/services/view-service/backup.ts
696
737
  function useViewService() {
697
- const { env } = useEnv();
738
+ const { env: env2 } = useEnv();
698
739
  const getView = (0, import_react.useCallback)(
699
740
  async ({ model, views, context = {}, options = {}, aid }) => {
700
741
  const defaultOptions = {
@@ -711,13 +752,13 @@ function useViewService() {
711
752
  },
712
753
  with_context: context
713
754
  };
714
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
755
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
715
756
  headers: {
716
757
  "Content-Type": "application/json"
717
758
  }
718
759
  });
719
760
  },
720
- [env]
761
+ [env2]
721
762
  );
722
763
  const getMenu = (0, import_react.useCallback)(
723
764
  async (context) => {
@@ -824,13 +865,13 @@ function useViewService() {
824
865
  ]
825
866
  }
826
867
  };
827
- return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
868
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
828
869
  headers: {
829
870
  "Content-Type": "application/json"
830
871
  }
831
872
  });
832
873
  },
833
- [env]
874
+ [env2]
834
875
  );
835
876
  const getActionDetail = (0, import_react.useCallback)(
836
877
  async (aid, context) => {
@@ -854,13 +895,13 @@ function useViewService() {
854
895
  }
855
896
  }
856
897
  };
857
- return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
898
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
858
899
  headers: {
859
900
  "Content-Type": "application/json"
860
901
  }
861
902
  });
862
903
  },
863
- [env]
904
+ [env2]
864
905
  );
865
906
  const getResequence = (0, import_react.useCallback)(
866
907
  async ({ model, ids, context, offset }) => {
@@ -871,13 +912,13 @@ function useViewService() {
871
912
  field: "sequence",
872
913
  ...offset > 0 ? { offset } : {}
873
914
  };
874
- return env?.requests.post("/web/dataset/resequence", jsonData, {
915
+ return env2?.requests.post("/web/dataset/resequence", jsonData, {
875
916
  headers: {
876
917
  "Content-Type": "application/json"
877
918
  }
878
919
  });
879
920
  },
880
- [env]
921
+ [env2]
881
922
  );
882
923
  const getSelectionItem = (0, import_react.useCallback)(
883
924
  async ({ data }) => {
@@ -898,17 +939,17 @@ function useViewService() {
898
939
  }
899
940
  }
900
941
  };
901
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
942
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
902
943
  headers: {
903
944
  "Content-Type": "application/json"
904
945
  }
905
946
  });
906
947
  },
907
- [env]
948
+ [env2]
908
949
  );
909
950
  const loadMessages = (0, import_react.useCallback)(
910
951
  async () => {
911
- return env.requests.post(
952
+ return env2.requests.post(
912
953
  "/load_message_failures" /* LOAD_MESSAGE */,
913
954
  {},
914
955
  {
@@ -918,18 +959,18 @@ function useViewService() {
918
959
  }
919
960
  );
920
961
  },
921
- [env]
962
+ [env2]
922
963
  );
923
964
  const getVersion = (0, import_react.useCallback)(
924
965
  async () => {
925
- console.log("env?.requests", env, env?.requests);
926
- return env?.requests?.get("", {
966
+ console.log("env?.requests", env2, env2?.requests);
967
+ return env2?.requests?.get("", {
927
968
  headers: {
928
969
  "Content-Type": "application/json"
929
970
  }
930
971
  });
931
972
  },
932
- [env]
973
+ [env2]
933
974
  );
934
975
  return {
935
976
  getView,
@@ -3059,6 +3100,21 @@ function matchDomain(record, domain) {
3059
3100
 
3060
3101
  // src/utils/function.ts
3061
3102
  var import_react2 = require("react");
3103
+ var isBase64File = (str) => {
3104
+ try {
3105
+ const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
3106
+ if (dataUriPattern.test(str)) {
3107
+ return true;
3108
+ }
3109
+ const base64Pattern = (
3110
+ // eslint-disable-next-line no-useless-escape
3111
+ /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
3112
+ );
3113
+ return base64Pattern.test(str);
3114
+ } catch (e) {
3115
+ return false;
3116
+ }
3117
+ };
3062
3118
  var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
3063
3119
  if (!originalRequest.data) return originalRequest.data;
3064
3120
  if (typeof originalRequest.data === "string") {
@@ -3289,14 +3345,1070 @@ var axiosClient = {
3289
3345
  }
3290
3346
  };
3291
3347
 
3348
+ // src/environment/EnvStore.ts
3349
+ var EventEmitter = class {
3350
+ listeners = {};
3351
+ on(event, callback) {
3352
+ if (!this.listeners[event]) {
3353
+ this.listeners[event] = [];
3354
+ }
3355
+ this.listeners[event].push(callback);
3356
+ }
3357
+ emit(event, data) {
3358
+ if (this.listeners[event]) {
3359
+ this.listeners[event].forEach((callback) => callback(data));
3360
+ }
3361
+ }
3362
+ };
3363
+ var EnvStore = class {
3364
+ state;
3365
+ emitter;
3366
+ localStorageUtil;
3367
+ sessionStorageUtil;
3368
+ constructor(localStorageUtil = localStorageUtils(), sessionStorageUtil = sessionStorageUtils()) {
3369
+ this.state = {
3370
+ baseUrl: "",
3371
+ requests: null,
3372
+ companies: [],
3373
+ user: {},
3374
+ config: null,
3375
+ envFile: null,
3376
+ defaultCompany: {
3377
+ id: null,
3378
+ logo: "",
3379
+ secondary_color: "",
3380
+ primary_color: ""
3381
+ },
3382
+ context: {
3383
+ uid: null,
3384
+ allowed_company_ids: [],
3385
+ lang: "vi_VN",
3386
+ tz: "Asia/Saigon"
3387
+ },
3388
+ localStorageUtils: localStorageUtil,
3389
+ sessionStorageUtils: sessionStorageUtil
3390
+ };
3391
+ this.emitter = new EventEmitter();
3392
+ this.localStorageUtil = localStorageUtil;
3393
+ this.sessionStorageUtil = sessionStorageUtil;
3394
+ }
3395
+ getEnv() {
3396
+ return { ...this.state };
3397
+ }
3398
+ onUpdate(callback) {
3399
+ this.emitter.on("update", callback);
3400
+ }
3401
+ setupEnv(envConfig) {
3402
+ this.state = {
3403
+ ...this.state,
3404
+ ...envConfig,
3405
+ localStorageUtils: this.localStorageUtil,
3406
+ sessionStorageUtils: this.sessionStorageUtil
3407
+ };
3408
+ this.state.requests = axiosClient.init(this.state);
3409
+ this.emitter.emit("update", this.getEnv());
3410
+ return this.getEnv();
3411
+ }
3412
+ setUid(uid) {
3413
+ this.state = {
3414
+ ...this.state,
3415
+ context: { ...this.state.context, uid }
3416
+ };
3417
+ this.emitter.emit("update", this.getEnv());
3418
+ }
3419
+ setLang(lang) {
3420
+ this.state = {
3421
+ ...this.state,
3422
+ context: { ...this.state.context, lang }
3423
+ };
3424
+ this.emitter.emit("update", this.getEnv());
3425
+ }
3426
+ setAllowCompanies(allowed_company_ids) {
3427
+ this.state = {
3428
+ ...this.state,
3429
+ context: { ...this.state.context, allowed_company_ids }
3430
+ };
3431
+ this.emitter.emit("update", this.getEnv());
3432
+ }
3433
+ setCompanies(companies) {
3434
+ this.state = { ...this.state, companies };
3435
+ this.emitter.emit("update", this.getEnv());
3436
+ }
3437
+ setDefaultCompany(defaultCompany) {
3438
+ this.state = { ...this.state, defaultCompany };
3439
+ this.emitter.emit("update", this.getEnv());
3440
+ }
3441
+ setUserInfo(user) {
3442
+ this.state = { ...this.state, user };
3443
+ this.emitter.emit("update", this.getEnv());
3444
+ }
3445
+ setConfig(config) {
3446
+ this.state = { ...this.state, config };
3447
+ this.emitter.emit("update", this.getEnv());
3448
+ }
3449
+ setEnvFile(envFile) {
3450
+ this.state = { ...this.state, envFile };
3451
+ this.emitter.emit("update", this.getEnv());
3452
+ }
3453
+ };
3454
+ var env = null;
3455
+ function initEnv({
3456
+ localStorageUtils: localStorageUtil = localStorageUtils(),
3457
+ sessionStorageUtils: sessionStorageUtil = sessionStorageUtils()
3458
+ }) {
3459
+ if (!env) {
3460
+ env = new EnvStore(localStorageUtil, sessionStorageUtil);
3461
+ }
3462
+ return env;
3463
+ }
3464
+ function getEnv() {
3465
+ if (!env) {
3466
+ env = initEnv({});
3467
+ }
3468
+ return env?.getEnv();
3469
+ }
3470
+
3471
+ // src/services/auth-service/index.ts
3472
+ var AuthService = {
3473
+ async login(body) {
3474
+ const env2 = getEnv();
3475
+ const payload = Object.fromEntries(
3476
+ Object.entries({
3477
+ username: body.email,
3478
+ password: body.password,
3479
+ grant_type: env2?.config?.grantType || "",
3480
+ client_id: env2?.config?.clientId || "",
3481
+ client_secret: env2?.config?.clientSecret || ""
3482
+ }).filter(([_, value]) => !!value)
3483
+ );
3484
+ const encodedData = new URLSearchParams(payload).toString();
3485
+ return env2?.requests?.post(body.path, encodedData, {
3486
+ headers: {
3487
+ "Content-Type": "application/x-www-form-urlencoded"
3488
+ }
3489
+ });
3490
+ },
3491
+ async forgotPassword(email) {
3492
+ const env2 = getEnv();
3493
+ const bodyData = {
3494
+ login: email,
3495
+ url: `${window.location.origin}/reset-password`
3496
+ };
3497
+ return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3498
+ headers: {
3499
+ "Content-Type": "application/json"
3500
+ }
3501
+ });
3502
+ },
3503
+ async forgotPasswordSSO({
3504
+ email,
3505
+ with_context,
3506
+ method
3507
+ }) {
3508
+ const env2 = getEnv();
3509
+ const body = {
3510
+ method,
3511
+ kwargs: {
3512
+ vals: {
3513
+ email
3514
+ }
3515
+ },
3516
+ with_context
3517
+ };
3518
+ return env2?.requests?.post("/call" /* CALL_PATH */, body, {
3519
+ headers: {
3520
+ "Content-Type": "application/json"
3521
+ }
3522
+ });
3523
+ },
3524
+ async resetPassword(data, token) {
3525
+ const env2 = getEnv();
3526
+ const bodyData = {
3527
+ token,
3528
+ password: data.password,
3529
+ new_password: data.confirmPassword
3530
+ };
3531
+ return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3532
+ headers: {
3533
+ "Content-Type": "application/json"
3534
+ }
3535
+ });
3536
+ },
3537
+ async resetPasswordSSO({
3538
+ method,
3539
+ password,
3540
+ with_context
3541
+ }) {
3542
+ const env2 = getEnv();
3543
+ const bodyData = {
3544
+ method,
3545
+ kwargs: {
3546
+ vals: {
3547
+ password
3548
+ }
3549
+ },
3550
+ with_context
3551
+ };
3552
+ return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3553
+ headers: {
3554
+ "Content-Type": "application/json"
3555
+ }
3556
+ });
3557
+ },
3558
+ async updatePassword(data, token) {
3559
+ const env2 = getEnv();
3560
+ const bodyData = {
3561
+ token,
3562
+ old_password: data.oldPassword,
3563
+ new_password: data.newPassword
3564
+ };
3565
+ return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3566
+ headers: {
3567
+ "Content-Type": "application/json"
3568
+ }
3569
+ });
3570
+ },
3571
+ async isValidToken(token) {
3572
+ const env2 = getEnv();
3573
+ const bodyData = {
3574
+ token
3575
+ };
3576
+ return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3577
+ headers: {
3578
+ "Content-Type": "application/json"
3579
+ }
3580
+ });
3581
+ },
3582
+ async isValidActionToken(actionToken, path) {
3583
+ const env2 = getEnv();
3584
+ return env2?.requests?.post(
3585
+ path,
3586
+ {},
3587
+ {
3588
+ headers: {
3589
+ "Content-Type": "application/json"
3590
+ },
3591
+ useActionToken: true,
3592
+ actionToken
3593
+ }
3594
+ );
3595
+ },
3596
+ async loginSocial({
3597
+ db,
3598
+ state,
3599
+ access_token
3600
+ }) {
3601
+ const env2 = getEnv();
3602
+ return env2?.requests?.post(
3603
+ "/token/generate" /* GENTOKEN_SOCIAL */,
3604
+ { state, access_token },
3605
+ {
3606
+ headers: {
3607
+ "Content-Type": "application/json"
3608
+ }
3609
+ }
3610
+ );
3611
+ },
3612
+ async getProviders(db) {
3613
+ const env2 = getEnv();
3614
+ return env2?.requests?.get("/oauth/providers", { params: { db } });
3615
+ },
3616
+ async getAccessByCode(code) {
3617
+ const env2 = getEnv();
3618
+ const data = new URLSearchParams();
3619
+ data.append("code", code);
3620
+ data.append("grant_type", "authorization_code");
3621
+ data.append("client_id", env2?.config?.clientId || "");
3622
+ data.append("redirect_uri", env2?.config?.redirectUri || "");
3623
+ return env2?.requests?.post(
3624
+ `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3625
+ data,
3626
+ {
3627
+ headers: {
3628
+ "Content-Type": "application/x-www-form-urlencoded"
3629
+ }
3630
+ }
3631
+ );
3632
+ },
3633
+ async logout(data) {
3634
+ const env2 = getEnv();
3635
+ console.log(data);
3636
+ return env2?.requests?.post(
3637
+ "/logout" /* LOGOUT */,
3638
+ {},
3639
+ {
3640
+ headers: {
3641
+ "Content-Type": "application/json"
3642
+ },
3643
+ withCredentials: true,
3644
+ useRefreshToken: true
3645
+ }
3646
+ );
3647
+ }
3648
+ };
3649
+ var auth_service_default = AuthService;
3650
+
3651
+ // src/services/company-service/index.ts
3652
+ var CompanyService = {
3653
+ async getCurrentCompany() {
3654
+ const env2 = getEnv();
3655
+ return await env2.requests.get("/company" /* COMPANY_PATH */, {
3656
+ headers: {
3657
+ "Content-Type": "application/json"
3658
+ }
3659
+ });
3660
+ },
3661
+ async getInfoCompany(id) {
3662
+ const env2 = getEnv();
3663
+ const jsonData = {
3664
+ ids: [id],
3665
+ model: "res.company" /* COMPANY */,
3666
+ method: "web_read" /* WEB_READ */,
3667
+ kwargs: {
3668
+ specification: {
3669
+ primary_color: {},
3670
+ secondary_color: {},
3671
+ logo: {},
3672
+ display_name: {},
3673
+ secondary_logo: {}
3674
+ }
3675
+ }
3676
+ };
3677
+ return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3678
+ headers: {
3679
+ "Content-Type": "application/json"
3680
+ }
3681
+ });
3682
+ }
3683
+ };
3684
+ var company_service_default = CompanyService;
3685
+
3686
+ // src/services/excel-service/index.ts
3687
+ var ExcelService = {
3688
+ async uploadFile({ formData }) {
3689
+ const env2 = getEnv();
3690
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3691
+ headers: {
3692
+ "Content-Type": "multipart/form-data"
3693
+ }
3694
+ });
3695
+ },
3696
+ async uploadIdFile({ formData }) {
3697
+ const env2 = getEnv();
3698
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3699
+ headers: {
3700
+ "Content-Type": "multipart/form-data"
3701
+ }
3702
+ });
3703
+ },
3704
+ async parsePreview({
3705
+ id,
3706
+ selectedSheet,
3707
+ isHeader,
3708
+ context
3709
+ }) {
3710
+ const env2 = getEnv();
3711
+ const jsonData = {
3712
+ model: "base_import.import" /* BASE_IMPORT */,
3713
+ method: "parse_preview",
3714
+ ids: [id],
3715
+ kwargs: {
3716
+ options: {
3717
+ import_skip_records: [],
3718
+ import_set_empty_fields: [],
3719
+ fallback_values: {},
3720
+ name_create_enabled_fields: {},
3721
+ encoding: "",
3722
+ separator: "",
3723
+ quoting: '"',
3724
+ date_format: "",
3725
+ datetime_format: "",
3726
+ float_thousand_separator: ",",
3727
+ float_decimal_separator: ".",
3728
+ advanced: true,
3729
+ has_headers: isHeader,
3730
+ keep_matches: false,
3731
+ limit: 2e3,
3732
+ sheets: [],
3733
+ sheet: selectedSheet,
3734
+ skip: 0,
3735
+ tracking_disable: true
3736
+ }
3737
+ },
3738
+ with_context: context
3739
+ };
3740
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3741
+ headers: {
3742
+ "Content-Type": "multipart/form-data"
3743
+ }
3744
+ });
3745
+ },
3746
+ async executeImport({
3747
+ columns,
3748
+ fields,
3749
+ idFile,
3750
+ options,
3751
+ dryrun,
3752
+ context
3753
+ }) {
3754
+ const env2 = getEnv();
3755
+ const jsonData = {
3756
+ model: "base_import.import" /* BASE_IMPORT */,
3757
+ method: "execute_import",
3758
+ ids: [idFile],
3759
+ kwargs: {
3760
+ fields,
3761
+ columns,
3762
+ options,
3763
+ dryrun
3764
+ },
3765
+ with_context: context
3766
+ };
3767
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3768
+ headers: {
3769
+ "Content-Type": "multipart/form-data"
3770
+ }
3771
+ });
3772
+ },
3773
+ async getFileExcel({ model }) {
3774
+ const env2 = getEnv();
3775
+ const jsonData = {
3776
+ model,
3777
+ method: "get_import_templates" /* GET_IMPORT */,
3778
+ args: []
3779
+ };
3780
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3781
+ },
3782
+ async getFieldExport({
3783
+ ids,
3784
+ model,
3785
+ isShow,
3786
+ parentField,
3787
+ fieldType,
3788
+ parentName,
3789
+ prefix,
3790
+ name,
3791
+ context,
3792
+ importCompat
3793
+ }) {
3794
+ const env2 = getEnv();
3795
+ const jsonData = {
3796
+ model,
3797
+ import_compat: importCompat,
3798
+ domain: [["id", "in", ids]],
3799
+ with_context: context
3800
+ };
3801
+ if (isShow) {
3802
+ jsonData.parent_field = parentField;
3803
+ jsonData.parent_field_type = fieldType;
3804
+ jsonData.parent_name = parentName;
3805
+ jsonData.name = name;
3806
+ jsonData.prefix = prefix;
3807
+ jsonData.exclude = [null];
3808
+ }
3809
+ return env2.requests.post("/export/get_fields", jsonData);
3810
+ },
3811
+ async exportExcel({
3812
+ model,
3813
+ domain,
3814
+ ids,
3815
+ fields,
3816
+ type,
3817
+ importCompat,
3818
+ context,
3819
+ groupby
3820
+ }) {
3821
+ const env2 = getEnv();
3822
+ const jsonData = {
3823
+ model,
3824
+ domain,
3825
+ ids,
3826
+ import_compat: importCompat,
3827
+ fields,
3828
+ with_context: context,
3829
+ groupby: groupby ?? []
3830
+ };
3831
+ return env2.requests.post_excel(`/export/${type}`, jsonData);
3832
+ }
3833
+ };
3834
+ var excel_service_default = ExcelService;
3835
+
3836
+ // src/services/form-service/index.ts
3837
+ var FormService = {
3838
+ async getComment({ data }) {
3839
+ try {
3840
+ const env2 = getEnv();
3841
+ const jsonData = {
3842
+ thread_id: data.thread_id,
3843
+ thread_model: data.thread_model,
3844
+ limit: 100,
3845
+ with_context: {
3846
+ lang: data.lang
3847
+ }
3848
+ };
3849
+ return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3850
+ headers: {
3851
+ "Content-Type": "application/json"
3852
+ }
3853
+ });
3854
+ } catch (error) {
3855
+ console.error("Error when sending message:", error);
3856
+ throw error;
3857
+ }
3858
+ },
3859
+ async sentComment({ data }) {
3860
+ try {
3861
+ const env2 = getEnv();
3862
+ const jsonData = {
3863
+ context: {
3864
+ tz: "Asia/Saigon",
3865
+ uid: 2,
3866
+ allowed_company_ids: [1],
3867
+ mail_post_autofollow: false,
3868
+ temporary_id: 142183.01
3869
+ },
3870
+ post_data: {
3871
+ body: data.message,
3872
+ message_type: "comment",
3873
+ attachment_ids: data.attachment_ids,
3874
+ attachment_tokens: [],
3875
+ subtype_xmlid: data.subtype
3876
+ },
3877
+ thread_id: Number(data.thread_id),
3878
+ thread_model: data.thread_model
3879
+ };
3880
+ return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3881
+ headers: {
3882
+ "Content-Type": "application/json"
3883
+ }
3884
+ });
3885
+ } catch (error) {
3886
+ console.error("Error when sent message:", error);
3887
+ throw error;
3888
+ }
3889
+ },
3890
+ async deleteComment({ data }) {
3891
+ try {
3892
+ const env2 = getEnv();
3893
+ const jsonData = {
3894
+ attachment_ids: [],
3895
+ attachment_tokens: [],
3896
+ body: "",
3897
+ message_id: data.message_id
3898
+ };
3899
+ return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3900
+ headers: {
3901
+ "Content-Type": "application/json"
3902
+ }
3903
+ });
3904
+ } catch (error) {
3905
+ console.error("Error when sent message:", error);
3906
+ throw error;
3907
+ }
3908
+ },
3909
+ async getImage({ data }) {
3910
+ try {
3911
+ const env2 = getEnv();
3912
+ return env2.requests.get(
3913
+ `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3914
+ {
3915
+ headers: {
3916
+ "Content-Type": "application/json"
3917
+ }
3918
+ }
3919
+ );
3920
+ } catch (error) {
3921
+ console.error("Error when sent message:", error);
3922
+ throw error;
3923
+ }
3924
+ },
3925
+ async uploadImage({ data }) {
3926
+ try {
3927
+ const env2 = getEnv();
3928
+ return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3929
+ headers: {
3930
+ "Content-Type": "multipart/form-data"
3931
+ }
3932
+ });
3933
+ } catch (error) {
3934
+ console.error("Error when sent message:", error);
3935
+ throw error;
3936
+ }
3937
+ },
3938
+ async getFormView({ data }) {
3939
+ try {
3940
+ const env2 = getEnv();
3941
+ const jsonData = {
3942
+ model: data.model,
3943
+ method: "get_formview_action",
3944
+ ids: data.id ? [data.id] : [],
3945
+ with_context: data.context
3946
+ };
3947
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3948
+ headers: {
3949
+ "Content-Type": "application/json"
3950
+ }
3951
+ });
3952
+ } catch (error) {
3953
+ console.error("Error when fetching form view:", error);
3954
+ throw error;
3955
+ }
3956
+ },
3957
+ async changeStatus({ data }) {
3958
+ const env2 = getEnv();
3959
+ const vals = {
3960
+ [data.name]: data.stage_id
3961
+ };
3962
+ const jsonData = {
3963
+ model: data.model,
3964
+ method: "web_save",
3965
+ with_context: {
3966
+ lang: data.lang,
3967
+ allowed_company_ids: [1],
3968
+ uid: 2,
3969
+ search_default_my_ticket: true,
3970
+ search_default_is_open: true
3971
+ },
3972
+ ids: [data.id],
3973
+ kwargs: {
3974
+ vals,
3975
+ specification: {}
3976
+ }
3977
+ };
3978
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3979
+ headers: {
3980
+ "Content-Type": "application/json"
3981
+ }
3982
+ });
3983
+ }
3984
+ };
3985
+ var form_service_default = FormService;
3986
+
3987
+ // src/services/model-service/index.ts
3988
+ var OBJECT_POSITION = 2;
3989
+ var ModelService = {
3990
+ async getListMyBankAccount({
3991
+ domain,
3992
+ spectification,
3993
+ model
3994
+ }) {
3995
+ const env2 = getEnv();
3996
+ const jsonData = {
3997
+ model,
3998
+ method: "web_search_read",
3999
+ kwargs: {
4000
+ specification: spectification,
4001
+ domain,
4002
+ limit: 100,
4003
+ offset: 0
4004
+ }
4005
+ };
4006
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4007
+ headers: {
4008
+ "Content-Type": "application/json"
4009
+ }
4010
+ });
4011
+ },
4012
+ async getCurrency() {
4013
+ const env2 = getEnv();
4014
+ const jsonData = {
4015
+ model: "res.currency",
4016
+ method: "web_search_read",
4017
+ kwargs: {
4018
+ specification: {
4019
+ icon_url: {},
4020
+ name: {}
4021
+ },
4022
+ domain: [["active", "=", true]],
4023
+ limit: 100,
4024
+ offset: 0
4025
+ }
4026
+ };
4027
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4028
+ headers: {
4029
+ "Content-Type": "application/json"
4030
+ }
4031
+ });
4032
+ },
4033
+ async getConversionRate() {
4034
+ const env2 = getEnv();
4035
+ const jsonData = {
4036
+ model: "res.currency",
4037
+ method: "web_search_read",
4038
+ kwargs: {
4039
+ specification: {
4040
+ name: {},
4041
+ icon_url: {},
4042
+ rate_ids: {
4043
+ fields: {
4044
+ company_rate: {},
4045
+ sell: {}
4046
+ }
4047
+ }
4048
+ },
4049
+ domain: [["active", "=", true]],
4050
+ limit: 100,
4051
+ offset: 0
4052
+ }
4053
+ };
4054
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4055
+ headers: {
4056
+ "Content-Type": "application/json"
4057
+ }
4058
+ });
4059
+ },
4060
+ async getAll({ data }) {
4061
+ const env2 = getEnv();
4062
+ const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
4063
+ fields: data.fields,
4064
+ groupby: data.groupby
4065
+ } : {
4066
+ count_limit: 10001,
4067
+ order: data.sort,
4068
+ specification: data.specification
4069
+ };
4070
+ const jsonData = {
4071
+ model: String(data.model),
4072
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
4073
+ ids: data.ids,
4074
+ with_context: data.context,
4075
+ kwargs: {
4076
+ domain: data.domain,
4077
+ limit: data.limit,
4078
+ offset: data.offset,
4079
+ ...jsonReadGroup
4080
+ }
4081
+ };
4082
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4083
+ headers: {
4084
+ "Content-Type": "application/json"
4085
+ }
4086
+ });
4087
+ },
4088
+ async getListCalendar({ data }) {
4089
+ const env2 = getEnv();
4090
+ const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
4091
+ fields: data.fields,
4092
+ groupby: data.groupby
4093
+ } : {
4094
+ count_limit: 10001,
4095
+ order: data.sort,
4096
+ specification: data.specification
4097
+ };
4098
+ const jsonData = {
4099
+ model: String(data.model),
4100
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
4101
+ ids: data.ids,
4102
+ with_context: data.context,
4103
+ kwargs: {
4104
+ domain: data.domain,
4105
+ limit: data.limit,
4106
+ offset: data.offset,
4107
+ fields: data.fields,
4108
+ ...jsonReadGroup
4109
+ }
4110
+ };
4111
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4112
+ headers: {
4113
+ "Content-Type": "application/json"
4114
+ }
4115
+ });
4116
+ },
4117
+ async getList({
4118
+ model,
4119
+ ids = [],
4120
+ specification = {},
4121
+ domain = [],
4122
+ offset,
4123
+ order,
4124
+ context = {},
4125
+ limit = 10
4126
+ }) {
4127
+ const env2 = getEnv();
4128
+ const jsonData = {
4129
+ model,
4130
+ method: "web_search_read" /* WEB_SEARCH_READ */,
4131
+ ids,
4132
+ with_context: context,
4133
+ kwargs: {
4134
+ specification,
4135
+ domain,
4136
+ limit,
4137
+ offset,
4138
+ order
4139
+ }
4140
+ };
4141
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4142
+ headers: {
4143
+ "Content-Type": "application/json"
4144
+ }
4145
+ });
4146
+ },
4147
+ async getDetail({
4148
+ ids = [],
4149
+ model,
4150
+ specification,
4151
+ context
4152
+ }) {
4153
+ const env2 = getEnv();
4154
+ const jsonData = {
4155
+ model,
4156
+ method: "web_read" /* WEB_READ */,
4157
+ ids,
4158
+ with_context: context,
4159
+ kwargs: {
4160
+ specification
4161
+ }
4162
+ };
4163
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4164
+ headers: {
4165
+ "Content-Type": "application/json"
4166
+ }
4167
+ });
4168
+ },
4169
+ async save({
4170
+ model,
4171
+ ids = [],
4172
+ data = {},
4173
+ specification = {},
4174
+ context = {},
4175
+ path
4176
+ }) {
4177
+ const env2 = getEnv();
4178
+ const jsonData = {
4179
+ model,
4180
+ method: "web_save" /* WEB_SAVE */,
4181
+ with_context: context,
4182
+ ids,
4183
+ kwargs: {
4184
+ vals: data,
4185
+ specification
4186
+ }
4187
+ };
4188
+ return env2?.requests?.post(path ?? "/call" /* CALL_PATH */, jsonData, {
4189
+ headers: {
4190
+ "Content-Type": "application/json"
4191
+ }
4192
+ });
4193
+ },
4194
+ async delete({ ids = [], model }) {
4195
+ const env2 = getEnv();
4196
+ const jsonData = {
4197
+ model,
4198
+ method: "unlink" /* UNLINK */,
4199
+ ids
4200
+ };
4201
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4202
+ headers: {
4203
+ "Content-Type": "application/json"
4204
+ }
4205
+ });
4206
+ },
4207
+ async onChange({
4208
+ ids = [],
4209
+ model,
4210
+ object,
4211
+ specification,
4212
+ context,
4213
+ fieldChange
4214
+ }) {
4215
+ const env2 = getEnv();
4216
+ const jsonData = {
4217
+ model,
4218
+ method: "onchange" /* ONCHANGE */,
4219
+ ids,
4220
+ with_context: context,
4221
+ args: [
4222
+ object ? object : {},
4223
+ fieldChange ? fieldChange : [],
4224
+ specification
4225
+ ]
4226
+ };
4227
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4228
+ headers: {
4229
+ "Content-Type": "application/json"
4230
+ }
4231
+ });
4232
+ },
4233
+ async getListFieldsOnchange({ model }) {
4234
+ const env2 = getEnv();
4235
+ const jsonData = {
4236
+ model,
4237
+ method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
4238
+ };
4239
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4240
+ headers: {
4241
+ "Content-Type": "application/json"
4242
+ }
4243
+ });
4244
+ },
4245
+ parseORMOdoo(data) {
4246
+ for (const key in data) {
4247
+ if (key === "display_name") {
4248
+ delete data[key];
4249
+ }
4250
+ if (!data[key] && data[key] !== 0) {
4251
+ data[key] = false;
4252
+ } else if (data[key] === "Draft") {
4253
+ data[key] = "/";
4254
+ }
4255
+ }
4256
+ return { ...data };
4257
+ },
4258
+ toDataJS(data, viewData, model) {
4259
+ for (const key in data) {
4260
+ if (data[key] === false) {
4261
+ if (viewData && model) {
4262
+ if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
4263
+ data[key] = null;
4264
+ }
4265
+ } else {
4266
+ data[key] = null;
4267
+ }
4268
+ } else if (data[key] === "/") {
4269
+ data[key] = "Draft";
4270
+ } else if (data[key] !== false) {
4271
+ if (model !== void 0) {
4272
+ if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
4273
+ data[key] = (data[key] ??= [])?.map((item) => {
4274
+ const relation = viewData?.models?.[model]?.[key]?.relation;
4275
+ if (relation !== void 0) {
4276
+ if (viewData?.models?.[relation]) {
4277
+ if (item?.length >= 3) {
4278
+ return ModelService.toDataJS(
4279
+ item[OBJECT_POSITION],
4280
+ viewData,
4281
+ relation
4282
+ );
4283
+ } else {
4284
+ return ModelService.toDataJS(item, viewData, relation);
4285
+ }
4286
+ } else {
4287
+ if (item?.length >= 3) {
4288
+ return item[OBJECT_POSITION];
4289
+ } else {
4290
+ return item;
4291
+ }
4292
+ }
4293
+ }
4294
+ });
4295
+ }
4296
+ }
4297
+ }
4298
+ }
4299
+ return { ...data };
4300
+ }
4301
+ };
4302
+ var model_service_default = ModelService;
4303
+
4304
+ // src/services/user-service/index.ts
4305
+ var UserService = {
4306
+ async getProfile(path) {
4307
+ const env2 = getEnv();
4308
+ return env2?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4309
+ headers: {
4310
+ "Content-Type": "application/x-www-form-urlencoded"
4311
+ }
4312
+ });
4313
+ },
4314
+ async getUser({ context, id }) {
4315
+ const env2 = getEnv();
4316
+ const jsonData = {
4317
+ model: "res.users",
4318
+ method: "web_read",
4319
+ ids: [id],
4320
+ with_context: context,
4321
+ kwargs: {
4322
+ specification: {
4323
+ display_name: {},
4324
+ image_1920: {},
4325
+ name: {},
4326
+ login: {},
4327
+ email: {},
4328
+ password: {},
4329
+ visible_group_id: {
4330
+ fields: {
4331
+ id: {},
4332
+ display_name: {}
4333
+ }
4334
+ },
4335
+ company_id: {
4336
+ fields: {
4337
+ id: {},
4338
+ display_name: {}
4339
+ }
4340
+ }
4341
+ }
4342
+ }
4343
+ };
4344
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4345
+ headers: {
4346
+ "Content-Type": "application/json"
4347
+ }
4348
+ });
4349
+ },
4350
+ switchUserLocale: async ({ id, values }) => {
4351
+ const env2 = getEnv();
4352
+ const jsonData = {
4353
+ model: "res.users",
4354
+ domain: [["id", "=", id]],
4355
+ values
4356
+ };
4357
+ return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4358
+ headers: {
4359
+ "Content-Type": "application/json"
4360
+ }
4361
+ });
4362
+ }
4363
+ };
4364
+ var user_service_default = UserService;
4365
+
4366
+ // src/hooks/auth/use-forgot-password.ts
4367
+ var useForgotPassword = () => {
4368
+ return (0, import_react_query2.useMutation)({
4369
+ mutationFn: (email) => {
4370
+ return auth_service_default.forgotPassword(email);
4371
+ }
4372
+ });
4373
+ };
4374
+ var use_forgot_password_default = useForgotPassword;
4375
+
3292
4376
  // src/hooks/auth/use-forgotpassword-sso.ts
3293
4377
  var import_react_query3 = require("@tanstack/react-query");
4378
+ var useForgotPasswordSSO = () => {
4379
+ return (0, import_react_query3.useMutation)({
4380
+ mutationFn: ({
4381
+ email,
4382
+ with_context,
4383
+ method
4384
+ }) => {
4385
+ return auth_service_default.forgotPasswordSSO({ email, with_context, method });
4386
+ }
4387
+ });
4388
+ };
4389
+ var use_forgotpassword_sso_default = useForgotPasswordSSO;
3294
4390
 
3295
4391
  // src/hooks/auth/use-get-provider.ts
3296
4392
  var import_react_query4 = require("@tanstack/react-query");
4393
+ var useGetProvider = () => {
4394
+ return (0, import_react_query4.useMutation)({
4395
+ mutationFn: (data) => {
4396
+ return auth_service_default.getProviders(data?.db);
4397
+ }
4398
+ });
4399
+ };
4400
+ var use_get_provider_default = useGetProvider;
3297
4401
 
3298
4402
  // src/hooks/auth/use-isvalid-token.ts
3299
4403
  var import_react_query5 = require("@tanstack/react-query");
4404
+ var useIsValidToken = () => {
4405
+ return (0, import_react_query5.useMutation)({
4406
+ mutationFn: (token) => {
4407
+ return auth_service_default.isValidToken(token);
4408
+ }
4409
+ });
4410
+ };
4411
+ var use_isvalid_token_default = useIsValidToken;
3300
4412
 
3301
4413
  // src/hooks/auth/use-login-credential.tsx
3302
4414
  var import_react_query6 = require("@tanstack/react-query");
@@ -3304,26 +4416,26 @@ var import_react_query6 = require("@tanstack/react-query");
3304
4416
  // src/services/auth-service/backup.ts
3305
4417
  var import_react3 = require("react");
3306
4418
  function useAuthService() {
3307
- const { env } = useEnv();
4419
+ const { env: env2 } = useEnv();
3308
4420
  const login = (0, import_react3.useCallback)(
3309
4421
  async (body) => {
3310
4422
  const payload = Object.fromEntries(
3311
4423
  Object.entries({
3312
4424
  username: body.email,
3313
4425
  password: body.password,
3314
- grant_type: env?.config?.grantType || "",
3315
- client_id: env?.config?.clientId || "",
3316
- client_secret: env?.config?.clientSecret || ""
4426
+ grant_type: env2?.config?.grantType || "",
4427
+ client_id: env2?.config?.clientId || "",
4428
+ client_secret: env2?.config?.clientSecret || ""
3317
4429
  }).filter(([_, value]) => !!value)
3318
4430
  );
3319
4431
  const encodedData = new URLSearchParams(payload).toString();
3320
- return env?.requests?.post(body.path, encodedData, {
4432
+ return env2?.requests?.post(body.path, encodedData, {
3321
4433
  headers: {
3322
4434
  "Content-Type": "application/x-www-form-urlencoded"
3323
4435
  }
3324
4436
  });
3325
4437
  },
3326
- [env]
4438
+ [env2]
3327
4439
  );
3328
4440
  const forgotPassword = (0, import_react3.useCallback)(
3329
4441
  async (email) => {
@@ -3331,13 +4443,13 @@ function useAuthService() {
3331
4443
  login: email,
3332
4444
  url: `${window.location.origin}/reset-password`
3333
4445
  };
3334
- return env?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
4446
+ return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3335
4447
  headers: {
3336
4448
  "Content-Type": "application/json"
3337
4449
  }
3338
4450
  });
3339
4451
  },
3340
- [env]
4452
+ [env2]
3341
4453
  );
3342
4454
  const forgotPasswordSSO = (0, import_react3.useCallback)(
3343
4455
  async ({
@@ -3354,13 +4466,13 @@ function useAuthService() {
3354
4466
  },
3355
4467
  with_context
3356
4468
  };
3357
- return env?.requests?.post("/call" /* CALL_PATH */, body, {
4469
+ return env2?.requests?.post("/call" /* CALL_PATH */, body, {
3358
4470
  headers: {
3359
4471
  "Content-Type": "application/json"
3360
4472
  }
3361
4473
  });
3362
4474
  },
3363
- [env]
4475
+ [env2]
3364
4476
  );
3365
4477
  const resetPassword = (0, import_react3.useCallback)(
3366
4478
  async (data, token) => {
@@ -3369,13 +4481,13 @@ function useAuthService() {
3369
4481
  password: data.password,
3370
4482
  new_password: data.confirmPassword
3371
4483
  };
3372
- return env?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
4484
+ return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3373
4485
  headers: {
3374
4486
  "Content-Type": "application/json"
3375
4487
  }
3376
4488
  });
3377
4489
  },
3378
- [env]
4490
+ [env2]
3379
4491
  );
3380
4492
  const resetPasswordSSO = (0, import_react3.useCallback)(
3381
4493
  async ({
@@ -3392,13 +4504,13 @@ function useAuthService() {
3392
4504
  },
3393
4505
  with_context
3394
4506
  };
3395
- return env?.requests?.post("/call" /* CALL_PATH */, bodyData, {
4507
+ return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
3396
4508
  headers: {
3397
4509
  "Content-Type": "application/json"
3398
4510
  }
3399
4511
  });
3400
4512
  },
3401
- [env]
4513
+ [env2]
3402
4514
  );
3403
4515
  const updatePassword = (0, import_react3.useCallback)(
3404
4516
  async (data, token) => {
@@ -3407,30 +4519,30 @@ function useAuthService() {
3407
4519
  old_password: data.oldPassword,
3408
4520
  new_password: data.newPassword
3409
4521
  };
3410
- return env?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
4522
+ return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3411
4523
  headers: {
3412
4524
  "Content-Type": "application/json"
3413
4525
  }
3414
4526
  });
3415
4527
  },
3416
- [env]
4528
+ [env2]
3417
4529
  );
3418
4530
  const isValidToken = (0, import_react3.useCallback)(
3419
4531
  async (token) => {
3420
4532
  const bodyData = {
3421
4533
  token
3422
4534
  };
3423
- return env?.requests?.post("/check_token" /* TOKEN */, bodyData, {
4535
+ return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3424
4536
  headers: {
3425
4537
  "Content-Type": "application/json"
3426
4538
  }
3427
4539
  });
3428
4540
  },
3429
- [env]
4541
+ [env2]
3430
4542
  );
3431
4543
  const isValidActionToken = (0, import_react3.useCallback)(
3432
4544
  async (actionToken, path) => {
3433
- return env?.requests?.post(
4545
+ return env2?.requests?.post(
3434
4546
  path,
3435
4547
  {},
3436
4548
  {
@@ -3442,7 +4554,7 @@ function useAuthService() {
3442
4554
  }
3443
4555
  );
3444
4556
  },
3445
- [env]
4557
+ [env2]
3446
4558
  );
3447
4559
  const loginSocial = (0, import_react3.useCallback)(
3448
4560
  async ({
@@ -3450,7 +4562,7 @@ function useAuthService() {
3450
4562
  state,
3451
4563
  access_token
3452
4564
  }) => {
3453
- return env?.requests?.post(
4565
+ return env2?.requests?.post(
3454
4566
  "/token/generate" /* GENTOKEN_SOCIAL */,
3455
4567
  { state, access_token },
3456
4568
  {
@@ -3460,23 +4572,23 @@ function useAuthService() {
3460
4572
  }
3461
4573
  );
3462
4574
  },
3463
- [env]
4575
+ [env2]
3464
4576
  );
3465
4577
  const getProviders = (0, import_react3.useCallback)(
3466
4578
  async (db) => {
3467
- return env?.requests?.get("/oauth/providers", { params: { db } });
4579
+ return env2?.requests?.get("/oauth/providers", { params: { db } });
3468
4580
  },
3469
- [env]
4581
+ [env2]
3470
4582
  );
3471
4583
  const getAccessByCode = (0, import_react3.useCallback)(
3472
4584
  async (code) => {
3473
4585
  const data = new URLSearchParams();
3474
4586
  data.append("code", code);
3475
4587
  data.append("grant_type", "authorization_code");
3476
- data.append("client_id", env?.config?.clientId || "");
3477
- data.append("redirect_uri", env?.config?.redirectUri || "");
3478
- return env?.requests?.post(
3479
- `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
4588
+ data.append("client_id", env2?.config?.clientId || "");
4589
+ data.append("redirect_uri", env2?.config?.redirectUri || "");
4590
+ return env2?.requests?.post(
4591
+ `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3480
4592
  data,
3481
4593
  {
3482
4594
  headers: {
@@ -3485,12 +4597,12 @@ function useAuthService() {
3485
4597
  }
3486
4598
  );
3487
4599
  },
3488
- [env]
4600
+ [env2]
3489
4601
  );
3490
4602
  const logout = (0, import_react3.useCallback)(
3491
4603
  async (data) => {
3492
4604
  console.log(data);
3493
- return env?.requests?.post(
4605
+ return env2?.requests?.post(
3494
4606
  "/logout" /* LOGOUT */,
3495
4607
  {},
3496
4608
  {
@@ -3502,7 +4614,7 @@ function useAuthService() {
3502
4614
  }
3503
4615
  );
3504
4616
  },
3505
- [env]
4617
+ [env2]
3506
4618
  );
3507
4619
  return {
3508
4620
  login,
@@ -3550,7 +4662,7 @@ function EnvProvider({
3550
4662
  localStorageUtils: localStorageUtil = localStorageUtils(),
3551
4663
  sessionStorageUtils: sessionStorageUtil = sessionStorageUtils()
3552
4664
  }) {
3553
- const [env, setEnvState] = (0, import_react4.useState)({
4665
+ const [env2, setEnvState] = (0, import_react4.useState)({
3554
4666
  ...initialEnvState,
3555
4667
  localStorageUtils: localStorageUtil,
3556
4668
  sessionStorageUtils: sessionStorageUtil
@@ -3558,7 +4670,7 @@ function EnvProvider({
3558
4670
  const setupEnv = (0, import_react4.useCallback)(
3559
4671
  (envConfig) => {
3560
4672
  const updatedEnv = {
3561
- ...env,
4673
+ ...env2,
3562
4674
  ...envConfig,
3563
4675
  localStorageUtils: localStorageUtil,
3564
4676
  sessionStorageUtils: sessionStorageUtil
@@ -3567,7 +4679,7 @@ function EnvProvider({
3567
4679
  setEnvState({ ...updatedEnv, requests });
3568
4680
  return updatedEnv;
3569
4681
  },
3570
- [env, localStorageUtil, sessionStorageUtil]
4682
+ [env2, localStorageUtil, sessionStorageUtil]
3571
4683
  );
3572
4684
  const setUid2 = (0, import_react4.useCallback)((uid) => {
3573
4685
  setEnvState((prev) => ({
@@ -3624,7 +4736,7 @@ function EnvProvider({
3624
4736
  EnvContext.Provider,
3625
4737
  {
3626
4738
  value: {
3627
- env,
4739
+ env: env2,
3628
4740
  setupEnv,
3629
4741
  setUid: setUid2,
3630
4742
  setLang: setLang2,
@@ -3649,8 +4761,8 @@ function useEnv() {
3649
4761
 
3650
4762
  // src/hooks/auth/use-login-credential.tsx
3651
4763
  var useLoginCredential = () => {
3652
- const { env } = useEnv();
3653
- console.log("useLoginCredential called", env, new Error().stack);
4764
+ const { env: env2 } = useEnv();
4765
+ console.log("useLoginCredential called", env2, new Error().stack);
3654
4766
  const { login } = useAuthService();
3655
4767
  return (0, import_react_query6.useMutation)({
3656
4768
  mutationFn: (data) => {
@@ -3662,111 +4774,696 @@ var use_login_credential_default = useLoginCredential;
3662
4774
 
3663
4775
  // src/hooks/auth/use-login-socical.ts
3664
4776
  var import_react_query7 = require("@tanstack/react-query");
4777
+ var useLoginSocial = () => {
4778
+ return (0, import_react_query7.useMutation)({
4779
+ mutationFn: (data) => {
4780
+ return auth_service_default.loginSocial(data);
4781
+ }
4782
+ });
4783
+ };
4784
+ var use_login_socical_default = useLoginSocial;
3665
4785
 
3666
4786
  // src/hooks/auth/use-reset-password.ts
3667
4787
  var import_react_query8 = require("@tanstack/react-query");
4788
+ var useResetPassword = () => {
4789
+ return (0, import_react_query8.useMutation)({
4790
+ mutationFn: (request) => {
4791
+ return auth_service_default.resetPassword(request.data, request.token);
4792
+ }
4793
+ });
4794
+ };
4795
+ var use_reset_password_default = useResetPassword;
3668
4796
 
3669
4797
  // src/hooks/auth/use-reset-password-sso.ts
3670
4798
  var import_react_query9 = require("@tanstack/react-query");
4799
+ var useResetPasswordSSO = () => {
4800
+ return (0, import_react_query9.useMutation)({
4801
+ mutationFn: ({
4802
+ method,
4803
+ password,
4804
+ with_context
4805
+ }) => {
4806
+ return auth_service_default.resetPasswordSSO({
4807
+ method,
4808
+ password,
4809
+ with_context
4810
+ });
4811
+ }
4812
+ });
4813
+ };
4814
+ var use_reset_password_sso_default = useResetPasswordSSO;
3671
4815
 
3672
4816
  // src/hooks/auth/use-update-password.ts
3673
4817
  var import_react_query10 = require("@tanstack/react-query");
4818
+ var useUpdatePassword = () => {
4819
+ return (0, import_react_query10.useMutation)({
4820
+ mutationFn: (request) => {
4821
+ return auth_service_default.updatePassword(request.data, request.token);
4822
+ }
4823
+ });
4824
+ };
4825
+ var use_update_password_default = useUpdatePassword;
3674
4826
 
3675
4827
  // src/hooks/auth/use-logout.ts
3676
4828
  var import_react_query11 = require("@tanstack/react-query");
4829
+ var useLogout = () => {
4830
+ return (0, import_react_query11.useMutation)({
4831
+ mutationFn: (data) => {
4832
+ return auth_service_default.logout(data);
4833
+ }
4834
+ });
4835
+ };
4836
+ var use_logout_default = useLogout;
3677
4837
 
3678
4838
  // src/hooks/auth/use-get-access-by-code.ts
3679
4839
  var import_react_query12 = require("@tanstack/react-query");
4840
+ var useGetAccessByCode = () => {
4841
+ return (0, import_react_query12.useMutation)({
4842
+ mutationFn: ({ code }) => {
4843
+ return auth_service_default.getAccessByCode(code);
4844
+ }
4845
+ });
4846
+ };
4847
+ var use_get_access_by_code_default = useGetAccessByCode;
3680
4848
 
3681
4849
  // src/hooks/auth/use-validate-action-token.ts
3682
4850
  var import_react_query13 = require("@tanstack/react-query");
4851
+ var useValidateActionToken = () => {
4852
+ return (0, import_react_query13.useMutation)({
4853
+ mutationFn: ({
4854
+ actionToken,
4855
+ path
4856
+ }) => {
4857
+ return auth_service_default.isValidActionToken(actionToken, path);
4858
+ }
4859
+ });
4860
+ };
4861
+ var use_validate_action_token_default = useValidateActionToken;
3683
4862
 
3684
4863
  // src/hooks/company/use-get-company-info.ts
3685
4864
  var import_react_query14 = require("@tanstack/react-query");
4865
+ var useGetCompanyInfo = () => {
4866
+ return (0, import_react_query14.useMutation)({
4867
+ mutationFn: (id) => company_service_default.getInfoCompany(id)
4868
+ });
4869
+ };
4870
+ var use_get_company_info_default = useGetCompanyInfo;
3686
4871
 
3687
4872
  // src/hooks/company/use-get-current-company.ts
3688
4873
  var import_react_query15 = require("@tanstack/react-query");
4874
+ var useGetCurrentCompany = () => {
4875
+ return (0, import_react_query15.useMutation)({
4876
+ mutationFn: () => company_service_default.getCurrentCompany()
4877
+ });
4878
+ };
4879
+ var use_get_current_company_default = useGetCurrentCompany;
3689
4880
 
3690
4881
  // src/hooks/company/use-get-list-company.ts
3691
4882
  var import_react_query16 = require("@tanstack/react-query");
4883
+ var useGetListCompany = (companyIDs = []) => {
4884
+ const companySpec = {
4885
+ id: {},
4886
+ name: {}
4887
+ };
4888
+ const getListParams = {
4889
+ model: "res.company" /* COMPANY */,
4890
+ ids: companyIDs,
4891
+ specification: companySpec
4892
+ };
4893
+ return (0, import_react_query16.useQuery)({
4894
+ queryKey: ["list_company" /* LIST_COMPANY */, companyIDs],
4895
+ queryFn: () => model_service_default.getList(getListParams),
4896
+ refetchOnWindowFocus: false
4897
+ });
4898
+ };
4899
+ var use_get_list_company_default = useGetListCompany;
3692
4900
 
3693
4901
  // src/hooks/excel/use-export-excel.ts
3694
4902
  var import_react_query17 = require("@tanstack/react-query");
4903
+ var useExportExcel = () => {
4904
+ return (0, import_react_query17.useMutation)({
4905
+ mutationFn: ({
4906
+ model,
4907
+ domain,
4908
+ ids,
4909
+ fields,
4910
+ type,
4911
+ importCompat,
4912
+ context,
4913
+ groupby
4914
+ }) => excel_service_default.exportExcel({
4915
+ model,
4916
+ domain,
4917
+ ids,
4918
+ fields,
4919
+ type,
4920
+ importCompat,
4921
+ context,
4922
+ groupby
4923
+ })
4924
+ });
4925
+ };
4926
+ var use_export_excel_default = useExportExcel;
3695
4927
 
3696
4928
  // src/hooks/excel/use-get-field-export.ts
3697
4929
  var import_react_query18 = require("@tanstack/react-query");
4930
+ var useGetFieldExport = () => {
4931
+ return (0, import_react_query18.useMutation)({
4932
+ mutationFn: ({
4933
+ ids,
4934
+ model,
4935
+ isShow,
4936
+ parentField,
4937
+ fieldType,
4938
+ parentName,
4939
+ prefix,
4940
+ name,
4941
+ context,
4942
+ importCompat
4943
+ }) => excel_service_default.getFieldExport({
4944
+ ids,
4945
+ model,
4946
+ isShow,
4947
+ parentField,
4948
+ fieldType,
4949
+ parentName,
4950
+ prefix,
4951
+ name,
4952
+ context,
4953
+ importCompat
4954
+ })
4955
+ });
4956
+ };
4957
+ var use_get_field_export_default = useGetFieldExport;
3698
4958
 
3699
4959
  // src/hooks/excel/use-get-file-excel.ts
3700
4960
  var import_react_query19 = require("@tanstack/react-query");
4961
+ var useGetFileExcel = ({ model }) => {
4962
+ return (0, import_react_query19.useQuery)({
4963
+ queryKey: [],
4964
+ queryFn: () => excel_service_default.getFileExcel({
4965
+ model
4966
+ }).then((res) => {
4967
+ if (res) {
4968
+ return res;
4969
+ }
4970
+ return [];
4971
+ }),
4972
+ refetchOnWindowFocus: false
4973
+ });
4974
+ };
4975
+ var use_get_file_excel_default = useGetFileExcel;
3701
4976
 
3702
4977
  // src/hooks/excel/use-parse-preview.ts
3703
4978
  var import_react_query20 = require("@tanstack/react-query");
4979
+ var useParsePreview = () => {
4980
+ return (0, import_react_query20.useMutation)({
4981
+ mutationFn: ({
4982
+ id,
4983
+ selectedSheet,
4984
+ isHeader,
4985
+ context
4986
+ }) => excel_service_default.parsePreview({
4987
+ id,
4988
+ selectedSheet,
4989
+ isHeader,
4990
+ context
4991
+ })
4992
+ });
4993
+ };
4994
+ var use_parse_preview_default = useParsePreview;
3704
4995
 
3705
4996
  // src/hooks/excel/use-upload-file.ts
3706
4997
  var import_react_query21 = require("@tanstack/react-query");
4998
+ var useUploadFile = () => {
4999
+ return (0, import_react_query21.useMutation)({
5000
+ mutationFn: ({ formData }) => excel_service_default.uploadFile({
5001
+ formData
5002
+ })
5003
+ });
5004
+ };
5005
+ var use_upload_file_default = useUploadFile;
3707
5006
 
3708
5007
  // src/hooks/excel/use-upload-id-file.ts
3709
5008
  var import_react_query22 = require("@tanstack/react-query");
5009
+ var useUploadIdFile = () => {
5010
+ return (0, import_react_query22.useMutation)({
5011
+ mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
5012
+ formData
5013
+ })
5014
+ });
5015
+ };
5016
+ var use_upload_id_file_default = useUploadIdFile;
3710
5017
 
3711
5018
  // src/hooks/excel/uss-execute-import.ts
3712
5019
  var import_react_query23 = require("@tanstack/react-query");
5020
+ var useExecuteImport = () => {
5021
+ return (0, import_react_query23.useMutation)({
5022
+ mutationFn: ({
5023
+ fields,
5024
+ columns,
5025
+ idFile,
5026
+ options,
5027
+ dryrun,
5028
+ context
5029
+ }) => excel_service_default.executeImport({
5030
+ fields,
5031
+ columns,
5032
+ idFile,
5033
+ options,
5034
+ dryrun,
5035
+ context
5036
+ })
5037
+ });
5038
+ };
5039
+ var uss_execute_import_default = useExecuteImport;
3713
5040
 
3714
5041
  // src/hooks/form/use-change-status.ts
3715
5042
  var import_react_query24 = require("@tanstack/react-query");
5043
+ var useChangeStatus = () => {
5044
+ return (0, import_react_query24.useMutation)({
5045
+ mutationFn: ({ data }) => {
5046
+ return form_service_default.changeStatus({
5047
+ data
5048
+ });
5049
+ }
5050
+ });
5051
+ };
5052
+ var use_change_status_default = useChangeStatus;
3716
5053
 
3717
5054
  // src/hooks/form/use-delete-comment.ts
3718
5055
  var import_react_query25 = require("@tanstack/react-query");
5056
+ var useDeleteComment = () => {
5057
+ return (0, import_react_query25.useMutation)({
5058
+ mutationFn: ({ data }) => form_service_default.deleteComment({
5059
+ data
5060
+ })
5061
+ });
5062
+ };
5063
+ var use_delete_comment_default = useDeleteComment;
3719
5064
 
3720
5065
  // src/hooks/form/use-get-comment.ts
3721
5066
  var import_react_query26 = require("@tanstack/react-query");
5067
+ var useGetComment = ({ data, queryKey }) => {
5068
+ return (0, import_react_query26.useQuery)({
5069
+ queryKey,
5070
+ queryFn: () => form_service_default.getComment({ data }).then((res) => {
5071
+ if (res) {
5072
+ return res;
5073
+ }
5074
+ }),
5075
+ enabled: !!data.thread_id && !isNaN(data.thread_id),
5076
+ refetchOnWindowFocus: false
5077
+ });
5078
+ };
5079
+ var use_get_comment_default = useGetComment;
3722
5080
 
3723
5081
  // src/hooks/form/use-get-form-view.ts
3724
5082
  var import_react_query27 = require("@tanstack/react-query");
5083
+ var useGetFormView = ({
5084
+ data,
5085
+ queryKey,
5086
+ enabled
5087
+ }) => {
5088
+ return (0, import_react_query27.useQuery)({
5089
+ queryKey,
5090
+ queryFn: () => form_service_default.getFormView({ data }).then((res) => {
5091
+ if (res) {
5092
+ return res;
5093
+ }
5094
+ }),
5095
+ enabled,
5096
+ refetchOnWindowFocus: false
5097
+ });
5098
+ };
5099
+ var use_get_form_view_default = useGetFormView;
3725
5100
 
3726
5101
  // src/hooks/form/use-get-image.ts
3727
5102
  var import_react_query28 = require("@tanstack/react-query");
5103
+ var useGetImage = ({
5104
+ data,
5105
+ queryKey,
5106
+ src
5107
+ }) => {
5108
+ return (0, import_react_query28.useQuery)({
5109
+ queryKey,
5110
+ queryFn: () => form_service_default.getImage({ data }).then((res) => {
5111
+ if (res) {
5112
+ return res;
5113
+ }
5114
+ }),
5115
+ enabled: !src && !isBase64File(src),
5116
+ refetchOnWindowFocus: false
5117
+ });
5118
+ };
5119
+ var use_get_image_default = useGetImage;
3728
5120
 
3729
5121
  // src/hooks/form/use-send-comment.ts
3730
5122
  var import_react_query29 = require("@tanstack/react-query");
5123
+ var useSendComment = () => {
5124
+ return (0, import_react_query29.useMutation)({
5125
+ mutationFn: ({ data }) => form_service_default.sentComment({
5126
+ data
5127
+ })
5128
+ });
5129
+ };
5130
+ var use_send_comment_default = useSendComment;
3731
5131
 
3732
5132
  // src/hooks/form/use-upload-image.ts
3733
5133
  var import_react_query30 = require("@tanstack/react-query");
5134
+ var useUploadImage = () => {
5135
+ return (0, import_react_query30.useMutation)({
5136
+ mutationFn: ({ data }) => form_service_default.uploadImage({
5137
+ data
5138
+ })
5139
+ });
5140
+ };
5141
+ var use_upload_image_default = useUploadImage;
3734
5142
 
3735
5143
  // src/hooks/model/use-delete.ts
3736
5144
  var import_react_query31 = require("@tanstack/react-query");
5145
+ var useDelete = () => {
5146
+ return (0, import_react_query31.useMutation)({
5147
+ mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
5148
+ });
5149
+ };
5150
+ var use_delete_default = useDelete;
3737
5151
 
3738
5152
  // src/hooks/model/use-get-all.ts
3739
5153
  var import_react_query32 = require("@tanstack/react-query");
5154
+ var useGetAll = ({ data, queryKey, viewResponse }) => {
5155
+ return (0, import_react_query32.useQuery)({
5156
+ queryKey,
5157
+ queryFn: () => model_service_default.getAll({ data }).then((res) => {
5158
+ if (res) {
5159
+ return res;
5160
+ }
5161
+ }),
5162
+ enabled: !!data.specification && !!data.model && !!data.domain && !!viewResponse,
5163
+ refetchOnWindowFocus: false
5164
+ // placeholderData: keepPreviousData,
5165
+ });
5166
+ };
5167
+ var use_get_all_default = useGetAll;
3740
5168
 
3741
5169
  // src/hooks/model/use-get-conversion-rate.ts
3742
5170
  var import_react_query33 = require("@tanstack/react-query");
5171
+ var useGetConversionRate = () => {
5172
+ return (0, import_react_query33.useQuery)({
5173
+ queryKey: ["currency-rate"],
5174
+ queryFn: () => model_service_default.getConversionRate().then((res) => {
5175
+ if (res) {
5176
+ return res;
5177
+ }
5178
+ }),
5179
+ enabled: true
5180
+ });
5181
+ };
5182
+ var use_get_conversion_rate_default = useGetConversionRate;
3743
5183
 
3744
5184
  // src/hooks/model/use-get-currency.ts
3745
5185
  var import_react_query34 = require("@tanstack/react-query");
5186
+ var useGetCurrency = () => {
5187
+ return (0, import_react_query34.useQuery)({
5188
+ queryKey: ["currency"],
5189
+ queryFn: () => model_service_default.getCurrency().then((res) => {
5190
+ if (res) {
5191
+ return res;
5192
+ }
5193
+ }),
5194
+ enabled: true
5195
+ });
5196
+ };
5197
+ var use_get_currency_default = useGetCurrency;
3746
5198
 
3747
5199
  // src/hooks/model/use-get-detail.ts
3748
5200
  var import_react_query35 = require("@tanstack/react-query");
5201
+ var useGetDetail = () => {
5202
+ return (0, import_react_query35.useMutation)({
5203
+ mutationFn: ({
5204
+ model,
5205
+ ids,
5206
+ specification,
5207
+ context
5208
+ }) => model_service_default.getDetail({
5209
+ model,
5210
+ ids,
5211
+ specification,
5212
+ context
5213
+ })
5214
+ });
5215
+ };
5216
+ var use_get_detail_default = useGetDetail;
3749
5217
 
3750
5218
  // src/hooks/model/use-get-field-onchange.ts
3751
5219
  var import_react_query36 = require("@tanstack/react-query");
5220
+ var useGetFieldOnChange = ({ model }) => {
5221
+ return (0, import_react_query36.useQuery)({
5222
+ queryKey: [`field-onchange-${model}`, model],
5223
+ queryFn: () => model_service_default.getListFieldsOnchange({
5224
+ model
5225
+ }).then((res) => {
5226
+ if (res) {
5227
+ return res;
5228
+ }
5229
+ }),
5230
+ refetchOnWindowFocus: false,
5231
+ staleTime: Infinity
5232
+ });
5233
+ };
5234
+ var use_get_field_onchange_default = useGetFieldOnChange;
3752
5235
 
3753
5236
  // src/hooks/model/use-get-list-my-bank-account.ts
3754
5237
  var import_react_query37 = require("@tanstack/react-query");
5238
+ var useGetListMyBankAccount = ({
5239
+ domain,
5240
+ spectification,
5241
+ model
5242
+ }) => {
5243
+ return (0, import_react_query37.useQuery)({
5244
+ queryKey: ["bank-account", model, domain],
5245
+ queryFn: () => model_service_default.getListMyBankAccount({
5246
+ domain,
5247
+ spectification,
5248
+ model
5249
+ }).then((res) => {
5250
+ if (res) {
5251
+ return res;
5252
+ }
5253
+ }),
5254
+ enabled: true
5255
+ });
5256
+ };
5257
+ var use_get_list_my_bank_account_default = useGetListMyBankAccount;
5258
+
5259
+ // src/models/base-model/index.ts
5260
+ var BaseModel = class {
5261
+ name;
5262
+ view;
5263
+ actContext;
5264
+ fields;
5265
+ constructor(init) {
5266
+ this.name = init.name;
5267
+ this.view = init.view;
5268
+ this.actContext = init.actContext;
5269
+ this.fields = init.fields;
5270
+ }
5271
+ getSpecificationByFields({
5272
+ fields = [],
5273
+ specification = {},
5274
+ modelsData,
5275
+ model,
5276
+ modelRoot
5277
+ }) {
5278
+ if (Array.isArray(fields)) {
5279
+ let spec = { ...specification };
5280
+ fields.forEach((field) => {
5281
+ if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
5282
+ if (modelsData?.[model]?.[field?.name]) {
5283
+ if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
5284
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
5285
+ const modelRelation = modelsData?.[relation];
5286
+ if (modelRelation) {
5287
+ spec[field?.name] = {
5288
+ fields: {}
5289
+ };
5290
+ if (modelRoot && modelRoot === relation) {
5291
+ spec[field?.name].fields = { id: {} };
5292
+ } else {
5293
+ spec[field?.name].fields = this.getSpecificationByFields({
5294
+ fields: Object.values(modelRelation),
5295
+ specification: {},
5296
+ modelsData,
5297
+ model: relation,
5298
+ modelRoot: model
5299
+ });
5300
+ }
5301
+ } else {
5302
+ spec[field?.name] = {
5303
+ fields: {
5304
+ id: {},
5305
+ display_name: {}
5306
+ }
5307
+ };
5308
+ }
5309
+ } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
5310
+ spec[field?.name] = {
5311
+ fields: {
5312
+ id: {},
5313
+ display_name: {},
5314
+ ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
5315
+ ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
5316
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
5317
+ }
5318
+ };
5319
+ } else {
5320
+ spec[field?.name] = {};
5321
+ }
5322
+ }
5323
+ } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
5324
+ const specGroup = this.getSpecificationByFields({
5325
+ fields: field?.fields,
5326
+ specification: spec,
5327
+ modelsData,
5328
+ model
5329
+ });
5330
+ spec = { ...spec, ...specGroup };
5331
+ } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
5332
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
5333
+ const specTreee = this.getSpecificationByFields({
5334
+ fields: field?.fields,
5335
+ specification: {},
5336
+ modelsData,
5337
+ model: relation,
5338
+ modelRoot: model
5339
+ });
5340
+ spec = { ...spec, [field?.name]: { fields: specTreee } };
5341
+ }
5342
+ });
5343
+ return spec;
5344
+ } else {
5345
+ console.warn("fields is not array");
5346
+ }
5347
+ }
5348
+ getTreeProps() {
5349
+ const props = this.view?.views?.list || {};
5350
+ return props;
5351
+ }
5352
+ getTreeFields() {
5353
+ const fields = this.view?.views?.list?.fields || [];
5354
+ return fields;
5355
+ }
5356
+ getSpecification() {
5357
+ const specInit = {};
5358
+ const modelData = this.view?.models || {};
5359
+ const specification = this.getSpecificationByFields({
5360
+ fields: this.fields,
5361
+ specification: specInit,
5362
+ modelsData: modelData,
5363
+ model: this.name,
5364
+ modelRoot: ""
5365
+ });
5366
+ return specification;
5367
+ }
5368
+ };
5369
+ var base_model_default = BaseModel;
5370
+
5371
+ // src/hooks/model/use-model.ts
5372
+ var useModel = () => {
5373
+ const initModel = (modelData) => {
5374
+ switch (modelData?.name) {
5375
+ default:
5376
+ return new base_model_default(modelData);
5377
+ }
5378
+ };
5379
+ return {
5380
+ initModel
5381
+ };
5382
+ };
5383
+ var use_model_default = useModel;
5384
+
5385
+ // src/hooks/model/use-odoo-data-transform.ts
5386
+ var useOdooDataTransform = () => {
5387
+ return {
5388
+ toDataJS: model_service_default.toDataJS,
5389
+ parseORM: model_service_default.parseORMOdoo
5390
+ };
5391
+ };
5392
+ var use_odoo_data_transform_default = useOdooDataTransform;
3755
5393
 
3756
5394
  // src/hooks/model/use-onchange-form.ts
3757
5395
  var import_react_query38 = require("@tanstack/react-query");
5396
+ var useOnChangeForm = () => {
5397
+ return (0, import_react_query38.useMutation)({
5398
+ mutationFn: ({
5399
+ ids,
5400
+ model,
5401
+ specification,
5402
+ context,
5403
+ object,
5404
+ fieldChange
5405
+ }) => model_service_default.onChange({
5406
+ ids,
5407
+ model,
5408
+ specification,
5409
+ context,
5410
+ object,
5411
+ fieldChange
5412
+ })
5413
+ });
5414
+ };
5415
+ var use_onchange_form_default = useOnChangeForm;
3758
5416
 
3759
5417
  // src/hooks/model/use-save.ts
3760
5418
  var import_react_query39 = require("@tanstack/react-query");
5419
+ var useSave = () => {
5420
+ return (0, import_react_query39.useMutation)({
5421
+ mutationFn: ({
5422
+ ids,
5423
+ model,
5424
+ data,
5425
+ specification,
5426
+ context,
5427
+ path
5428
+ }) => model_service_default.save({ ids, model, data, specification, context, path })
5429
+ });
5430
+ };
5431
+ var use_save_default = useSave;
3761
5432
 
3762
5433
  // src/hooks/user/use-get-profile.ts
3763
5434
  var import_react_query40 = require("@tanstack/react-query");
5435
+ var useGetProfile = (path) => {
5436
+ return (0, import_react_query40.useMutation)({
5437
+ mutationFn: () => user_service_default.getProfile(path)
5438
+ });
5439
+ };
5440
+ var use_get_profile_default = useGetProfile;
3764
5441
 
3765
5442
  // src/hooks/user/use-get-user.ts
3766
5443
  var import_react_query41 = require("@tanstack/react-query");
5444
+ var useGetUser = () => {
5445
+ return (0, import_react_query41.useMutation)({
5446
+ mutationFn: ({ id, context }) => user_service_default.getUser({
5447
+ id,
5448
+ context
5449
+ })
5450
+ });
5451
+ };
5452
+ var use_get_user_default = useGetUser;
3767
5453
 
3768
5454
  // src/hooks/user/use-switch-locale.ts
3769
5455
  var import_react_query42 = require("@tanstack/react-query");
5456
+ var useSwitchLocale = () => {
5457
+ return (0, import_react_query42.useMutation)({
5458
+ mutationFn: ({ data }) => {
5459
+ return user_service_default.switchUserLocale({
5460
+ id: data.id,
5461
+ values: data.values
5462
+ });
5463
+ }
5464
+ });
5465
+ };
5466
+ var use_switch_locale_default = useSwitchLocale;
3770
5467
 
3771
5468
  // src/hooks/view/use-button.ts
3772
5469
  var import_react_query43 = require("@tanstack/react-query");
@@ -3882,11 +5579,75 @@ var VersionGate = ({ children }) => {
3882
5579
  }, [queryClient]);
3883
5580
  return ready ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children }) : null;
3884
5581
  };
5582
+
5583
+ // src/provider/service-provider.tsx
5584
+ var import_react6 = require("react");
5585
+ var import_jsx_runtime6 = require("react/jsx-runtime");
5586
+ var ServiceContext = (0, import_react6.createContext)(null);
5587
+ var ServiceProvider = ({
5588
+ children
5589
+ }) => {
5590
+ const services = {
5591
+ useForgotPassword: use_forgot_password_default,
5592
+ useForgotPasswordSSO: use_forgotpassword_sso_default,
5593
+ useGetProvider: use_get_provider_default,
5594
+ useIsValidToken: use_isvalid_token_default,
5595
+ useLoginCredential: use_login_credential_default,
5596
+ useLoginSocial: use_login_socical_default,
5597
+ useResetPassword: use_reset_password_default,
5598
+ useResetPasswordSSO: use_reset_password_sso_default,
5599
+ useUpdatePassword: use_update_password_default,
5600
+ useLogout: use_logout_default,
5601
+ useGetAccessByCode: use_get_access_by_code_default,
5602
+ useValidateActionToken: use_validate_action_token_default,
5603
+ useGetCompanyInfo: use_get_company_info_default,
5604
+ useGetCurrentCompany: use_get_current_company_default,
5605
+ useGetListCompany: use_get_list_company_default,
5606
+ useExecuteImport: uss_execute_import_default,
5607
+ useExportExcel: use_export_excel_default,
5608
+ useGetFieldExport: use_get_field_export_default,
5609
+ useGetFileExcel: use_get_file_excel_default,
5610
+ useParsePreview: use_parse_preview_default,
5611
+ useUploadFile: use_upload_file_default,
5612
+ useUploadIdFile: use_upload_id_file_default,
5613
+ useChangeStatus: use_change_status_default,
5614
+ useDeleteComment: use_delete_comment_default,
5615
+ useGetComment: use_get_comment_default,
5616
+ useGetFormView: use_get_form_view_default,
5617
+ useGetImage: use_get_image_default,
5618
+ useSendComment: use_send_comment_default,
5619
+ useUploadImage: use_upload_image_default,
5620
+ useDelete: use_delete_default,
5621
+ useGetAll: use_get_all_default,
5622
+ useGetConversionRate: use_get_conversion_rate_default,
5623
+ useGetCurrency: use_get_currency_default,
5624
+ useGetDetail: use_get_detail_default,
5625
+ useGetFieldOnChange: use_get_field_onchange_default,
5626
+ useGetListMyBankAccount: use_get_list_my_bank_account_default,
5627
+ useModel: use_model_default,
5628
+ useOdooDataTransform: use_odoo_data_transform_default,
5629
+ useOnChangeForm: use_onchange_form_default,
5630
+ useSave: use_save_default,
5631
+ useGetProfile: use_get_profile_default,
5632
+ useGetUser: use_get_user_default,
5633
+ useSwitchLocale: use_switch_locale_default
5634
+ };
5635
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ServiceContext.Provider, { value: services, children });
5636
+ };
5637
+ var useService = () => {
5638
+ const context = (0, import_react6.useContext)(ServiceContext);
5639
+ if (!context) {
5640
+ throw new Error("useService must be used within a ServiceProvider");
5641
+ }
5642
+ return context;
5643
+ };
3885
5644
  // Annotate the CommonJS export names for ESM import in node:
3886
5645
  0 && (module.exports = {
3887
5646
  EnvProvider,
3888
5647
  MainProvider,
3889
5648
  ReactQueryProvider,
5649
+ ServiceProvider,
3890
5650
  VersionGate,
3891
- useEnv
5651
+ useEnv,
5652
+ useService
3892
5653
  });