@fctc/interface-logic 2.2.2 → 2.2.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/provider.mjs CHANGED
@@ -2849,15 +2849,21 @@ function useActionService() {
2849
2849
  const loadAction = useCallback(
2850
2850
  async ({
2851
2851
  idAction,
2852
- context
2852
+ context,
2853
+ service
2853
2854
  }) => {
2854
2855
  const jsonData = {
2855
2856
  action_id: idAction,
2856
2857
  with_context: { ...context }
2857
2858
  };
2858
- return env.requests.post("/load_action" /* LOAD_ACTION */, jsonData, {
2859
- headers: { "Content-Type": "application/json" }
2860
- });
2859
+ return env.requests.post(
2860
+ "/load_action" /* LOAD_ACTION */,
2861
+ jsonData,
2862
+ {
2863
+ headers: { "Content-Type": "application/json" }
2864
+ },
2865
+ service
2866
+ );
2861
2867
  },
2862
2868
  [env]
2863
2869
  );
@@ -2866,7 +2872,8 @@ function useActionService() {
2866
2872
  model,
2867
2873
  ids = [],
2868
2874
  context,
2869
- method
2875
+ method,
2876
+ service
2870
2877
  }) => {
2871
2878
  try {
2872
2879
  const jsonData = {
@@ -2875,9 +2882,14 @@ function useActionService() {
2875
2882
  ids,
2876
2883
  with_context: context
2877
2884
  };
2878
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2879
- headers: { "Content-Type": "application/json" }
2880
- });
2885
+ return env.requests.post(
2886
+ "/call" /* CALL_PATH */,
2887
+ jsonData,
2888
+ {
2889
+ headers: { "Content-Type": "application/json" }
2890
+ },
2891
+ service
2892
+ );
2881
2893
  } catch (error) {
2882
2894
  console.error("Error when calling button action:", error);
2883
2895
  throw error;
@@ -2889,7 +2901,8 @@ function useActionService() {
2889
2901
  async ({
2890
2902
  model,
2891
2903
  ids,
2892
- context
2904
+ context,
2905
+ service
2893
2906
  }) => {
2894
2907
  const jsonData = {
2895
2908
  model,
@@ -2897,9 +2910,14 @@ function useActionService() {
2897
2910
  ids,
2898
2911
  with_context: context
2899
2912
  };
2900
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2901
- headers: { "Content-Type": "application/json" }
2902
- });
2913
+ return env.requests.post(
2914
+ "/call" /* CALL_PATH */,
2915
+ jsonData,
2916
+ {
2917
+ headers: { "Content-Type": "application/json" }
2918
+ },
2919
+ service
2920
+ );
2903
2921
  },
2904
2922
  [env]
2905
2923
  );
@@ -2907,7 +2925,8 @@ function useActionService() {
2907
2925
  async ({
2908
2926
  model,
2909
2927
  id,
2910
- context
2928
+ context,
2929
+ service
2911
2930
  }) => {
2912
2931
  const jsonData = {
2913
2932
  model,
@@ -2915,9 +2934,14 @@ function useActionService() {
2915
2934
  ids: id,
2916
2935
  with_context: context
2917
2936
  };
2918
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2919
- headers: { "Content-Type": "application/json" }
2920
- });
2937
+ return env.requests.post(
2938
+ "/call" /* CALL_PATH */,
2939
+ jsonData,
2940
+ {
2941
+ headers: { "Content-Type": "application/json" }
2942
+ },
2943
+ service
2944
+ );
2921
2945
  },
2922
2946
  [env]
2923
2947
  );
@@ -2960,15 +2984,21 @@ function useActionService() {
2960
2984
  const runAction = useCallback(
2961
2985
  async ({
2962
2986
  idAction,
2963
- context
2987
+ context,
2988
+ service
2964
2989
  }) => {
2965
2990
  const jsonData = {
2966
2991
  action_id: idAction,
2967
2992
  with_context: { ...context }
2968
2993
  };
2969
- return env.requests.post("/run_action" /* RUN_ACTION_PATH */, jsonData, {
2970
- headers: { "Content-Type": "application/json" }
2971
- });
2994
+ return env.requests.post(
2995
+ "/run_action" /* RUN_ACTION_PATH */,
2996
+ jsonData,
2997
+ {
2998
+ headers: { "Content-Type": "application/json" }
2999
+ },
3000
+ service
3001
+ );
2972
3002
  },
2973
3003
  [env]
2974
3004
  );
@@ -3155,13 +3185,14 @@ function useAuthService() {
3155
3185
  data.append("client_id", env?.config?.clientId || "");
3156
3186
  data.append("redirect_uri", env?.config?.redirectUri || "");
3157
3187
  return env?.requests?.post(
3158
- `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3188
+ "/token" /* TOKEN_BY_CODE */,
3159
3189
  data,
3160
3190
  {
3161
3191
  headers: {
3162
3192
  "Content-Type": "application/x-www-form-urlencoded"
3163
3193
  }
3164
- }
3194
+ },
3195
+ "id"
3165
3196
  );
3166
3197
  },
3167
3198
  [env]
@@ -3680,7 +3711,7 @@ function useModelService() {
3680
3711
  });
3681
3712
  }, [env]);
3682
3713
  const getAll = useCallback7(
3683
- async ({ data }) => {
3714
+ async ({ data, service }) => {
3684
3715
  const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3685
3716
  fields: data.fields,
3686
3717
  groupby: data.groupby
@@ -3701,11 +3732,16 @@ function useModelService() {
3701
3732
  ...jsonReadGroup
3702
3733
  }
3703
3734
  };
3704
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3705
- headers: {
3706
- "Content-Type": "application/json"
3707
- }
3708
- });
3735
+ return env.requests.post(
3736
+ "/call" /* CALL_PATH */,
3737
+ jsonData,
3738
+ {
3739
+ headers: {
3740
+ "Content-Type": "application/json"
3741
+ }
3742
+ },
3743
+ service
3744
+ );
3709
3745
  },
3710
3746
  [env]
3711
3747
  );
@@ -3773,7 +3809,13 @@ function useModelService() {
3773
3809
  [env]
3774
3810
  );
3775
3811
  const getDetail = useCallback7(
3776
- async ({ ids = [], model, specification, context }) => {
3812
+ async ({
3813
+ ids = [],
3814
+ model,
3815
+ specification,
3816
+ context,
3817
+ service
3818
+ }) => {
3777
3819
  const jsonData = {
3778
3820
  model,
3779
3821
  method: "web_read" /* WEB_READ */,
@@ -3783,11 +3825,16 @@ function useModelService() {
3783
3825
  specification
3784
3826
  }
3785
3827
  };
3786
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3787
- headers: {
3788
- "Content-Type": "application/json"
3789
- }
3790
- });
3828
+ return env.requests.post(
3829
+ "/call" /* CALL_PATH */,
3830
+ jsonData,
3831
+ {
3832
+ headers: {
3833
+ "Content-Type": "application/json"
3834
+ }
3835
+ },
3836
+ service
3837
+ );
3791
3838
  },
3792
3839
  [env]
3793
3840
  );
@@ -3798,7 +3845,8 @@ function useModelService() {
3798
3845
  data = {},
3799
3846
  specification = {},
3800
3847
  context = {},
3801
- path
3848
+ path,
3849
+ service
3802
3850
  }) => {
3803
3851
  const jsonData = {
3804
3852
  model,
@@ -3810,26 +3858,36 @@ function useModelService() {
3810
3858
  specification
3811
3859
  }
3812
3860
  };
3813
- return env.requests.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3814
- headers: {
3815
- "Content-Type": "application/json"
3816
- }
3817
- });
3861
+ return env.requests.post(
3862
+ path ?? "/call" /* CALL_PATH */,
3863
+ jsonData,
3864
+ {
3865
+ headers: {
3866
+ "Content-Type": "application/json"
3867
+ }
3868
+ },
3869
+ service
3870
+ );
3818
3871
  },
3819
3872
  [env]
3820
3873
  );
3821
3874
  const deleteApi = useCallback7(
3822
- async ({ ids = [], model }) => {
3875
+ async ({ ids = [], model, service }) => {
3823
3876
  const jsonData = {
3824
3877
  model,
3825
3878
  method: "unlink" /* UNLINK */,
3826
3879
  ids
3827
3880
  };
3828
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3829
- headers: {
3830
- "Content-Type": "application/json"
3831
- }
3832
- });
3881
+ return env.requests.post(
3882
+ "/call" /* CALL_PATH */,
3883
+ jsonData,
3884
+ {
3885
+ headers: {
3886
+ "Content-Type": "application/json"
3887
+ }
3888
+ },
3889
+ service
3890
+ );
3833
3891
  },
3834
3892
  [env]
3835
3893
  );
@@ -3840,7 +3898,8 @@ function useModelService() {
3840
3898
  object,
3841
3899
  specification,
3842
3900
  context,
3843
- fieldChange
3901
+ fieldChange,
3902
+ service
3844
3903
  }) => {
3845
3904
  const jsonData = {
3846
3905
  model,
@@ -3853,25 +3912,35 @@ function useModelService() {
3853
3912
  specification
3854
3913
  ]
3855
3914
  };
3856
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3857
- headers: {
3858
- "Content-Type": "application/json"
3859
- }
3860
- });
3915
+ return env.requests.post(
3916
+ "/call" /* CALL_PATH */,
3917
+ jsonData,
3918
+ {
3919
+ headers: {
3920
+ "Content-Type": "application/json"
3921
+ }
3922
+ },
3923
+ service
3924
+ );
3861
3925
  },
3862
3926
  [env]
3863
3927
  );
3864
3928
  const getListFieldsOnchange = useCallback7(
3865
- async ({ model }) => {
3929
+ async ({ model, service }) => {
3866
3930
  const jsonData = {
3867
3931
  model,
3868
3932
  method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3869
3933
  };
3870
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3871
- headers: {
3872
- "Content-Type": "application/json"
3873
- }
3874
- });
3934
+ return env.requests.post(
3935
+ "/call" /* CALL_PATH */,
3936
+ jsonData,
3937
+ {
3938
+ headers: {
3939
+ "Content-Type": "application/json"
3940
+ }
3941
+ },
3942
+ service
3943
+ );
3875
3944
  },
3876
3945
  [env]
3877
3946
  );
@@ -4031,7 +4100,8 @@ function useViewService() {
4031
4100
  views,
4032
4101
  context = {},
4033
4102
  options = {},
4034
- aid
4103
+ aid,
4104
+ service
4035
4105
  }) => {
4036
4106
  const defaultOptions = {
4037
4107
  load_filters: true,
@@ -4047,11 +4117,16 @@ function useViewService() {
4047
4117
  },
4048
4118
  with_context: context
4049
4119
  };
4050
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4051
- headers: {
4052
- "Content-Type": "application/json"
4053
- }
4054
- });
4120
+ return env?.requests?.post(
4121
+ "/call" /* CALL_PATH */,
4122
+ jsonDataView,
4123
+ {
4124
+ headers: {
4125
+ "Content-Type": "application/json"
4126
+ }
4127
+ },
4128
+ service
4129
+ );
4055
4130
  },
4056
4131
  [env]
4057
4132
  );
@@ -4134,7 +4209,7 @@ function useViewService() {
4134
4209
  [env]
4135
4210
  );
4136
4211
  const getSelectionItem = useCallback9(
4137
- async ({ data }) => {
4212
+ async ({ data, service }) => {
4138
4213
  const jsonData = {
4139
4214
  model: data.model,
4140
4215
  ids: [],
@@ -4152,11 +4227,16 @@ function useViewService() {
4152
4227
  }
4153
4228
  }
4154
4229
  };
4155
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4156
- headers: {
4157
- "Content-Type": "application/json"
4158
- }
4159
- });
4230
+ return env?.requests.post(
4231
+ "/call" /* CALL_PATH */,
4232
+ jsonData,
4233
+ {
4234
+ headers: {
4235
+ "Content-Type": "application/json"
4236
+ }
4237
+ },
4238
+ service
4239
+ );
4160
4240
  },
4161
4241
  [env]
4162
4242
  );
@@ -4449,7 +4529,6 @@ var sessionStorageUtils = () => {
4449
4529
  // src/configs/axios-client.ts
4450
4530
  var axiosClient = {
4451
4531
  init(config) {
4452
- console.log("config", config);
4453
4532
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
4454
4533
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
4455
4534
  const db = config?.db;
@@ -4468,7 +4547,7 @@ var axiosClient = {
4468
4547
  };
4469
4548
  const instance = axios.create({
4470
4549
  adapter: axios.defaults.adapter,
4471
- baseURL: config.baseUrl,
4550
+ baseURL: config?.baseUrl,
4472
4551
  timeout: 5e4,
4473
4552
  paramsSerializer: (params) => new URLSearchParams(params).toString()
4474
4553
  });
@@ -4487,6 +4566,7 @@ var axiosClient = {
4487
4566
  if (database) {
4488
4567
  config2.headers["DATABASE"] = database;
4489
4568
  }
4569
+ if (token) config2.headers["Authorization"] = `Bearer ${token}`;
4490
4570
  return config2;
4491
4571
  }, Promise.reject);
4492
4572
  instance.interceptors.response.use(
@@ -4541,7 +4621,7 @@ var axiosClient = {
4541
4621
  );
4542
4622
  return new Promise(function(resolve) {
4543
4623
  axios.post(
4544
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4624
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4545
4625
  payload,
4546
4626
  {
4547
4627
  headers: {
@@ -4609,20 +4689,47 @@ var axiosClient = {
4609
4689
  function formatUrl(url, db2) {
4610
4690
  return url + (db2 ? "?db=" + db2 : "");
4611
4691
  }
4692
+ const getBaseUrl = (baseUrl, serviceName) => {
4693
+ const service = serviceName || config?.default_service;
4694
+ return `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
4695
+ };
4612
4696
  const responseBody = (response) => response;
4613
4697
  const requests = {
4614
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
4615
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
4616
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
4617
- responseType: "arraybuffer",
4618
- headers: {
4619
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4620
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
4698
+ get: (url, headers, serviceName) => instance.get(
4699
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4700
+ headers
4701
+ ).then(responseBody),
4702
+ post: (url, body, headers, serviceName) => instance.post(
4703
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4704
+ body,
4705
+ headers
4706
+ ).then(responseBody),
4707
+ post_excel: (url, body, headers, serviceName) => instance.post(
4708
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4709
+ body,
4710
+ {
4711
+ responseType: "arraybuffer",
4712
+ headers: {
4713
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4714
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
4715
+ ...headers
4716
+ }
4621
4717
  }
4622
- }).then(responseBody),
4623
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
4624
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
4625
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
4718
+ ).then(responseBody),
4719
+ put: (url, body, headers, serviceName) => instance.put(
4720
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4721
+ body,
4722
+ headers
4723
+ ).then(responseBody),
4724
+ patch: (url, body, headers, serviceName) => instance.patch(
4725
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4726
+ body,
4727
+ headers
4728
+ ).then(responseBody),
4729
+ delete: (url, headers, serviceName) => instance.delete(
4730
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4731
+ headers
4732
+ ).then(responseBody)
4626
4733
  };
4627
4734
  return requests;
4628
4735
  }
@@ -5215,7 +5322,7 @@ import { useMutation as useMutation25 } from "@tanstack/react-query";
5215
5322
  var useDelete = () => {
5216
5323
  const { deleteApi } = useModelService();
5217
5324
  return useMutation25({
5218
- mutationFn: ({ ids, model }) => deleteApi({ ids, model })
5325
+ mutationFn: ({ ids, model, service }) => deleteApi({ ids, model, service })
5219
5326
  });
5220
5327
  };
5221
5328
  var use_delete_default = useDelete;
@@ -5278,12 +5385,14 @@ var useGetDetail = () => {
5278
5385
  model,
5279
5386
  ids,
5280
5387
  specification,
5281
- context
5388
+ context,
5389
+ service
5282
5390
  }) => getDetail({
5283
5391
  model,
5284
5392
  ids,
5285
5393
  specification,
5286
- context
5394
+ context,
5395
+ service
5287
5396
  })
5288
5397
  });
5289
5398
  };
@@ -5291,12 +5400,16 @@ var use_get_detail_default = useGetDetail;
5291
5400
 
5292
5401
  // src/hooks/model/use-get-field-onchange.ts
5293
5402
  import { useQuery as useQuery9 } from "@tanstack/react-query";
5294
- var useGetFieldOnChange = ({ model }) => {
5403
+ var useGetFieldOnChange = ({
5404
+ model,
5405
+ service
5406
+ }) => {
5295
5407
  const { getListFieldsOnchange } = useModelService();
5296
5408
  return useQuery9({
5297
5409
  queryKey: [`field-onchange-${model}`, model],
5298
5410
  queryFn: () => getListFieldsOnchange({
5299
- model
5411
+ model,
5412
+ service
5300
5413
  }).then((res) => {
5301
5414
  if (res) {
5302
5415
  return res;
@@ -5479,14 +5592,16 @@ var useOnChangeForm = () => {
5479
5592
  specification,
5480
5593
  context,
5481
5594
  object,
5482
- fieldChange
5595
+ fieldChange,
5596
+ service
5483
5597
  }) => onChange({
5484
5598
  ids,
5485
5599
  model,
5486
5600
  specification,
5487
5601
  context,
5488
5602
  object,
5489
- fieldChange
5603
+ fieldChange,
5604
+ service
5490
5605
  })
5491
5606
  });
5492
5607
  };
@@ -5503,8 +5618,9 @@ var useSave = () => {
5503
5618
  data,
5504
5619
  specification,
5505
5620
  context,
5506
- path
5507
- }) => save({ ids, model, data, specification, context, path })
5621
+ path,
5622
+ service
5623
+ }) => save({ ids, model, data, specification, context, path, service })
5508
5624
  });
5509
5625
  };
5510
5626
  var use_save_default = useSave;
@@ -5556,12 +5672,14 @@ var useButton = () => {
5556
5672
  model,
5557
5673
  ids,
5558
5674
  context,
5559
- method
5675
+ method,
5676
+ service
5560
5677
  }) => callButton({
5561
5678
  model,
5562
5679
  ids,
5563
5680
  context,
5564
- method
5681
+ method,
5682
+ service
5565
5683
  }),
5566
5684
  onSuccess: (response) => {
5567
5685
  return response;
@@ -5578,11 +5696,13 @@ var useDuplicateRecord = () => {
5578
5696
  mutationFn: ({
5579
5697
  id,
5580
5698
  model,
5581
- context
5699
+ context,
5700
+ service
5582
5701
  }) => duplicateRecord({
5583
5702
  id,
5584
5703
  model,
5585
- context
5704
+ context,
5705
+ service
5586
5706
  })
5587
5707
  });
5588
5708
  };
@@ -5665,11 +5785,11 @@ var use_get_groups_default = useGetGroups;
5665
5785
 
5666
5786
  // src/hooks/view/use-get-list-data.ts
5667
5787
  import { useQuery as useQuery14 } from "@tanstack/react-query";
5668
- var useGetListData = (listDataProps, queryKey, enabled) => {
5788
+ var useGetListData = (listDataProps, queryKey, enabled, service) => {
5669
5789
  const { getAll } = useModelService();
5670
5790
  return useQuery14({
5671
5791
  queryKey,
5672
- queryFn: () => getAll({ data: listDataProps }).then((res) => {
5792
+ queryFn: () => getAll({ data: listDataProps, service }).then((res) => {
5673
5793
  if (res) {
5674
5794
  return res;
5675
5795
  }
@@ -5745,12 +5865,13 @@ import { useQuery as useQuery17 } from "@tanstack/react-query";
5745
5865
  var useGetSelection = ({
5746
5866
  data,
5747
5867
  queryKey,
5748
- enabled
5868
+ enabled,
5869
+ service
5749
5870
  }) => {
5750
5871
  const { getSelectionItem } = useViewService();
5751
5872
  return useQuery17({
5752
5873
  queryKey,
5753
- queryFn: () => getSelectionItem({ data }),
5874
+ queryFn: () => getSelectionItem({ data, service }),
5754
5875
  enabled,
5755
5876
  refetchOnWindowFocus: false
5756
5877
  });
@@ -5778,11 +5899,13 @@ var useLoadAction = () => {
5778
5899
  return useMutation35({
5779
5900
  mutationFn: ({
5780
5901
  idAction,
5781
- context
5902
+ context,
5903
+ service
5782
5904
  }) => {
5783
5905
  return loadAction({
5784
5906
  idAction,
5785
- context
5907
+ context,
5908
+ service
5786
5909
  });
5787
5910
  }
5788
5911
  });
@@ -5823,11 +5946,13 @@ var useRemoveRow = () => {
5823
5946
  mutationFn: ({
5824
5947
  model,
5825
5948
  ids,
5826
- context
5949
+ context,
5950
+ service
5827
5951
  }) => removeRows({
5828
5952
  model,
5829
5953
  ids,
5830
- context
5954
+ context,
5955
+ service
5831
5956
  })
5832
5957
  });
5833
5958
  };
@@ -5858,10 +5983,12 @@ var useRunAction = () => {
5858
5983
  return useMutation38({
5859
5984
  mutationFn: ({
5860
5985
  idAction,
5861
- context
5986
+ context,
5987
+ service
5862
5988
  }) => runAction({
5863
5989
  idAction,
5864
- context
5990
+ context,
5991
+ service
5865
5992
  })
5866
5993
  });
5867
5994
  };