@fctc/interface-logic 2.0.5 → 2.0.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
@@ -2891,15 +2891,21 @@ function useActionService() {
2891
2891
  const loadAction = (0, import_react2.useCallback)(
2892
2892
  async ({
2893
2893
  idAction,
2894
- context
2894
+ context,
2895
+ service
2895
2896
  }) => {
2896
2897
  const jsonData = {
2897
2898
  action_id: idAction,
2898
2899
  with_context: { ...context }
2899
2900
  };
2900
- return env.requests.post("/load_action" /* LOAD_ACTION */, jsonData, {
2901
- headers: { "Content-Type": "application/json" }
2902
- });
2901
+ return env.requests.post(
2902
+ "/load_action" /* LOAD_ACTION */,
2903
+ jsonData,
2904
+ {
2905
+ headers: { "Content-Type": "application/json" }
2906
+ },
2907
+ service
2908
+ );
2903
2909
  },
2904
2910
  [env]
2905
2911
  );
@@ -2908,7 +2914,8 @@ function useActionService() {
2908
2914
  model,
2909
2915
  ids = [],
2910
2916
  context,
2911
- method
2917
+ method,
2918
+ service
2912
2919
  }) => {
2913
2920
  try {
2914
2921
  const jsonData = {
@@ -2917,9 +2924,14 @@ function useActionService() {
2917
2924
  ids,
2918
2925
  with_context: context
2919
2926
  };
2920
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2921
- headers: { "Content-Type": "application/json" }
2922
- });
2927
+ return env.requests.post(
2928
+ "/call" /* CALL_PATH */,
2929
+ jsonData,
2930
+ {
2931
+ headers: { "Content-Type": "application/json" }
2932
+ },
2933
+ service
2934
+ );
2923
2935
  } catch (error) {
2924
2936
  console.error("Error when calling button action:", error);
2925
2937
  throw error;
@@ -2931,7 +2943,8 @@ function useActionService() {
2931
2943
  async ({
2932
2944
  model,
2933
2945
  ids,
2934
- context
2946
+ context,
2947
+ service
2935
2948
  }) => {
2936
2949
  const jsonData = {
2937
2950
  model,
@@ -2939,9 +2952,14 @@ function useActionService() {
2939
2952
  ids,
2940
2953
  with_context: context
2941
2954
  };
2942
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2943
- headers: { "Content-Type": "application/json" }
2944
- });
2955
+ return env.requests.post(
2956
+ "/call" /* CALL_PATH */,
2957
+ jsonData,
2958
+ {
2959
+ headers: { "Content-Type": "application/json" }
2960
+ },
2961
+ service
2962
+ );
2945
2963
  },
2946
2964
  [env]
2947
2965
  );
@@ -2949,7 +2967,8 @@ function useActionService() {
2949
2967
  async ({
2950
2968
  model,
2951
2969
  id,
2952
- context
2970
+ context,
2971
+ service
2953
2972
  }) => {
2954
2973
  const jsonData = {
2955
2974
  model,
@@ -2957,9 +2976,14 @@ function useActionService() {
2957
2976
  ids: id,
2958
2977
  with_context: context
2959
2978
  };
2960
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2961
- headers: { "Content-Type": "application/json" }
2962
- });
2979
+ return env.requests.post(
2980
+ "/call" /* CALL_PATH */,
2981
+ jsonData,
2982
+ {
2983
+ headers: { "Content-Type": "application/json" }
2984
+ },
2985
+ service
2986
+ );
2963
2987
  },
2964
2988
  [env]
2965
2989
  );
@@ -3002,15 +3026,21 @@ function useActionService() {
3002
3026
  const runAction = (0, import_react2.useCallback)(
3003
3027
  async ({
3004
3028
  idAction,
3005
- context
3029
+ context,
3030
+ service
3006
3031
  }) => {
3007
3032
  const jsonData = {
3008
3033
  action_id: idAction,
3009
3034
  with_context: { ...context }
3010
3035
  };
3011
- return env.requests.post("/run_action" /* RUN_ACTION_PATH */, jsonData, {
3012
- headers: { "Content-Type": "application/json" }
3013
- });
3036
+ return env.requests.post(
3037
+ "/run_action" /* RUN_ACTION_PATH */,
3038
+ jsonData,
3039
+ {
3040
+ headers: { "Content-Type": "application/json" }
3041
+ },
3042
+ service
3043
+ );
3014
3044
  },
3015
3045
  [env]
3016
3046
  );
@@ -3725,7 +3755,7 @@ function useModelService() {
3725
3755
  });
3726
3756
  }, [env]);
3727
3757
  const getAll = (0, import_react8.useCallback)(
3728
- async ({ data }) => {
3758
+ async ({ data, service }) => {
3729
3759
  const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3730
3760
  fields: data.fields,
3731
3761
  groupby: data.groupby
@@ -3746,11 +3776,16 @@ function useModelService() {
3746
3776
  ...jsonReadGroup
3747
3777
  }
3748
3778
  };
3749
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3750
- headers: {
3751
- "Content-Type": "application/json"
3752
- }
3753
- });
3779
+ return env.requests.post(
3780
+ "/call" /* CALL_PATH */,
3781
+ jsonData,
3782
+ {
3783
+ headers: {
3784
+ "Content-Type": "application/json"
3785
+ }
3786
+ },
3787
+ service
3788
+ );
3754
3789
  },
3755
3790
  [env]
3756
3791
  );
@@ -3818,7 +3853,13 @@ function useModelService() {
3818
3853
  [env]
3819
3854
  );
3820
3855
  const getDetail = (0, import_react8.useCallback)(
3821
- async ({ ids = [], model, specification, context }) => {
3856
+ async ({
3857
+ ids = [],
3858
+ model,
3859
+ specification,
3860
+ context,
3861
+ service
3862
+ }) => {
3822
3863
  const jsonData = {
3823
3864
  model,
3824
3865
  method: "web_read" /* WEB_READ */,
@@ -3828,11 +3869,16 @@ function useModelService() {
3828
3869
  specification
3829
3870
  }
3830
3871
  };
3831
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3832
- headers: {
3833
- "Content-Type": "application/json"
3834
- }
3835
- });
3872
+ return env.requests.post(
3873
+ "/call" /* CALL_PATH */,
3874
+ jsonData,
3875
+ {
3876
+ headers: {
3877
+ "Content-Type": "application/json"
3878
+ }
3879
+ },
3880
+ service
3881
+ );
3836
3882
  },
3837
3883
  [env]
3838
3884
  );
@@ -3843,7 +3889,8 @@ function useModelService() {
3843
3889
  data = {},
3844
3890
  specification = {},
3845
3891
  context = {},
3846
- path
3892
+ path,
3893
+ service
3847
3894
  }) => {
3848
3895
  const jsonData = {
3849
3896
  model,
@@ -3855,26 +3902,36 @@ function useModelService() {
3855
3902
  specification
3856
3903
  }
3857
3904
  };
3858
- return env.requests.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3859
- headers: {
3860
- "Content-Type": "application/json"
3861
- }
3862
- });
3905
+ return env.requests.post(
3906
+ path ?? "/call" /* CALL_PATH */,
3907
+ jsonData,
3908
+ {
3909
+ headers: {
3910
+ "Content-Type": "application/json"
3911
+ }
3912
+ },
3913
+ service
3914
+ );
3863
3915
  },
3864
3916
  [env]
3865
3917
  );
3866
3918
  const deleteApi = (0, import_react8.useCallback)(
3867
- async ({ ids = [], model }) => {
3919
+ async ({ ids = [], model, service }) => {
3868
3920
  const jsonData = {
3869
3921
  model,
3870
3922
  method: "unlink" /* UNLINK */,
3871
3923
  ids
3872
3924
  };
3873
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3874
- headers: {
3875
- "Content-Type": "application/json"
3876
- }
3877
- });
3925
+ return env.requests.post(
3926
+ "/call" /* CALL_PATH */,
3927
+ jsonData,
3928
+ {
3929
+ headers: {
3930
+ "Content-Type": "application/json"
3931
+ }
3932
+ },
3933
+ service
3934
+ );
3878
3935
  },
3879
3936
  [env]
3880
3937
  );
@@ -3885,7 +3942,8 @@ function useModelService() {
3885
3942
  object,
3886
3943
  specification,
3887
3944
  context,
3888
- fieldChange
3945
+ fieldChange,
3946
+ service
3889
3947
  }) => {
3890
3948
  const jsonData = {
3891
3949
  model,
@@ -3898,11 +3956,16 @@ function useModelService() {
3898
3956
  specification
3899
3957
  ]
3900
3958
  };
3901
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3902
- headers: {
3903
- "Content-Type": "application/json"
3904
- }
3905
- });
3959
+ return env.requests.post(
3960
+ "/call" /* CALL_PATH */,
3961
+ jsonData,
3962
+ {
3963
+ headers: {
3964
+ "Content-Type": "application/json"
3965
+ }
3966
+ },
3967
+ service
3968
+ );
3906
3969
  },
3907
3970
  [env]
3908
3971
  );
@@ -4076,7 +4139,8 @@ function useViewService() {
4076
4139
  views,
4077
4140
  context = {},
4078
4141
  options = {},
4079
- aid
4142
+ aid,
4143
+ service
4080
4144
  }) => {
4081
4145
  const defaultOptions = {
4082
4146
  load_filters: true,
@@ -4092,11 +4156,16 @@ function useViewService() {
4092
4156
  },
4093
4157
  with_context: context
4094
4158
  };
4095
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4096
- headers: {
4097
- "Content-Type": "application/json"
4098
- }
4099
- });
4159
+ return env?.requests?.post(
4160
+ "/call" /* CALL_PATH */,
4161
+ jsonDataView,
4162
+ {
4163
+ headers: {
4164
+ "Content-Type": "application/json"
4165
+ }
4166
+ },
4167
+ service
4168
+ );
4100
4169
  },
4101
4170
  [env]
4102
4171
  );
@@ -4179,7 +4248,7 @@ function useViewService() {
4179
4248
  [env]
4180
4249
  );
4181
4250
  const getSelectionItem = (0, import_react10.useCallback)(
4182
- async ({ data }) => {
4251
+ async ({ data, service }) => {
4183
4252
  const jsonData = {
4184
4253
  model: data.model,
4185
4254
  ids: [],
@@ -4197,11 +4266,16 @@ function useViewService() {
4197
4266
  }
4198
4267
  }
4199
4268
  };
4200
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4201
- headers: {
4202
- "Content-Type": "application/json"
4203
- }
4204
- });
4269
+ return env?.requests.post(
4270
+ "/call" /* CALL_PATH */,
4271
+ jsonData,
4272
+ {
4273
+ headers: {
4274
+ "Content-Type": "application/json"
4275
+ }
4276
+ },
4277
+ service
4278
+ );
4205
4279
  },
4206
4280
  [env]
4207
4281
  );
@@ -4494,7 +4568,6 @@ var sessionStorageUtils = () => {
4494
4568
  // src/configs/axios-client.ts
4495
4569
  var axiosClient = {
4496
4570
  init(config) {
4497
- console.log("config", config);
4498
4571
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
4499
4572
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
4500
4573
  const db = config?.db;
@@ -4513,7 +4586,7 @@ var axiosClient = {
4513
4586
  };
4514
4587
  const instance = import_axios.default.create({
4515
4588
  adapter: import_axios.default.defaults.adapter,
4516
- baseURL: config.baseUrl,
4589
+ baseURL: config?.baseUrl,
4517
4590
  timeout: 5e4,
4518
4591
  paramsSerializer: (params) => new URLSearchParams(params).toString()
4519
4592
  });
@@ -4525,7 +4598,6 @@ var axiosClient = {
4525
4598
  if (database) {
4526
4599
  config2.headers["DATABASE"] = database;
4527
4600
  }
4528
- console.log("database", database);
4529
4601
  const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
4530
4602
  const token = await getToken?.();
4531
4603
  if (token) config2.headers["Authorization"] = `Bearer ${token}`;
@@ -4583,7 +4655,7 @@ var axiosClient = {
4583
4655
  );
4584
4656
  return new Promise(function(resolve) {
4585
4657
  import_axios.default.post(
4586
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4658
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4587
4659
  payload,
4588
4660
  {
4589
4661
  headers: {
@@ -4651,20 +4723,47 @@ var axiosClient = {
4651
4723
  function formatUrl(url, db2) {
4652
4724
  return url + (db2 ? "?db=" + db2 : "");
4653
4725
  }
4726
+ const getBaseUrl = (baseUrl, serviceName) => {
4727
+ const service = serviceName || config?.default_service;
4728
+ return `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
4729
+ };
4654
4730
  const responseBody = (response) => response;
4655
4731
  const requests = {
4656
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
4657
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
4658
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
4659
- responseType: "arraybuffer",
4660
- headers: {
4661
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4662
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
4732
+ get: (url, headers, serviceName) => instance.get(
4733
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4734
+ headers
4735
+ ).then(responseBody),
4736
+ post: (url, body, headers, serviceName) => instance.post(
4737
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4738
+ body,
4739
+ headers
4740
+ ).then(responseBody),
4741
+ post_excel: (url, body, headers, serviceName) => instance.post(
4742
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4743
+ body,
4744
+ {
4745
+ responseType: "arraybuffer",
4746
+ headers: {
4747
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4748
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
4749
+ ...headers
4750
+ }
4663
4751
  }
4664
- }).then(responseBody),
4665
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
4666
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
4667
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
4752
+ ).then(responseBody),
4753
+ put: (url, body, headers, serviceName) => instance.put(
4754
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4755
+ body,
4756
+ headers
4757
+ ).then(responseBody),
4758
+ patch: (url, body, headers, serviceName) => instance.patch(
4759
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4760
+ body,
4761
+ headers
4762
+ ).then(responseBody),
4763
+ delete: (url, headers, serviceName) => instance.delete(
4764
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4765
+ headers
4766
+ ).then(responseBody)
4668
4767
  };
4669
4768
  return requests;
4670
4769
  }
@@ -5260,7 +5359,7 @@ var import_react_query32 = require("@tanstack/react-query");
5260
5359
  var useDelete = () => {
5261
5360
  const { deleteApi } = useModelService();
5262
5361
  return (0, import_react_query32.useMutation)({
5263
- mutationFn: ({ ids, model }) => deleteApi({ ids, model })
5362
+ mutationFn: ({ ids, model, service }) => deleteApi({ ids, model, service })
5264
5363
  });
5265
5364
  };
5266
5365
  var use_delete_default = useDelete;
@@ -5323,12 +5422,14 @@ var useGetDetail = () => {
5323
5422
  model,
5324
5423
  ids,
5325
5424
  specification,
5326
- context
5425
+ context,
5426
+ service
5327
5427
  }) => getDetail({
5328
5428
  model,
5329
5429
  ids,
5330
5430
  specification,
5331
- context
5431
+ context,
5432
+ service
5332
5433
  })
5333
5434
  });
5334
5435
  };
@@ -5524,14 +5625,16 @@ var useOnChangeForm = () => {
5524
5625
  specification,
5525
5626
  context,
5526
5627
  object,
5527
- fieldChange
5628
+ fieldChange,
5629
+ service
5528
5630
  }) => onChange({
5529
5631
  ids,
5530
5632
  model,
5531
5633
  specification,
5532
5634
  context,
5533
5635
  object,
5534
- fieldChange
5636
+ fieldChange,
5637
+ service
5535
5638
  })
5536
5639
  });
5537
5640
  };
@@ -5548,8 +5651,9 @@ var useSave = () => {
5548
5651
  data,
5549
5652
  specification,
5550
5653
  context,
5551
- path
5552
- }) => save({ ids, model, data, specification, context, path })
5654
+ path,
5655
+ service
5656
+ }) => save({ ids, model, data, specification, context, path, service })
5553
5657
  });
5554
5658
  };
5555
5659
  var use_save_default = useSave;
@@ -5601,12 +5705,14 @@ var useButton = () => {
5601
5705
  model,
5602
5706
  ids,
5603
5707
  context,
5604
- method
5708
+ method,
5709
+ service
5605
5710
  }) => callButton({
5606
5711
  model,
5607
5712
  ids,
5608
5713
  context,
5609
- method
5714
+ method,
5715
+ service
5610
5716
  }),
5611
5717
  onSuccess: (response) => {
5612
5718
  return response;
@@ -5623,11 +5729,13 @@ var useDuplicateRecord = () => {
5623
5729
  mutationFn: ({
5624
5730
  id,
5625
5731
  model,
5626
- context
5732
+ context,
5733
+ service
5627
5734
  }) => duplicateRecord({
5628
5735
  id,
5629
5736
  model,
5630
- context
5737
+ context,
5738
+ service
5631
5739
  })
5632
5740
  });
5633
5741
  };
@@ -5710,11 +5818,11 @@ var use_get_groups_default = useGetGroups;
5710
5818
 
5711
5819
  // src/hooks/view/use-get-list-data.ts
5712
5820
  var import_react_query49 = require("@tanstack/react-query");
5713
- var useGetListData = (listDataProps, queryKey, enabled) => {
5821
+ var useGetListData = (listDataProps, queryKey, enabled, service) => {
5714
5822
  const { getAll } = useModelService();
5715
5823
  return (0, import_react_query49.useQuery)({
5716
5824
  queryKey,
5717
- queryFn: () => getAll({ data: listDataProps }).then((res) => {
5825
+ queryFn: () => getAll({ data: listDataProps, service }).then((res) => {
5718
5826
  if (res) {
5719
5827
  return res;
5720
5828
  }
@@ -5790,12 +5898,13 @@ var import_react_query53 = require("@tanstack/react-query");
5790
5898
  var useGetSelection = ({
5791
5899
  data,
5792
5900
  queryKey,
5793
- enabled
5901
+ enabled,
5902
+ service
5794
5903
  }) => {
5795
5904
  const { getSelectionItem } = useViewService();
5796
5905
  return (0, import_react_query53.useQuery)({
5797
5906
  queryKey,
5798
- queryFn: () => getSelectionItem({ data }),
5907
+ queryFn: () => getSelectionItem({ data, service }),
5799
5908
  enabled,
5800
5909
  refetchOnWindowFocus: false
5801
5910
  });
@@ -5823,11 +5932,13 @@ var useLoadAction = () => {
5823
5932
  return (0, import_react_query55.useMutation)({
5824
5933
  mutationFn: ({
5825
5934
  idAction,
5826
- context
5935
+ context,
5936
+ service
5827
5937
  }) => {
5828
5938
  return loadAction({
5829
5939
  idAction,
5830
- context
5940
+ context,
5941
+ service
5831
5942
  });
5832
5943
  }
5833
5944
  });
@@ -5868,11 +5979,13 @@ var useRemoveRow = () => {
5868
5979
  mutationFn: ({
5869
5980
  model,
5870
5981
  ids,
5871
- context
5982
+ context,
5983
+ service
5872
5984
  }) => removeRows({
5873
5985
  model,
5874
5986
  ids,
5875
- context
5987
+ context,
5988
+ service
5876
5989
  })
5877
5990
  });
5878
5991
  };
@@ -5903,10 +6016,12 @@ var useRunAction = () => {
5903
6016
  return (0, import_react_query60.useMutation)({
5904
6017
  mutationFn: ({
5905
6018
  idAction,
5906
- context
6019
+ context,
6020
+ service
5907
6021
  }) => runAction({
5908
6022
  idAction,
5909
- context
6023
+ context,
6024
+ service
5910
6025
  })
5911
6026
  });
5912
6027
  };