3 {-# LANGUAGE TemplateHaskell #-}
5 module Gargantext.API.Admin.EnvTypes where
8 import Data.Pool (Pool)
9 import Database.PostgreSQL.Simple (Connection)
10 import GHC.Generics (Generic)
11 import Network.HTTP.Client (Manager)
12 import Servant.Client (BaseUrl)
13 import Servant.Job.Async (HasJobEnv(..), Job)
14 import System.Log.FastLogger
15 import qualified Servant.Job.Core
17 import Gargantext.API.Ngrams.Types (HasRepoVar(..), HasRepoSaver(..), HasRepo(..), RepoEnv(..))
18 import Gargantext.API.Admin.Types
19 import Gargantext.API.Admin.Orchestrator.Types
20 import Gargantext.Core.NodeStory
21 import Gargantext.Core.Mail.Types (HasMail, mailSettings)
22 import Gargantext.Database.Prelude (HasConnectionPool(..), HasConfig(..))
23 import Gargantext.Prelude
24 import Gargantext.Prelude.Config (GargConfig(..))
25 import Gargantext.Prelude.Mail.Types (MailConfig)
28 { _env_settings :: !Settings
29 , _env_logger :: !LoggerSet
30 , _env_pool :: !(Pool Connection)
31 , _env_repo :: !RepoEnv
32 , _env_nodeStory :: !NodeStoryEnv
33 , _env_manager :: !Manager
34 , _env_self_url :: !BaseUrl
35 , _env_scrapers :: !ScrapersEnv
36 , _env_config :: !GargConfig
37 , _env_mail :: !MailConfig
43 instance HasConfig Env where
44 hasConfig = env_config
46 instance HasConnectionPool Env where
49 instance HasNodeStoryEnv Env where
50 hasNodeStory = env_nodeStory
52 instance HasNodeStoryVar Env where
53 hasNodeStoryVar = hasNodeStory . nse_getter
55 instance HasNodeStorySaver Env where
56 hasNodeStorySaver = hasNodeStory . nse_saver
58 instance HasSettings Env where
59 settings = env_settings
61 instance HasMail Env where
62 mailSettings = env_mail
65 instance HasRepoVar Env where
66 repoVar = repoEnv . repoVar
67 instance HasRepoSaver Env where
68 repoSaver = repoEnv . repoSaver
69 instance HasRepo Env where
75 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
76 _env = env_scrapers . Servant.Job.Core._env
78 instance HasJobEnv Env JobLog JobLog where
79 job_env = env_scrapers
81 data MockEnv = MockEnv
82 { _menv_firewall :: !FireWall
91 { _dev_env_settings :: !Settings
92 , _dev_env_repo :: !RepoEnv
93 , _dev_env_config :: !GargConfig
94 , _dev_env_pool :: !(Pool Connection)
95 , _dev_env_nodeStory :: !NodeStoryEnv
96 , _dev_env_mail :: !MailConfig
101 instance HasConfig DevEnv where
102 hasConfig = dev_env_config
104 instance HasConnectionPool DevEnv where
105 connPool = dev_env_pool
107 instance HasSettings DevEnv where
108 settings = dev_env_settings
111 instance HasNodeStoryEnv DevEnv where
112 hasNodeStory = dev_env_nodeStory
114 instance HasNodeStoryVar DevEnv where
115 hasNodeStoryVar = hasNodeStory . nse_getter
117 instance HasNodeStorySaver DevEnv where
118 hasNodeStorySaver = hasNodeStory . nse_saver
121 instance HasRepoVar DevEnv where
122 repoVar = repoEnv . repoVar
123 instance HasRepoSaver DevEnv where
124 repoSaver = repoEnv . repoSaver
125 instance HasRepo DevEnv where
126 repoEnv = dev_env_repo
128 instance HasMail DevEnv where
129 mailSettings = dev_env_mail