@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/hooks.js CHANGED
@@ -2943,15 +2943,21 @@ function useActionService() {
2943
2943
  const loadAction = (0, import_react6.useCallback)(
2944
2944
  async ({
2945
2945
  idAction,
2946
- context
2946
+ context,
2947
+ service
2947
2948
  }) => {
2948
2949
  const jsonData = {
2949
2950
  action_id: idAction,
2950
2951
  with_context: { ...context }
2951
2952
  };
2952
- return env.requests.post("/load_action" /* LOAD_ACTION */, jsonData, {
2953
- headers: { "Content-Type": "application/json" }
2954
- });
2953
+ return env.requests.post(
2954
+ "/load_action" /* LOAD_ACTION */,
2955
+ jsonData,
2956
+ {
2957
+ headers: { "Content-Type": "application/json" }
2958
+ },
2959
+ service
2960
+ );
2955
2961
  },
2956
2962
  [env]
2957
2963
  );
@@ -2960,7 +2966,8 @@ function useActionService() {
2960
2966
  model,
2961
2967
  ids = [],
2962
2968
  context,
2963
- method
2969
+ method,
2970
+ service
2964
2971
  }) => {
2965
2972
  try {
2966
2973
  const jsonData = {
@@ -2969,9 +2976,14 @@ function useActionService() {
2969
2976
  ids,
2970
2977
  with_context: context
2971
2978
  };
2972
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2973
- headers: { "Content-Type": "application/json" }
2974
- });
2979
+ return env.requests.post(
2980
+ "/call" /* CALL_PATH */,
2981
+ jsonData,
2982
+ {
2983
+ headers: { "Content-Type": "application/json" }
2984
+ },
2985
+ service
2986
+ );
2975
2987
  } catch (error) {
2976
2988
  console.error("Error when calling button action:", error);
2977
2989
  throw error;
@@ -2983,7 +2995,8 @@ function useActionService() {
2983
2995
  async ({
2984
2996
  model,
2985
2997
  ids,
2986
- context
2998
+ context,
2999
+ service
2987
3000
  }) => {
2988
3001
  const jsonData = {
2989
3002
  model,
@@ -2991,9 +3004,14 @@ function useActionService() {
2991
3004
  ids,
2992
3005
  with_context: context
2993
3006
  };
2994
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
2995
- headers: { "Content-Type": "application/json" }
2996
- });
3007
+ return env.requests.post(
3008
+ "/call" /* CALL_PATH */,
3009
+ jsonData,
3010
+ {
3011
+ headers: { "Content-Type": "application/json" }
3012
+ },
3013
+ service
3014
+ );
2997
3015
  },
2998
3016
  [env]
2999
3017
  );
@@ -3001,7 +3019,8 @@ function useActionService() {
3001
3019
  async ({
3002
3020
  model,
3003
3021
  id,
3004
- context
3022
+ context,
3023
+ service
3005
3024
  }) => {
3006
3025
  const jsonData = {
3007
3026
  model,
@@ -3009,9 +3028,14 @@ function useActionService() {
3009
3028
  ids: id,
3010
3029
  with_context: context
3011
3030
  };
3012
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3013
- headers: { "Content-Type": "application/json" }
3014
- });
3031
+ return env.requests.post(
3032
+ "/call" /* CALL_PATH */,
3033
+ jsonData,
3034
+ {
3035
+ headers: { "Content-Type": "application/json" }
3036
+ },
3037
+ service
3038
+ );
3015
3039
  },
3016
3040
  [env]
3017
3041
  );
@@ -3054,15 +3078,21 @@ function useActionService() {
3054
3078
  const runAction = (0, import_react6.useCallback)(
3055
3079
  async ({
3056
3080
  idAction,
3057
- context
3081
+ context,
3082
+ service
3058
3083
  }) => {
3059
3084
  const jsonData = {
3060
3085
  action_id: idAction,
3061
3086
  with_context: { ...context }
3062
3087
  };
3063
- return env.requests.post("/run_action" /* RUN_ACTION_PATH */, jsonData, {
3064
- headers: { "Content-Type": "application/json" }
3065
- });
3088
+ return env.requests.post(
3089
+ "/run_action" /* RUN_ACTION_PATH */,
3090
+ jsonData,
3091
+ {
3092
+ headers: { "Content-Type": "application/json" }
3093
+ },
3094
+ service
3095
+ );
3066
3096
  },
3067
3097
  [env]
3068
3098
  );
@@ -3248,15 +3278,11 @@ function useAuthService() {
3248
3278
  data.append("grant_type", "authorization_code");
3249
3279
  data.append("client_id", env?.config?.clientId || "");
3250
3280
  data.append("redirect_uri", env?.config?.redirectUri || "");
3251
- return env?.requests?.post(
3252
- `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3253
- data,
3254
- {
3255
- headers: {
3256
- "Content-Type": "application/x-www-form-urlencoded"
3257
- }
3281
+ return env?.requests?.post("/token" /* TOKEN_BY_CODE */, data, {
3282
+ headers: {
3283
+ "Content-Type": "application/x-www-form-urlencoded"
3258
3284
  }
3259
- );
3285
+ });
3260
3286
  },
3261
3287
  [env]
3262
3288
  );
@@ -3774,7 +3800,7 @@ function useModelService() {
3774
3800
  });
3775
3801
  }, [env]);
3776
3802
  const getAll = (0, import_react12.useCallback)(
3777
- async ({ data }) => {
3803
+ async ({ data, service }) => {
3778
3804
  const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3779
3805
  fields: data.fields,
3780
3806
  groupby: data.groupby
@@ -3795,11 +3821,16 @@ function useModelService() {
3795
3821
  ...jsonReadGroup
3796
3822
  }
3797
3823
  };
3798
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3799
- headers: {
3800
- "Content-Type": "application/json"
3801
- }
3802
- });
3824
+ return env.requests.post(
3825
+ "/call" /* CALL_PATH */,
3826
+ jsonData,
3827
+ {
3828
+ headers: {
3829
+ "Content-Type": "application/json"
3830
+ }
3831
+ },
3832
+ service
3833
+ );
3803
3834
  },
3804
3835
  [env]
3805
3836
  );
@@ -3867,7 +3898,13 @@ function useModelService() {
3867
3898
  [env]
3868
3899
  );
3869
3900
  const getDetail = (0, import_react12.useCallback)(
3870
- async ({ ids = [], model, specification, context }) => {
3901
+ async ({
3902
+ ids = [],
3903
+ model,
3904
+ specification,
3905
+ context,
3906
+ service
3907
+ }) => {
3871
3908
  const jsonData = {
3872
3909
  model,
3873
3910
  method: "web_read" /* WEB_READ */,
@@ -3877,11 +3914,16 @@ function useModelService() {
3877
3914
  specification
3878
3915
  }
3879
3916
  };
3880
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3881
- headers: {
3882
- "Content-Type": "application/json"
3883
- }
3884
- });
3917
+ return env.requests.post(
3918
+ "/call" /* CALL_PATH */,
3919
+ jsonData,
3920
+ {
3921
+ headers: {
3922
+ "Content-Type": "application/json"
3923
+ }
3924
+ },
3925
+ service
3926
+ );
3885
3927
  },
3886
3928
  [env]
3887
3929
  );
@@ -3892,7 +3934,8 @@ function useModelService() {
3892
3934
  data = {},
3893
3935
  specification = {},
3894
3936
  context = {},
3895
- path
3937
+ path,
3938
+ service
3896
3939
  }) => {
3897
3940
  const jsonData = {
3898
3941
  model,
@@ -3904,26 +3947,36 @@ function useModelService() {
3904
3947
  specification
3905
3948
  }
3906
3949
  };
3907
- return env.requests.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3908
- headers: {
3909
- "Content-Type": "application/json"
3910
- }
3911
- });
3950
+ return env.requests.post(
3951
+ path ?? "/call" /* CALL_PATH */,
3952
+ jsonData,
3953
+ {
3954
+ headers: {
3955
+ "Content-Type": "application/json"
3956
+ }
3957
+ },
3958
+ service
3959
+ );
3912
3960
  },
3913
3961
  [env]
3914
3962
  );
3915
3963
  const deleteApi = (0, import_react12.useCallback)(
3916
- async ({ ids = [], model }) => {
3964
+ async ({ ids = [], model, service }) => {
3917
3965
  const jsonData = {
3918
3966
  model,
3919
3967
  method: "unlink" /* UNLINK */,
3920
3968
  ids
3921
3969
  };
3922
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3923
- headers: {
3924
- "Content-Type": "application/json"
3925
- }
3926
- });
3970
+ return env.requests.post(
3971
+ "/call" /* CALL_PATH */,
3972
+ jsonData,
3973
+ {
3974
+ headers: {
3975
+ "Content-Type": "application/json"
3976
+ }
3977
+ },
3978
+ service
3979
+ );
3927
3980
  },
3928
3981
  [env]
3929
3982
  );
@@ -3934,7 +3987,8 @@ function useModelService() {
3934
3987
  object,
3935
3988
  specification,
3936
3989
  context,
3937
- fieldChange
3990
+ fieldChange,
3991
+ service
3938
3992
  }) => {
3939
3993
  const jsonData = {
3940
3994
  model,
@@ -3947,25 +4001,35 @@ function useModelService() {
3947
4001
  specification
3948
4002
  ]
3949
4003
  };
3950
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3951
- headers: {
3952
- "Content-Type": "application/json"
3953
- }
3954
- });
4004
+ return env.requests.post(
4005
+ "/call" /* CALL_PATH */,
4006
+ jsonData,
4007
+ {
4008
+ headers: {
4009
+ "Content-Type": "application/json"
4010
+ }
4011
+ },
4012
+ service
4013
+ );
3955
4014
  },
3956
4015
  [env]
3957
4016
  );
3958
4017
  const getListFieldsOnchange = (0, import_react12.useCallback)(
3959
- async ({ model }) => {
4018
+ async ({ model, service }) => {
3960
4019
  const jsonData = {
3961
4020
  model,
3962
4021
  method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3963
4022
  };
3964
- return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3965
- headers: {
3966
- "Content-Type": "application/json"
3967
- }
3968
- });
4023
+ return env.requests.post(
4024
+ "/call" /* CALL_PATH */,
4025
+ jsonData,
4026
+ {
4027
+ headers: {
4028
+ "Content-Type": "application/json"
4029
+ }
4030
+ },
4031
+ service
4032
+ );
3969
4033
  },
3970
4034
  [env]
3971
4035
  );
@@ -4125,7 +4189,8 @@ function useViewService() {
4125
4189
  views,
4126
4190
  context = {},
4127
4191
  options = {},
4128
- aid
4192
+ aid,
4193
+ service
4129
4194
  }) => {
4130
4195
  const defaultOptions = {
4131
4196
  load_filters: true,
@@ -4141,11 +4206,16 @@ function useViewService() {
4141
4206
  },
4142
4207
  with_context: context
4143
4208
  };
4144
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4145
- headers: {
4146
- "Content-Type": "application/json"
4147
- }
4148
- });
4209
+ return env?.requests?.post(
4210
+ "/call" /* CALL_PATH */,
4211
+ jsonDataView,
4212
+ {
4213
+ headers: {
4214
+ "Content-Type": "application/json"
4215
+ }
4216
+ },
4217
+ service
4218
+ );
4149
4219
  },
4150
4220
  [env]
4151
4221
  );
@@ -4228,7 +4298,7 @@ function useViewService() {
4228
4298
  [env]
4229
4299
  );
4230
4300
  const getSelectionItem = (0, import_react14.useCallback)(
4231
- async ({ data }) => {
4301
+ async ({ data, service }) => {
4232
4302
  const jsonData = {
4233
4303
  model: data.model,
4234
4304
  ids: [],
@@ -4246,11 +4316,16 @@ function useViewService() {
4246
4316
  }
4247
4317
  }
4248
4318
  };
4249
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4250
- headers: {
4251
- "Content-Type": "application/json"
4252
- }
4253
- });
4319
+ return env?.requests.post(
4320
+ "/call" /* CALL_PATH */,
4321
+ jsonData,
4322
+ {
4323
+ headers: {
4324
+ "Content-Type": "application/json"
4325
+ }
4326
+ },
4327
+ service
4328
+ );
4254
4329
  },
4255
4330
  [env]
4256
4331
  );
@@ -4918,7 +4993,7 @@ var import_react_query32 = require("@tanstack/react-query");
4918
4993
  var useDelete = () => {
4919
4994
  const { deleteApi } = useModelService();
4920
4995
  return (0, import_react_query32.useMutation)({
4921
- mutationFn: ({ ids, model }) => deleteApi({ ids, model })
4996
+ mutationFn: ({ ids, model, service }) => deleteApi({ ids, model, service })
4922
4997
  });
4923
4998
  };
4924
4999
  var use_delete_default = useDelete;
@@ -4981,12 +5056,14 @@ var useGetDetail = () => {
4981
5056
  model,
4982
5057
  ids,
4983
5058
  specification,
4984
- context
5059
+ context,
5060
+ service
4985
5061
  }) => getDetail({
4986
5062
  model,
4987
5063
  ids,
4988
5064
  specification,
4989
- context
5065
+ context,
5066
+ service
4990
5067
  })
4991
5068
  });
4992
5069
  };
@@ -4994,12 +5071,16 @@ var use_get_detail_default = useGetDetail;
4994
5071
 
4995
5072
  // src/hooks/model/use-get-field-onchange.ts
4996
5073
  var import_react_query37 = require("@tanstack/react-query");
4997
- var useGetFieldOnChange = ({ model }) => {
5074
+ var useGetFieldOnChange = ({
5075
+ model,
5076
+ service
5077
+ }) => {
4998
5078
  const { getListFieldsOnchange } = useModelService();
4999
5079
  return (0, import_react_query37.useQuery)({
5000
5080
  queryKey: [`field-onchange-${model}`, model],
5001
5081
  queryFn: () => getListFieldsOnchange({
5002
- model
5082
+ model,
5083
+ service
5003
5084
  }).then((res) => {
5004
5085
  if (res) {
5005
5086
  return res;
@@ -5182,14 +5263,16 @@ var useOnChangeForm = () => {
5182
5263
  specification,
5183
5264
  context,
5184
5265
  object,
5185
- fieldChange
5266
+ fieldChange,
5267
+ service
5186
5268
  }) => onChange({
5187
5269
  ids,
5188
5270
  model,
5189
5271
  specification,
5190
5272
  context,
5191
5273
  object,
5192
- fieldChange
5274
+ fieldChange,
5275
+ service
5193
5276
  })
5194
5277
  });
5195
5278
  };
@@ -5206,8 +5289,9 @@ var useSave = () => {
5206
5289
  data,
5207
5290
  specification,
5208
5291
  context,
5209
- path
5210
- }) => save({ ids, model, data, specification, context, path })
5292
+ path,
5293
+ service
5294
+ }) => save({ ids, model, data, specification, context, path, service })
5211
5295
  });
5212
5296
  };
5213
5297
  var use_save_default = useSave;
@@ -5259,12 +5343,14 @@ var useButton = () => {
5259
5343
  model,
5260
5344
  ids,
5261
5345
  context,
5262
- method
5346
+ method,
5347
+ service
5263
5348
  }) => callButton({
5264
5349
  model,
5265
5350
  ids,
5266
5351
  context,
5267
- method
5352
+ method,
5353
+ service
5268
5354
  }),
5269
5355
  onSuccess: (response) => {
5270
5356
  return response;
@@ -5281,11 +5367,13 @@ var useDuplicateRecord = () => {
5281
5367
  mutationFn: ({
5282
5368
  id,
5283
5369
  model,
5284
- context
5370
+ context,
5371
+ service
5285
5372
  }) => duplicateRecord({
5286
5373
  id,
5287
5374
  model,
5288
- context
5375
+ context,
5376
+ service
5289
5377
  })
5290
5378
  });
5291
5379
  };
@@ -5368,11 +5456,11 @@ var use_get_groups_default = useGetGroups;
5368
5456
 
5369
5457
  // src/hooks/view/use-get-list-data.ts
5370
5458
  var import_react_query49 = require("@tanstack/react-query");
5371
- var useGetListData = (listDataProps, queryKey, enabled) => {
5459
+ var useGetListData = (listDataProps, queryKey, enabled, service) => {
5372
5460
  const { getAll } = useModelService();
5373
5461
  return (0, import_react_query49.useQuery)({
5374
5462
  queryKey,
5375
- queryFn: () => getAll({ data: listDataProps }).then((res) => {
5463
+ queryFn: () => getAll({ data: listDataProps, service }).then((res) => {
5376
5464
  if (res) {
5377
5465
  return res;
5378
5466
  }
@@ -5448,12 +5536,13 @@ var import_react_query53 = require("@tanstack/react-query");
5448
5536
  var useGetSelection = ({
5449
5537
  data,
5450
5538
  queryKey,
5451
- enabled
5539
+ enabled,
5540
+ service
5452
5541
  }) => {
5453
5542
  const { getSelectionItem } = useViewService();
5454
5543
  return (0, import_react_query53.useQuery)({
5455
5544
  queryKey,
5456
- queryFn: () => getSelectionItem({ data }),
5545
+ queryFn: () => getSelectionItem({ data, service }),
5457
5546
  enabled,
5458
5547
  refetchOnWindowFocus: false
5459
5548
  });
@@ -5481,11 +5570,13 @@ var useLoadAction = () => {
5481
5570
  return (0, import_react_query55.useMutation)({
5482
5571
  mutationFn: ({
5483
5572
  idAction,
5484
- context
5573
+ context,
5574
+ service
5485
5575
  }) => {
5486
5576
  return loadAction({
5487
5577
  idAction,
5488
- context
5578
+ context,
5579
+ service
5489
5580
  });
5490
5581
  }
5491
5582
  });
@@ -5526,11 +5617,13 @@ var useRemoveRow = () => {
5526
5617
  mutationFn: ({
5527
5618
  model,
5528
5619
  ids,
5529
- context
5620
+ context,
5621
+ service
5530
5622
  }) => removeRows({
5531
5623
  model,
5532
5624
  ids,
5533
- context
5625
+ context,
5626
+ service
5534
5627
  })
5535
5628
  });
5536
5629
  };
@@ -5561,10 +5654,12 @@ var useRunAction = () => {
5561
5654
  return (0, import_react_query60.useMutation)({
5562
5655
  mutationFn: ({
5563
5656
  idAction,
5564
- context
5657
+ context,
5658
+ service
5565
5659
  }) => runAction({
5566
5660
  idAction,
5567
- context
5661
+ context,
5662
+ service
5568
5663
  })
5569
5664
  });
5570
5665
  };