@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.mjs CHANGED
@@ -2997,81 +2997,69 @@ var axiosClient = {
2997
2997
  };
2998
2998
 
2999
2999
  // src/environment/EnvStore.ts
3000
- var EnvStore = class _EnvStore {
3001
- static instance = null;
3002
- static localStorageUtils;
3003
- static sessionStorageUtils;
3004
- constructor() {
3005
- }
3006
- static getInstance(localStorageUtils2, sessionStorageUtils2) {
3007
- if (!_EnvStore.instance) {
3008
- console.log("Creating new EnvStore instance");
3009
- _EnvStore.instance = new _EnvStore();
3010
- _EnvStore.localStorageUtils = localStorageUtils2;
3011
- _EnvStore.sessionStorageUtils = sessionStorageUtils2;
3012
- } else {
3013
- console.log("Returning existing EnvStore instance");
3014
- }
3015
- return _EnvStore.instance;
3016
- }
3017
- static getState() {
3018
- const state = envStore.getState().env;
3019
- console.log("Redux env state:", state);
3020
- return {
3021
- baseUrl: state?.baseUrl,
3022
- requests: state?.requests,
3023
- context: state?.context,
3024
- defaultCompany: state?.defaultCompany,
3025
- config: state?.config,
3026
- companies: state?.companies || [],
3027
- user: state?.user,
3028
- db: state?.db,
3029
- refreshTokenEndpoint: state?.refreshTokenEndpoint,
3030
- uid: state?.uid,
3031
- lang: state?.lang,
3032
- allowCompanies: state?.allowCompanies
3033
- };
3034
- }
3035
- static setupEnv(envConfig) {
3036
- const dispatch = envStore.dispatch;
3037
- const env = {
3038
- ..._EnvStore.getState(),
3000
+ function createEnvStore(store, localUtils, sessionUtils) {
3001
+ let envData = store.getState().env;
3002
+ const getEnvData = () => {
3003
+ envData = store.getState().env;
3004
+ return envData;
3005
+ };
3006
+ const setupEnv = (envConfig) => {
3007
+ const requests = axiosClient.init({
3039
3008
  ...envConfig,
3040
- localStorageUtils: _EnvStore.localStorageUtils,
3041
- sessionStorageUtils: _EnvStore.sessionStorageUtils
3042
- };
3043
- console.log("Setting up env with config:", envConfig);
3044
- const requests = axiosClient.init(env);
3045
- console.log("axiosClient.init result:", requests);
3046
- dispatch(setEnv({ ...env, requests }));
3047
- }
3048
- static setUid(uid) {
3049
- const dispatch = envStore.dispatch;
3050
- dispatch(setUid(uid));
3051
- }
3052
- static setLang(lang) {
3053
- const dispatch = envStore.dispatch;
3054
- dispatch(setLang(lang));
3055
- }
3056
- static setAllowCompanies(allowCompanies) {
3057
- const dispatch = envStore.dispatch;
3058
- dispatch(setAllowCompanies(allowCompanies));
3059
- }
3060
- static setCompanies(companies) {
3061
- const dispatch = envStore.dispatch;
3062
- dispatch(setCompanies(companies));
3063
- }
3064
- static setDefaultCompany(company) {
3065
- const dispatch = envStore.dispatch;
3066
- dispatch(setDefaultCompany(company));
3067
- }
3068
- static setUserInfo(userInfo) {
3069
- const dispatch = envStore.dispatch;
3070
- dispatch(setUser(userInfo));
3071
- }
3072
- };
3009
+ localStorageUtils: localUtils,
3010
+ sessionStorageUtils: sessionUtils
3011
+ });
3012
+ store.dispatch(
3013
+ setEnv({
3014
+ ...envConfig,
3015
+ requests,
3016
+ localStorageUtils: localUtils,
3017
+ sessionStorageUtils: sessionUtils
3018
+ })
3019
+ );
3020
+ getEnvData();
3021
+ };
3022
+ const setLangValue = (lang) => {
3023
+ store.dispatch(setLang(lang));
3024
+ getEnvData();
3025
+ };
3026
+ const setUidValue = (uid) => {
3027
+ store.dispatch(setUid(uid));
3028
+ getEnvData();
3029
+ };
3030
+ const setAllowCompaniesValue = (allowCompanies) => {
3031
+ store.dispatch(setAllowCompanies(allowCompanies));
3032
+ getEnvData();
3033
+ };
3034
+ const setCompaniesValue = (companies) => {
3035
+ store.dispatch(setCompanies(companies));
3036
+ getEnvData();
3037
+ };
3038
+ const setDefaultCompanyValue = (company) => {
3039
+ store.dispatch(setDefaultCompany(company));
3040
+ getEnvData();
3041
+ };
3042
+ const setUserInfoValue = (user) => {
3043
+ store.dispatch(setUser(user));
3044
+ getEnvData();
3045
+ };
3046
+ return {
3047
+ getEnvData,
3048
+ setupEnv,
3049
+ setLangValue,
3050
+ setUidValue,
3051
+ setAllowCompaniesValue,
3052
+ setCompaniesValue,
3053
+ setDefaultCompanyValue,
3054
+ setUserInfoValue
3055
+ };
3056
+ }
3057
+ var env = null;
3073
3058
  function getEnv() {
3074
- return EnvStore.getState();
3059
+ if (!env) {
3060
+ env = createEnvStore(envStore, localStorageUtils(), sessionStorageUtils());
3061
+ }
3062
+ return env?.getEnvData();
3075
3063
  }
3076
3064
 
3077
3065
  // src/services/view-service/index.ts
@@ -3083,7 +3071,7 @@ var ViewService = {
3083
3071
  options = {},
3084
3072
  aid
3085
3073
  }) {
3086
- const env = getEnv();
3074
+ const env2 = getEnv();
3087
3075
  const defaultOptions = {
3088
3076
  load_filters: true,
3089
3077
  toolbar: true,
@@ -3098,14 +3086,14 @@ var ViewService = {
3098
3086
  },
3099
3087
  with_context: context
3100
3088
  };
3101
- return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3089
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3102
3090
  headers: {
3103
3091
  "Content-Type": "application/json"
3104
3092
  }
3105
3093
  });
3106
3094
  },
3107
3095
  async getMenu(context) {
3108
- const env = getEnv();
3096
+ const env2 = getEnv();
3109
3097
  const jsonData = {
3110
3098
  model: "ir.ui.menu" /* MENU */,
3111
3099
  method: "web_search_read" /* WEB_SEARCH_READ */,
@@ -3242,14 +3230,14 @@ var ViewService = {
3242
3230
  ]
3243
3231
  }
3244
3232
  };
3245
- return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3233
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3246
3234
  headers: {
3247
3235
  "Content-Type": "application/json"
3248
3236
  }
3249
3237
  });
3250
3238
  },
3251
3239
  async getActionDetail(aid, context) {
3252
- const env = getEnv();
3240
+ const env2 = getEnv();
3253
3241
  const jsonData = {
3254
3242
  model: "ir.actions.act_window" /* WINDOW_ACTION */,
3255
3243
  method: "web_read" /* WEB_READ */,
@@ -3270,7 +3258,7 @@ var ViewService = {
3270
3258
  }
3271
3259
  }
3272
3260
  };
3273
- return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3261
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3274
3262
  headers: {
3275
3263
  "Content-Type": "application/json"
3276
3264
  }
@@ -3282,7 +3270,7 @@ var ViewService = {
3282
3270
  context,
3283
3271
  offset
3284
3272
  }) {
3285
- const env = getEnv();
3273
+ const env2 = getEnv();
3286
3274
  const jsonData = {
3287
3275
  model,
3288
3276
  with_context: context,
@@ -3290,14 +3278,14 @@ var ViewService = {
3290
3278
  field: "sequence",
3291
3279
  ...offset > 0 ? { offset } : {}
3292
3280
  };
3293
- return env?.requests.post("/web/dataset/resequence", jsonData, {
3281
+ return env2?.requests.post("/web/dataset/resequence", jsonData, {
3294
3282
  headers: {
3295
3283
  "Content-Type": "application/json"
3296
3284
  }
3297
3285
  });
3298
3286
  },
3299
3287
  async getSelectionItem({ data }) {
3300
- const env = getEnv();
3288
+ const env2 = getEnv();
3301
3289
  const jsonData = {
3302
3290
  model: data.model,
3303
3291
  ids: [],
@@ -3315,15 +3303,15 @@ var ViewService = {
3315
3303
  }
3316
3304
  }
3317
3305
  };
3318
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3306
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3319
3307
  headers: {
3320
3308
  "Content-Type": "application/json"
3321
3309
  }
3322
3310
  });
3323
3311
  },
3324
3312
  async loadMessages() {
3325
- const env = getEnv();
3326
- return env.requests.post(
3313
+ const env2 = getEnv();
3314
+ return env2.requests.post(
3327
3315
  "/load_message_failures" /* LOAD_MESSAGE */,
3328
3316
  {},
3329
3317
  {
@@ -3334,9 +3322,9 @@ var ViewService = {
3334
3322
  );
3335
3323
  },
3336
3324
  async getVersion() {
3337
- const env = getEnv();
3338
- console.log("env?.requests", env, env?.requests);
3339
- return env?.requests?.get("", {
3325
+ const env2 = getEnv();
3326
+ console.log("env?.requests", env2, env2?.requests);
3327
+ return env2?.requests?.get("", {
3340
3328
  headers: {
3341
3329
  "Content-Type": "application/json"
3342
3330
  }
@@ -3346,12 +3334,12 @@ var ViewService = {
3346
3334
  method,
3347
3335
  with_context
3348
3336
  }) {
3349
- const env = getEnv();
3337
+ const env2 = getEnv();
3350
3338
  const jsonData = {
3351
3339
  method,
3352
3340
  with_context
3353
3341
  };
3354
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3342
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3355
3343
  headers: {
3356
3344
  "Content-Type": "application/json"
3357
3345
  }
@@ -3364,7 +3352,7 @@ var ViewService = {
3364
3352
  device,
3365
3353
  location
3366
3354
  }) {
3367
- const env = getEnv();
3355
+ const env2 = getEnv();
3368
3356
  const jsonData = {
3369
3357
  method,
3370
3358
  kwargs: {
@@ -3376,7 +3364,7 @@ var ViewService = {
3376
3364
  },
3377
3365
  with_context
3378
3366
  };
3379
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3367
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3380
3368
  headers: {
3381
3369
  "Content-Type": "application/json"
3382
3370
  },
@@ -3390,7 +3378,7 @@ var ViewService = {
3390
3378
  response_type,
3391
3379
  path
3392
3380
  }) {
3393
- const env = getEnv();
3381
+ const env2 = getEnv();
3394
3382
  const params = new URLSearchParams({
3395
3383
  response_type,
3396
3384
  client_id,
@@ -3398,7 +3386,7 @@ var ViewService = {
3398
3386
  state
3399
3387
  });
3400
3388
  const url = `${path}?${params.toString()}`;
3401
- return env?.requests.get(url, {
3389
+ return env2?.requests.get(url, {
3402
3390
  headers: {
3403
3391
  "Content-Type": "application/json"
3404
3392
  },
@@ -3411,14 +3399,14 @@ var ViewService = {
3411
3399
  client_id,
3412
3400
  scopes
3413
3401
  }) {
3414
- const env = getEnv();
3402
+ const env2 = getEnv();
3415
3403
  const jsonData = {
3416
3404
  redirect_uri,
3417
3405
  state,
3418
3406
  client_id,
3419
3407
  scopes
3420
3408
  };
3421
- return env?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
3409
+ return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
3422
3410
  headers: {
3423
3411
  "Content-Type": "application/json"
3424
3412
  },
@@ -3430,7 +3418,7 @@ var ViewService = {
3430
3418
  token,
3431
3419
  views
3432
3420
  }) {
3433
- const env = getEnv();
3421
+ const env2 = getEnv();
3434
3422
  const jsonData = {
3435
3423
  method,
3436
3424
  kwargs: {
@@ -3440,7 +3428,7 @@ var ViewService = {
3440
3428
  token
3441
3429
  }
3442
3430
  };
3443
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3431
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3444
3432
  headers: {
3445
3433
  "Content-Type": "application/json"
3446
3434
  }
@@ -3452,7 +3440,7 @@ var ViewService = {
3452
3440
  kwargs,
3453
3441
  token
3454
3442
  }) {
3455
- const env = getEnv();
3443
+ const env2 = getEnv();
3456
3444
  const jsonData = {
3457
3445
  method,
3458
3446
  model,
@@ -3461,21 +3449,21 @@ var ViewService = {
3461
3449
  token
3462
3450
  }
3463
3451
  };
3464
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3452
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3465
3453
  headers: {
3466
3454
  "Content-Type": "application/json"
3467
3455
  }
3468
3456
  });
3469
3457
  },
3470
3458
  async requestSetupTotp({ method, token }) {
3471
- const env = getEnv();
3459
+ const env2 = getEnv();
3472
3460
  const jsonData = {
3473
3461
  method,
3474
3462
  with_context: {
3475
3463
  token
3476
3464
  }
3477
3465
  };
3478
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3466
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3479
3467
  headers: {
3480
3468
  "Content-Type": "application/json"
3481
3469
  }
@@ -3486,7 +3474,7 @@ var ViewService = {
3486
3474
  action_token,
3487
3475
  code
3488
3476
  }) {
3489
- const env = getEnv();
3477
+ const env2 = getEnv();
3490
3478
  const jsonData = {
3491
3479
  method,
3492
3480
  kwargs: {
@@ -3498,21 +3486,21 @@ var ViewService = {
3498
3486
  action_token
3499
3487
  }
3500
3488
  };
3501
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3489
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3502
3490
  headers: {
3503
3491
  "Content-Type": "application/json"
3504
3492
  }
3505
3493
  });
3506
3494
  },
3507
3495
  async removeTotpSetUp({ method, token }) {
3508
- const env = getEnv();
3496
+ const env2 = getEnv();
3509
3497
  const jsonData = {
3510
3498
  method,
3511
3499
  with_context: {
3512
3500
  token
3513
3501
  }
3514
3502
  };
3515
- return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
3503
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3516
3504
  headers: {
3517
3505
  "Content-Type": "application/json"
3518
3506
  }