@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.
@@ -1,3 +1,10 @@
1
+ import { e as envStore } from './store-DvWeB4jm.mjs';
2
+ import '@reduxjs/toolkit';
3
+ import 'redux-thunk';
4
+ import 'redux';
5
+ import 'immer';
6
+ import 'react-redux';
7
+
1
8
  declare const localStorageUtils: () => {
2
9
  setToken: (access_token: string) => Promise<void>;
3
10
  setRefreshToken: (refresh_token: string) => Promise<void>;
@@ -12,47 +19,20 @@ declare const sessionStorageUtils: () => {
12
19
  };
13
20
  type SessionStorageUtilsType = ReturnType<typeof sessionStorageUtils>;
14
21
 
15
- declare global {
16
- interface Global {
17
- envStore?: EnvStore;
18
- }
19
- interface Window {
20
- envStore?: EnvStore;
21
- }
22
- }
23
- interface EnvState {
24
- baseUrl?: string;
25
- requests?: any;
26
- context?: any;
27
- defaultCompany?: any;
28
- config?: any;
29
- companies?: any[];
30
- user?: any;
31
- db?: string;
32
- refreshTokenEndpoint?: string;
33
- uid?: number;
34
- lang?: string;
35
- allowCompanies?: number[];
36
- }
37
- declare class EnvStore {
38
- private static instance;
39
- private static localStorageUtils?;
40
- private static sessionStorageUtils?;
41
- private constructor();
42
- static getInstance(localStorageUtils?: any, sessionStorageUtils?: any): EnvStore;
43
- static getState(): EnvState;
44
- static setupEnv(envConfig: Partial<EnvState>): void;
45
- static setUid(uid: number): void;
46
- static setLang(lang: string): void;
47
- static setAllowCompanies(allowCompanies: number[]): void;
48
- static setCompanies(companies: any[]): void;
49
- static setDefaultCompany(company: any): void;
50
- static setUserInfo(userInfo: any): void;
51
- }
22
+ type EnvStore = ReturnType<typeof envStore.getState>['env'];
52
23
  declare function initEnv({ localStorageUtils, sessionStorageUtils, }: {
53
24
  localStorageUtils?: LocalStorageUtilsType;
54
25
  sessionStorageUtils?: SessionStorageUtilsType;
55
- }): EnvStore;
56
- declare function getEnv(): EnvState;
26
+ }): {
27
+ getEnvData: () => any;
28
+ setupEnv: (envConfig: EnvStore) => void;
29
+ setLangValue: (lang: string) => void;
30
+ setUidValue: (uid: number) => void;
31
+ setAllowCompaniesValue: (allowCompanies: number[]) => void;
32
+ setCompaniesValue: (companies: any[]) => void;
33
+ setDefaultCompanyValue: (company: any) => void;
34
+ setUserInfoValue: (user: any) => void;
35
+ };
36
+ declare function getEnv(): any;
57
37
 
58
- export { EnvStore, getEnv, initEnv };
38
+ export { type EnvStore, getEnv, initEnv };
@@ -1,3 +1,10 @@
1
+ import { e as envStore } from './store-DvWeB4jm.js';
2
+ import '@reduxjs/toolkit';
3
+ import 'redux-thunk';
4
+ import 'redux';
5
+ import 'immer';
6
+ import 'react-redux';
7
+
1
8
  declare const localStorageUtils: () => {
2
9
  setToken: (access_token: string) => Promise<void>;
3
10
  setRefreshToken: (refresh_token: string) => Promise<void>;
@@ -12,47 +19,20 @@ declare const sessionStorageUtils: () => {
12
19
  };
13
20
  type SessionStorageUtilsType = ReturnType<typeof sessionStorageUtils>;
14
21
 
15
- declare global {
16
- interface Global {
17
- envStore?: EnvStore;
18
- }
19
- interface Window {
20
- envStore?: EnvStore;
21
- }
22
- }
23
- interface EnvState {
24
- baseUrl?: string;
25
- requests?: any;
26
- context?: any;
27
- defaultCompany?: any;
28
- config?: any;
29
- companies?: any[];
30
- user?: any;
31
- db?: string;
32
- refreshTokenEndpoint?: string;
33
- uid?: number;
34
- lang?: string;
35
- allowCompanies?: number[];
36
- }
37
- declare class EnvStore {
38
- private static instance;
39
- private static localStorageUtils?;
40
- private static sessionStorageUtils?;
41
- private constructor();
42
- static getInstance(localStorageUtils?: any, sessionStorageUtils?: any): EnvStore;
43
- static getState(): EnvState;
44
- static setupEnv(envConfig: Partial<EnvState>): void;
45
- static setUid(uid: number): void;
46
- static setLang(lang: string): void;
47
- static setAllowCompanies(allowCompanies: number[]): void;
48
- static setCompanies(companies: any[]): void;
49
- static setDefaultCompany(company: any): void;
50
- static setUserInfo(userInfo: any): void;
51
- }
22
+ type EnvStore = ReturnType<typeof envStore.getState>['env'];
52
23
  declare function initEnv({ localStorageUtils, sessionStorageUtils, }: {
53
24
  localStorageUtils?: LocalStorageUtilsType;
54
25
  sessionStorageUtils?: SessionStorageUtilsType;
55
- }): EnvStore;
56
- declare function getEnv(): EnvState;
26
+ }): {
27
+ getEnvData: () => any;
28
+ setupEnv: (envConfig: EnvStore) => void;
29
+ setLangValue: (lang: string) => void;
30
+ setUidValue: (uid: number) => void;
31
+ setAllowCompaniesValue: (allowCompanies: number[]) => void;
32
+ setCompaniesValue: (companies: any[]) => void;
33
+ setDefaultCompanyValue: (company: any) => void;
34
+ setUserInfoValue: (user: any) => void;
35
+ };
36
+ declare function getEnv(): any;
57
37
 
58
- export { EnvStore, getEnv, initEnv };
38
+ export { type EnvStore, getEnv, initEnv };
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/environment.ts
31
31
  var environment_exports = {};
32
32
  __export(environment_exports, {
33
- EnvStore: () => EnvStore,
34
33
  getEnv: () => getEnv,
35
34
  initEnv: () => initEnv
36
35
  });
@@ -2998,91 +2997,79 @@ var envStore = (0, import_toolkit11.configureStore)({
2998
2997
  });
2999
2998
 
3000
2999
  // src/environment/EnvStore.ts
3001
- var EnvStore = class _EnvStore {
3002
- static instance = null;
3003
- static localStorageUtils;
3004
- static sessionStorageUtils;
3005
- constructor() {
3006
- }
3007
- static getInstance(localStorageUtils2, sessionStorageUtils2) {
3008
- if (!_EnvStore.instance) {
3009
- console.log("Creating new EnvStore instance");
3010
- _EnvStore.instance = new _EnvStore();
3011
- _EnvStore.localStorageUtils = localStorageUtils2;
3012
- _EnvStore.sessionStorageUtils = sessionStorageUtils2;
3013
- } else {
3014
- console.log("Returning existing EnvStore instance");
3015
- }
3016
- return _EnvStore.instance;
3017
- }
3018
- static getState() {
3019
- const state = envStore.getState().env;
3020
- console.log("Redux env state:", state);
3021
- return {
3022
- baseUrl: state?.baseUrl,
3023
- requests: state?.requests,
3024
- context: state?.context,
3025
- defaultCompany: state?.defaultCompany,
3026
- config: state?.config,
3027
- companies: state?.companies || [],
3028
- user: state?.user,
3029
- db: state?.db,
3030
- refreshTokenEndpoint: state?.refreshTokenEndpoint,
3031
- uid: state?.uid,
3032
- lang: state?.lang,
3033
- allowCompanies: state?.allowCompanies
3034
- };
3035
- }
3036
- static setupEnv(envConfig) {
3037
- const dispatch = envStore.dispatch;
3038
- const env = {
3039
- ..._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({
3040
3008
  ...envConfig,
3041
- localStorageUtils: _EnvStore.localStorageUtils,
3042
- sessionStorageUtils: _EnvStore.sessionStorageUtils
3043
- };
3044
- console.log("Setting up env with config:", envConfig);
3045
- const requests = axiosClient.init(env);
3046
- console.log("axiosClient.init result:", requests);
3047
- dispatch(setEnv({ ...env, requests }));
3048
- }
3049
- static setUid(uid) {
3050
- const dispatch = envStore.dispatch;
3051
- dispatch(setUid(uid));
3052
- }
3053
- static setLang(lang) {
3054
- const dispatch = envStore.dispatch;
3055
- dispatch(setLang(lang));
3056
- }
3057
- static setAllowCompanies(allowCompanies) {
3058
- const dispatch = envStore.dispatch;
3059
- dispatch(setAllowCompanies(allowCompanies));
3060
- }
3061
- static setCompanies(companies) {
3062
- const dispatch = envStore.dispatch;
3063
- dispatch(setCompanies(companies));
3064
- }
3065
- static setDefaultCompany(company) {
3066
- const dispatch = envStore.dispatch;
3067
- dispatch(setDefaultCompany(company));
3068
- }
3069
- static setUserInfo(userInfo) {
3070
- const dispatch = envStore.dispatch;
3071
- dispatch(setUser(userInfo));
3072
- }
3073
- };
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;
3074
3058
  function initEnv({
3075
3059
  localStorageUtils: localStorageUtils2,
3076
3060
  sessionStorageUtils: sessionStorageUtils2
3077
3061
  }) {
3078
- return EnvStore.getInstance(localStorageUtils2, sessionStorageUtils2);
3062
+ env = createEnvStore(envStore, localStorageUtils2, sessionStorageUtils2);
3063
+ return env;
3079
3064
  }
3080
3065
  function getEnv() {
3081
- return EnvStore.getState();
3066
+ if (!env) {
3067
+ env = createEnvStore(envStore, localStorageUtils(), sessionStorageUtils());
3068
+ }
3069
+ return env?.getEnvData();
3082
3070
  }
3083
3071
  // Annotate the CommonJS export names for ESM import in node:
3084
3072
  0 && (module.exports = {
3085
- EnvStore,
3086
3073
  getEnv,
3087
3074
  initEnv
3088
3075
  });
@@ -2960,90 +2960,78 @@ var envStore = configureStore({
2960
2960
  });
2961
2961
 
2962
2962
  // src/environment/EnvStore.ts
2963
- var EnvStore = class _EnvStore {
2964
- static instance = null;
2965
- static localStorageUtils;
2966
- static sessionStorageUtils;
2967
- constructor() {
2968
- }
2969
- static getInstance(localStorageUtils2, sessionStorageUtils2) {
2970
- if (!_EnvStore.instance) {
2971
- console.log("Creating new EnvStore instance");
2972
- _EnvStore.instance = new _EnvStore();
2973
- _EnvStore.localStorageUtils = localStorageUtils2;
2974
- _EnvStore.sessionStorageUtils = sessionStorageUtils2;
2975
- } else {
2976
- console.log("Returning existing EnvStore instance");
2977
- }
2978
- return _EnvStore.instance;
2979
- }
2980
- static getState() {
2981
- const state = envStore.getState().env;
2982
- console.log("Redux env state:", state);
2983
- return {
2984
- baseUrl: state?.baseUrl,
2985
- requests: state?.requests,
2986
- context: state?.context,
2987
- defaultCompany: state?.defaultCompany,
2988
- config: state?.config,
2989
- companies: state?.companies || [],
2990
- user: state?.user,
2991
- db: state?.db,
2992
- refreshTokenEndpoint: state?.refreshTokenEndpoint,
2993
- uid: state?.uid,
2994
- lang: state?.lang,
2995
- allowCompanies: state?.allowCompanies
2996
- };
2997
- }
2998
- static setupEnv(envConfig) {
2999
- const dispatch = envStore.dispatch;
3000
- const env = {
3001
- ..._EnvStore.getState(),
2963
+ function createEnvStore(store, localUtils, sessionUtils) {
2964
+ let envData = store.getState().env;
2965
+ const getEnvData = () => {
2966
+ envData = store.getState().env;
2967
+ return envData;
2968
+ };
2969
+ const setupEnv = (envConfig) => {
2970
+ const requests = axiosClient.init({
3002
2971
  ...envConfig,
3003
- localStorageUtils: _EnvStore.localStorageUtils,
3004
- sessionStorageUtils: _EnvStore.sessionStorageUtils
3005
- };
3006
- console.log("Setting up env with config:", envConfig);
3007
- const requests = axiosClient.init(env);
3008
- console.log("axiosClient.init result:", requests);
3009
- dispatch(setEnv({ ...env, requests }));
3010
- }
3011
- static setUid(uid) {
3012
- const dispatch = envStore.dispatch;
3013
- dispatch(setUid(uid));
3014
- }
3015
- static setLang(lang) {
3016
- const dispatch = envStore.dispatch;
3017
- dispatch(setLang(lang));
3018
- }
3019
- static setAllowCompanies(allowCompanies) {
3020
- const dispatch = envStore.dispatch;
3021
- dispatch(setAllowCompanies(allowCompanies));
3022
- }
3023
- static setCompanies(companies) {
3024
- const dispatch = envStore.dispatch;
3025
- dispatch(setCompanies(companies));
3026
- }
3027
- static setDefaultCompany(company) {
3028
- const dispatch = envStore.dispatch;
3029
- dispatch(setDefaultCompany(company));
3030
- }
3031
- static setUserInfo(userInfo) {
3032
- const dispatch = envStore.dispatch;
3033
- dispatch(setUser(userInfo));
3034
- }
3035
- };
2972
+ localStorageUtils: localUtils,
2973
+ sessionStorageUtils: sessionUtils
2974
+ });
2975
+ store.dispatch(
2976
+ setEnv({
2977
+ ...envConfig,
2978
+ requests,
2979
+ localStorageUtils: localUtils,
2980
+ sessionStorageUtils: sessionUtils
2981
+ })
2982
+ );
2983
+ getEnvData();
2984
+ };
2985
+ const setLangValue = (lang) => {
2986
+ store.dispatch(setLang(lang));
2987
+ getEnvData();
2988
+ };
2989
+ const setUidValue = (uid) => {
2990
+ store.dispatch(setUid(uid));
2991
+ getEnvData();
2992
+ };
2993
+ const setAllowCompaniesValue = (allowCompanies) => {
2994
+ store.dispatch(setAllowCompanies(allowCompanies));
2995
+ getEnvData();
2996
+ };
2997
+ const setCompaniesValue = (companies) => {
2998
+ store.dispatch(setCompanies(companies));
2999
+ getEnvData();
3000
+ };
3001
+ const setDefaultCompanyValue = (company) => {
3002
+ store.dispatch(setDefaultCompany(company));
3003
+ getEnvData();
3004
+ };
3005
+ const setUserInfoValue = (user) => {
3006
+ store.dispatch(setUser(user));
3007
+ getEnvData();
3008
+ };
3009
+ return {
3010
+ getEnvData,
3011
+ setupEnv,
3012
+ setLangValue,
3013
+ setUidValue,
3014
+ setAllowCompaniesValue,
3015
+ setCompaniesValue,
3016
+ setDefaultCompanyValue,
3017
+ setUserInfoValue
3018
+ };
3019
+ }
3020
+ var env = null;
3036
3021
  function initEnv({
3037
3022
  localStorageUtils: localStorageUtils2,
3038
3023
  sessionStorageUtils: sessionStorageUtils2
3039
3024
  }) {
3040
- return EnvStore.getInstance(localStorageUtils2, sessionStorageUtils2);
3025
+ env = createEnvStore(envStore, localStorageUtils2, sessionStorageUtils2);
3026
+ return env;
3041
3027
  }
3042
3028
  function getEnv() {
3043
- return EnvStore.getState();
3029
+ if (!env) {
3030
+ env = createEnvStore(envStore, localStorageUtils(), sessionStorageUtils());
3031
+ }
3032
+ return env?.getEnvData();
3044
3033
  }
3045
3034
  export {
3046
- EnvStore,
3047
3035
  getEnv,
3048
3036
  initEnv
3049
3037
  };