@fctc/interface-logic 2.1.3 → 2.1.5

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.mjs CHANGED
@@ -25,6 +25,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
25
25
  UriConstants2["IMAGE_PATH"] = `/web/image`;
26
26
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
27
27
  UriConstants2["TOKEN"] = `/check_token`;
28
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
28
29
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
29
30
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
30
31
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -3101,9 +3102,9 @@ function useAuthService() {
3101
3102
  [env]
3102
3103
  );
3103
3104
  const isValidActionToken = useCallback3(
3104
- async (actionToken, path) => {
3105
+ async (actionToken) => {
3105
3106
  return env?.requests?.post(
3106
- path,
3107
+ "/action-token/validate" /* VALIDATE_ACTION_TOKEN */,
3107
3108
  {},
3108
3109
  {
3109
3110
  headers: {
@@ -4049,101 +4050,14 @@ function useViewService() {
4049
4050
  [env]
4050
4051
  );
4051
4052
  const getMenu = useCallback10(
4052
- async (context) => {
4053
+ async (context, specification) => {
4053
4054
  const jsonData = {
4054
4055
  model: "ir.ui.menu" /* MENU */,
4055
4056
  method: "web_search_read" /* WEB_SEARCH_READ */,
4056
4057
  ids: [],
4057
4058
  with_context: context,
4058
4059
  kwargs: {
4059
- specification: {
4060
- active: {},
4061
- name: {},
4062
- is_display: {},
4063
- sequence: {},
4064
- complete_name: {},
4065
- action: {
4066
- fields: {
4067
- display_name: {},
4068
- type: {},
4069
- binding_view_types: {}
4070
- }
4071
- },
4072
- url_icon: {},
4073
- web_icon: {},
4074
- web_icon_data: {},
4075
- groups_id: {
4076
- fields: {
4077
- full_name: {}
4078
- },
4079
- limit: 40,
4080
- order: ""
4081
- },
4082
- display_name: {},
4083
- child_id: {
4084
- fields: {
4085
- active: {},
4086
- name: {},
4087
- is_display: {},
4088
- sequence: {},
4089
- complete_name: {},
4090
- action: {
4091
- fields: {
4092
- display_name: {},
4093
- type: {},
4094
- binding_view_types: {}
4095
- }
4096
- },
4097
- url_icon: {},
4098
- web_icon: {},
4099
- web_icon_data: {},
4100
- groups_id: {
4101
- fields: {
4102
- full_name: {}
4103
- },
4104
- limit: 40,
4105
- order: ""
4106
- },
4107
- display_name: {},
4108
- child_id: {
4109
- fields: {
4110
- active: {},
4111
- name: {},
4112
- is_display: {},
4113
- sequence: {},
4114
- complete_name: {},
4115
- action: {
4116
- fields: {
4117
- display_name: {},
4118
- type: {},
4119
- binding_view_types: {}
4120
- }
4121
- },
4122
- url_icon: {},
4123
- web_icon: {},
4124
- web_icon_data: {},
4125
- groups_id: {
4126
- fields: {
4127
- full_name: {}
4128
- },
4129
- limit: 40,
4130
- order: ""
4131
- },
4132
- display_name: {},
4133
- child_id: {
4134
- fields: {},
4135
- limit: 40,
4136
- order: ""
4137
- }
4138
- },
4139
- limit: 40,
4140
- order: ""
4141
- }
4142
- },
4143
- limit: 40,
4144
- order: ""
4145
- }
4146
- },
4060
+ specification,
4147
4061
  domain: [
4148
4062
  "&",
4149
4063
  ["is_display", "=", true],
@@ -4338,18 +4252,25 @@ function useViewService() {
4338
4252
  redirect_uri,
4339
4253
  state,
4340
4254
  client_id,
4341
- response_type
4255
+ response_type,
4256
+ path,
4257
+ scope
4342
4258
  }) => {
4343
- const jsonData = {
4344
- redirect_uri,
4345
- state,
4259
+ const params = new URLSearchParams({
4260
+ response_type,
4346
4261
  client_id,
4347
- response_type
4348
- };
4349
- return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4262
+ redirect_uri,
4263
+ state
4264
+ });
4265
+ const queryString = `${params.toString()}&scope=${encodeURIComponent(
4266
+ scope
4267
+ )}`;
4268
+ const url = `${path}?${queryString}`;
4269
+ return env?.requests.get(url, {
4350
4270
  headers: {
4351
- credentials: "include"
4352
- }
4271
+ "Content-Type": "application/json"
4272
+ },
4273
+ withCredentials: true
4353
4274
  });
4354
4275
  },
4355
4276
  [env]
@@ -4588,11 +4509,8 @@ import { useMutation as useMutation12 } from "@tanstack/react-query";
4588
4509
  var useValidateActionToken = () => {
4589
4510
  const { isValidActionToken } = useAuthService();
4590
4511
  return useMutation12({
4591
- mutationFn: ({
4592
- actionToken,
4593
- path
4594
- }) => {
4595
- return isValidActionToken(actionToken, path);
4512
+ mutationFn: ({ actionToken }) => {
4513
+ return isValidActionToken(actionToken);
4596
4514
  }
4597
4515
  });
4598
4516
  };
@@ -5283,7 +5201,6 @@ var useGetActionDetail = ({
5283
5201
  model,
5284
5202
  queryKey
5285
5203
  }) => {
5286
- const { getFormView } = useFormService();
5287
5204
  const { getActionDetail } = useViewService();
5288
5205
  const data = {
5289
5206
  id,
@@ -5298,9 +5215,6 @@ var useGetActionDetail = ({
5298
5215
  if (res && res.length > 0) {
5299
5216
  return res[0];
5300
5217
  }
5301
- } else {
5302
- const res = await getFormView({ data });
5303
- return res;
5304
5218
  }
5305
5219
  },
5306
5220
  enabled,
@@ -5373,11 +5287,11 @@ var use_get_list_data_default = useGetListData;
5373
5287
 
5374
5288
  // src/hooks/view/use-get-menu.ts
5375
5289
  import { useQuery as useQuery15 } from "@tanstack/react-query";
5376
- var useGetMenu = (context, enabled) => {
5290
+ var useGetMenu = (context, specification, enabled) => {
5377
5291
  const { getMenu } = useViewService();
5378
5292
  return useQuery15({
5379
5293
  queryKey: ["menus" /* MENU */, context],
5380
- queryFn: () => getMenu(context).then((res) => {
5294
+ queryFn: () => getMenu(context, specification).then((res) => {
5381
5295
  if (res && res?.records && res?.records?.length > 0) {
5382
5296
  return res?.records;
5383
5297
  }
@@ -5566,13 +5480,16 @@ var useSignInSSO = () => {
5566
5480
  state,
5567
5481
  client_id,
5568
5482
  response_type,
5569
- path
5483
+ path,
5484
+ scope
5570
5485
  }) => {
5571
5486
  return signInSSO({
5572
5487
  redirect_uri,
5573
5488
  state,
5574
5489
  client_id,
5575
- response_type
5490
+ response_type,
5491
+ path,
5492
+ scope
5576
5493
  });
5577
5494
  }
5578
5495
  });
@@ -1,3 +1,4 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import { ReactNode } from 'react';
2
3
  import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './session-storage-ARp_lhTD.mjs';
3
4
  import { useForgotPassword, useForgotPasswordSSO, useGetProvider, useIsValidToken, useLoginCredential, useLoginSocial, useResetPassword, useResetPasswordSSO, useUpdatePassword, useLogout, useGetAccessByCode, useValidateActionToken, useGetCompanyInfo, useGetCurrentCompany, useGetListCompany, useExecuteImport, useExportExcel, useGetFieldExport, useGetFileExcel, useParsePreview, useUploadFile, useUploadIdFile, useChangeStatus, useDeleteComment, useGetComment, useGetFormView, useGetImage, useSendComment, useUploadImage, useDelete, useGetAll, useGetConversionRate, useGetCurrency, useGetDetail, useGetFieldOnChange, useGetListMyBankAccount, useModel, useOdooDataTransform, useOnChangeForm, useSave, useGetProfile, useGetUser, useSwitchLocale, useButton, useDuplicateRecord, useGet2FAMethods, useGetActionDetail, useGetCalendar, useGetGroups, useGetListData, useGetMenu, useGetPrintReport, useGetProGressBar, useGetResequence, useGetSelection, useGetView, useLoadAction, useLoadMessage, usePrint, useRemoveRow, useRunAction, useSignInSSO, useVerify2FA, useGrantAccess, useRemoveTotpSetup, useRequestSetupTotp, useSettingsWebRead2fa, useVerifyTotp } from './hooks.mjs';
@@ -6,15 +7,15 @@ import './view-type-BGJfDe73.mjs';
6
7
 
7
8
  declare const MainProvider: ({ children }: {
8
9
  children: ReactNode;
9
- }) => JSX.Element;
10
+ }) => react_jsx_runtime.JSX.Element;
10
11
 
11
12
  declare const ReactQueryProvider: ({ children }: {
12
13
  children: ReactNode;
13
- }) => JSX.Element;
14
+ }) => react_jsx_runtime.JSX.Element;
14
15
 
15
16
  declare const VersionGate: ({ children }: {
16
17
  children: ReactNode;
17
- }) => JSX.Element | null;
18
+ }) => react_jsx_runtime.JSX.Element | null;
18
19
 
19
20
  interface EnvConfig {
20
21
  env?: any;
@@ -45,7 +46,7 @@ declare function EnvProvider({ children, localStorageUtils: localStorageUtil, se
45
46
  children: React.ReactNode;
46
47
  localStorageUtils?: LocalStorageUtilsType;
47
48
  sessionStorageUtils?: SessionStorageUtilsType;
48
- }): JSX.Element;
49
+ }): react_jsx_runtime.JSX.Element;
49
50
  declare function useEnv(): {
50
51
  env: EnvConfig;
51
52
  setupEnv: (envConfig: Partial<EnvConfig>) => EnvConfig;
@@ -131,12 +132,12 @@ interface ServiceContextType {
131
132
  }
132
133
  declare const ServiceProvider: ({ children, }: {
133
134
  children: React.ReactNode;
134
- }) => JSX.Element;
135
+ }) => react_jsx_runtime.JSX.Element;
135
136
  declare const useService: () => ServiceContextType;
136
137
 
137
138
  type MetaProviderProps = {
138
139
  children: ReactNode;
139
140
  };
140
- declare const MetaProvider: ({ children }: MetaProviderProps) => JSX.Element;
141
+ declare const MetaProvider: ({ children }: MetaProviderProps) => react_jsx_runtime.JSX.Element;
141
142
 
142
143
  export { EnvProvider, MainProvider, MetaProvider, ReactQueryProvider, ServiceProvider, VersionGate, useEnv, useService };
@@ -1,3 +1,4 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import { ReactNode } from 'react';
2
3
  import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './session-storage-ARp_lhTD.js';
3
4
  import { useForgotPassword, useForgotPasswordSSO, useGetProvider, useIsValidToken, useLoginCredential, useLoginSocial, useResetPassword, useResetPasswordSSO, useUpdatePassword, useLogout, useGetAccessByCode, useValidateActionToken, useGetCompanyInfo, useGetCurrentCompany, useGetListCompany, useExecuteImport, useExportExcel, useGetFieldExport, useGetFileExcel, useParsePreview, useUploadFile, useUploadIdFile, useChangeStatus, useDeleteComment, useGetComment, useGetFormView, useGetImage, useSendComment, useUploadImage, useDelete, useGetAll, useGetConversionRate, useGetCurrency, useGetDetail, useGetFieldOnChange, useGetListMyBankAccount, useModel, useOdooDataTransform, useOnChangeForm, useSave, useGetProfile, useGetUser, useSwitchLocale, useButton, useDuplicateRecord, useGet2FAMethods, useGetActionDetail, useGetCalendar, useGetGroups, useGetListData, useGetMenu, useGetPrintReport, useGetProGressBar, useGetResequence, useGetSelection, useGetView, useLoadAction, useLoadMessage, usePrint, useRemoveRow, useRunAction, useSignInSSO, useVerify2FA, useGrantAccess, useRemoveTotpSetup, useRequestSetupTotp, useSettingsWebRead2fa, useVerifyTotp } from './hooks.js';
@@ -6,15 +7,15 @@ import './view-type-BGJfDe73.js';
6
7
 
7
8
  declare const MainProvider: ({ children }: {
8
9
  children: ReactNode;
9
- }) => JSX.Element;
10
+ }) => react_jsx_runtime.JSX.Element;
10
11
 
11
12
  declare const ReactQueryProvider: ({ children }: {
12
13
  children: ReactNode;
13
- }) => JSX.Element;
14
+ }) => react_jsx_runtime.JSX.Element;
14
15
 
15
16
  declare const VersionGate: ({ children }: {
16
17
  children: ReactNode;
17
- }) => JSX.Element | null;
18
+ }) => react_jsx_runtime.JSX.Element | null;
18
19
 
19
20
  interface EnvConfig {
20
21
  env?: any;
@@ -45,7 +46,7 @@ declare function EnvProvider({ children, localStorageUtils: localStorageUtil, se
45
46
  children: React.ReactNode;
46
47
  localStorageUtils?: LocalStorageUtilsType;
47
48
  sessionStorageUtils?: SessionStorageUtilsType;
48
- }): JSX.Element;
49
+ }): react_jsx_runtime.JSX.Element;
49
50
  declare function useEnv(): {
50
51
  env: EnvConfig;
51
52
  setupEnv: (envConfig: Partial<EnvConfig>) => EnvConfig;
@@ -131,12 +132,12 @@ interface ServiceContextType {
131
132
  }
132
133
  declare const ServiceProvider: ({ children, }: {
133
134
  children: React.ReactNode;
134
- }) => JSX.Element;
135
+ }) => react_jsx_runtime.JSX.Element;
135
136
  declare const useService: () => ServiceContextType;
136
137
 
137
138
  type MetaProviderProps = {
138
139
  children: ReactNode;
139
140
  };
140
- declare const MetaProvider: ({ children }: MetaProviderProps) => JSX.Element;
141
+ declare const MetaProvider: ({ children }: MetaProviderProps) => react_jsx_runtime.JSX.Element;
141
142
 
142
143
  export { EnvProvider, MainProvider, MetaProvider, ReactQueryProvider, ServiceProvider, VersionGate, useEnv, useService };
package/dist/provider.js CHANGED
@@ -718,6 +718,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
718
718
  UriConstants2["IMAGE_PATH"] = `/web/image`;
719
719
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
720
720
  UriConstants2["TOKEN"] = `/check_token`;
721
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
721
722
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
722
723
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
723
724
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -3153,9 +3154,9 @@ function useAuthService() {
3153
3154
  [env]
3154
3155
  );
3155
3156
  const isValidActionToken = (0, import_react3.useCallback)(
3156
- async (actionToken, path) => {
3157
+ async (actionToken) => {
3157
3158
  return env?.requests?.post(
3158
- path,
3159
+ "/action-token/validate" /* VALIDATE_ACTION_TOKEN */,
3159
3160
  {},
3160
3161
  {
3161
3162
  headers: {
@@ -4101,101 +4102,14 @@ function useViewService() {
4101
4102
  [env]
4102
4103
  );
4103
4104
  const getMenu = (0, import_react10.useCallback)(
4104
- async (context) => {
4105
+ async (context, specification) => {
4105
4106
  const jsonData = {
4106
4107
  model: "ir.ui.menu" /* MENU */,
4107
4108
  method: "web_search_read" /* WEB_SEARCH_READ */,
4108
4109
  ids: [],
4109
4110
  with_context: context,
4110
4111
  kwargs: {
4111
- specification: {
4112
- active: {},
4113
- name: {},
4114
- is_display: {},
4115
- sequence: {},
4116
- complete_name: {},
4117
- action: {
4118
- fields: {
4119
- display_name: {},
4120
- type: {},
4121
- binding_view_types: {}
4122
- }
4123
- },
4124
- url_icon: {},
4125
- web_icon: {},
4126
- web_icon_data: {},
4127
- groups_id: {
4128
- fields: {
4129
- full_name: {}
4130
- },
4131
- limit: 40,
4132
- order: ""
4133
- },
4134
- display_name: {},
4135
- child_id: {
4136
- fields: {
4137
- active: {},
4138
- name: {},
4139
- is_display: {},
4140
- sequence: {},
4141
- complete_name: {},
4142
- action: {
4143
- fields: {
4144
- display_name: {},
4145
- type: {},
4146
- binding_view_types: {}
4147
- }
4148
- },
4149
- url_icon: {},
4150
- web_icon: {},
4151
- web_icon_data: {},
4152
- groups_id: {
4153
- fields: {
4154
- full_name: {}
4155
- },
4156
- limit: 40,
4157
- order: ""
4158
- },
4159
- display_name: {},
4160
- child_id: {
4161
- fields: {
4162
- active: {},
4163
- name: {},
4164
- is_display: {},
4165
- sequence: {},
4166
- complete_name: {},
4167
- action: {
4168
- fields: {
4169
- display_name: {},
4170
- type: {},
4171
- binding_view_types: {}
4172
- }
4173
- },
4174
- url_icon: {},
4175
- web_icon: {},
4176
- web_icon_data: {},
4177
- groups_id: {
4178
- fields: {
4179
- full_name: {}
4180
- },
4181
- limit: 40,
4182
- order: ""
4183
- },
4184
- display_name: {},
4185
- child_id: {
4186
- fields: {},
4187
- limit: 40,
4188
- order: ""
4189
- }
4190
- },
4191
- limit: 40,
4192
- order: ""
4193
- }
4194
- },
4195
- limit: 40,
4196
- order: ""
4197
- }
4198
- },
4112
+ specification,
4199
4113
  domain: [
4200
4114
  "&",
4201
4115
  ["is_display", "=", true],
@@ -4390,18 +4304,25 @@ function useViewService() {
4390
4304
  redirect_uri,
4391
4305
  state,
4392
4306
  client_id,
4393
- response_type
4307
+ response_type,
4308
+ path,
4309
+ scope
4394
4310
  }) => {
4395
- const jsonData = {
4396
- redirect_uri,
4397
- state,
4311
+ const params = new URLSearchParams({
4312
+ response_type,
4398
4313
  client_id,
4399
- response_type
4400
- };
4401
- return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4314
+ redirect_uri,
4315
+ state
4316
+ });
4317
+ const queryString = `${params.toString()}&scope=${encodeURIComponent(
4318
+ scope
4319
+ )}`;
4320
+ const url = `${path}?${queryString}`;
4321
+ return env?.requests.get(url, {
4402
4322
  headers: {
4403
- credentials: "include"
4404
- }
4323
+ "Content-Type": "application/json"
4324
+ },
4325
+ withCredentials: true
4405
4326
  });
4406
4327
  },
4407
4328
  [env]
@@ -4574,9 +4495,11 @@ var sessionStorageUtils = () => {
4574
4495
  // src/configs/axios-client.ts
4575
4496
  var axiosClient = {
4576
4497
  init(config) {
4498
+ console.log("config", config);
4577
4499
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
4578
4500
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
4579
4501
  const db = config?.db;
4502
+ const database = config?.config?.database;
4580
4503
  let isRefreshing = false;
4581
4504
  let failedQueue = [];
4582
4505
  const processQueue = (error, token = null) => {
@@ -4597,12 +4520,19 @@ var axiosClient = {
4597
4520
  });
4598
4521
  instance.interceptors.request.use(async (config2) => {
4599
4522
  const { useRefreshToken, useActionToken, actionToken } = config2;
4523
+ let token = null;
4600
4524
  if (useActionToken && actionToken) {
4601
- config2.headers["Action-Token"] = actionToken;
4525
+ token = actionToken;
4526
+ } else {
4527
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
4528
+ token = await getToken?.();
4529
+ }
4530
+ if (token) {
4531
+ config2.headers["Authorization"] = `Bearer ${token}`;
4532
+ }
4533
+ if (database) {
4534
+ config2.headers["DATABASE"] = database;
4602
4535
  }
4603
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
4604
- const token = await getToken?.();
4605
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
4606
4536
  return config2;
4607
4537
  }, Promise.reject);
4608
4538
  instance.interceptors.response.use(
@@ -5022,11 +4952,8 @@ var import_react_query14 = require("@tanstack/react-query");
5022
4952
  var useValidateActionToken = () => {
5023
4953
  const { isValidActionToken } = useAuthService();
5024
4954
  return (0, import_react_query14.useMutation)({
5025
- mutationFn: ({
5026
- actionToken,
5027
- path
5028
- }) => {
5029
- return isValidActionToken(actionToken, path);
4955
+ mutationFn: ({ actionToken }) => {
4956
+ return isValidActionToken(actionToken);
5030
4957
  }
5031
4958
  });
5032
4959
  };
@@ -5717,7 +5644,6 @@ var useGetActionDetail = ({
5717
5644
  model,
5718
5645
  queryKey
5719
5646
  }) => {
5720
- const { getFormView } = useFormService();
5721
5647
  const { getActionDetail } = useViewService();
5722
5648
  const data = {
5723
5649
  id,
@@ -5732,9 +5658,6 @@ var useGetActionDetail = ({
5732
5658
  if (res && res.length > 0) {
5733
5659
  return res[0];
5734
5660
  }
5735
- } else {
5736
- const res = await getFormView({ data });
5737
- return res;
5738
5661
  }
5739
5662
  },
5740
5663
  enabled,
@@ -5807,11 +5730,11 @@ var use_get_list_data_default = useGetListData;
5807
5730
 
5808
5731
  // src/hooks/view/use-get-menu.ts
5809
5732
  var import_react_query50 = require("@tanstack/react-query");
5810
- var useGetMenu = (context, enabled) => {
5733
+ var useGetMenu = (context, specification, enabled) => {
5811
5734
  const { getMenu } = useViewService();
5812
5735
  return (0, import_react_query50.useQuery)({
5813
5736
  queryKey: ["menus" /* MENU */, context],
5814
- queryFn: () => getMenu(context).then((res) => {
5737
+ queryFn: () => getMenu(context, specification).then((res) => {
5815
5738
  if (res && res?.records && res?.records?.length > 0) {
5816
5739
  return res?.records;
5817
5740
  }
@@ -6000,13 +5923,16 @@ var useSignInSSO = () => {
6000
5923
  state,
6001
5924
  client_id,
6002
5925
  response_type,
6003
- path
5926
+ path,
5927
+ scope
6004
5928
  }) => {
6005
5929
  return signInSSO({
6006
5930
  redirect_uri,
6007
5931
  state,
6008
5932
  client_id,
6009
- response_type
5933
+ response_type,
5934
+ path,
5935
+ scope
6010
5936
  });
6011
5937
  }
6012
5938
  });