@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.js CHANGED
@@ -2892,15 +2892,21 @@ function useActionService() {
2892
2892
  const loadAction = (0, import_react2.useCallback)(
2893
2893
  async ({
2894
2894
  idAction,
2895
- context
2895
+ context,
2896
+ service
2896
2897
  }) => {
2897
2898
  const jsonData = {
2898
2899
  action_id: idAction,
2899
2900
  with_context: { ...context }
2900
2901
  };
2901
- return env.requests.post("/load_action" /* LOAD_ACTION */, jsonData, {
2902
- headers: { "Content-Type": "application/json" }
2903
- });
2902
+ return env.requests.post(
2903
+ "/load_action" /* LOAD_ACTION */,
2904
+ jsonData,
2905
+ {
2906
+ headers: { "Content-Type": "application/json" }
2907
+ },
2908
+ service
2909
+ );
2904
2910
  },
2905
2911
  [env]
2906
2912
  );
@@ -2909,7 +2915,8 @@ function useActionService() {
2909
2915
  model,
2910
2916
  ids = [],
2911
2917
  context,
2912
- method
2918
+ method,
2919
+ service
2913
2920
  }) => {
2914
2921
  try {
2915
2922
  const jsonData = {
@@ -2918,9 +2925,14 @@ function useActionService() {
2918
2925
  ids,
2919
2926
  with_context: context
2920
2927
  };
2921
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2922
- headers: { "Content-Type": "application/json" }
2923
- });
2928
+ return env.requests.post(
2929
+ "/call" /* CALL_PATH */,
2930
+ jsonData,
2931
+ {
2932
+ headers: { "Content-Type": "application/json" }
2933
+ },
2934
+ service
2935
+ );
2924
2936
  } catch (error) {
2925
2937
  console.error("Error when calling button action:", error);
2926
2938
  throw error;
@@ -2932,7 +2944,8 @@ function useActionService() {
2932
2944
  async ({
2933
2945
  model,
2934
2946
  ids,
2935
- context
2947
+ context,
2948
+ service
2936
2949
  }) => {
2937
2950
  const jsonData = {
2938
2951
  model,
@@ -2940,9 +2953,14 @@ function useActionService() {
2940
2953
  ids,
2941
2954
  with_context: context
2942
2955
  };
2943
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2944
- headers: { "Content-Type": "application/json" }
2945
- });
2956
+ return env.requests.post(
2957
+ "/call" /* CALL_PATH */,
2958
+ jsonData,
2959
+ {
2960
+ headers: { "Content-Type": "application/json" }
2961
+ },
2962
+ service
2963
+ );
2946
2964
  },
2947
2965
  [env]
2948
2966
  );
@@ -2950,7 +2968,8 @@ function useActionService() {
2950
2968
  async ({
2951
2969
  model,
2952
2970
  id,
2953
- context
2971
+ context,
2972
+ service
2954
2973
  }) => {
2955
2974
  const jsonData = {
2956
2975
  model,
@@ -2958,9 +2977,14 @@ function useActionService() {
2958
2977
  ids: id,
2959
2978
  with_context: context
2960
2979
  };
2961
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2962
- headers: { "Content-Type": "application/json" }
2963
- });
2980
+ return env.requests.post(
2981
+ "/call" /* CALL_PATH */,
2982
+ jsonData,
2983
+ {
2984
+ headers: { "Content-Type": "application/json" }
2985
+ },
2986
+ service
2987
+ );
2964
2988
  },
2965
2989
  [env]
2966
2990
  );
@@ -3003,15 +3027,21 @@ function useActionService() {
3003
3027
  const runAction = (0, import_react2.useCallback)(
3004
3028
  async ({
3005
3029
  idAction,
3006
- context
3030
+ context,
3031
+ service
3007
3032
  }) => {
3008
3033
  const jsonData = {
3009
3034
  action_id: idAction,
3010
3035
  with_context: { ...context }
3011
3036
  };
3012
- return env.requests.post("/run_action" /* RUN_ACTION_PATH */, jsonData, {
3013
- headers: { "Content-Type": "application/json" }
3014
- });
3037
+ return env.requests.post(
3038
+ "/run_action" /* RUN_ACTION_PATH */,
3039
+ jsonData,
3040
+ {
3041
+ headers: { "Content-Type": "application/json" }
3042
+ },
3043
+ service
3044
+ );
3015
3045
  },
3016
3046
  [env]
3017
3047
  );
@@ -3198,13 +3228,14 @@ function useAuthService() {
3198
3228
  data.append("client_id", env?.config?.clientId || "");
3199
3229
  data.append("redirect_uri", env?.config?.redirectUri || "");
3200
3230
  return env?.requests?.post(
3201
- `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3231
+ "/token" /* TOKEN_BY_CODE */,
3202
3232
  data,
3203
3233
  {
3204
3234
  headers: {
3205
3235
  "Content-Type": "application/x-www-form-urlencoded"
3206
3236
  }
3207
- }
3237
+ },
3238
+ "id"
3208
3239
  );
3209
3240
  },
3210
3241
  [env]
@@ -3723,7 +3754,7 @@ function useModelService() {
3723
3754
  });
3724
3755
  }, [env]);
3725
3756
  const getAll = (0, import_react8.useCallback)(
3726
- async ({ data }) => {
3757
+ async ({ data, service }) => {
3727
3758
  const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3728
3759
  fields: data.fields,
3729
3760
  groupby: data.groupby
@@ -3744,11 +3775,16 @@ function useModelService() {
3744
3775
  ...jsonReadGroup
3745
3776
  }
3746
3777
  };
3747
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3748
- headers: {
3749
- "Content-Type": "application/json"
3750
- }
3751
- });
3778
+ return env.requests.post(
3779
+ "/call" /* CALL_PATH */,
3780
+ jsonData,
3781
+ {
3782
+ headers: {
3783
+ "Content-Type": "application/json"
3784
+ }
3785
+ },
3786
+ service
3787
+ );
3752
3788
  },
3753
3789
  [env]
3754
3790
  );
@@ -3816,7 +3852,13 @@ function useModelService() {
3816
3852
  [env]
3817
3853
  );
3818
3854
  const getDetail = (0, import_react8.useCallback)(
3819
- async ({ ids = [], model, specification, context }) => {
3855
+ async ({
3856
+ ids = [],
3857
+ model,
3858
+ specification,
3859
+ context,
3860
+ service
3861
+ }) => {
3820
3862
  const jsonData = {
3821
3863
  model,
3822
3864
  method: "web_read" /* WEB_READ */,
@@ -3826,11 +3868,16 @@ function useModelService() {
3826
3868
  specification
3827
3869
  }
3828
3870
  };
3829
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3830
- headers: {
3831
- "Content-Type": "application/json"
3832
- }
3833
- });
3871
+ return env.requests.post(
3872
+ "/call" /* CALL_PATH */,
3873
+ jsonData,
3874
+ {
3875
+ headers: {
3876
+ "Content-Type": "application/json"
3877
+ }
3878
+ },
3879
+ service
3880
+ );
3834
3881
  },
3835
3882
  [env]
3836
3883
  );
@@ -3841,7 +3888,8 @@ function useModelService() {
3841
3888
  data = {},
3842
3889
  specification = {},
3843
3890
  context = {},
3844
- path
3891
+ path,
3892
+ service
3845
3893
  }) => {
3846
3894
  const jsonData = {
3847
3895
  model,
@@ -3853,26 +3901,36 @@ function useModelService() {
3853
3901
  specification
3854
3902
  }
3855
3903
  };
3856
- return env.requests.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3857
- headers: {
3858
- "Content-Type": "application/json"
3859
- }
3860
- });
3904
+ return env.requests.post(
3905
+ path ?? "/call" /* CALL_PATH */,
3906
+ jsonData,
3907
+ {
3908
+ headers: {
3909
+ "Content-Type": "application/json"
3910
+ }
3911
+ },
3912
+ service
3913
+ );
3861
3914
  },
3862
3915
  [env]
3863
3916
  );
3864
3917
  const deleteApi = (0, import_react8.useCallback)(
3865
- async ({ ids = [], model }) => {
3918
+ async ({ ids = [], model, service }) => {
3866
3919
  const jsonData = {
3867
3920
  model,
3868
3921
  method: "unlink" /* UNLINK */,
3869
3922
  ids
3870
3923
  };
3871
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3872
- headers: {
3873
- "Content-Type": "application/json"
3874
- }
3875
- });
3924
+ return env.requests.post(
3925
+ "/call" /* CALL_PATH */,
3926
+ jsonData,
3927
+ {
3928
+ headers: {
3929
+ "Content-Type": "application/json"
3930
+ }
3931
+ },
3932
+ service
3933
+ );
3876
3934
  },
3877
3935
  [env]
3878
3936
  );
@@ -3883,7 +3941,8 @@ function useModelService() {
3883
3941
  object,
3884
3942
  specification,
3885
3943
  context,
3886
- fieldChange
3944
+ fieldChange,
3945
+ service
3887
3946
  }) => {
3888
3947
  const jsonData = {
3889
3948
  model,
@@ -3896,25 +3955,35 @@ function useModelService() {
3896
3955
  specification
3897
3956
  ]
3898
3957
  };
3899
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3900
- headers: {
3901
- "Content-Type": "application/json"
3902
- }
3903
- });
3958
+ return env.requests.post(
3959
+ "/call" /* CALL_PATH */,
3960
+ jsonData,
3961
+ {
3962
+ headers: {
3963
+ "Content-Type": "application/json"
3964
+ }
3965
+ },
3966
+ service
3967
+ );
3904
3968
  },
3905
3969
  [env]
3906
3970
  );
3907
3971
  const getListFieldsOnchange = (0, import_react8.useCallback)(
3908
- async ({ model }) => {
3972
+ async ({ model, service }) => {
3909
3973
  const jsonData = {
3910
3974
  model,
3911
3975
  method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3912
3976
  };
3913
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3914
- headers: {
3915
- "Content-Type": "application/json"
3916
- }
3917
- });
3977
+ return env.requests.post(
3978
+ "/call" /* CALL_PATH */,
3979
+ jsonData,
3980
+ {
3981
+ headers: {
3982
+ "Content-Type": "application/json"
3983
+ }
3984
+ },
3985
+ service
3986
+ );
3918
3987
  },
3919
3988
  [env]
3920
3989
  );
@@ -4074,7 +4143,8 @@ function useViewService() {
4074
4143
  views,
4075
4144
  context = {},
4076
4145
  options = {},
4077
- aid
4146
+ aid,
4147
+ service
4078
4148
  }) => {
4079
4149
  const defaultOptions = {
4080
4150
  load_filters: true,
@@ -4090,11 +4160,16 @@ function useViewService() {
4090
4160
  },
4091
4161
  with_context: context
4092
4162
  };
4093
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4094
- headers: {
4095
- "Content-Type": "application/json"
4096
- }
4097
- });
4163
+ return env?.requests?.post(
4164
+ "/call" /* CALL_PATH */,
4165
+ jsonDataView,
4166
+ {
4167
+ headers: {
4168
+ "Content-Type": "application/json"
4169
+ }
4170
+ },
4171
+ service
4172
+ );
4098
4173
  },
4099
4174
  [env]
4100
4175
  );
@@ -4177,7 +4252,7 @@ function useViewService() {
4177
4252
  [env]
4178
4253
  );
4179
4254
  const getSelectionItem = (0, import_react10.useCallback)(
4180
- async ({ data }) => {
4255
+ async ({ data, service }) => {
4181
4256
  const jsonData = {
4182
4257
  model: data.model,
4183
4258
  ids: [],
@@ -4195,11 +4270,16 @@ function useViewService() {
4195
4270
  }
4196
4271
  }
4197
4272
  };
4198
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4199
- headers: {
4200
- "Content-Type": "application/json"
4201
- }
4202
- });
4273
+ return env?.requests.post(
4274
+ "/call" /* CALL_PATH */,
4275
+ jsonData,
4276
+ {
4277
+ headers: {
4278
+ "Content-Type": "application/json"
4279
+ }
4280
+ },
4281
+ service
4282
+ );
4203
4283
  },
4204
4284
  [env]
4205
4285
  );
@@ -4492,7 +4572,6 @@ var sessionStorageUtils = () => {
4492
4572
  // src/configs/axios-client.ts
4493
4573
  var axiosClient = {
4494
4574
  init(config) {
4495
- console.log("config", config);
4496
4575
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
4497
4576
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
4498
4577
  const db = config?.db;
@@ -4511,7 +4590,7 @@ var axiosClient = {
4511
4590
  };
4512
4591
  const instance = import_axios.default.create({
4513
4592
  adapter: import_axios.default.defaults.adapter,
4514
- baseURL: config.baseUrl,
4593
+ baseURL: config?.baseUrl,
4515
4594
  timeout: 5e4,
4516
4595
  paramsSerializer: (params) => new URLSearchParams(params).toString()
4517
4596
  });
@@ -4530,6 +4609,7 @@ var axiosClient = {
4530
4609
  if (database) {
4531
4610
  config2.headers["DATABASE"] = database;
4532
4611
  }
4612
+ if (token) config2.headers["Authorization"] = `Bearer ${token}`;
4533
4613
  return config2;
4534
4614
  }, Promise.reject);
4535
4615
  instance.interceptors.response.use(
@@ -4584,7 +4664,7 @@ var axiosClient = {
4584
4664
  );
4585
4665
  return new Promise(function(resolve) {
4586
4666
  import_axios.default.post(
4587
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4667
+ `${config?.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
4588
4668
  payload,
4589
4669
  {
4590
4670
  headers: {
@@ -4652,20 +4732,47 @@ var axiosClient = {
4652
4732
  function formatUrl(url, db2) {
4653
4733
  return url + (db2 ? "?db=" + db2 : "");
4654
4734
  }
4735
+ const getBaseUrl = (baseUrl, serviceName) => {
4736
+ const service = serviceName || config?.default_service;
4737
+ return `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
4738
+ };
4655
4739
  const responseBody = (response) => response;
4656
4740
  const requests = {
4657
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
4658
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
4659
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
4660
- responseType: "arraybuffer",
4661
- headers: {
4662
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4663
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
4741
+ get: (url, headers, serviceName) => instance.get(
4742
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4743
+ headers
4744
+ ).then(responseBody),
4745
+ post: (url, body, headers, serviceName) => instance.post(
4746
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4747
+ body,
4748
+ headers
4749
+ ).then(responseBody),
4750
+ post_excel: (url, body, headers, serviceName) => instance.post(
4751
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4752
+ body,
4753
+ {
4754
+ responseType: "arraybuffer",
4755
+ headers: {
4756
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
4757
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
4758
+ ...headers
4759
+ }
4664
4760
  }
4665
- }).then(responseBody),
4666
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
4667
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
4668
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
4761
+ ).then(responseBody),
4762
+ put: (url, body, headers, serviceName) => instance.put(
4763
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4764
+ body,
4765
+ headers
4766
+ ).then(responseBody),
4767
+ patch: (url, body, headers, serviceName) => instance.patch(
4768
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4769
+ body,
4770
+ headers
4771
+ ).then(responseBody),
4772
+ delete: (url, headers, serviceName) => instance.delete(
4773
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
4774
+ headers
4775
+ ).then(responseBody)
4669
4776
  };
4670
4777
  return requests;
4671
4778
  }
@@ -5258,7 +5365,7 @@ var import_react_query32 = require("@tanstack/react-query");
5258
5365
  var useDelete = () => {
5259
5366
  const { deleteApi } = useModelService();
5260
5367
  return (0, import_react_query32.useMutation)({
5261
- mutationFn: ({ ids, model }) => deleteApi({ ids, model })
5368
+ mutationFn: ({ ids, model, service }) => deleteApi({ ids, model, service })
5262
5369
  });
5263
5370
  };
5264
5371
  var use_delete_default = useDelete;
@@ -5321,12 +5428,14 @@ var useGetDetail = () => {
5321
5428
  model,
5322
5429
  ids,
5323
5430
  specification,
5324
- context
5431
+ context,
5432
+ service
5325
5433
  }) => getDetail({
5326
5434
  model,
5327
5435
  ids,
5328
5436
  specification,
5329
- context
5437
+ context,
5438
+ service
5330
5439
  })
5331
5440
  });
5332
5441
  };
@@ -5334,12 +5443,16 @@ var use_get_detail_default = useGetDetail;
5334
5443
 
5335
5444
  // src/hooks/model/use-get-field-onchange.ts
5336
5445
  var import_react_query37 = require("@tanstack/react-query");
5337
- var useGetFieldOnChange = ({ model }) => {
5446
+ var useGetFieldOnChange = ({
5447
+ model,
5448
+ service
5449
+ }) => {
5338
5450
  const { getListFieldsOnchange } = useModelService();
5339
5451
  return (0, import_react_query37.useQuery)({
5340
5452
  queryKey: [`field-onchange-${model}`, model],
5341
5453
  queryFn: () => getListFieldsOnchange({
5342
- model
5454
+ model,
5455
+ service
5343
5456
  }).then((res) => {
5344
5457
  if (res) {
5345
5458
  return res;
@@ -5522,14 +5635,16 @@ var useOnChangeForm = () => {
5522
5635
  specification,
5523
5636
  context,
5524
5637
  object,
5525
- fieldChange
5638
+ fieldChange,
5639
+ service
5526
5640
  }) => onChange({
5527
5641
  ids,
5528
5642
  model,
5529
5643
  specification,
5530
5644
  context,
5531
5645
  object,
5532
- fieldChange
5646
+ fieldChange,
5647
+ service
5533
5648
  })
5534
5649
  });
5535
5650
  };
@@ -5546,8 +5661,9 @@ var useSave = () => {
5546
5661
  data,
5547
5662
  specification,
5548
5663
  context,
5549
- path
5550
- }) => save({ ids, model, data, specification, context, path })
5664
+ path,
5665
+ service
5666
+ }) => save({ ids, model, data, specification, context, path, service })
5551
5667
  });
5552
5668
  };
5553
5669
  var use_save_default = useSave;
@@ -5599,12 +5715,14 @@ var useButton = () => {
5599
5715
  model,
5600
5716
  ids,
5601
5717
  context,
5602
- method
5718
+ method,
5719
+ service
5603
5720
  }) => callButton({
5604
5721
  model,
5605
5722
  ids,
5606
5723
  context,
5607
- method
5724
+ method,
5725
+ service
5608
5726
  }),
5609
5727
  onSuccess: (response) => {
5610
5728
  return response;
@@ -5621,11 +5739,13 @@ var useDuplicateRecord = () => {
5621
5739
  mutationFn: ({
5622
5740
  id,
5623
5741
  model,
5624
- context
5742
+ context,
5743
+ service
5625
5744
  }) => duplicateRecord({
5626
5745
  id,
5627
5746
  model,
5628
- context
5747
+ context,
5748
+ service
5629
5749
  })
5630
5750
  });
5631
5751
  };
@@ -5708,11 +5828,11 @@ var use_get_groups_default = useGetGroups;
5708
5828
 
5709
5829
  // src/hooks/view/use-get-list-data.ts
5710
5830
  var import_react_query49 = require("@tanstack/react-query");
5711
- var useGetListData = (listDataProps, queryKey, enabled) => {
5831
+ var useGetListData = (listDataProps, queryKey, enabled, service) => {
5712
5832
  const { getAll } = useModelService();
5713
5833
  return (0, import_react_query49.useQuery)({
5714
5834
  queryKey,
5715
- queryFn: () => getAll({ data: listDataProps }).then((res) => {
5835
+ queryFn: () => getAll({ data: listDataProps, service }).then((res) => {
5716
5836
  if (res) {
5717
5837
  return res;
5718
5838
  }
@@ -5788,12 +5908,13 @@ var import_react_query53 = require("@tanstack/react-query");
5788
5908
  var useGetSelection = ({
5789
5909
  data,
5790
5910
  queryKey,
5791
- enabled
5911
+ enabled,
5912
+ service
5792
5913
  }) => {
5793
5914
  const { getSelectionItem } = useViewService();
5794
5915
  return (0, import_react_query53.useQuery)({
5795
5916
  queryKey,
5796
- queryFn: () => getSelectionItem({ data }),
5917
+ queryFn: () => getSelectionItem({ data, service }),
5797
5918
  enabled,
5798
5919
  refetchOnWindowFocus: false
5799
5920
  });
@@ -5821,11 +5942,13 @@ var useLoadAction = () => {
5821
5942
  return (0, import_react_query55.useMutation)({
5822
5943
  mutationFn: ({
5823
5944
  idAction,
5824
- context
5945
+ context,
5946
+ service
5825
5947
  }) => {
5826
5948
  return loadAction({
5827
5949
  idAction,
5828
- context
5950
+ context,
5951
+ service
5829
5952
  });
5830
5953
  }
5831
5954
  });
@@ -5866,11 +5989,13 @@ var useRemoveRow = () => {
5866
5989
  mutationFn: ({
5867
5990
  model,
5868
5991
  ids,
5869
- context
5992
+ context,
5993
+ service
5870
5994
  }) => removeRows({
5871
5995
  model,
5872
5996
  ids,
5873
- context
5997
+ context,
5998
+ service
5874
5999
  })
5875
6000
  });
5876
6001
  };
@@ -5901,10 +6026,12 @@ var useRunAction = () => {
5901
6026
  return (0, import_react_query60.useMutation)({
5902
6027
  mutationFn: ({
5903
6028
  idAction,
5904
- context
6029
+ context,
6030
+ service
5905
6031
  }) => runAction({
5906
6032
  idAction,
5907
- context
6033
+ context,
6034
+ service
5908
6035
  })
5909
6036
  });
5910
6037
  };