@fctc/interface-logic 1.7.8 → 1.7.9

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
@@ -3035,81 +3035,69 @@ var axiosClient = {
3035
3035
  };
3036
3036
 
3037
3037
  // src/environment/EnvStore.ts
3038
- var EnvStore = class _EnvStore {
3039
- static instance = null;
3040
- static localStorageUtils;
3041
- static sessionStorageUtils;
3042
- constructor() {
3043
- }
3044
- static getInstance(localStorageUtils2, sessionStorageUtils2) {
3045
- if (!_EnvStore.instance) {
3046
- console.log("Creating new EnvStore instance");
3047
- _EnvStore.instance = new _EnvStore();
3048
- _EnvStore.localStorageUtils = localStorageUtils2;
3049
- _EnvStore.sessionStorageUtils = sessionStorageUtils2;
3050
- } else {
3051
- console.log("Returning existing EnvStore instance");
3052
- }
3053
- return _EnvStore.instance;
3054
- }
3055
- static getState() {
3056
- const state = envStore.getState().env;
3057
- console.log("Redux env state:", state);
3058
- return {
3059
- baseUrl: state?.baseUrl,
3060
- requests: state?.requests,
3061
- context: state?.context,
3062
- defaultCompany: state?.defaultCompany,
3063
- config: state?.config,
3064
- companies: state?.companies || [],
3065
- user: state?.user,
3066
- db: state?.db,
3067
- refreshTokenEndpoint: state?.refreshTokenEndpoint,
3068
- uid: state?.uid,
3069
- lang: state?.lang,
3070
- allowCompanies: state?.allowCompanies
3071
- };
3072
- }
3073
- static setupEnv(envConfig) {
3074
- const dispatch = envStore.dispatch;
3075
- const env = {
3076
- ..._EnvStore.getState(),
3038
+ function createEnvStore(store, localUtils, sessionUtils) {
3039
+ let envData = store.getState().env;
3040
+ const getEnvData = () => {
3041
+ envData = store.getState().env;
3042
+ return envData;
3043
+ };
3044
+ const setupEnv = (envConfig) => {
3045
+ const requests = axiosClient.init({
3077
3046
  ...envConfig,
3078
- localStorageUtils: _EnvStore.localStorageUtils,
3079
- sessionStorageUtils: _EnvStore.sessionStorageUtils
3080
- };
3081
- console.log("Setting up env with config:", envConfig);
3082
- const requests = axiosClient.init(env);
3083
- console.log("axiosClient.init result:", requests);
3084
- dispatch(setEnv({ ...env, requests }));
3085
- }
3086
- static setUid(uid) {
3087
- const dispatch = envStore.dispatch;
3088
- dispatch(setUid(uid));
3089
- }
3090
- static setLang(lang) {
3091
- const dispatch = envStore.dispatch;
3092
- dispatch(setLang(lang));
3093
- }
3094
- static setAllowCompanies(allowCompanies) {
3095
- const dispatch = envStore.dispatch;
3096
- dispatch(setAllowCompanies(allowCompanies));
3097
- }
3098
- static setCompanies(companies) {
3099
- const dispatch = envStore.dispatch;
3100
- dispatch(setCompanies(companies));
3101
- }
3102
- static setDefaultCompany(company) {
3103
- const dispatch = envStore.dispatch;
3104
- dispatch(setDefaultCompany(company));
3105
- }
3106
- static setUserInfo(userInfo) {
3107
- const dispatch = envStore.dispatch;
3108
- dispatch(setUser(userInfo));
3109
- }
3110
- };
3047
+ localStorageUtils: localUtils,
3048
+ sessionStorageUtils: sessionUtils
3049
+ });
3050
+ store.dispatch(
3051
+ setEnv({
3052
+ ...envConfig,
3053
+ requests,
3054
+ localStorageUtils: localUtils,
3055
+ sessionStorageUtils: sessionUtils
3056
+ })
3057
+ );
3058
+ getEnvData();
3059
+ };
3060
+ const setLangValue = (lang) => {
3061
+ store.dispatch(setLang(lang));
3062
+ getEnvData();
3063
+ };
3064
+ const setUidValue = (uid) => {
3065
+ store.dispatch(setUid(uid));
3066
+ getEnvData();
3067
+ };
3068
+ const setAllowCompaniesValue = (allowCompanies) => {
3069
+ store.dispatch(setAllowCompanies(allowCompanies));
3070
+ getEnvData();
3071
+ };
3072
+ const setCompaniesValue = (companies) => {
3073
+ store.dispatch(setCompanies(companies));
3074
+ getEnvData();
3075
+ };
3076
+ const setDefaultCompanyValue = (company) => {
3077
+ store.dispatch(setDefaultCompany(company));
3078
+ getEnvData();
3079
+ };
3080
+ const setUserInfoValue = (user) => {
3081
+ store.dispatch(setUser(user));
3082
+ getEnvData();
3083
+ };
3084
+ return {
3085
+ getEnvData,
3086
+ setupEnv,
3087
+ setLangValue,
3088
+ setUidValue,
3089
+ setAllowCompaniesValue,
3090
+ setCompaniesValue,
3091
+ setDefaultCompanyValue,
3092
+ setUserInfoValue
3093
+ };
3094
+ }
3095
+ var env = null;
3111
3096
  function getEnv() {
3112
- return EnvStore.getState();
3097
+ if (!env) {
3098
+ env = createEnvStore(envStore, localStorageUtils(), sessionStorageUtils());
3099
+ }
3100
+ return env?.getEnvData();
3113
3101
  }
3114
3102
 
3115
3103
  // src/services/view-service/index.ts
@@ -3121,7 +3109,7 @@ var ViewService = {
3121
3109
  options = {},
3122
3110
  aid
3123
3111
  }) {
3124
- const env = getEnv();
3112
+ const env2 = getEnv();
3125
3113
  const defaultOptions = {
3126
3114
  load_filters: true,
3127
3115
  toolbar: true,
@@ -3136,14 +3124,14 @@ var ViewService = {
3136
3124
  },
3137
3125
  with_context: context
3138
3126
  };
3139
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3127
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3140
3128
  headers: {
3141
3129
  "Content-Type": "application/json"
3142
3130
  }
3143
3131
  });
3144
3132
  },
3145
3133
  async getMenu(context) {
3146
- const env = getEnv();
3134
+ const env2 = getEnv();
3147
3135
  const jsonData = {
3148
3136
  model: "ir.ui.menu" /* MENU */,
3149
3137
  method: "web_search_read" /* WEB_SEARCH_READ */,
@@ -3280,14 +3268,14 @@ var ViewService = {
3280
3268
  ]
3281
3269
  }
3282
3270
  };
3283
- return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3271
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3284
3272
  headers: {
3285
3273
  "Content-Type": "application/json"
3286
3274
  }
3287
3275
  });
3288
3276
  },
3289
3277
  async getActionDetail(aid, context) {
3290
- const env = getEnv();
3278
+ const env2 = getEnv();
3291
3279
  const jsonData = {
3292
3280
  model: "ir.actions.act_window" /* WINDOW_ACTION */,
3293
3281
  method: "web_read" /* WEB_READ */,
@@ -3308,7 +3296,7 @@ var ViewService = {
3308
3296
  }
3309
3297
  }
3310
3298
  };
3311
- return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3299
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3312
3300
  headers: {
3313
3301
  "Content-Type": "application/json"
3314
3302
  }
@@ -3320,7 +3308,7 @@ var ViewService = {
3320
3308
  context,
3321
3309
  offset
3322
3310
  }) {
3323
- const env = getEnv();
3311
+ const env2 = getEnv();
3324
3312
  const jsonData = {
3325
3313
  model,
3326
3314
  with_context: context,
@@ -3328,14 +3316,14 @@ var ViewService = {
3328
3316
  field: "sequence",
3329
3317
  ...offset > 0 ? { offset } : {}
3330
3318
  };
3331
- return env?.requests.post("/web/dataset/resequence", jsonData, {
3319
+ return env2?.requests.post("/web/dataset/resequence", jsonData, {
3332
3320
  headers: {
3333
3321
  "Content-Type": "application/json"
3334
3322
  }
3335
3323
  });
3336
3324
  },
3337
3325
  async getSelectionItem({ data }) {
3338
- const env = getEnv();
3326
+ const env2 = getEnv();
3339
3327
  const jsonData = {
3340
3328
  model: data.model,
3341
3329
  ids: [],
@@ -3353,15 +3341,15 @@ var ViewService = {
3353
3341
  }
3354
3342
  }
3355
3343
  };
3356
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3344
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3357
3345
  headers: {
3358
3346
  "Content-Type": "application/json"
3359
3347
  }
3360
3348
  });
3361
3349
  },
3362
3350
  async loadMessages() {
3363
- const env = getEnv();
3364
- return env.requests.post(
3351
+ const env2 = getEnv();
3352
+ return env2.requests.post(
3365
3353
  "/load_message_failures" /* LOAD_MESSAGE */,
3366
3354
  {},
3367
3355
  {
@@ -3372,9 +3360,9 @@ var ViewService = {
3372
3360
  );
3373
3361
  },
3374
3362
  async getVersion() {
3375
- const env = getEnv();
3376
- console.log("env?.requests", env, env?.requests);
3377
- return env?.requests?.get("", {
3363
+ const env2 = getEnv();
3364
+ console.log("env?.requests", env2, env2?.requests);
3365
+ return env2?.requests?.get("", {
3378
3366
  headers: {
3379
3367
  "Content-Type": "application/json"
3380
3368
  }
@@ -3384,12 +3372,12 @@ var ViewService = {
3384
3372
  method,
3385
3373
  with_context
3386
3374
  }) {
3387
- const env = getEnv();
3375
+ const env2 = getEnv();
3388
3376
  const jsonData = {
3389
3377
  method,
3390
3378
  with_context
3391
3379
  };
3392
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3380
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3393
3381
  headers: {
3394
3382
  "Content-Type": "application/json"
3395
3383
  }
@@ -3402,7 +3390,7 @@ var ViewService = {
3402
3390
  device,
3403
3391
  location
3404
3392
  }) {
3405
- const env = getEnv();
3393
+ const env2 = getEnv();
3406
3394
  const jsonData = {
3407
3395
  method,
3408
3396
  kwargs: {
@@ -3414,7 +3402,7 @@ var ViewService = {
3414
3402
  },
3415
3403
  with_context
3416
3404
  };
3417
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3405
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3418
3406
  headers: {
3419
3407
  "Content-Type": "application/json"
3420
3408
  },
@@ -3428,7 +3416,7 @@ var ViewService = {
3428
3416
  response_type,
3429
3417
  path
3430
3418
  }) {
3431
- const env = getEnv();
3419
+ const env2 = getEnv();
3432
3420
  const params = new URLSearchParams({
3433
3421
  response_type,
3434
3422
  client_id,
@@ -3436,7 +3424,7 @@ var ViewService = {
3436
3424
  state
3437
3425
  });
3438
3426
  const url = `${path}?${params.toString()}`;
3439
- return env?.requests.get(url, {
3427
+ return env2?.requests.get(url, {
3440
3428
  headers: {
3441
3429
  "Content-Type": "application/json"
3442
3430
  },
@@ -3449,14 +3437,14 @@ var ViewService = {
3449
3437
  client_id,
3450
3438
  scopes
3451
3439
  }) {
3452
- const env = getEnv();
3440
+ const env2 = getEnv();
3453
3441
  const jsonData = {
3454
3442
  redirect_uri,
3455
3443
  state,
3456
3444
  client_id,
3457
3445
  scopes
3458
3446
  };
3459
- return env?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
3447
+ return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
3460
3448
  headers: {
3461
3449
  "Content-Type": "application/json"
3462
3450
  },
@@ -3468,7 +3456,7 @@ var ViewService = {
3468
3456
  token,
3469
3457
  views
3470
3458
  }) {
3471
- const env = getEnv();
3459
+ const env2 = getEnv();
3472
3460
  const jsonData = {
3473
3461
  method,
3474
3462
  kwargs: {
@@ -3478,7 +3466,7 @@ var ViewService = {
3478
3466
  token
3479
3467
  }
3480
3468
  };
3481
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3469
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3482
3470
  headers: {
3483
3471
  "Content-Type": "application/json"
3484
3472
  }
@@ -3490,7 +3478,7 @@ var ViewService = {
3490
3478
  kwargs,
3491
3479
  token
3492
3480
  }) {
3493
- const env = getEnv();
3481
+ const env2 = getEnv();
3494
3482
  const jsonData = {
3495
3483
  method,
3496
3484
  model,
@@ -3499,21 +3487,21 @@ var ViewService = {
3499
3487
  token
3500
3488
  }
3501
3489
  };
3502
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3490
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3503
3491
  headers: {
3504
3492
  "Content-Type": "application/json"
3505
3493
  }
3506
3494
  });
3507
3495
  },
3508
3496
  async requestSetupTotp({ method, token }) {
3509
- const env = getEnv();
3497
+ const env2 = getEnv();
3510
3498
  const jsonData = {
3511
3499
  method,
3512
3500
  with_context: {
3513
3501
  token
3514
3502
  }
3515
3503
  };
3516
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3504
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3517
3505
  headers: {
3518
3506
  "Content-Type": "application/json"
3519
3507
  }
@@ -3524,7 +3512,7 @@ var ViewService = {
3524
3512
  action_token,
3525
3513
  code
3526
3514
  }) {
3527
- const env = getEnv();
3515
+ const env2 = getEnv();
3528
3516
  const jsonData = {
3529
3517
  method,
3530
3518
  kwargs: {
@@ -3536,21 +3524,21 @@ var ViewService = {
3536
3524
  action_token
3537
3525
  }
3538
3526
  };
3539
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3527
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3540
3528
  headers: {
3541
3529
  "Content-Type": "application/json"
3542
3530
  }
3543
3531
  });
3544
3532
  },
3545
3533
  async removeTotpSetUp({ method, token }) {
3546
- const env = getEnv();
3534
+ const env2 = getEnv();
3547
3535
  const jsonData = {
3548
3536
  method,
3549
3537
  with_context: {
3550
3538
  token
3551
3539
  }
3552
3540
  };
3553
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3541
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3554
3542
  headers: {
3555
3543
  "Content-Type": "application/json"
3556
3544
  }