@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/configs.js CHANGED
@@ -2208,9 +2208,11 @@ var sessionStorageUtils = () => {
2208
2208
  // src/configs/axios-client.ts
2209
2209
  var axiosClient = {
2210
2210
  init(config) {
2211
+ console.log("config", config);
2211
2212
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2212
2213
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2213
2214
  const db = config?.db;
2215
+ const database = config?.config?.database;
2214
2216
  let isRefreshing = false;
2215
2217
  let failedQueue = [];
2216
2218
  const processQueue = (error, token = null) => {
@@ -2231,12 +2233,19 @@ var axiosClient = {
2231
2233
  });
2232
2234
  instance.interceptors.request.use(async (config2) => {
2233
2235
  const { useRefreshToken, useActionToken, actionToken } = config2;
2236
+ let token = null;
2234
2237
  if (useActionToken && actionToken) {
2235
- config2.headers["Action-Token"] = actionToken;
2238
+ token = actionToken;
2239
+ } else {
2240
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2241
+ token = await getToken?.();
2242
+ }
2243
+ if (token) {
2244
+ config2.headers["Authorization"] = `Bearer ${token}`;
2245
+ }
2246
+ if (database) {
2247
+ config2.headers["DATABASE"] = database;
2236
2248
  }
2237
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2238
- const token = await getToken?.();
2239
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2240
2249
  return config2;
2241
2250
  }, Promise.reject);
2242
2251
  instance.interceptors.response.use(
package/dist/configs.mjs CHANGED
@@ -2172,9 +2172,11 @@ var sessionStorageUtils = () => {
2172
2172
  // src/configs/axios-client.ts
2173
2173
  var axiosClient = {
2174
2174
  init(config) {
2175
+ console.log("config", config);
2175
2176
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2176
2177
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2177
2178
  const db = config?.db;
2179
+ const database = config?.config?.database;
2178
2180
  let isRefreshing = false;
2179
2181
  let failedQueue = [];
2180
2182
  const processQueue = (error, token = null) => {
@@ -2195,12 +2197,19 @@ var axiosClient = {
2195
2197
  });
2196
2198
  instance.interceptors.request.use(async (config2) => {
2197
2199
  const { useRefreshToken, useActionToken, actionToken } = config2;
2200
+ let token = null;
2198
2201
  if (useActionToken && actionToken) {
2199
- config2.headers["Action-Token"] = actionToken;
2202
+ token = actionToken;
2203
+ } else {
2204
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2205
+ token = await getToken?.();
2206
+ }
2207
+ if (token) {
2208
+ config2.headers["Authorization"] = `Bearer ${token}`;
2209
+ }
2210
+ if (database) {
2211
+ config2.headers["DATABASE"] = database;
2200
2212
  }
2201
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2202
- const token = await getToken?.();
2203
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2204
2213
  return config2;
2205
2214
  }, Promise.reject);
2206
2215
  instance.interceptors.response.use(
@@ -43,6 +43,7 @@ declare enum UriConstants {
43
43
  IMAGE_PATH = "/web/image",
44
44
  LOAD_MESSAGE = "/load_message_failures",
45
45
  TOKEN = "/check_token",
46
+ VALIDATE_ACTION_TOKEN = "/action-token/validate",
46
47
  CREATE_UPDATE_PATH = "/create_update",
47
48
  TWOFA_METHOD_PATH = "/id/api/v2/call",
48
49
  SIGNIN_SSO = "/signin-sso/oauth",
@@ -43,6 +43,7 @@ declare enum UriConstants {
43
43
  IMAGE_PATH = "/web/image",
44
44
  LOAD_MESSAGE = "/load_message_failures",
45
45
  TOKEN = "/check_token",
46
+ VALIDATE_ACTION_TOKEN = "/action-token/validate",
46
47
  CREATE_UPDATE_PATH = "/create_update",
47
48
  TWOFA_METHOD_PATH = "/id/api/v2/call",
48
49
  SIGNIN_SSO = "/signin-sso/oauth",
package/dist/constants.js CHANGED
@@ -86,6 +86,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
86
86
  UriConstants2["IMAGE_PATH"] = `/web/image`;
87
87
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
88
88
  UriConstants2["TOKEN"] = `/check_token`;
89
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
89
90
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
90
91
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
91
92
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -48,6 +48,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
48
48
  UriConstants2["IMAGE_PATH"] = `/web/image`;
49
49
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
50
50
  UriConstants2["TOKEN"] = `/check_token`;
51
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
51
52
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
52
53
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
53
54
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -19,6 +19,7 @@ interface EnvConfig {
19
19
  companies?: any[];
20
20
  user?: any;
21
21
  db?: string;
22
+ database?: string;
22
23
  refreshTokenEndpoint?: string;
23
24
  localStorageUtils?: LocalStorageUtilsType;
24
25
  sessionStorageUtils?: SessionStorageUtilsType;
@@ -19,6 +19,7 @@ interface EnvConfig {
19
19
  companies?: any[];
20
20
  user?: any;
21
21
  db?: string;
22
+ database?: string;
22
23
  refreshTokenEndpoint?: string;
23
24
  localStorageUtils?: LocalStorageUtilsType;
24
25
  sessionStorageUtils?: SessionStorageUtilsType;
@@ -2210,9 +2210,11 @@ var sessionStorageUtils = () => {
2210
2210
  // src/configs/axios-client.ts
2211
2211
  var axiosClient = {
2212
2212
  init(config) {
2213
+ console.log("config", config);
2213
2214
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2214
2215
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2215
2216
  const db = config?.db;
2217
+ const database = config?.config?.database;
2216
2218
  let isRefreshing = false;
2217
2219
  let failedQueue = [];
2218
2220
  const processQueue = (error, token = null) => {
@@ -2233,12 +2235,19 @@ var axiosClient = {
2233
2235
  });
2234
2236
  instance.interceptors.request.use(async (config2) => {
2235
2237
  const { useRefreshToken, useActionToken, actionToken } = config2;
2238
+ let token = null;
2236
2239
  if (useActionToken && actionToken) {
2237
- config2.headers["Action-Token"] = actionToken;
2240
+ token = actionToken;
2241
+ } else {
2242
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2243
+ token = await getToken?.();
2244
+ }
2245
+ if (token) {
2246
+ config2.headers["Authorization"] = `Bearer ${token}`;
2247
+ }
2248
+ if (database) {
2249
+ config2.headers["DATABASE"] = database;
2238
2250
  }
2239
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2240
- const token = await getToken?.();
2241
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2242
2251
  return config2;
2243
2252
  }, Promise.reject);
2244
2253
  instance.interceptors.response.use(
@@ -2172,9 +2172,11 @@ var sessionStorageUtils = () => {
2172
2172
  // src/configs/axios-client.ts
2173
2173
  var axiosClient = {
2174
2174
  init(config) {
2175
+ console.log("config", config);
2175
2176
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2176
2177
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2177
2178
  const db = config?.db;
2179
+ const database = config?.config?.database;
2178
2180
  let isRefreshing = false;
2179
2181
  let failedQueue = [];
2180
2182
  const processQueue = (error, token = null) => {
@@ -2195,12 +2197,19 @@ var axiosClient = {
2195
2197
  });
2196
2198
  instance.interceptors.request.use(async (config2) => {
2197
2199
  const { useRefreshToken, useActionToken, actionToken } = config2;
2200
+ let token = null;
2198
2201
  if (useActionToken && actionToken) {
2199
- config2.headers["Action-Token"] = actionToken;
2202
+ token = actionToken;
2203
+ } else {
2204
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2205
+ token = await getToken?.();
2206
+ }
2207
+ if (token) {
2208
+ config2.headers["Authorization"] = `Bearer ${token}`;
2209
+ }
2210
+ if (database) {
2211
+ config2.headers["DATABASE"] = database;
2200
2212
  }
2201
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2202
- const token = await getToken?.();
2203
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2204
2213
  return config2;
2205
2214
  }, Promise.reject);
2206
2215
  instance.interceptors.response.use(
package/dist/hooks.d.mts CHANGED
@@ -38,7 +38,6 @@ declare const useGetAccessByCode: () => _tanstack_react_query.UseMutationResult<
38
38
 
39
39
  declare const useValidateActionToken: () => _tanstack_react_query.UseMutationResult<any, Error, {
40
40
  actionToken: string;
41
- path: string;
42
41
  }, unknown>;
43
42
 
44
43
  declare const useGetCompanyInfo: () => _tanstack_react_query.UseMutationResult<any, Error, number, unknown>;
@@ -261,7 +260,7 @@ declare const useGetGroups: ({ model, width_context, }: {
261
260
 
262
261
  declare const useGetListData: (listDataProps: any, queryKey?: any, enabled?: any) => _tanstack_react_query.UseQueryResult<any, Error>;
263
262
 
264
- declare const useGetMenu: (context: any, enabled?: boolean) => _tanstack_react_query.UseQueryResult<any, Error>;
263
+ declare const useGetMenu: (context: any, specification: any, enabled?: boolean) => _tanstack_react_query.UseQueryResult<any, Error>;
265
264
 
266
265
  declare const useGetPrintReport: () => _tanstack_react_query.UseMutationResult<any, Error, {
267
266
  id: number;
@@ -314,6 +313,7 @@ declare const useSignInSSO: () => _tanstack_react_query.UseMutationResult<any, E
314
313
  client_id: string;
315
314
  response_type: string;
316
315
  path: string;
316
+ scope: string;
317
317
  }, unknown>;
318
318
 
319
319
  declare const useVerify2FA: () => _tanstack_react_query.UseMutationResult<unknown, Error, {
package/dist/hooks.d.ts CHANGED
@@ -38,7 +38,6 @@ declare const useGetAccessByCode: () => _tanstack_react_query.UseMutationResult<
38
38
 
39
39
  declare const useValidateActionToken: () => _tanstack_react_query.UseMutationResult<any, Error, {
40
40
  actionToken: string;
41
- path: string;
42
41
  }, unknown>;
43
42
 
44
43
  declare const useGetCompanyInfo: () => _tanstack_react_query.UseMutationResult<any, Error, number, unknown>;
@@ -261,7 +260,7 @@ declare const useGetGroups: ({ model, width_context, }: {
261
260
 
262
261
  declare const useGetListData: (listDataProps: any, queryKey?: any, enabled?: any) => _tanstack_react_query.UseQueryResult<any, Error>;
263
262
 
264
- declare const useGetMenu: (context: any, enabled?: boolean) => _tanstack_react_query.UseQueryResult<any, Error>;
263
+ declare const useGetMenu: (context: any, specification: any, enabled?: boolean) => _tanstack_react_query.UseQueryResult<any, Error>;
265
264
 
266
265
  declare const useGetPrintReport: () => _tanstack_react_query.UseMutationResult<any, Error, {
267
266
  id: number;
@@ -314,6 +313,7 @@ declare const useSignInSSO: () => _tanstack_react_query.UseMutationResult<any, E
314
313
  client_id: string;
315
314
  response_type: string;
316
315
  path: string;
316
+ scope: string;
317
317
  }, unknown>;
318
318
 
319
319
  declare const useVerify2FA: () => _tanstack_react_query.UseMutationResult<unknown, Error, {
package/dist/hooks.js CHANGED
@@ -128,6 +128,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
128
128
  UriConstants2["IMAGE_PATH"] = `/web/image`;
129
129
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
130
130
  UriConstants2["TOKEN"] = `/check_token`;
131
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
131
132
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
132
133
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
133
134
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -3204,9 +3205,9 @@ function useAuthService() {
3204
3205
  [env]
3205
3206
  );
3206
3207
  const isValidActionToken = (0, import_react7.useCallback)(
3207
- async (actionToken, path) => {
3208
+ async (actionToken) => {
3208
3209
  return env?.requests?.post(
3209
- path,
3210
+ "/action-token/validate" /* VALIDATE_ACTION_TOKEN */,
3210
3211
  {},
3211
3212
  {
3212
3213
  headers: {
@@ -4152,101 +4153,14 @@ function useViewService() {
4152
4153
  [env]
4153
4154
  );
4154
4155
  const getMenu = (0, import_react14.useCallback)(
4155
- async (context) => {
4156
+ async (context, specification) => {
4156
4157
  const jsonData = {
4157
4158
  model: "ir.ui.menu" /* MENU */,
4158
4159
  method: "web_search_read" /* WEB_SEARCH_READ */,
4159
4160
  ids: [],
4160
4161
  with_context: context,
4161
4162
  kwargs: {
4162
- specification: {
4163
- active: {},
4164
- name: {},
4165
- is_display: {},
4166
- sequence: {},
4167
- complete_name: {},
4168
- action: {
4169
- fields: {
4170
- display_name: {},
4171
- type: {},
4172
- binding_view_types: {}
4173
- }
4174
- },
4175
- url_icon: {},
4176
- web_icon: {},
4177
- web_icon_data: {},
4178
- groups_id: {
4179
- fields: {
4180
- full_name: {}
4181
- },
4182
- limit: 40,
4183
- order: ""
4184
- },
4185
- display_name: {},
4186
- child_id: {
4187
- fields: {
4188
- active: {},
4189
- name: {},
4190
- is_display: {},
4191
- sequence: {},
4192
- complete_name: {},
4193
- action: {
4194
- fields: {
4195
- display_name: {},
4196
- type: {},
4197
- binding_view_types: {}
4198
- }
4199
- },
4200
- url_icon: {},
4201
- web_icon: {},
4202
- web_icon_data: {},
4203
- groups_id: {
4204
- fields: {
4205
- full_name: {}
4206
- },
4207
- limit: 40,
4208
- order: ""
4209
- },
4210
- display_name: {},
4211
- child_id: {
4212
- fields: {
4213
- active: {},
4214
- name: {},
4215
- is_display: {},
4216
- sequence: {},
4217
- complete_name: {},
4218
- action: {
4219
- fields: {
4220
- display_name: {},
4221
- type: {},
4222
- binding_view_types: {}
4223
- }
4224
- },
4225
- url_icon: {},
4226
- web_icon: {},
4227
- web_icon_data: {},
4228
- groups_id: {
4229
- fields: {
4230
- full_name: {}
4231
- },
4232
- limit: 40,
4233
- order: ""
4234
- },
4235
- display_name: {},
4236
- child_id: {
4237
- fields: {},
4238
- limit: 40,
4239
- order: ""
4240
- }
4241
- },
4242
- limit: 40,
4243
- order: ""
4244
- }
4245
- },
4246
- limit: 40,
4247
- order: ""
4248
- }
4249
- },
4163
+ specification,
4250
4164
  domain: [
4251
4165
  "&",
4252
4166
  ["is_display", "=", true],
@@ -4441,18 +4355,25 @@ function useViewService() {
4441
4355
  redirect_uri,
4442
4356
  state,
4443
4357
  client_id,
4444
- response_type
4358
+ response_type,
4359
+ path,
4360
+ scope
4445
4361
  }) => {
4446
- const jsonData = {
4447
- redirect_uri,
4448
- state,
4362
+ const params = new URLSearchParams({
4363
+ response_type,
4449
4364
  client_id,
4450
- response_type
4451
- };
4452
- return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4365
+ redirect_uri,
4366
+ state
4367
+ });
4368
+ const queryString = `${params.toString()}&scope=${encodeURIComponent(
4369
+ scope
4370
+ )}`;
4371
+ const url = `${path}?${queryString}`;
4372
+ return env?.requests.get(url, {
4453
4373
  headers: {
4454
- credentials: "include"
4455
- }
4374
+ "Content-Type": "application/json"
4375
+ },
4376
+ withCredentials: true
4456
4377
  });
4457
4378
  },
4458
4379
  [env]
@@ -4691,11 +4612,8 @@ var import_react_query14 = require("@tanstack/react-query");
4691
4612
  var useValidateActionToken = () => {
4692
4613
  const { isValidActionToken } = useAuthService();
4693
4614
  return (0, import_react_query14.useMutation)({
4694
- mutationFn: ({
4695
- actionToken,
4696
- path
4697
- }) => {
4698
- return isValidActionToken(actionToken, path);
4615
+ mutationFn: ({ actionToken }) => {
4616
+ return isValidActionToken(actionToken);
4699
4617
  }
4700
4618
  });
4701
4619
  };
@@ -5386,7 +5304,6 @@ var useGetActionDetail = ({
5386
5304
  model,
5387
5305
  queryKey
5388
5306
  }) => {
5389
- const { getFormView } = useFormService();
5390
5307
  const { getActionDetail } = useViewService();
5391
5308
  const data = {
5392
5309
  id,
@@ -5401,9 +5318,6 @@ var useGetActionDetail = ({
5401
5318
  if (res && res.length > 0) {
5402
5319
  return res[0];
5403
5320
  }
5404
- } else {
5405
- const res = await getFormView({ data });
5406
- return res;
5407
5321
  }
5408
5322
  },
5409
5323
  enabled,
@@ -5476,11 +5390,11 @@ var use_get_list_data_default = useGetListData;
5476
5390
 
5477
5391
  // src/hooks/view/use-get-menu.ts
5478
5392
  var import_react_query50 = require("@tanstack/react-query");
5479
- var useGetMenu = (context, enabled) => {
5393
+ var useGetMenu = (context, specification, enabled) => {
5480
5394
  const { getMenu } = useViewService();
5481
5395
  return (0, import_react_query50.useQuery)({
5482
5396
  queryKey: ["menus" /* MENU */, context],
5483
- queryFn: () => getMenu(context).then((res) => {
5397
+ queryFn: () => getMenu(context, specification).then((res) => {
5484
5398
  if (res && res?.records && res?.records?.length > 0) {
5485
5399
  return res?.records;
5486
5400
  }
@@ -5669,13 +5583,16 @@ var useSignInSSO = () => {
5669
5583
  state,
5670
5584
  client_id,
5671
5585
  response_type,
5672
- path
5586
+ path,
5587
+ scope
5673
5588
  }) => {
5674
5589
  return signInSSO({
5675
5590
  redirect_uri,
5676
5591
  state,
5677
5592
  client_id,
5678
- response_type
5593
+ response_type,
5594
+ path,
5595
+ scope
5679
5596
  });
5680
5597
  }
5681
5598
  });