@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/provider.mjs CHANGED
@@ -675,6 +675,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
675
675
  UriConstants2["IMAGE_PATH"] = `/web/image`;
676
676
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
677
677
  UriConstants2["TOKEN"] = `/check_token`;
678
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
678
679
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
679
680
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
680
681
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -3110,9 +3111,9 @@ function useAuthService() {
3110
3111
  [env]
3111
3112
  );
3112
3113
  const isValidActionToken = useCallback2(
3113
- async (actionToken, path) => {
3114
+ async (actionToken) => {
3114
3115
  return env?.requests?.post(
3115
- path,
3116
+ "/action-token/validate" /* VALIDATE_ACTION_TOKEN */,
3116
3117
  {},
3117
3118
  {
3118
3119
  headers: {
@@ -4058,101 +4059,14 @@ function useViewService() {
4058
4059
  [env]
4059
4060
  );
4060
4061
  const getMenu = useCallback9(
4061
- async (context) => {
4062
+ async (context, specification) => {
4062
4063
  const jsonData = {
4063
4064
  model: "ir.ui.menu" /* MENU */,
4064
4065
  method: "web_search_read" /* WEB_SEARCH_READ */,
4065
4066
  ids: [],
4066
4067
  with_context: context,
4067
4068
  kwargs: {
4068
- specification: {
4069
- active: {},
4070
- name: {},
4071
- is_display: {},
4072
- sequence: {},
4073
- complete_name: {},
4074
- action: {
4075
- fields: {
4076
- display_name: {},
4077
- type: {},
4078
- binding_view_types: {}
4079
- }
4080
- },
4081
- url_icon: {},
4082
- web_icon: {},
4083
- web_icon_data: {},
4084
- groups_id: {
4085
- fields: {
4086
- full_name: {}
4087
- },
4088
- limit: 40,
4089
- order: ""
4090
- },
4091
- display_name: {},
4092
- child_id: {
4093
- fields: {
4094
- active: {},
4095
- name: {},
4096
- is_display: {},
4097
- sequence: {},
4098
- complete_name: {},
4099
- action: {
4100
- fields: {
4101
- display_name: {},
4102
- type: {},
4103
- binding_view_types: {}
4104
- }
4105
- },
4106
- url_icon: {},
4107
- web_icon: {},
4108
- web_icon_data: {},
4109
- groups_id: {
4110
- fields: {
4111
- full_name: {}
4112
- },
4113
- limit: 40,
4114
- order: ""
4115
- },
4116
- display_name: {},
4117
- child_id: {
4118
- fields: {
4119
- active: {},
4120
- name: {},
4121
- is_display: {},
4122
- sequence: {},
4123
- complete_name: {},
4124
- action: {
4125
- fields: {
4126
- display_name: {},
4127
- type: {},
4128
- binding_view_types: {}
4129
- }
4130
- },
4131
- url_icon: {},
4132
- web_icon: {},
4133
- web_icon_data: {},
4134
- groups_id: {
4135
- fields: {
4136
- full_name: {}
4137
- },
4138
- limit: 40,
4139
- order: ""
4140
- },
4141
- display_name: {},
4142
- child_id: {
4143
- fields: {},
4144
- limit: 40,
4145
- order: ""
4146
- }
4147
- },
4148
- limit: 40,
4149
- order: ""
4150
- }
4151
- },
4152
- limit: 40,
4153
- order: ""
4154
- }
4155
- },
4069
+ specification,
4156
4070
  domain: [
4157
4071
  "&",
4158
4072
  ["is_display", "=", true],
@@ -4347,18 +4261,25 @@ function useViewService() {
4347
4261
  redirect_uri,
4348
4262
  state,
4349
4263
  client_id,
4350
- response_type
4264
+ response_type,
4265
+ path,
4266
+ scope
4351
4267
  }) => {
4352
- const jsonData = {
4353
- redirect_uri,
4354
- state,
4268
+ const params = new URLSearchParams({
4269
+ response_type,
4355
4270
  client_id,
4356
- response_type
4357
- };
4358
- return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4271
+ redirect_uri,
4272
+ state
4273
+ });
4274
+ const queryString = `${params.toString()}&scope=${encodeURIComponent(
4275
+ scope
4276
+ )}`;
4277
+ const url = `${path}?${queryString}`;
4278
+ return env?.requests.get(url, {
4359
4279
  headers: {
4360
- credentials: "include"
4361
- }
4280
+ "Content-Type": "application/json"
4281
+ },
4282
+ withCredentials: true
4362
4283
  });
4363
4284
  },
4364
4285
  [env]
@@ -4531,9 +4452,11 @@ var sessionStorageUtils = () => {
4531
4452
  // src/configs/axios-client.ts
4532
4453
  var axiosClient = {
4533
4454
  init(config) {
4455
+ console.log("config", config);
4534
4456
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
4535
4457
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
4536
4458
  const db = config?.db;
4459
+ const database = config?.config?.database;
4537
4460
  let isRefreshing = false;
4538
4461
  let failedQueue = [];
4539
4462
  const processQueue = (error, token = null) => {
@@ -4554,12 +4477,19 @@ var axiosClient = {
4554
4477
  });
4555
4478
  instance.interceptors.request.use(async (config2) => {
4556
4479
  const { useRefreshToken, useActionToken, actionToken } = config2;
4480
+ let token = null;
4557
4481
  if (useActionToken && actionToken) {
4558
- config2.headers["Action-Token"] = actionToken;
4482
+ token = actionToken;
4483
+ } else {
4484
+ const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
4485
+ token = await getToken?.();
4486
+ }
4487
+ if (token) {
4488
+ config2.headers["Authorization"] = `Bearer ${token}`;
4489
+ }
4490
+ if (database) {
4491
+ config2.headers["DATABASE"] = database;
4559
4492
  }
4560
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
4561
- const token = await getToken?.();
4562
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
4563
4493
  return config2;
4564
4494
  }, Promise.reject);
4565
4495
  instance.interceptors.response.use(
@@ -4979,11 +4909,8 @@ import { useMutation as useMutation12 } from "@tanstack/react-query";
4979
4909
  var useValidateActionToken = () => {
4980
4910
  const { isValidActionToken } = useAuthService();
4981
4911
  return useMutation12({
4982
- mutationFn: ({
4983
- actionToken,
4984
- path
4985
- }) => {
4986
- return isValidActionToken(actionToken, path);
4912
+ mutationFn: ({ actionToken }) => {
4913
+ return isValidActionToken(actionToken);
4987
4914
  }
4988
4915
  });
4989
4916
  };
@@ -5674,7 +5601,6 @@ var useGetActionDetail = ({
5674
5601
  model,
5675
5602
  queryKey
5676
5603
  }) => {
5677
- const { getFormView } = useFormService();
5678
5604
  const { getActionDetail } = useViewService();
5679
5605
  const data = {
5680
5606
  id,
@@ -5689,9 +5615,6 @@ var useGetActionDetail = ({
5689
5615
  if (res && res.length > 0) {
5690
5616
  return res[0];
5691
5617
  }
5692
- } else {
5693
- const res = await getFormView({ data });
5694
- return res;
5695
5618
  }
5696
5619
  },
5697
5620
  enabled,
@@ -5764,11 +5687,11 @@ var use_get_list_data_default = useGetListData;
5764
5687
 
5765
5688
  // src/hooks/view/use-get-menu.ts
5766
5689
  import { useQuery as useQuery15 } from "@tanstack/react-query";
5767
- var useGetMenu = (context, enabled) => {
5690
+ var useGetMenu = (context, specification, enabled) => {
5768
5691
  const { getMenu } = useViewService();
5769
5692
  return useQuery15({
5770
5693
  queryKey: ["menus" /* MENU */, context],
5771
- queryFn: () => getMenu(context).then((res) => {
5694
+ queryFn: () => getMenu(context, specification).then((res) => {
5772
5695
  if (res && res?.records && res?.records?.length > 0) {
5773
5696
  return res?.records;
5774
5697
  }
@@ -5957,13 +5880,16 @@ var useSignInSSO = () => {
5957
5880
  state,
5958
5881
  client_id,
5959
5882
  response_type,
5960
- path
5883
+ path,
5884
+ scope
5961
5885
  }) => {
5962
5886
  return signInSSO({
5963
5887
  redirect_uri,
5964
5888
  state,
5965
5889
  client_id,
5966
- response_type
5890
+ response_type,
5891
+ path,
5892
+ scope
5967
5893
  });
5968
5894
  }
5969
5895
  });
@@ -51,7 +51,7 @@ declare function useAuthService(): {
51
51
  }) => Promise<any>;
52
52
  updatePassword: (data: UpdatePasswordRequest, token: string | null) => Promise<any>;
53
53
  isValidToken: (token: string | null) => Promise<any>;
54
- isValidActionToken: (actionToken: string | null, path: string) => Promise<any>;
54
+ isValidActionToken: (actionToken: string | null) => Promise<any>;
55
55
  loginSocial: ({ db, state, access_token, }: {
56
56
  db: string;
57
57
  state: object;
@@ -196,7 +196,7 @@ declare function useUserService(): {
196
196
 
197
197
  declare function useViewService(): {
198
198
  getView: ({ model, views, context, options, aid, }: GetViewParams) => Promise<any>;
199
- getMenu: (context: any) => Promise<any>;
199
+ getMenu: (context: any, specification: any) => Promise<any>;
200
200
  getActionDetail: (aid: number, context: any) => Promise<any>;
201
201
  getResequence: ({ model, ids, context, offset, }: {
202
202
  model: string;
@@ -229,11 +229,13 @@ declare function useViewService(): {
229
229
  kwargs: any;
230
230
  model: string;
231
231
  }) => Promise<any>;
232
- signInSSO: ({ redirect_uri, state, client_id, response_type, }: {
232
+ signInSSO: ({ redirect_uri, state, client_id, response_type, path, scope, }: {
233
233
  redirect_uri: string;
234
234
  state: string;
235
235
  client_id: string;
236
236
  response_type: string;
237
+ path: string;
238
+ scope: string;
237
239
  }) => Promise<any>;
238
240
  verify2FA: ({ method, with_context, code, device, location, }: {
239
241
  method: string;
@@ -51,7 +51,7 @@ declare function useAuthService(): {
51
51
  }) => Promise<any>;
52
52
  updatePassword: (data: UpdatePasswordRequest, token: string | null) => Promise<any>;
53
53
  isValidToken: (token: string | null) => Promise<any>;
54
- isValidActionToken: (actionToken: string | null, path: string) => Promise<any>;
54
+ isValidActionToken: (actionToken: string | null) => Promise<any>;
55
55
  loginSocial: ({ db, state, access_token, }: {
56
56
  db: string;
57
57
  state: object;
@@ -196,7 +196,7 @@ declare function useUserService(): {
196
196
 
197
197
  declare function useViewService(): {
198
198
  getView: ({ model, views, context, options, aid, }: GetViewParams) => Promise<any>;
199
- getMenu: (context: any) => Promise<any>;
199
+ getMenu: (context: any, specification: any) => Promise<any>;
200
200
  getActionDetail: (aid: number, context: any) => Promise<any>;
201
201
  getResequence: ({ model, ids, context, offset, }: {
202
202
  model: string;
@@ -229,11 +229,13 @@ declare function useViewService(): {
229
229
  kwargs: any;
230
230
  model: string;
231
231
  }) => Promise<any>;
232
- signInSSO: ({ redirect_uri, state, client_id, response_type, }: {
232
+ signInSSO: ({ redirect_uri, state, client_id, response_type, path, scope, }: {
233
233
  redirect_uri: string;
234
234
  state: string;
235
235
  client_id: string;
236
236
  response_type: string;
237
+ path: string;
238
+ scope: string;
237
239
  }) => Promise<any>;
238
240
  verify2FA: ({ method, with_context, code, device, location, }: {
239
241
  method: string;
package/dist/services.js CHANGED
@@ -66,6 +66,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
66
66
  UriConstants2["IMAGE_PATH"] = `/web/image`;
67
67
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
68
68
  UriConstants2["TOKEN"] = `/check_token`;
69
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
69
70
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
70
71
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
71
72
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -3320,9 +3321,9 @@ function useAuthService() {
3320
3321
  [env]
3321
3322
  );
3322
3323
  const isValidActionToken = (0, import_react7.useCallback)(
3323
- async (actionToken, path) => {
3324
+ async (actionToken) => {
3324
3325
  return env?.requests?.post(
3325
- path,
3326
+ "/action-token/validate" /* VALIDATE_ACTION_TOKEN */,
3326
3327
  {},
3327
3328
  {
3328
3329
  headers: {
@@ -4268,101 +4269,14 @@ function useViewService() {
4268
4269
  [env]
4269
4270
  );
4270
4271
  const getMenu = (0, import_react14.useCallback)(
4271
- async (context) => {
4272
+ async (context, specification) => {
4272
4273
  const jsonData = {
4273
4274
  model: "ir.ui.menu" /* MENU */,
4274
4275
  method: "web_search_read" /* WEB_SEARCH_READ */,
4275
4276
  ids: [],
4276
4277
  with_context: context,
4277
4278
  kwargs: {
4278
- specification: {
4279
- active: {},
4280
- name: {},
4281
- is_display: {},
4282
- sequence: {},
4283
- complete_name: {},
4284
- action: {
4285
- fields: {
4286
- display_name: {},
4287
- type: {},
4288
- binding_view_types: {}
4289
- }
4290
- },
4291
- url_icon: {},
4292
- web_icon: {},
4293
- web_icon_data: {},
4294
- groups_id: {
4295
- fields: {
4296
- full_name: {}
4297
- },
4298
- limit: 40,
4299
- order: ""
4300
- },
4301
- display_name: {},
4302
- child_id: {
4303
- fields: {
4304
- active: {},
4305
- name: {},
4306
- is_display: {},
4307
- sequence: {},
4308
- complete_name: {},
4309
- action: {
4310
- fields: {
4311
- display_name: {},
4312
- type: {},
4313
- binding_view_types: {}
4314
- }
4315
- },
4316
- url_icon: {},
4317
- web_icon: {},
4318
- web_icon_data: {},
4319
- groups_id: {
4320
- fields: {
4321
- full_name: {}
4322
- },
4323
- limit: 40,
4324
- order: ""
4325
- },
4326
- display_name: {},
4327
- child_id: {
4328
- fields: {
4329
- active: {},
4330
- name: {},
4331
- is_display: {},
4332
- sequence: {},
4333
- complete_name: {},
4334
- action: {
4335
- fields: {
4336
- display_name: {},
4337
- type: {},
4338
- binding_view_types: {}
4339
- }
4340
- },
4341
- url_icon: {},
4342
- web_icon: {},
4343
- web_icon_data: {},
4344
- groups_id: {
4345
- fields: {
4346
- full_name: {}
4347
- },
4348
- limit: 40,
4349
- order: ""
4350
- },
4351
- display_name: {},
4352
- child_id: {
4353
- fields: {},
4354
- limit: 40,
4355
- order: ""
4356
- }
4357
- },
4358
- limit: 40,
4359
- order: ""
4360
- }
4361
- },
4362
- limit: 40,
4363
- order: ""
4364
- }
4365
- },
4279
+ specification,
4366
4280
  domain: [
4367
4281
  "&",
4368
4282
  ["is_display", "=", true],
@@ -4557,18 +4471,25 @@ function useViewService() {
4557
4471
  redirect_uri,
4558
4472
  state,
4559
4473
  client_id,
4560
- response_type
4474
+ response_type,
4475
+ path,
4476
+ scope
4561
4477
  }) => {
4562
- const jsonData = {
4563
- redirect_uri,
4564
- state,
4478
+ const params = new URLSearchParams({
4479
+ response_type,
4565
4480
  client_id,
4566
- response_type
4567
- };
4568
- return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4481
+ redirect_uri,
4482
+ state
4483
+ });
4484
+ const queryString = `${params.toString()}&scope=${encodeURIComponent(
4485
+ scope
4486
+ )}`;
4487
+ const url = `${path}?${queryString}`;
4488
+ return env?.requests.get(url, {
4569
4489
  headers: {
4570
- credentials: "include"
4571
- }
4490
+ "Content-Type": "application/json"
4491
+ },
4492
+ withCredentials: true
4572
4493
  });
4573
4494
  },
4574
4495
  [env]
package/dist/services.mjs CHANGED
@@ -22,6 +22,7 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
22
22
  UriConstants2["IMAGE_PATH"] = `/web/image`;
23
23
  UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
24
24
  UriConstants2["TOKEN"] = `/check_token`;
25
+ UriConstants2["VALIDATE_ACTION_TOKEN"] = "/action-token/validate";
25
26
  UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
26
27
  UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
27
28
  UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
@@ -3276,9 +3277,9 @@ function useAuthService() {
3276
3277
  [env]
3277
3278
  );
3278
3279
  const isValidActionToken = useCallback3(
3279
- async (actionToken, path) => {
3280
+ async (actionToken) => {
3280
3281
  return env?.requests?.post(
3281
- path,
3282
+ "/action-token/validate" /* VALIDATE_ACTION_TOKEN */,
3282
3283
  {},
3283
3284
  {
3284
3285
  headers: {
@@ -4224,101 +4225,14 @@ function useViewService() {
4224
4225
  [env]
4225
4226
  );
4226
4227
  const getMenu = useCallback10(
4227
- async (context) => {
4228
+ async (context, specification) => {
4228
4229
  const jsonData = {
4229
4230
  model: "ir.ui.menu" /* MENU */,
4230
4231
  method: "web_search_read" /* WEB_SEARCH_READ */,
4231
4232
  ids: [],
4232
4233
  with_context: context,
4233
4234
  kwargs: {
4234
- specification: {
4235
- active: {},
4236
- name: {},
4237
- is_display: {},
4238
- sequence: {},
4239
- complete_name: {},
4240
- action: {
4241
- fields: {
4242
- display_name: {},
4243
- type: {},
4244
- binding_view_types: {}
4245
- }
4246
- },
4247
- url_icon: {},
4248
- web_icon: {},
4249
- web_icon_data: {},
4250
- groups_id: {
4251
- fields: {
4252
- full_name: {}
4253
- },
4254
- limit: 40,
4255
- order: ""
4256
- },
4257
- display_name: {},
4258
- child_id: {
4259
- fields: {
4260
- active: {},
4261
- name: {},
4262
- is_display: {},
4263
- sequence: {},
4264
- complete_name: {},
4265
- action: {
4266
- fields: {
4267
- display_name: {},
4268
- type: {},
4269
- binding_view_types: {}
4270
- }
4271
- },
4272
- url_icon: {},
4273
- web_icon: {},
4274
- web_icon_data: {},
4275
- groups_id: {
4276
- fields: {
4277
- full_name: {}
4278
- },
4279
- limit: 40,
4280
- order: ""
4281
- },
4282
- display_name: {},
4283
- child_id: {
4284
- fields: {
4285
- active: {},
4286
- name: {},
4287
- is_display: {},
4288
- sequence: {},
4289
- complete_name: {},
4290
- action: {
4291
- fields: {
4292
- display_name: {},
4293
- type: {},
4294
- binding_view_types: {}
4295
- }
4296
- },
4297
- url_icon: {},
4298
- web_icon: {},
4299
- web_icon_data: {},
4300
- groups_id: {
4301
- fields: {
4302
- full_name: {}
4303
- },
4304
- limit: 40,
4305
- order: ""
4306
- },
4307
- display_name: {},
4308
- child_id: {
4309
- fields: {},
4310
- limit: 40,
4311
- order: ""
4312
- }
4313
- },
4314
- limit: 40,
4315
- order: ""
4316
- }
4317
- },
4318
- limit: 40,
4319
- order: ""
4320
- }
4321
- },
4235
+ specification,
4322
4236
  domain: [
4323
4237
  "&",
4324
4238
  ["is_display", "=", true],
@@ -4513,18 +4427,25 @@ function useViewService() {
4513
4427
  redirect_uri,
4514
4428
  state,
4515
4429
  client_id,
4516
- response_type
4430
+ response_type,
4431
+ path,
4432
+ scope
4517
4433
  }) => {
4518
- const jsonData = {
4519
- redirect_uri,
4520
- state,
4434
+ const params = new URLSearchParams({
4435
+ response_type,
4521
4436
  client_id,
4522
- response_type
4523
- };
4524
- return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4437
+ redirect_uri,
4438
+ state
4439
+ });
4440
+ const queryString = `${params.toString()}&scope=${encodeURIComponent(
4441
+ scope
4442
+ )}`;
4443
+ const url = `${path}?${queryString}`;
4444
+ return env?.requests.get(url, {
4525
4445
  headers: {
4526
- credentials: "include"
4527
- }
4446
+ "Content-Type": "application/json"
4447
+ },
4448
+ withCredentials: true
4528
4449
  });
4529
4450
  },
4530
4451
  [env]
package/dist/types.d.mts CHANGED
@@ -5,6 +5,7 @@ interface Config {
5
5
  grantType: string;
6
6
  clientId: string;
7
7
  clientSecret: string;
8
+ database: string;
8
9
  }
9
10
 
10
11
  interface Context {
package/dist/types.d.ts CHANGED
@@ -5,6 +5,7 @@ interface Config {
5
5
  grantType: string;
6
6
  clientId: string;
7
7
  clientSecret: string;
8
+ database: string;
8
9
  }
9
10
 
10
11
  interface Context {