@fctc/interface-logic 2.2.2 → 2.2.3

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
  );
@@ -3154,15 +3184,11 @@ function useAuthService() {
3154
3184
  data.append("grant_type", "authorization_code");
3155
3185
  data.append("client_id", env?.config?.clientId || "");
3156
3186
  data.append("redirect_uri", env?.config?.redirectUri || "");
3157
- return env?.requests?.post(
3158
- `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3159
- data,
3160
- {
3161
- headers: {
3162
- "Content-Type": "application/x-www-form-urlencoded"
3163
- }
3187
+ return env?.requests?.post("/token" /* TOKEN_BY_CODE */, data, {
3188
+ headers: {
3189
+ "Content-Type": "application/x-www-form-urlencoded"
3164
3190
  }
3165
- );
3191
+ });
3166
3192
  },
3167
3193
  [env]
3168
3194
  );
@@ -3680,7 +3706,7 @@ function useModelService() {
3680
3706
  });
3681
3707
  }, [env]);
3682
3708
  const getAll = useCallback7(
3683
- async ({ data }) => {
3709
+ async ({ data, service }) => {
3684
3710
  const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3685
3711
  fields: data.fields,
3686
3712
  groupby: data.groupby
@@ -3701,11 +3727,16 @@ function useModelService() {
3701
3727
  ...jsonReadGroup
3702
3728
  }
3703
3729
  };
3704
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3705
- headers: {
3706
- "Content-Type": "application/json"
3707
- }
3708
- });
3730
+ return env.requests.post(
3731
+ "/call" /* CALL_PATH */,
3732
+ jsonData,
3733
+ {
3734
+ headers: {
3735
+ "Content-Type": "application/json"
3736
+ }
3737
+ },
3738
+ service
3739
+ );
3709
3740
  },
3710
3741
  [env]
3711
3742
  );
@@ -3773,7 +3804,13 @@ function useModelService() {
3773
3804
  [env]
3774
3805
  );
3775
3806
  const getDetail = useCallback7(
3776
- async ({ ids = [], model, specification, context }) => {
3807
+ async ({
3808
+ ids = [],
3809
+ model,
3810
+ specification,
3811
+ context,
3812
+ service
3813
+ }) => {
3777
3814
  const jsonData = {
3778
3815
  model,
3779
3816
  method: "web_read" /* WEB_READ */,
@@ -3783,11 +3820,16 @@ function useModelService() {
3783
3820
  specification
3784
3821
  }
3785
3822
  };
3786
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3787
- headers: {
3788
- "Content-Type": "application/json"
3789
- }
3790
- });
3823
+ return env.requests.post(
3824
+ "/call" /* CALL_PATH */,
3825
+ jsonData,
3826
+ {
3827
+ headers: {
3828
+ "Content-Type": "application/json"
3829
+ }
3830
+ },
3831
+ service
3832
+ );
3791
3833
  },
3792
3834
  [env]
3793
3835
  );
@@ -3798,7 +3840,8 @@ function useModelService() {
3798
3840
  data = {},
3799
3841
  specification = {},
3800
3842
  context = {},
3801
- path
3843
+ path,
3844
+ service
3802
3845
  }) => {
3803
3846
  const jsonData = {
3804
3847
  model,
@@ -3810,26 +3853,36 @@ function useModelService() {
3810
3853
  specification
3811
3854
  }
3812
3855
  };
3813
- return env.requests.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3814
- headers: {
3815
- "Content-Type": "application/json"
3816
- }
3817
- });
3856
+ return env.requests.post(
3857
+ path ?? "/call" /* CALL_PATH */,
3858
+ jsonData,
3859
+ {
3860
+ headers: {
3861
+ "Content-Type": "application/json"
3862
+ }
3863
+ },
3864
+ service
3865
+ );
3818
3866
  },
3819
3867
  [env]
3820
3868
  );
3821
3869
  const deleteApi = useCallback7(
3822
- async ({ ids = [], model }) => {
3870
+ async ({ ids = [], model, service }) => {
3823
3871
  const jsonData = {
3824
3872
  model,
3825
3873
  method: "unlink" /* UNLINK */,
3826
3874
  ids
3827
3875
  };
3828
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3829
- headers: {
3830
- "Content-Type": "application/json"
3831
- }
3832
- });
3876
+ return env.requests.post(
3877
+ "/call" /* CALL_PATH */,
3878
+ jsonData,
3879
+ {
3880
+ headers: {
3881
+ "Content-Type": "application/json"
3882
+ }
3883
+ },
3884
+ service
3885
+ );
3833
3886
  },
3834
3887
  [env]
3835
3888
  );
@@ -3840,7 +3893,8 @@ function useModelService() {
3840
3893
  object,
3841
3894
  specification,
3842
3895
  context,
3843
- fieldChange
3896
+ fieldChange,
3897
+ service
3844
3898
  }) => {
3845
3899
  const jsonData = {
3846
3900
  model,
@@ -3853,25 +3907,35 @@ function useModelService() {
3853
3907
  specification
3854
3908
  ]
3855
3909
  };
3856
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3857
- headers: {
3858
- "Content-Type": "application/json"
3859
- }
3860
- });
3910
+ return env.requests.post(
3911
+ "/call" /* CALL_PATH */,
3912
+ jsonData,
3913
+ {
3914
+ headers: {
3915
+ "Content-Type": "application/json"
3916
+ }
3917
+ },
3918
+ service
3919
+ );
3861
3920
  },
3862
3921
  [env]
3863
3922
  );
3864
3923
  const getListFieldsOnchange = useCallback7(
3865
- async ({ model }) => {
3924
+ async ({ model, service }) => {
3866
3925
  const jsonData = {
3867
3926
  model,
3868
3927
  method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3869
3928
  };
3870
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3871
- headers: {
3872
- "Content-Type": "application/json"
3873
- }
3874
- });
3929
+ return env.requests.post(
3930
+ "/call" /* CALL_PATH */,
3931
+ jsonData,
3932
+ {
3933
+ headers: {
3934
+ "Content-Type": "application/json"
3935
+ }
3936
+ },
3937
+ service
3938
+ );
3875
3939
  },
3876
3940
  [env]
3877
3941
  );
@@ -4031,7 +4095,8 @@ function useViewService() {
4031
4095
  views,
4032
4096
  context = {},
4033
4097
  options = {},
4034
- aid
4098
+ aid,
4099
+ service
4035
4100
  }) => {
4036
4101
  const defaultOptions = {
4037
4102
  load_filters: true,
@@ -4047,11 +4112,16 @@ function useViewService() {
4047
4112
  },
4048
4113
  with_context: context
4049
4114
  };
4050
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4051
- headers: {
4052
- "Content-Type": "application/json"
4053
- }
4054
- });
4115
+ return env?.requests?.post(
4116
+ "/call" /* CALL_PATH */,
4117
+ jsonDataView,
4118
+ {
4119
+ headers: {
4120
+ "Content-Type": "application/json"
4121
+ }
4122
+ },
4123
+ service
4124
+ );
4055
4125
  },
4056
4126
  [env]
4057
4127
  );
@@ -4134,7 +4204,7 @@ function useViewService() {
4134
4204
  [env]
4135
4205
  );
4136
4206
  const getSelectionItem = useCallback9(
4137
- async ({ data }) => {
4207
+ async ({ data, service }) => {
4138
4208
  const jsonData = {
4139
4209
  model: data.model,
4140
4210
  ids: [],
@@ -4152,11 +4222,16 @@ function useViewService() {
4152
4222
  }
4153
4223
  }
4154
4224
  };
4155
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4156
- headers: {
4157
- "Content-Type": "application/json"
4158
- }
4159
- });
4225
+ return env?.requests.post(
4226
+ "/call" /* CALL_PATH */,
4227
+ jsonData,
4228
+ {
4229
+ headers: {
4230
+ "Content-Type": "application/json"
4231
+ }
4232
+ },
4233
+ service
4234
+ );
4160
4235
  },
4161
4236
  [env]
4162
4237
  );
@@ -4449,7 +4524,6 @@ var sessionStorageUtils = () => {
4449
4524
  // src/configs/axios-client.ts
4450
4525
  var axiosClient = {
4451
4526
  init(config) {
4452
- console.log("config", config);
4453
4527
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
4454
4528
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
4455
4529
  const db = config?.db;
@@ -4468,7 +4542,7 @@ var axiosClient = {
4468
4542
  };
4469
4543
  const instance = axios.create({
4470
4544
  adapter: axios.defaults.adapter,
4471
- baseURL: config.baseUrl,
4545
+ baseURL: config?.baseUrl,
4472
4546
  timeout: 5e4,
4473
4547
  paramsSerializer: (params) => new URLSearchParams(params).toString()
4474
4548
  });
@@ -4487,6 +4561,7 @@ var axiosClient = {
4487
4561
  if (database) {
4488
4562
  config2.headers["DATABASE"] = database;
4489
4563
  }
4564
+ if (token) config2.headers["Authorization"] = `Bearer ${token}`;
4490
4565
  return config2;
4491
4566
  }, Promise.reject);
4492
4567
  instance.interceptors.response.use(
@@ -4541,7 +4616,7 @@ var axiosClient = {
4541
4616
  );
4542
4617
  return new Promise(function(resolve) {
4543
4618
  axios.post(
4544
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4619
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4545
4620
  payload,
4546
4621
  {
4547
4622
  headers: {
@@ -4609,20 +4684,47 @@ var axiosClient = {
4609
4684
  function formatUrl(url, db2) {
4610
4685
  return url + (db2 ? "?db=" + db2 : "");
4611
4686
  }
4687
+ const getBaseUrl = (baseUrl, serviceName) => {
4688
+ const service = serviceName || config?.default_service;
4689
+ return `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
4690
+ };
4612
4691
  const responseBody = (response) => response;
4613
4692
  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"
4693
+ get: (url, headers, serviceName) => instance.get(
4694
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4695
+ headers
4696
+ ).then(responseBody),
4697
+ post: (url, body, headers, serviceName) => instance.post(
4698
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4699
+ body,
4700
+ headers
4701
+ ).then(responseBody),
4702
+ post_excel: (url, body, headers, serviceName) => instance.post(
4703
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4704
+ body,
4705
+ {
4706
+ responseType: "arraybuffer",
4707
+ headers: {
4708
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4709
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
4710
+ ...headers
4711
+ }
4621
4712
  }
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)
4713
+ ).then(responseBody),
4714
+ put: (url, body, headers, serviceName) => instance.put(
4715
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4716
+ body,
4717
+ headers
4718
+ ).then(responseBody),
4719
+ patch: (url, body, headers, serviceName) => instance.patch(
4720
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4721
+ body,
4722
+ headers
4723
+ ).then(responseBody),
4724
+ delete: (url, headers, serviceName) => instance.delete(
4725
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4726
+ headers
4727
+ ).then(responseBody)
4626
4728
  };
4627
4729
  return requests;
4628
4730
  }
@@ -5215,7 +5317,7 @@ import { useMutation as useMutation25 } from "@tanstack/react-query";
5215
5317
  var useDelete = () => {
5216
5318
  const { deleteApi } = useModelService();
5217
5319
  return useMutation25({
5218
- mutationFn: ({ ids, model }) => deleteApi({ ids, model })
5320
+ mutationFn: ({ ids, model, service }) => deleteApi({ ids, model, service })
5219
5321
  });
5220
5322
  };
5221
5323
  var use_delete_default = useDelete;
@@ -5278,12 +5380,14 @@ var useGetDetail = () => {
5278
5380
  model,
5279
5381
  ids,
5280
5382
  specification,
5281
- context
5383
+ context,
5384
+ service
5282
5385
  }) => getDetail({
5283
5386
  model,
5284
5387
  ids,
5285
5388
  specification,
5286
- context
5389
+ context,
5390
+ service
5287
5391
  })
5288
5392
  });
5289
5393
  };
@@ -5291,12 +5395,16 @@ var use_get_detail_default = useGetDetail;
5291
5395
 
5292
5396
  // src/hooks/model/use-get-field-onchange.ts
5293
5397
  import { useQuery as useQuery9 } from "@tanstack/react-query";
5294
- var useGetFieldOnChange = ({ model }) => {
5398
+ var useGetFieldOnChange = ({
5399
+ model,
5400
+ service
5401
+ }) => {
5295
5402
  const { getListFieldsOnchange } = useModelService();
5296
5403
  return useQuery9({
5297
5404
  queryKey: [`field-onchange-${model}`, model],
5298
5405
  queryFn: () => getListFieldsOnchange({
5299
- model
5406
+ model,
5407
+ service
5300
5408
  }).then((res) => {
5301
5409
  if (res) {
5302
5410
  return res;
@@ -5479,14 +5587,16 @@ var useOnChangeForm = () => {
5479
5587
  specification,
5480
5588
  context,
5481
5589
  object,
5482
- fieldChange
5590
+ fieldChange,
5591
+ service
5483
5592
  }) => onChange({
5484
5593
  ids,
5485
5594
  model,
5486
5595
  specification,
5487
5596
  context,
5488
5597
  object,
5489
- fieldChange
5598
+ fieldChange,
5599
+ service
5490
5600
  })
5491
5601
  });
5492
5602
  };
@@ -5503,8 +5613,9 @@ var useSave = () => {
5503
5613
  data,
5504
5614
  specification,
5505
5615
  context,
5506
- path
5507
- }) => save({ ids, model, data, specification, context, path })
5616
+ path,
5617
+ service
5618
+ }) => save({ ids, model, data, specification, context, path, service })
5508
5619
  });
5509
5620
  };
5510
5621
  var use_save_default = useSave;
@@ -5556,12 +5667,14 @@ var useButton = () => {
5556
5667
  model,
5557
5668
  ids,
5558
5669
  context,
5559
- method
5670
+ method,
5671
+ service
5560
5672
  }) => callButton({
5561
5673
  model,
5562
5674
  ids,
5563
5675
  context,
5564
- method
5676
+ method,
5677
+ service
5565
5678
  }),
5566
5679
  onSuccess: (response) => {
5567
5680
  return response;
@@ -5578,11 +5691,13 @@ var useDuplicateRecord = () => {
5578
5691
  mutationFn: ({
5579
5692
  id,
5580
5693
  model,
5581
- context
5694
+ context,
5695
+ service
5582
5696
  }) => duplicateRecord({
5583
5697
  id,
5584
5698
  model,
5585
- context
5699
+ context,
5700
+ service
5586
5701
  })
5587
5702
  });
5588
5703
  };
@@ -5665,11 +5780,11 @@ var use_get_groups_default = useGetGroups;
5665
5780
 
5666
5781
  // src/hooks/view/use-get-list-data.ts
5667
5782
  import { useQuery as useQuery14 } from "@tanstack/react-query";
5668
- var useGetListData = (listDataProps, queryKey, enabled) => {
5783
+ var useGetListData = (listDataProps, queryKey, enabled, service) => {
5669
5784
  const { getAll } = useModelService();
5670
5785
  return useQuery14({
5671
5786
  queryKey,
5672
- queryFn: () => getAll({ data: listDataProps }).then((res) => {
5787
+ queryFn: () => getAll({ data: listDataProps, service }).then((res) => {
5673
5788
  if (res) {
5674
5789
  return res;
5675
5790
  }
@@ -5745,12 +5860,13 @@ import { useQuery as useQuery17 } from "@tanstack/react-query";
5745
5860
  var useGetSelection = ({
5746
5861
  data,
5747
5862
  queryKey,
5748
- enabled
5863
+ enabled,
5864
+ service
5749
5865
  }) => {
5750
5866
  const { getSelectionItem } = useViewService();
5751
5867
  return useQuery17({
5752
5868
  queryKey,
5753
- queryFn: () => getSelectionItem({ data }),
5869
+ queryFn: () => getSelectionItem({ data, service }),
5754
5870
  enabled,
5755
5871
  refetchOnWindowFocus: false
5756
5872
  });
@@ -5778,11 +5894,13 @@ var useLoadAction = () => {
5778
5894
  return useMutation35({
5779
5895
  mutationFn: ({
5780
5896
  idAction,
5781
- context
5897
+ context,
5898
+ service
5782
5899
  }) => {
5783
5900
  return loadAction({
5784
5901
  idAction,
5785
- context
5902
+ context,
5903
+ service
5786
5904
  });
5787
5905
  }
5788
5906
  });
@@ -5823,11 +5941,13 @@ var useRemoveRow = () => {
5823
5941
  mutationFn: ({
5824
5942
  model,
5825
5943
  ids,
5826
- context
5944
+ context,
5945
+ service
5827
5946
  }) => removeRows({
5828
5947
  model,
5829
5948
  ids,
5830
- context
5949
+ context,
5950
+ service
5831
5951
  })
5832
5952
  });
5833
5953
  };
@@ -5858,10 +5978,12 @@ var useRunAction = () => {
5858
5978
  return useMutation38({
5859
5979
  mutationFn: ({
5860
5980
  idAction,
5861
- context
5981
+ context,
5982
+ service
5862
5983
  }) => runAction({
5863
5984
  idAction,
5864
- context
5985
+ context,
5986
+ service
5865
5987
  })
5866
5988
  });
5867
5989
  };