Verified Commit 9195326c authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch '304-dev-toml-config-rewrite-and-update-deps' into 238-dev-async-job-worker

parents 890a8076 177173ea
......@@ -75,10 +75,16 @@ convertConfigs ini@(Ini.GargConfig { .. }) iniMail nlpConfig connInfo =
, _jc_js_job_timeout = _gc_js_job_timeout
, _jc_js_id_timeout = _gc_js_id_timeout }
, _gc_apis = CTypes.APIsConfig { _ac_pubmed_api_key = _gc_pubmed_api_key
, _ac_epo_api_url = _gc_epo_api_url }
, _ac_epo_api_url = _gc_epo_api_url
, _ac_scrapyd_url }
, _gc_worker = WorkerSettings { _wsDefinitions = [] }
, _gc_log_level = LevelDebug
}
where
_ac_scrapyd_url =
case parseBaseUrl "http://localhost:6800" of
Nothing -> panicTrace "Cannot parse base url for scrapyd"
Just b -> b
mkFrontendConfig :: Ini.GargConfig -> CTypes.FrontendConfig
mkFrontendConfig (Ini.GargConfig { .. }) =
......@@ -87,7 +93,8 @@ mkFrontendConfig (Ini.GargConfig { .. }) =
, _fc_url_backend_api = _gc_url_backend_api
, _fc_cors
, _fc_microservices
, _fc_appPort = 3000 }
, _fc_appPort = 3000
, _fc_cookie_settings = CTypes.defaultCookieSettings }
where
_fc_cors = CTypes.CORSSettings { _corsAllowedOrigins = [
toCORSOrigin "https://demo.gargantext.org"
......
......@@ -18,7 +18,6 @@ module CLI.Init where
import CLI.Parsers
import CLI.Types
import Data.List.NonEmpty qualified as NE
import Gargantext.API.Admin.Types
import Gargantext.API.Dev (withDevEnv, runCmdDev)
import Gargantext.API.Errors.Types
import Gargantext.API.Node () -- instances only
......@@ -50,18 +49,18 @@ initCLI (InitArgs settingsPath) = do
cfg <- readConfig settingsPath
let secret = _s_secret_key $ _gc_secrets cfg
let createUsers :: forall env. HasSettings env => DBCmd' env BackendInternalError Int64
let createUsers :: forall env. DBCmd' env BackendInternalError Int64
createUsers = insertNewUsers (NewUser "gargantua" (cs email) (GargPassword $ cs password)
NE.:| arbitraryNewUsers
)
let
mkRoots :: forall env. HasSettings env => DBCmd' env BackendInternalError [(UserId, RootId)]
mkRoots :: forall env. DBCmd' env BackendInternalError [(UserId, RootId)]
mkRoots = mapM getOrMkRoot $ map UserName ("gargantua" : arbitraryUsername)
-- TODO create all users roots
let
initMaster :: forall env. HasSettings env => DBCmd' env BackendInternalError (UserId, RootId, CorpusId, ListId)
initMaster :: forall env. DBCmd' env BackendInternalError (UserId, RootId, CorpusId, ListId)
initMaster = do
(masterUserId, masterRootId, masterCorpusId)
<- getOrMkRootWithCorpus MkCorpusUserMaster
......
......@@ -16,7 +16,6 @@ module CLI.Invitations where
import CLI.Parsers
import CLI.Types
import Gargantext.API.Admin.Types
import Gargantext.API.Dev (withDevEnv, runCmdDev)
import Gargantext.API.Errors.Types
import Gargantext.API.Node () -- instances only
......@@ -35,8 +34,7 @@ invitationsCLI :: InvitationsArgs -> IO ()
invitationsCLI (InvitationsArgs settingsPath user node_id email) = do
-- _cfg <- readConfig settingsPath
let invite :: ( HasSettings env
, CmdRandom env BackendInternalError m
let invite :: ( CmdRandom env BackendInternalError m
, HasNLPServer env
, CET.HasCentralExchangeNotification env ) => m Int
invite = Share.api (UserName $ cs user) node_id (Share.ShareTeamParams $ cs email)
......
......@@ -65,6 +65,9 @@ api_key = ENTER_PUBMED_API_KEY
[apis.epo]
api_url = EPO_API_URL
[apis.scrapyd]
url = "http://localhost:6800"
[external]
......
......@@ -108,7 +108,6 @@ library
Gargantext.API.Admin.EnvTypes
Gargantext.API.Admin.Orchestrator.Types
Gargantext.API.Admin.Settings
Gargantext.API.Admin.Types
Gargantext.API.Auth.PolicyCheck
Gargantext.API.Count.Types
Gargantext.API.Dev
......
......@@ -44,15 +44,14 @@ import Data.Text.Encoding qualified as TE
import Data.Text.IO (putStrLn)
import Data.Validity
import Gargantext.API.Admin.Auth.Types (AuthContext)
import Gargantext.API.Admin.EnvTypes (Env, Mode(..), env_config, env_jwt_settings)
import Gargantext.API.Admin.EnvTypes (Env, FireWall(..), Mode(..), env_config, env_jwt_settings)
import Gargantext.API.Admin.Settings (newEnv)
import Gargantext.API.Admin.Types (FireWall(..), cookieSettings, settings)
import Gargantext.API.Middleware (logStdoutDevSanitised)
import Gargantext.API.Routes.Named (API)
import Gargantext.API.Routes.Named.EKG
import Gargantext.API.Server.Named (server)
import Gargantext.Core.Config (gc_notifications_config, gc_frontend_config)
import Gargantext.Core.Config.Types (CORSOrigin(..), CORSSettings, MicroServicesProxyStatus(..), NotificationsConfig(..), PortNumber, SettingsFile(..), corsAllowedOrigins, fc_cors, microServicesProxyStatus)
import Gargantext.Core.Config.Types (CORSOrigin(..), CORSSettings, MicroServicesProxyStatus(..), NotificationsConfig(..), PortNumber, SettingsFile(..), corsAllowedOrigins, fc_cors, fc_cookie_settings, microServicesProxyStatus)
import Gargantext.Database.Prelude qualified as DB
import Gargantext.MicroServices.ReverseProxy (microServicesProxyApp)
import Gargantext.Prelude hiding (putStrLn, to)
......@@ -132,7 +131,7 @@ stopGargantext scheduledPeriodicActions = do
-- | Schedules all sorts of useful periodic actions to be run while
-- the server is alive accepting requests.
schedulePeriodicActions :: DB.CmdCommon env => env -> IO [ThreadId]
schedulePeriodicActions :: env -> IO [ThreadId]
schedulePeriodicActions _env =
-- Add your scheduled actions here.
let actions = [
......@@ -205,7 +204,7 @@ makeApp env = do
where
cfg :: Servant.Context AuthContext
cfg = env ^. env_jwt_settings
:. env ^. settings . cookieSettings
:. env ^. env_config . gc_frontend_config . fc_cookie_settings
:. EmptyContext
---------------------------------------------------------------------
......
......@@ -52,7 +52,6 @@ import Data.UUID.V4 (nextRandom)
import Gargantext.API.Admin.Auth.Types
import Gargantext.API.Admin.EnvTypes (GargJob(..), Env)
import Gargantext.API.Admin.Orchestrator.Types (AsyncJobs(..))
import Gargantext.API.Admin.Types
import Gargantext.API.Auth.PolicyCheck
import Gargantext.API.Errors
import Gargantext.API.Prelude (authenticationError, HasServerError, GargServerC, _ServerError, GargM, IsGargServer)
......@@ -241,12 +240,12 @@ forgotPassword = Named.ForgotPasswordAPI
, forgotPasswordGetEp = forgotPasswordGet
}
forgotPasswordPost :: (CmdCommon env, HasSettings env)
forgotPasswordPost :: (CmdCommon env)
=> ForgotPasswordRequest -> Cmd' env err ForgotPasswordResponse
forgotPasswordPost (ForgotPasswordRequest _email) = do
pure $ ForgotPasswordResponse "ok"
forgotPasswordGet :: (HasSettings env, CmdCommon env, HasAuthenticationError err, HasServerError err)
forgotPasswordGet :: (CmdCommon env, HasServerError err)
=> Maybe Text -> Cmd' env err ForgotPasswordGet
forgotPasswordGet Nothing = pure $ ForgotPasswordGet ""
forgotPasswordGet (Just uuid) = do
......@@ -263,7 +262,7 @@ forgotPasswordGet (Just uuid) = do
---------------------
forgotPasswordGetUser :: ( HasSettings env, CmdCommon env, HasAuthenticationError err, HasServerError err)
forgotPasswordGetUser :: ( CmdCommon env)
=> UserLight -> Cmd' env err ForgotPasswordGet
forgotPasswordGetUser (UserLight { .. }) = do
-- pick some random password
......
......@@ -14,7 +14,6 @@ module Gargantext.API.Admin.EnvTypes (
, env_config
, env_logger
, env_manager
, env_settings
, env_self_url
, env_central_exchange
, env_dispatcher
......@@ -23,6 +22,7 @@ module Gargantext.API.Admin.EnvTypes (
, menv_firewall
, dev_env_logger
, FireWall(..)
, MockEnv(..)
, DevEnv(..)
, DevJobHandle(..)
......@@ -41,7 +41,6 @@ import Data.Sequence (ViewL(..), viewl)
import Data.Text qualified as T
import Database.PostgreSQL.Simple (Connection)
import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.Admin.Types
import Gargantext.API.Errors.Types
import Gargantext.API.Job
import Gargantext.API.Prelude (GargM, IsGargServer)
......@@ -172,8 +171,7 @@ instance ToJSON GargJob where
-- having to specify /everything/. This means that when we /construct/ an 'Env',
-- we need to remember to force the fields to WHNF at that point.
data Env = Env
{ _env_settings :: ~Settings
, _env_logger :: ~(Logger (GargM Env BackendInternalError))
{ _env_logger :: ~(Logger (GargM Env BackendInternalError))
, _env_pool :: ~(Pool Connection)
, _env_nodeStory :: ~NodeStoryEnv
, _env_manager :: ~Manager
......@@ -204,9 +202,6 @@ instance HasNodeStoryImmediateSaver Env where
instance HasNodeArchiveStoryImmediateSaver Env where
hasNodeArchiveStoryImmediateSaver = hasNodeStory . nse_archive_saver_immediate
instance HasSettings Env where
settings = env_settings
instance HasJWTSettings Env where
jwtSettings = env_jwt_settings
......@@ -313,6 +308,8 @@ instance Jobs.MonadJobStatus (GargM Env err) where
addMoreSteps steps jh = updateJobProgress jh (jobLogAddMore steps)
data FireWall = FireWall { unFireWall :: Bool }
data MockEnv = MockEnv
{ _menv_firewall :: !FireWall
}
......@@ -342,8 +339,7 @@ instance HasLogger (GargM DevEnv BackendInternalError) where
logTxt lgr lvl msg = logMsg lgr lvl (FL.toLogStr $ T.unpack msg)
data DevEnv = DevEnv
{ _dev_env_settings :: !Settings
, _dev_env_config :: !GargConfig
{ _dev_env_config :: !GargConfig
, _dev_env_logger :: !(Logger (GargM DevEnv BackendInternalError))
, _dev_env_pool :: !(Pool Connection)
, _dev_env_nodeStory :: !NodeStoryEnv
......@@ -391,9 +387,6 @@ instance HasConfig DevEnv where
instance HasConnectionPool DevEnv where
connPool = dev_env_pool
instance HasSettings DevEnv where
settings = dev_env_settings
instance HasNodeStoryEnv DevEnv where
hasNodeStory = dev_env_nodeStory
......
......@@ -26,7 +26,6 @@ import Data.Pool (Pool)
import Data.Pool qualified as Pool
import Database.PostgreSQL.Simple (Connection, connect, close, ConnectInfo)
import Gargantext.API.Admin.EnvTypes
import Gargantext.API.Admin.Types
import Gargantext.API.Errors.Types
import Gargantext.API.Prelude
import Gargantext.Core.AsyncUpdates.CentralExchange qualified as CE
......@@ -42,7 +41,6 @@ import Gargantext.Utils.Jobs.Monad qualified as Jobs
import Gargantext.Utils.Jobs.Queue qualified as Jobs
import Gargantext.Utils.Jobs.Settings qualified as Jobs
import Network.HTTP.Client.TLS (newTlsManager)
import Servant.Auth.Server (CookieSettings(..), XsrfCookieSettings(..), defaultCookieSettings, defaultXsrfCookieSettings)
import Servant.Client (parseBaseUrl)
import Servant.Job.Async (newJobEnv, defaultSettings)
import System.Directory (renameFile)
......@@ -53,20 +51,6 @@ import System.IO.Temp (withTempFile)
newtype IniFile = IniFile { _IniFile :: FilePath }
deriving (Show, Eq, IsString)
devSettings :: Settings
devSettings =
-- GargTomlSettings{..} <- loadGargTomlSettings settingsFile
Settings
{ -- _corsSettings = _gargCorsSettings
-- , _microservicesSettings = _gargMicroServicesSettings
-- , _dbServer = "localhost"
_sendLoginEmails = LogEmailToConsole
, _scrapydUrl = fromMaybe (panicTrace "Invalid scrapy URL") $ parseBaseUrl "http://localhost:6800"
, _cookieSettings = defaultCookieSettings { cookieXsrfSetting = Just xsrfCookieSetting } -- TODO-SECURITY tune
}
where
xsrfCookieSetting = defaultXsrfCookieSettings { xsrfExcludeGet = True }
{- NOT USED YET
import System.Environment (lookupEnv)
......@@ -169,7 +153,6 @@ readRepoEnv repoDir = do
newEnv :: Logger (GargM Env BackendInternalError) -> PortNumber -> SettingsFile -> IO Env
newEnv logger port settingsFile@(SettingsFile sf) = do
!manager_env <- newTlsManager
let !settings' = devSettings
!config_env <- readConfig settingsFile <&> (gc_frontend_config . fc_appPort) .~ port -- TODO read from 'file'
when (port /= config_env ^. gc_frontend_config . fc_appPort) $
panicTrace "TODO: conflicting settings of port"
......@@ -198,8 +181,7 @@ newEnv logger port settingsFile@(SettingsFile sf) = do
we want to force them to WHNF to avoid accumulating unnecessary thunks.
-}
pure $ Env
{ _env_settings = settings'
, _env_logger = logger
{ _env_logger = logger
, _env_pool = pool
, _env_nodeStory = nodeStory_env
, _env_manager = manager_env
......
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.API.Admin.Types where
import Control.Lens
import GHC.Enum
import Gargantext.Prelude
import Servant.Auth.Server (CookieSettings(..))
import Servant.Client (BaseUrl)
data SendEmailType = SendEmailViaAws
| LogEmailToConsole
| WriteEmailToFile
deriving (Show, Read, Enum, Bounded, Generic)
data Settings = Settings
{
-- , _dbServer :: Text
-- ^ this is not used yet
_cookieSettings :: !CookieSettings
, _sendLoginEmails :: !SendEmailType
, _scrapydUrl :: !BaseUrl
}
makeLenses ''Settings
class HasSettings env where
settings :: Getter env Settings
instance HasSettings Settings where
settings = identity
data FireWall = FireWall { unFireWall :: Bool }
......@@ -29,5 +29,5 @@ import Servant.Server.Generic (AsServerT)
-- TODO-ACCESS: CanCount
-- TODO-EVENTS: No events as this is a read only query.
-----------------------------------------------------------------------
countAPI :: Monad m => Query -> Named.CountAPI (AsServerT m)
countAPI :: Query -> Named.CountAPI (AsServerT m)
countAPI _ = Named.CountAPI undefined
......@@ -17,7 +17,7 @@ import Control.Monad (fail)
import Data.Pool (withResource)
import Database.PostgreSQL.Simple qualified as PGS
import Gargantext.API.Admin.EnvTypes ( DevEnv(..), Mode(Dev) )
import Gargantext.API.Admin.Settings ( devSettings, newPool )
import Gargantext.API.Admin.Settings ( newPool )
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Prelude ( GargM )
import Gargantext.Core.Config (_gc_database_config)
......@@ -41,12 +41,10 @@ withDevEnv settingsFile k = withLoggerHoisted Dev $ \logger -> do
--nodeStory_env <- fromDBNodeStoryEnv (_gc_repofilepath cfg)
pool <- newPool (_gc_database_config cfg)
nodeStory_env <- fromDBNodeStoryEnv pool
let setts = devSettings
pure $ DevEnv
{ _dev_env_pool = pool
, _dev_env_logger = logger
, _dev_env_nodeStory = nodeStory_env
, _dev_env_settings = setts
, _dev_env_config = cfg
}
......
......@@ -8,6 +8,7 @@ Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -Wredundant-constraints #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE LambdaCase #-}
......@@ -39,9 +40,6 @@ module Gargantext.API.Errors.Types (
-- * Evidence carrying
, Dict(..)
, IsFrontendErrorData(..)
-- * Generating test cases
, genFrontendErr
) where
import Control.Lens (makePrisms)
......@@ -51,7 +49,7 @@ import Data.Aeson.Types (typeMismatch, emptyArray)
import Data.List.NonEmpty qualified as NE
import Data.Singletons.TH ( SingI(sing), SingKind(fromSing) )
import Data.Text qualified as T
import Data.Validity (Validation(..), ValidationChain (..), prettyValidation)
import Data.Validity (Validation(..))
import Gargantext.API.Admin.Auth.Types (AuthenticationError)
import Gargantext.API.Errors.Class (HasAuthenticationError(..))
import Gargantext.API.Errors.TH ( deriveIsFrontendErrorData )
......@@ -67,8 +65,6 @@ import Gargantext.Utils.Jobs.Monad qualified as Jobs
import Servant (ServerError)
import Servant.Job.Core ( HasServerError(..) )
import Servant.Job.Types qualified as SJ
import Test.QuickCheck
import Test.QuickCheck.Instances.Text ()
-- | A 'WithStacktrace' carries an error alongside its
-- 'CallStack', to be able to print the correct source location
......@@ -574,121 +570,6 @@ instance FromJSON (ToFrontendErrorData 'EC_500__job_generic_exception) where
jege_error <- o .: "error"
pure FE_job_generic_exception{..}
----------------------------------------------------------------------------
-- Arbitrary instances and test data generation
----------------------------------------------------------------------------
instance Arbitrary BackendErrorCode where
arbitrary = arbitraryBoundedEnum
genFrontendErr :: BackendErrorCode -> Gen FrontendError
genFrontendErr be = do
txt <- arbitrary
case be of
-- node errors
EC_404__node_list_not_found
-> arbitrary >>= \lid -> pure $ mkFrontendErr' txt $ FE_node_list_not_found lid
EC_404__node_root_not_found
-> pure $ mkFrontendErr' txt FE_node_root_not_found
EC_404__node_corpus_not_found
-> pure $ mkFrontendErr' txt FE_node_corpus_not_found
EC_500__node_not_implemented_yet
-> pure $ mkFrontendErr' txt FE_node_not_implemented_yet
EC_404__node_lookup_failed_not_found
-> do nodeId <- arbitrary
pure $ mkFrontendErr' txt (FE_node_lookup_failed_not_found nodeId)
EC_404__node_lookup_failed_parent_not_found
-> do nodeId <- arbitrary
pure $ mkFrontendErr' txt (FE_node_lookup_failed_parent_not_found nodeId)
EC_404__node_lookup_failed_user_not_found
-> do userId <- arbitrary
pure $ mkFrontendErr' txt (FE_node_lookup_failed_user_not_found userId)
EC_404__node_lookup_failed_username_not_found
-> do username <- arbitrary
pure $ mkFrontendErr' txt (FE_node_lookup_failed_username_not_found username)
EC_400__node_lookup_failed_user_too_many_roots
-> do userId <- arbitrary
roots <- arbitrary
pure $ mkFrontendErr' txt (FE_node_lookup_failed_user_too_many_roots userId roots)
EC_404__node_context_not_found
-> do contextId <- arbitrary
pure $ mkFrontendErr' txt (FE_node_context_not_found contextId)
EC_400__node_creation_failed_no_parent
-> do userId <- arbitrary
pure $ mkFrontendErr' txt (FE_node_creation_failed_no_parent userId)
EC_400__node_creation_failed_parent_exists
-> do userId <- arbitrary
parentId <- arbitrary
pure $ mkFrontendErr' txt (FE_node_creation_failed_parent_exists userId parentId)
EC_400__node_creation_failed_insert_node
-> do userId <- arbitrary
parentId <- arbitrary
pure $ mkFrontendErr' txt $ FE_node_creation_failed_insert_node parentId userId
EC_400__node_creation_failed_user_negative_id
-> pure $ mkFrontendErr' txt (FE_node_creation_failed_user_negative_id (UnsafeMkUserId (-42)))
EC_500__node_generic_exception
-> do err <- arbitrary
pure $ mkFrontendErr' txt $ FE_node_generic_exception err
EC_400__node_needs_configuration
-> pure $ mkFrontendErr' txt $ FE_node_needs_configuration
-- validation error
EC_400__validation_error
-> do let genValChain = oneof [ Violated <$> arbitrary, Location <$> arbitrary <*> genValChain ]
chain <- listOf1 genValChain
pure $ mkFrontendErr' txt $ FE_validation_error (T.pack $ fromMaybe "unknown_validation_error" $ prettyValidation $ Validation chain)
-- authentication error
EC_403__login_failed_error
-> do nid <- arbitrary
uid <- arbitrary
pure $ mkFrontendErr' txt $ FE_login_failed_error nid uid
EC_403__login_failed_invalid_username_or_password
-> do
pure $ mkFrontendErr' txt $ FE_login_failed_invalid_username_or_password
EC_403__user_not_authorized
-> do
uid <- arbitrary
msg <- arbitrary
pure $ mkFrontendErr' txt $ FE_user_not_authorized uid msg
-- internal error
EC_500__internal_server_error
-> do err <- arbitrary
pure $ mkFrontendErr' txt $ FE_internal_server_error err
EC_405__not_allowed
-> do err <- arbitrary
pure $ mkFrontendErr' txt $ FE_not_allowed err
-- tree errors
EC_404__tree_root_not_found
-> pure $ mkFrontendErr' txt $ FE_tree_root_not_found
EC_404__tree_empty_root
-> pure $ mkFrontendErr' txt $ FE_tree_empty_root
EC_500__tree_too_many_roots
-> do nodes <- getNonEmpty <$> arbitrary
pure $ mkFrontendErr' txt $ FE_tree_too_many_roots (NE.fromList nodes)
-- job errors
EC_500__job_invalid_id_type
-> do idTy <- arbitrary
pure $ mkFrontendErr' txt $ FE_job_invalid_id_type idTy
EC_500__job_expired
-> do jobId <- getPositive <$> arbitrary
pure $ mkFrontendErr' txt $ FE_job_expired jobId
EC_500__job_invalid_mac
-> do macId <- arbitrary
pure $ mkFrontendErr' txt $ FE_job_expired macId
EC_500__job_unknown_job
-> do jobId <- getPositive <$> arbitrary
pure $ mkFrontendErr' txt $ FE_job_unknown_job jobId
EC_500__job_generic_exception
-> do err <- arbitrary
pure $ mkFrontendErr' txt $ FE_job_generic_exception err
instance ToJSON BackendErrorCode where
toJSON = String . T.pack . show
......
......@@ -260,7 +260,7 @@ updatePie cId maybeListId tabType maybeLimit = do
_ <- updatePie' cId listId tabType maybeLimit
pure ()
updatePie' :: (HasNodeStory env err m, HasNodeError err)
updatePie' :: (HasNodeStory env err m)
=> CorpusId
-> ListId
-> TabType
......
......@@ -99,7 +99,6 @@ import Gargantext.Core.Types (ListType(..), NodeId, ListId, TODO, assertValid, H
import Gargantext.Core.Types.Query (Limit(..), Offset(..), MinSize(..), MaxSize(..))
import Gargantext.Database.Action.Metrics.NgramsByContext (getOccByNgramsOnlyFast)
import Gargantext.Database.Query.Table.Ngrams ( text2ngrams, insertNgrams )
import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
import Gargantext.Prelude hiding (log, to, toLower, (%), isInfixOf)
import Gargantext.Prelude.Clock (hasTime, getTime)
import Text.Collate qualified as Unicode
......@@ -256,7 +255,6 @@ newNgramsFromNgramsStatePatch p =
commitStatePatch :: ( HasNodeStory env err m
, HasNodeStoryImmediateSaver env
, HasNodeArchiveStoryImmediateSaver env )
=> ListId
-> Versioned NgramsStatePatch'
......@@ -364,7 +362,6 @@ tableNgramsPull listId ngramsType p_version = do
-- client.
-- TODO-ACCESS check
tableNgramsPut :: ( HasNodeStory env err m
, HasNodeStoryImmediateSaver env
, HasNodeArchiveStoryImmediateSaver env
, HasValidationError err
)
......@@ -520,8 +517,7 @@ unicodeDUCETSorter :: Text -> Text -> Ordering
unicodeDUCETSorter = Unicode.collate Unicode.rootCollator
getTableNgrams :: forall env err m.
( HasNodeStory env err m
, HasNodeError err )
( HasNodeStory env err m )
=> NodeId
-> ListId
-> TabType
......@@ -535,8 +531,7 @@ getTableNgrams nodeId listId tabType searchQuery = do
-- | Helper function to get the ngrams table with scores.
getNgramsTable' :: forall env err m.
( HasNodeStory env err m
, HasNodeError err )
( HasNodeStory env err m )
=> NodeId
-> ListId
-> NgramsType
......@@ -549,8 +544,7 @@ getNgramsTable' nId listId ngramsType = do
-- | Helper function to set scores on an `NgramsTable`.
setNgramsTableScores :: forall env err m t.
( Each t t NgramsElement NgramsElement
, HasNodeStory env err m
, HasNodeError err )
, HasNodeStory env err m )
=> NodeId
-> ListId
-> NgramsType
......@@ -586,8 +580,7 @@ needsScores (Just ScoreAsc) = True
needsScores (Just ScoreDesc) = True
needsScores _ = False
getTableNgramsCorpus :: ( HasNodeStory env err m
, HasNodeError err )
getTableNgramsCorpus :: ( HasNodeStory env err m )
=> NodeId
-> TabType
-> ListId
......
......@@ -15,7 +15,7 @@ Portability : POSIX
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS -fno-warn-orphans #-}
{-# OPTIONS -fno-warn-orphans #-} -- some instances are orphaned here
module Gargantext.API.Ngrams.Types where
......@@ -52,8 +52,6 @@ import Gargantext.Utils.Servant (TSV, ZIP)
import Gargantext.Utils.Zip (zipContentsPure)
import Servant ( FromHttpApiData(parseUrlPiece), ToHttpApiData(toUrlPiece), Required, Strict, QueryParam', MimeRender(.. ), MimeUnrender(..))
import Servant.Job.Utils (jsonOptions)
import Test.QuickCheck (elements, frequency)
import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
------------------------------------------------------------------------
......@@ -96,7 +94,7 @@ instance ToJSONKey TabType where
newtype MSet a = MSet (Map a ())
deriving stock (Eq, Ord, Show, Read, Generic)
deriving newtype (Arbitrary, Semigroup, Monoid)
deriving newtype (Semigroup, Monoid)
deriving anyclass (ToExpr)
instance ToJSON a => ToJSON (MSet a) where
......@@ -123,14 +121,14 @@ instance Foldable MSet where
instance (Ord a, FromJSON a) => FromJSON (MSet a) where
parseJSON = fmap mSetFromList . parseJSON
instance (ToJSONKey a, ToSchema a) => ToSchema (MSet a) where
instance ToSchema (MSet a) where
-- TODO
declareNamedSchema _ = wellNamedSchema "" (Proxy :: Proxy TODO)
------------------------------------------------------------------------
newtype NgramsTerm = NgramsTerm { unNgramsTerm :: Text }
deriving (Ord, Eq, Show, Read, Generic)
deriving newtype (ToJSONKey, ToJSON, FromJSON, Semigroup, Arbitrary, Serialise, ToSchema, Hashable, NFData, FromField, ToField)
deriving newtype (ToJSONKey, ToJSON, FromJSON, Semigroup, Serialise, ToSchema, Hashable, NFData, FromField, ToField)
deriving anyclass (ToExpr)
instance IsHashable NgramsTerm where
hash (NgramsTerm t) = hash t
......@@ -243,24 +241,6 @@ toNgramsElement ns = map toNgramsElement' ns
$ map (\(NgramsTableData _ p t _ _ _) -> (p, Set.singleton t)) ns
-}
mockTable :: NgramsTable
mockTable = NgramsTable
[ mkNgramsElement "animal" MapTerm Nothing (mSetFromList ["dog", "cat"])
, mkNgramsElement "cat" MapTerm (rp "animal") mempty
, mkNgramsElement "cats" StopTerm Nothing mempty
, mkNgramsElement "dog" MapTerm (rp "animal") (mSetFromList ["dogs"])
, mkNgramsElement "dogs" StopTerm (rp "dog") mempty
, mkNgramsElement "fox" MapTerm Nothing mempty
, mkNgramsElement "object" CandidateTerm Nothing mempty
, mkNgramsElement "nothing" StopTerm Nothing mempty
, mkNgramsElement "organic" MapTerm Nothing (mSetFromList ["flower"])
, mkNgramsElement "flower" MapTerm (rp "organic") mempty
, mkNgramsElement "moon" CandidateTerm Nothing mempty
, mkNgramsElement "sky" StopTerm Nothing mempty
]
where
rp n = Just $ RootParent n n
instance ToSchema NgramsTable
------------------------------------------------------------------------
......@@ -412,7 +392,7 @@ makePrisms ''PatchMSet
_PatchMSetIso :: Ord a => Iso' (PatchMSet a) (PatchSet a)
_PatchMSetIso = _PatchMSet . _PatchMap . iso f g . from _PatchSet
where
f :: Ord a => Map a (Replace (Maybe ())) -> (Set a, Set a)
f :: Map a (Replace (Maybe ())) -> (Set a, Set a)
f = Map.partition isRem >>> both %~ Map.keysSet
g :: Ord a => (Set a, Set a) -> Map a (Replace (Maybe ()))
......@@ -432,7 +412,7 @@ instance (Ord a, ToJSON a) => ToJSON (PatchMSet a) where
instance (Ord a, FromJSON a) => FromJSON (PatchMSet a) where
parseJSON = fmap (_PatchMSetIso #) . parseJSON
instance ToSchema a => ToSchema (PatchMSet a) where
instance ToSchema (PatchMSet a) where
-- TODO
declareNamedSchema _ = wellNamedSchema "" (Proxy :: Proxy TODO)
......@@ -833,37 +813,6 @@ instance (Serialise a, Ord a) => Serialise (PatchMap a AddRem)
instance (Serialise a, Ord a) => Serialise (PatchMSet a)
instance (Serialise s, Serialise p) => Serialise (Repo s p)
--
-- Arbitrary instances
--
instance Arbitrary TabType where
arbitrary = elements [minBound .. maxBound]
instance Arbitrary NgramsElement where
arbitrary = elements [newNgramsElement Nothing "sport"]
instance Arbitrary NgramsTable where
arbitrary = pure mockTable
instance Arbitrary OrderBy
where
arbitrary = elements [minBound..maxBound]
instance (Ord a, Arbitrary a) => Arbitrary (PatchMSet a) where
arbitrary = (PatchMSet . PM.fromMap) <$> arbitrary
instance (Eq a, Arbitrary a) => Arbitrary (Replace a) where
arbitrary = uncurry replace <$> arbitrary
-- If they happen to be equal then the patch is Keep.
instance Arbitrary NgramsPatch where
arbitrary = frequency [ (9, NgramsPatch <$> arbitrary <*> (replace <$> arbitrary <*> arbitrary))
, (1, NgramsReplace <$> arbitrary <*> arbitrary)
]
instance Arbitrary NgramsTablePatch where
arbitrary = NgramsTablePatch <$> PM.fromMap <$> arbitrary
instance Arbitrary a => Arbitrary (Versioned a) where
arbitrary = Versioned 1 <$> arbitrary -- TODO 1 is constant so far
instance Arbitrary a => Arbitrary (VersionedWithCount a) where
arbitrary = VersionedWithCount 1 1 <$> arbitrary -- TODO 1 is constant so far
instance Arbitrary NgramsRepoElement where
arbitrary = elements $ map ngramsElementToRepo ns
where
NgramsTable ns = mockTable
toNgramsPatch :: [NgramsTerm] -> NgramsPatch
......
......@@ -61,7 +61,6 @@ import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Prelude (Cmd, JSONB)
import Gargantext.Database.Query.Table.Node
import Gargantext.Database.Query.Table.Node.Children (getChildren)
import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..))
import Gargantext.Database.Query.Table.Node.Update (Update(..), update)
import Gargantext.Database.Query.Table.Node.Update qualified as U (update, Update(..))
import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
......@@ -187,7 +186,7 @@ treeFlatAPI authenticatedUser rootId =
rename :: NodeId -> RenameNode -> Cmd err [Int]
rename nId (RenameNode name') = U.update (U.Rename nId name')
putNode :: forall err a. (HasNodeError err, HyperdataC a)
putNode :: forall err a. (HyperdataC a)
=> NodeId
-> a
-> Cmd err Int
......@@ -223,7 +222,7 @@ nodeAPI authenticatedUser = Named.NodeAPIEndpoint $ \targetNode ->
concreteAPI = genericNodeAPI' (Proxy :: Proxy HyperdataAny) authenticatedUser
-- | The /actual/ (generic) node API, instantiated depending on the concrete type of node.
genericNodeAPI' :: forall a proxy. ( HyperdataC a, Show a, MimeUnrender JSON a, Named.IsGenericNodeRoute a )
genericNodeAPI' :: forall a proxy. ( HyperdataC a )
=> proxy a
-> AuthenticatedUser
-> NodeId
......
......@@ -22,7 +22,6 @@ import Conduit ( yield )
import Gargantext.API.Admin.Auth.Types ( AuthenticatedUser(AuthenticatedUser) )
import Gargantext.API.Admin.EnvTypes (Env, GargJob(..))
import Gargantext.API.Admin.Orchestrator.Types (AsyncJobs(..))
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Node ( nodeNodeAPI )
import Gargantext.API.Node.Contact.Types
......@@ -54,7 +53,7 @@ api_async u nId = Named.ContactAsyncAPI $ AsyncJobs $
serveJobsAPI AddContactJob $ \jHandle p ->
addContact u nId p jHandle
addContact :: (HasSettings env, FlowCmdM env err m, MonadJobStatus m)
addContact :: (FlowCmdM env err m, MonadJobStatus m)
=> User
-> NodeId
-> AddContactParams
......
......@@ -29,7 +29,6 @@ import Data.Text qualified as T
import Data.Text.Encoding qualified as TE
import EPO.API.Client.Types qualified as EPO
import Gargantext.API.Admin.Orchestrator.Types qualified as API
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Ngrams (commitStatePatch, Versioned(..))
import Gargantext.API.Node.Corpus.New.Types ( FileFormat(..), FileType(..) )
import Gargantext.API.Node.Corpus.Searx ( triggerSearxSearch )
......@@ -148,7 +147,6 @@ addToCorpusWithQuery :: ( FlowCmdM env err m
, MonadJobStatus m
, HasNodeStoryImmediateSaver env
, HasNodeArchiveStoryImmediateSaver env
, HasSettings env
)
=> User
-> CorpusId
......@@ -222,7 +220,6 @@ addToCorpusWithForm :: ( FlowCmdM env err m
, MonadJobStatus m
, HasNodeStoryImmediateSaver env
, HasNodeArchiveStoryImmediateSaver env
, HasSettings env
)
=> User
-> CorpusId
......@@ -326,7 +323,7 @@ addToCorpusWithFile cid input filetype logStatus = do
}
-}
addToCorpusWithFile :: (HasSettings env, FlowCmdM env err m, MonadJobStatus m)
addToCorpusWithFile :: (FlowCmdM env err m, MonadJobStatus m)
=> User
-> CorpusId
-> NewWithFile
......
......@@ -21,7 +21,6 @@ import Data.Text qualified as Text
import Data.Time.Calendar (Day, toGregorian)
import Data.Time.Format (defaultTimeLocale, formatTime, parseTimeM)
import Data.Tuple.Select (sel1, sel2, sel3)
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.Core (Lang(..))
import Gargantext.Core.Config (GargConfig(..), hasConfig)
import Gargantext.Core.Config.Types (FramesConfig(..))
......@@ -123,7 +122,6 @@ insertSearxResponse :: ( MonadBase IO m
, HasNodeError err
, HasTreeError err
, HasValidationError err
, HasSettings env
)
=> User
-> CorpusId
......@@ -168,7 +166,6 @@ triggerSearxSearch :: ( MonadBase IO m
, HasTreeError err
, HasValidationError err
, MonadJobStatus m
, HasSettings env
)
=> User
-> CorpusId
......
......@@ -20,7 +20,6 @@ import Control.Lens (view)
import Data.Text qualified as T
import Gargantext.API.Admin.EnvTypes (GargJob(..), Env)
import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Node.DocumentUpload.Types
import Gargantext.API.Prelude ( GargM )
......@@ -45,7 +44,7 @@ api nId = Named.DocumentUploadAPI $ AsyncJobs $
serveJobsAPI UploadDocumentJob $ \jHandle q -> do
documentUploadAsync nId q jHandle
documentUploadAsync :: (FlowCmdM env err m, MonadJobStatus m, HasSettings env)
documentUploadAsync :: (FlowCmdM env err m, MonadJobStatus m)
=> NodeId
-> DocumentUpload
-> JobHandle m
......@@ -56,7 +55,7 @@ documentUploadAsync nId doc jobHandle = do
-- printDebug "documentUploadAsync" docIds
markComplete jobHandle
documentUpload :: (FlowCmdM env err m, HasSettings env)
documentUpload :: (FlowCmdM env err m)
=> NodeId
-> DocumentUpload
-> m [DocId]
......
......@@ -22,7 +22,6 @@ import Data.Text qualified as T
import Gargantext.API.Admin.Auth.Types ( AuthenticatedUser, auth_node_id, auth_user_id )
import Gargantext.API.Admin.EnvTypes (Env, GargJob(..))
import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Ngrams (commitStatePatch, Versioned(..))
import Gargantext.API.Node.DocumentsFromWriteNodes.Types
......@@ -55,8 +54,7 @@ api authenticatedUser nId = Named.DocumentsFromWriteNodesAPI $ AsyncJobs $
serveJobsAPI DocumentFromWriteNodeJob $ \jHandle p ->
documentsFromWriteNodes authenticatedUser nId p jHandle
documentsFromWriteNodes :: ( HasSettings env
, FlowCmdM env err m
documentsFromWriteNodes :: ( FlowCmdM env err m
, MonadJobStatus m
, HasNodeStoryImmediateSaver env
, HasNodeArchiveStoryImmediateSaver env )
......
......@@ -22,7 +22,6 @@ import Data.Text qualified as T
import Gargantext.API.Admin.Auth.Types ( AuthenticatedUser, auth_user_id )
import Gargantext.API.Admin.EnvTypes (GargJob(..), Env)
import Gargantext.API.Admin.Orchestrator.Types (AsyncJobs(..))
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Node.File.Types
import Gargantext.API.Node.Types ( NewWithFile(NewWithFile) )
......@@ -41,12 +40,12 @@ import Gargantext.Utils.Jobs (serveJobsAPI, MonadJobStatus(..))
import Servant
import Servant.Server.Generic (AsServerT)
fileApi :: (HasSettings env, FlowCmdM env err m)
fileApi :: (FlowCmdM env err m)
=> NodeId
-> m (Headers '[Servant.Header "Content-Type" Text] BSResponse)
fileApi nId = fileDownload nId
fileDownload :: (HasSettings env, FlowCmdM env err m)
fileDownload :: (FlowCmdM env err m)
=> NodeId
-> m (Headers '[Servant.Header "Content-Type" Text] BSResponse)
fileDownload nId = do
......@@ -83,7 +82,7 @@ fileAsyncApi authenticatedUser nId = Named.FileAsyncAPI $ AsyncJobs $
addWithFile authenticatedUser nId i jHandle
addWithFile :: (HasSettings env, FlowCmdM env err m, MonadJobStatus m)
addWithFile :: (FlowCmdM env err m, MonadJobStatus m)
=> AuthenticatedUser
-- ^ The logged-in user
-> NodeId
......
......@@ -21,7 +21,6 @@ import Data.Text qualified as T
import Gargantext.API.Admin.Auth.Types ( auth_node_id, AuthenticatedUser )
import Gargantext.API.Admin.EnvTypes (GargJob(..), Env)
import Gargantext.API.Admin.Orchestrator.Types (AsyncJobs(..))
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Node.Corpus.New (addToCorpusWithForm)
import Gargantext.API.Node.Corpus.New.Types (FileFormat(..), FileType(..))
......@@ -55,7 +54,6 @@ frameCalcUploadAsync :: ( HasConfig env
, FlowCmdM env err m
, MonadJobStatus m
, HasNodeArchiveStoryImmediateSaver env
, HasSettings env
)
=> AuthenticatedUser
-- ^ The logged-in user
......
......@@ -23,7 +23,6 @@ import Control.Lens hiding (elements, Empty)
import Gargantext.API.Admin.Auth.Types
import Gargantext.API.Admin.EnvTypes (GargJob(..), Env)
import Gargantext.API.Admin.Orchestrator.Types (AsyncJobs (..))
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types
import Gargantext.API.Node.New.Types
import Gargantext.API.Prelude
......@@ -44,9 +43,8 @@ import Servant.Server.Generic (AsServerT)
------------------------------------------------------------------------
-- postNode :: (CmdM env err m, HasNodeError err, HasSettings env)
postNode :: ( HasMail env
, HasNLPServer env
, HasNodeError err
, HasSettings env
, HasNLPServer env
, CE.HasCentralExchangeNotification env)
=> AuthenticatedUser
-- ^ The logged-in user
......@@ -79,10 +77,8 @@ postNodeAsyncAPI authenticatedUser nId = Named.PostNodeAsyncAPI $ AsyncJobs $
-- -> m [NodeId]
-- postNode' authenticatedUser pId (PostNode nodeName nt) = do
postNode' :: ( CmdM env err m
, HasMail env
, HasNLPServer env
, HasNodeError err
, HasSettings env
, HasMail env
, CE.HasCentralExchangeNotification env)
=> AuthenticatedUser
-- ^ The logged in user
......
......@@ -33,7 +33,6 @@ import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..))
import Gargantext.Database.Query.Tree (findNodesWithType)
import Gargantext.Prelude
import Servant.Server.Generic (AsServerT)
import Gargantext.API.Admin.Types (HasSettings)
------------------------------------------------------------------------
-- TODO permission
......@@ -42,7 +41,6 @@ import Gargantext.API.Admin.Types (HasSettings)
api :: ( HasNodeError err
, HasNLPServer env
, CmdRandom env err m
, HasSettings env
, HasCentralExchangeNotification env )
=> User
-> NodeId
......
......@@ -18,7 +18,6 @@ import Control.Lens (view)
import Data.Set qualified as Set
import Gargantext.API.Admin.EnvTypes (GargJob(..), Env)
import Gargantext.API.Admin.Orchestrator.Types (AsyncJobs(..))
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Metrics qualified as Metrics
import Gargantext.API.Ngrams.Types qualified as NgramsTypes
......@@ -52,7 +51,6 @@ api nId = Named.UpdateAPI $ AsyncJobs $
updateNode nId p jHandle
updateNode :: (HasNodeStory env err m
, HasSettings env
, MonadJobStatus m
, MonadLogger m
)
......
......@@ -24,7 +24,6 @@ import Control.Lens ((#))
import Data.Aeson.Types
import Gargantext.API.Admin.Auth.Types (AuthenticationError)
import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.Admin.Types
import Gargantext.API.Errors.Class
import Gargantext.Core.AsyncUpdates.CentralExchange.Types (HasCentralExchangeNotification)
import Gargantext.Core.Config (HasConfig)
......@@ -49,7 +48,6 @@ type HasJobEnv' env = HasJobEnv env JobLog JobLog
type EnvC env =
( HasConnectionPool env
, HasSettings env -- TODO rename HasDbSettings
, HasJobEnv env JobLog JobLog
, HasConfig env
, HasNodeStoryEnv env
......@@ -97,7 +95,6 @@ type GargNoServer t =
type GargNoServer' env err m =
( CmdM env err m
, HasNodeStory env err m
, HasSettings env
, HasNodeError err
)
......
......@@ -12,7 +12,6 @@ import Gargantext.API.Admin.Auth (withNamedAccess)
import Gargantext.API.Admin.Auth.Types (AuthenticatedUser, PathId (..))
import Gargantext.API.Admin.EnvTypes
import Gargantext.API.Admin.Orchestrator.Types (AsyncJobs(..))
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types (BackendInternalError)
import Gargantext.API.Metrics qualified as Metrics
import Gargantext.API.Ngrams
......@@ -72,7 +71,6 @@ apiNgramsAsync _dId = Named.TableNgramsAsyncAPI $ AsyncJobs $
tableNgramsPostChartsAsync :: ( HasNodeStory env err m
, HasSettings env
, MonadJobStatus m )
=> UpdateTableNgramsCharts
-> JobHandle m
......
......@@ -31,7 +31,6 @@ import DeferredFolds.UnfoldlM qualified as UnfoldlM
import Data.UUID.V4 as UUID
import Gargantext.API.Admin.Auth.Types (AuthenticatedUser(_auth_user_id))
import Gargantext.API.Admin.Orchestrator.Types (JobLog)
import Gargantext.API.Admin.Types (Settings)
import Gargantext.API.Prelude (IsGargServer)
import Gargantext.Core.AsyncUpdates.CentralExchange.Types qualified as CETypes
import Gargantext.Core.Types (NodeId, UserId)
......
......@@ -9,8 +9,6 @@ Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.Core.Config.Ini.Mail (
-- * Types
GargMail(..)
......@@ -20,21 +18,13 @@ module Gargantext.Core.Config.Ini.Mail (
-- * Utility functions
, gargMail
, readConfig
-- * Lenses
, mc_mail_from
, mc_mail_host
, mc_mail_login_type
, mc_mail_password
, mc_mail_port
, mc_mail_user
)
where
import Data.Maybe
import Data.Text (unpack)
import Gargantext.Core.Config.Ini.Ini (readIniFile', val)
import Gargantext.Core.Config.Mail (LoginType(..), MailConfig(..))
import Gargantext.Core.Config.Mail (LoginType(..), MailConfig(..), SendEmailType(LogEmailToConsole))
import Gargantext.Prelude
import Network.Mail.Mime (plainPart)
import Network.Mail.SMTP hiding (htmlPart, STARTTLS)
......@@ -55,6 +45,7 @@ readConfig fp = do
, _mc_mail_from = cs $ val' "MAIL_FROM"
, _mc_mail_password = cs $ val' "MAIL_PASSWORD"
, _mc_mail_login_type = read $ cs $ val' "MAIL_LOGIN_TYPE"
, _mc_send_login_emails = LogEmailToConsole
}
......@@ -84,4 +75,3 @@ gargMail (MailConfig {..}) (GargMail { .. }) = do
cc = []
bcc = []
makeLenses ''MailConfig
......@@ -15,6 +15,7 @@ module Gargantext.Core.Config.Mail (
-- * Types
GargMail(..)
, LoginType(..)
, SendEmailType(..)
, MailConfig(..)
-- * Utility functions
......@@ -27,6 +28,7 @@ module Gargantext.Core.Config.Mail (
, mc_mail_password
, mc_mail_port
, mc_mail_user
, mc_send_login_emails
)
where
......@@ -47,7 +49,6 @@ type Name = Text
data LoginType = NoAuth | Normal | SSL | TLS | STARTTLS
deriving (Generic, Eq, Show, Read)
instance FromValue LoginType where
fromValue (Toml.Text' _ t) =
case t of
......@@ -61,12 +62,20 @@ instance FromValue LoginType where
instance ToValue LoginType where
toValue v = toValue (show v :: Text)
data SendEmailType = SendEmailViaAws
| LogEmailToConsole
| WriteEmailToFile
deriving (Show, Read, Enum, Bounded, Generic)
data MailConfig = MailConfig { _mc_mail_host :: !T.Text
, _mc_mail_port :: !PortNumber
, _mc_mail_user :: !T.Text
, _mc_mail_password :: !T.Text
, _mc_mail_login_type :: !LoginType
, _mc_mail_from :: !T.Text
, _mc_send_login_emails :: !SendEmailType
}
deriving (Generic, Show)
instance FromValue MailConfig where
......@@ -77,6 +86,7 @@ instance FromValue MailConfig where
_mc_mail_password <- reqKey "password"
_mc_mail_login_type <- reqKey "login_type"
_mc_mail_from <- reqKey "from"
let _mc_send_login_emails = LogEmailToConsole
return $ MailConfig { _mc_mail_port = fromIntegral port, .. }
instance ToValue MailConfig where
toValue = defaultTableToValue
......
......@@ -56,7 +56,9 @@ instance ToValue NLPConfig where
toValue = defaultTableToValue
instance ToTable NLPConfig where
toTable (NLPConfig { .. }) =
table [ k .= v | (k, v) <- Map.toList _nlp_languages ]
table ([ k .= v | (k, v) <- Map.toList _nlp_languages ]
-- output the default "EN" language as well
<> [ ("EN" :: Text) .= _nlp_default ])
-- readConfig :: SettingsFile -> IO NLPConfig
......
......@@ -17,6 +17,7 @@ module Gargantext.Core.Config.Types
( APIsConfig(..)
, ac_pubmed_api_key
, ac_epo_api_url
, ac_scrapyd_url
, CORSOrigin(..)
, CORSSettings(..)
, FramesConfig(..)
......@@ -33,6 +34,8 @@ module Gargantext.Core.Config.Types
, fc_cors
, fc_microservices
, fc_appPort
, fc_cookie_settings
, defaultCookieSettings
, MicroServicesProxyStatus(..)
, microServicesProxyStatus
, JobsConfig(..)
......@@ -59,7 +62,8 @@ import Control.Monad.Fail (fail)
import Data.Text qualified as T
import Database.PostgreSQL.Simple qualified as PGS
import Gargantext.Prelude
import Servant.Auth.Server (JWTSettings, defaultJWTSettings, readKey, writeKey)
import Servant.Auth.Server (CookieSettings(..), JWTSettings, XsrfCookieSettings(..), defaultJWTSettings, readKey, writeKey)
import Servant.Auth.Server qualified as SAuth
import Servant.Client.Core (BaseUrl, parseBaseUrl, showBaseUrl)
import System.Directory (doesFileExist)
import Toml
......@@ -189,14 +193,20 @@ makeLenses ''FramesConfig
type PortNumber = Int
defaultCookieSettings :: CookieSettings
defaultCookieSettings = SAuth.defaultCookieSettings { cookieXsrfSetting = Just xsrfCookieSetting } -- TODO-SECURITY tune
where
xsrfCookieSetting = SAuth.defaultXsrfCookieSettings { xsrfExcludeGet = True }
-- TODO jwtSettings = defaultJWTSettings
data FrontendConfig =
FrontendConfig { _fc_url :: !Text
, _fc_backend_name :: !Text
FrontendConfig { _fc_url :: !Text
, _fc_backend_name :: !Text
, _fc_url_backend_api :: !Text
, _fc_cors :: !CORSSettings
, _fc_microservices :: !MicroServicesSettings
, _fc_appPort :: !PortNumber
, _fc_cors :: !CORSSettings
, _fc_microservices :: !MicroServicesSettings
, _fc_appPort :: !PortNumber
, _fc_cookie_settings :: !CookieSettings
}
deriving (Generic, Show)
instance FromValue FrontendConfig where
......@@ -207,7 +217,7 @@ instance FromValue FrontendConfig where
_fc_cors <- reqKey "cors"
_fc_microservices <- reqKey "microservices"
let _fc_appPort = 3000
return $ FrontendConfig { .. }
return $ FrontendConfig { _fc_cookie_settings = defaultCookieSettings, .. }
instance ToValue FrontendConfig where
toValue = defaultTableToValue
instance ToTable FrontendConfig where
......@@ -290,18 +300,25 @@ makeLenses ''JobsConfig
data APIsConfig =
APIsConfig { _ac_pubmed_api_key :: !Text
, _ac_epo_api_url :: !Text }
, _ac_epo_api_url :: !Text
, _ac_scrapyd_url :: !BaseUrl }
deriving (Generic, Show)
instance FromValue APIsConfig where
fromValue = parseTableFromValue $ do
_ac_pubmed_api_key <- reqKeyOf "pubmed" $ parseTableFromValue $ reqKey "api_key"
_ac_epo_api_url <- reqKeyOf "epo" $ parseTableFromValue $ reqKey "api_url"
scrapyd_url <- reqKeyOf "scrapyd" $ parseTableFromValue $ reqKey "url"
_ac_scrapyd_url <-
case parseBaseUrl (T.unpack scrapyd_url) of
Nothing -> fail $ "Cannot parse scrapyd base url for: " <> T.unpack scrapyd_url
Just b -> return b
return $ APIsConfig { .. }
instance ToValue APIsConfig where
toValue = defaultTableToValue
instance ToTable APIsConfig where
toTable (APIsConfig { .. }) = table [ "pubmed" .= table [ "api_key" .= _ac_pubmed_api_key ]
, "epo" .= table [ "api_url" .= _ac_epo_api_url ]
, "scrapyd" .= table [ "url" .= showBaseUrl _ac_scrapyd_url ]
]
makeLenses ''APIsConfig
......
......@@ -22,7 +22,7 @@ Implementation use Accelerate library which enables GPU and CPU computation:
-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
{-# OPTIONS_GHC -fno-warn-deprecations -fno-warn-redundant-constraints #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
......
......@@ -81,6 +81,8 @@ where $n_{ij}$ is the cooccurrence between term $i$ and term $j$
)
-}
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
......
......@@ -26,7 +26,6 @@ module Gargantext.Core.NodeStory.Types
, NgramsStatePatch'
, NodeListStory
, ArchiveList
, initNodeListStoryMock
, NodeStoryEnv(..)
, initNodeStory
, nse_getter
......@@ -160,19 +159,6 @@ initArchive = Archive { _a_version = 0
, _a_state = mempty
, _a_history = [] }
initNodeListStoryMock :: NodeListStory
initNodeListStoryMock = NodeStory $ Map.singleton nodeListId archive
where
nodeListId = 0
archive = Archive { _a_version = 0
, _a_state = ngramsTableMap
, _a_history = [] }
ngramsTableMap = Map.singleton Ngrams.NgramsTerms
$ Map.fromList
[ (n ^. ne_ngrams, ngramsElementToRepo n)
| n <- mockTable ^. _NgramsTable
]
----------------------------------------------------------------------
data NodeStoryPoly nid v ngtid ngid nre =
NodeStoryDB { node_id :: !nid
......
......@@ -95,7 +95,7 @@ makeLenses ''I
type ModEntropy i o e = (e -> e) -> i -> o
set_autonomy :: Entropy e => ModEntropy (I e) (I e) e
set_autonomy :: ModEntropy (I e) (I e) e
set_autonomy fe i = i & info_autonomy .~ fe (i ^. info_entropy_var)
set_entropy_var :: Entropy e => Setter e (I e) e e
......
......@@ -61,7 +61,7 @@ randomString num = do
-- | Given a list of items of type 'a', return list with unique items
-- (like List.nub) but tuple-d with their counts in the original list
groupWithCounts :: (Ord a, Eq a) => [a] -> [(a, Int)]
groupWithCounts :: (Eq a, Ord a) => [a] -> [(a, Int)]
groupWithCounts = map f
. List.group
. List.sort
......
......@@ -21,7 +21,6 @@ module Gargantext.Core.Viz.Graph.API
import Control.Lens (set, _Just, (^?), at)
import Data.HashMap.Strict qualified as HashMap
import Gargantext.API.Admin.EnvTypes (GargJob(..), Env)
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Errors.Types ( BackendInternalError )
import Gargantext.API.Ngrams.Tools
import Gargantext.API.Prelude (GargM)
......@@ -267,7 +266,7 @@ recomputeVersions :: HasNodeStory env err m
recomputeVersions nId = recomputeGraph nId Spinglass BridgenessMethod_Basic Nothing Nothing NgramsTerms NgramsTerms False
------------------------------------------------------------
graphClone :: (HasNodeError err, HasSettings env)
graphClone :: (HasNodeError err)
=> UserId
-> NodeId
-> HyperdataGraphAPI
......
......@@ -24,8 +24,7 @@ import Data.Text qualified as T
import Database.PostgreSQL.Simple (Connection)
import Gargantext.API.Admin.EnvTypes (ConcreteJobHandle, GargJob, Mode(Dev), modeToLoggingLevels)
import Gargantext.API.Admin.Orchestrator.Types (JobLog, noJobLog)
import Gargantext.API.Admin.Settings ( devSettings, newPool )
import Gargantext.API.Admin.Types (HasSettings(..), Settings(..))
import Gargantext.API.Admin.Settings ( newPool )
import Gargantext.API.Prelude (GargM)
import Gargantext.Core.AsyncUpdates.CentralExchange qualified as CE
import Gargantext.Core.AsyncUpdates.CentralExchange.Types qualified as CET
......@@ -49,8 +48,7 @@ import System.Log.FastLogger qualified as FL
data WorkerEnv = WorkerEnv
{ _w_env_settings :: !Settings
, _w_env_config :: !GargConfig
{ _w_env_config :: !GargConfig
, _w_env_logger :: !(Logger (GargM WorkerEnv IOException))
, _w_env_pool :: !(Pool Connection)
, _w_env_nodeStory :: !NodeStoryEnv
......@@ -70,12 +68,10 @@ withWorkerEnv settingsFile k = withLoggerHoisted Dev $ \logger -> do
--nodeStory_env <- fromDBNodeStoryEnv (_gc_repofilepath cfg)
pool <- newPool $ _gc_database_config cfg
nodeStory_env <- fromDBNodeStoryEnv pool
let setts = devSettings
pure $ WorkerEnv
{ _w_env_pool = pool
, _w_env_logger = logger
, _w_env_nodeStory = nodeStory_env
, _w_env_settings = setts
, _w_env_config = cfg
, _w_env_mail = _gc_mail_config cfg
, _w_env_nlp = nlpServerMap $ _gc_nlp_config cfg
......@@ -84,9 +80,6 @@ withWorkerEnv settingsFile k = withLoggerHoisted Dev $ \logger -> do
instance HasConfig WorkerEnv where
hasConfig = to _w_env_config
instance HasSettings WorkerEnv where
settings = to _w_env_settings
instance HasLogger (GargM WorkerEnv IOException) where
data instance Logger (GargM WorkerEnv IOException) =
GargWorkerLogger {
......
......@@ -112,7 +112,6 @@ import PUBMED.Types qualified as PUBMED
------------------------------------------------------------------------
-- Imports for upgrade function
import Gargantext.Database.Query.Tree.Error ( HasTreeError )
import Gargantext.API.Admin.Types (HasSettings)
------------------------------------------------------------------------
......@@ -129,7 +128,7 @@ printDataText (DataNew (maybeInt, conduitData)) = do
putText $ show (maybeInt, res)
-- TODO use the split parameter in config file
getDataText :: (HasNodeError err, HasSettings env)
getDataText :: (HasNodeError err)
=> DataOrigin
-> TermType Lang
-> API.RawQuery
......@@ -146,7 +145,7 @@ getDataText (InternalOrigin _) la q _ _ _li = do
ids <- map fst <$> searchDocInDatabase cId (stem (_tt_lang la) GargPorterAlgorithm $ API.getRawQuery q)
pure $ Right $ DataOld ids
getDataText_Debug :: (HasNodeError err, HasSettings env)
getDataText_Debug :: (HasNodeError err)
=> DataOrigin
-> TermType Lang
-> API.RawQuery
......@@ -168,7 +167,6 @@ flowDataText :: forall env err m.
, HasTreeError err
, HasValidationError err
, MonadJobStatus m
, HasSettings env
, HasCentralExchangeNotification env
)
=> User
......@@ -199,7 +197,6 @@ flowAnnuaire :: ( DbCmd' env err m
, HasTreeError err
, HasValidationError err
, MonadJobStatus m
, HasSettings env
, HasCentralExchangeNotification env )
=> MkCorpusUser
-> TermType Lang
......@@ -219,7 +216,6 @@ flowCorpusFile :: ( DbCmd' env err m
, HasTreeError err
, HasValidationError err
, MonadJobStatus m
, HasSettings env
, HasCentralExchangeNotification env )
=> MkCorpusUser
-> Limit -- Limit the number of docs (for dev purpose)
......@@ -250,7 +246,6 @@ flowCorpus :: ( DbCmd' env err m
, HasValidationError err
, FlowCorpus a
, MonadJobStatus m
, HasSettings env
, HasCentralExchangeNotification env )
=> MkCorpusUser
-> TermType Lang
......@@ -271,7 +266,6 @@ flow :: forall env err m a c.
, FlowCorpus a
, MkCorpus c
, MonadJobStatus m
, HasSettings env
, HasCentralExchangeNotification env
)
=> Maybe c
......@@ -309,7 +303,6 @@ addDocumentsToHyperCorpus :: ( DbCmd' env err m
, HasNodeError err
, FlowCorpus document
, MkCorpus corpus
, HasSettings env
)
=> NLPServerConfig
-> Maybe corpus
......@@ -323,7 +316,7 @@ addDocumentsToHyperCorpus ncs mb_hyper la corpusId docs = do
pure ids
------------------------------------------------------------------------
createNodes :: ( DbCmd' env err m, HasNodeError err, HasSettings env
createNodes :: ( DbCmd' env err m, HasNodeError err
, MkCorpus c
, HasCentralExchangeNotification env
)
......@@ -356,7 +349,6 @@ flowCorpusUser :: ( HasNodeError err
, HasTreeError err
, HasNodeStory env err m
, MkCorpus c
, HasSettings env
)
=> Lang
-> User
......@@ -386,7 +378,6 @@ buildSocialList :: ( HasNodeError err
, HasTreeError err
, HasNodeStory env err m
, MkCorpus c
, HasSettings env
)
=> Lang
-> User
......@@ -422,7 +413,6 @@ insertMasterDocs :: ( DbCmd' env err m
, HasNodeError err
, FlowCorpus a
, MkCorpus c
, HasSettings env
)
=> NLPServerConfig
-> Maybe c
......
......@@ -29,7 +29,6 @@ import Control.Lens (view)
import Control.Monad.Random
import Data.Text (splitOn)
import Data.Text qualified as Text
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.Core.Mail
import Gargantext.Core.Mail.Types (HasMail, mailSettings)
import Gargantext.Core.Types.Individu
......@@ -46,7 +45,7 @@ import qualified Data.List.NonEmpty as NE
------------------------------------------------------------------------
-- | Creates a new 'User' from the input 'EmailAddress', which needs to
-- be valid (i.e. a valid username needs to be inferred via 'guessUsername').
newUser :: (CmdM env err m, MonadRandom m, HasNodeError err, HasMail env, HasSettings env)
newUser :: (CmdM env err m, MonadRandom m, HasNodeError err, HasMail env)
=> EmailAddress
-> m UserId
newUser emailAddress = do
......@@ -61,7 +60,7 @@ newUser emailAddress = do
-- This is an internal function and as such it /doesn't/ send out any email
-- notification, and thus lives in the 'DbCmd' effect stack. You may want to
-- use 'newUser' instead for standard Gargantext code.
new_user :: (HasNodeError err, HasSettings env)
new_user :: (HasNodeError err)
=> NewUser GargPassword
-> DBCmd' env err UserId
new_user rq = do
......@@ -73,7 +72,7 @@ new_user rq = do
-- This is an internal function and as such it /doesn't/ send out any email
-- notification, and thus lives in the 'DbCmd' effect stack. You may want to
-- use 'newUsers' instead for standard Gargantext code.
new_users :: (HasNodeError err, HasSettings env)
new_users :: (HasNodeError err)
=> NonEmpty (NewUser GargPassword)
-- ^ A list of users to create.
-> DBCmd' env err (NonEmpty UserId)
......@@ -83,7 +82,7 @@ new_users us = do
mapM (fmap fst . getOrMkRoot) $ NE.map (\u -> UserName (_nu_username u)) us
------------------------------------------------------------------------
newUsers :: (CmdM env err m, MonadRandom m, HasNodeError err, HasMail env, HasSettings env)
newUsers :: (CmdM env err m, MonadRandom m, HasNodeError err, HasMail env)
=> NonEmpty EmailAddress
-> m (NonEmpty UserId)
newUsers us = do
......@@ -109,7 +108,7 @@ guessUserName n = case splitOn "@" n of
_ -> Nothing
------------------------------------------------------------------------
newUsers' :: (HasNodeError err, HasSettings env)
newUsers' :: (HasNodeError err)
=> MailConfig -> NonEmpty (NewUser GargPassword) -> DBCmd' env err (NonEmpty UserId)
newUsers' cfg us = do
us' <- liftBase $ mapM toUserHash us
......
......@@ -14,7 +14,6 @@ module Gargantext.Database.Query.Tree.Root
where
import Control.Arrow (returnA)
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.Core (HasDBid(..))
import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Core.Types.Main (CorpusName)
......@@ -43,7 +42,7 @@ getRootId u = do
getRoot :: User -> DBCmd err [Node HyperdataUser]
getRoot = runOpaQuery . selectRoot
getOrMkRoot :: (HasNodeError err, HasSettings env)
getOrMkRoot :: (HasNodeError err)
=> User
-> DBCmd' env err (UserId, RootId)
getOrMkRoot user = do
......@@ -78,7 +77,7 @@ userFromMkCorpusUser (MkCorpusUserNormalCorpusIds u _cids) = u
userFromMkCorpusUser (MkCorpusUserNormalCorpusName u _cname) = u
getOrMkRootWithCorpus :: (HasNodeError err, MkCorpus a, HasSettings env)
getOrMkRootWithCorpus :: (HasNodeError err, MkCorpus a)
=> MkCorpusUser
-> Maybe a
-> DBCmd' env err (UserId, RootId, CorpusId)
......@@ -120,7 +119,7 @@ mkCorpus cName c rootId userId = do
pure (userId, rootId, corpusId)
mkRoot :: (HasNodeError err, HasSettings env)
mkRoot :: (HasNodeError err)
=> User
-> DBCmd' env err [RootId]
mkRoot user = do
......
......@@ -30,13 +30,12 @@ import Data.Text.Encoding qualified as TE
import GHC.Generics
import Gargantext.API.Admin.Auth.Types (AuthContext)
import Gargantext.API.Admin.EnvTypes
import Gargantext.API.Admin.Types
import Gargantext.API.Node.ShareURL qualified as Share
import Gargantext.API.Routes.Named.Private
import Gargantext.API.Routes.Named.Share (ShareLink(..))
import Gargantext.API.ThrowAll (throwAllRoutes)
import Gargantext.Core.Config (gc_frames, mkProxyUrl, hasConfig)
import Gargantext.Core.Config.Types (f_write_url)
import Gargantext.Core.Config (gc_frames, gc_frontend_config, mkProxyUrl, hasConfig)
import Gargantext.Core.Config.Types (f_write_url, fc_cookie_settings)
import Gargantext.Database.Admin.Types.Node (NodeType(..), NodeId (..))
import Gargantext.Prelude hiding (Handler)
import Network.HTTP.ReverseProxy
......@@ -158,7 +157,7 @@ microServicesProxyApp cache env = genericServeTWithContext identity (server cach
where
cfg :: Context AuthContext
cfg = env ^. env_jwt_settings
:. env ^. settings . cookieSettings
:. env ^. env_config . gc_frontend_config . fc_cookie_settings
:. EmptyContext
server :: ProxyCache -> Env -> ReverseProxyAPI (AsServerT Handler)
......
......@@ -28,6 +28,10 @@ api_key = "no_key"
[apis.epo]
api_url = ""
[apis.scrapyd]
url = "http://localhost:6800"
[external]
[external.frames]
write_url = "URL_TO_CHANGE"
......
......@@ -54,7 +54,6 @@ newTestEnv :: TestEnv -> Logger (GargM Env BackendInternalError) -> Warp.Port ->
newTestEnv testEnv logger port = do
tomlFile@(SettingsFile sf) <- fakeTomlPath
!manager_env <- newTlsManager
let !settings' = devSettings
!config_env <- readConfig tomlFile <&> (gc_frontend_config . fc_appPort) .~ port
prios <- withLogger () $ \ioLogger -> Jobs.readPrios ioLogger (sf <> ".jobs")
......@@ -77,8 +76,7 @@ newTestEnv testEnv logger port = do
-- !dispatcher <- D.dispatcher
pure $ Env
{ _env_settings = settings'
, _env_logger = logger
{ _env_logger = logger
, _env_pool = pool
, _env_nodeStory = nodeStory_env
, _env_manager = manager_env
......
......@@ -76,14 +76,12 @@ setup = do
bootstrapDB db pool gargConfig
ugen <- emptyCounter
test_nodeStory <- fromDBNodeStoryEnv pool
let stgs = devSettings
withLoggerHoisted Mock $ \logger -> do
pure $ TestEnv { test_db = DBHandle pool db
, test_config = gargConfig
, test_nodeStory
, test_usernameGen = ugen
, test_logger = logger
, test_settings = stgs
}
withTestDB :: (TestEnv -> IO ()) -> IO ()
......
......@@ -28,7 +28,6 @@ import Database.Postgres.Temp qualified as Tmp
import Gargantext hiding (to)
import Gargantext.API.Admin.EnvTypes
import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.Admin.Types
import Gargantext.API.Errors.Types
import Gargantext.API.Prelude
import Gargantext.Core.Config (HasConfig(..))
......@@ -38,7 +37,7 @@ import Gargantext.Core.NodeStory
import Gargantext.Database.Prelude (HasConnectionPool(..))
import Gargantext.Database.Query.Table.Node.Error
import Gargantext.Core.Config
import Gargantext.Core.Config.Mail (MailConfig(..), LoginType(NoAuth))
import Gargantext.Core.Config.Mail (MailConfig(..), LoginType(NoAuth), SendEmailType(LogEmailToConsole))
import Gargantext.System.Logging (HasLogger(..), Logger, MonadLogger(..))
import Gargantext.Utils.Jobs
import Network.URI (parseURI)
......@@ -63,7 +62,6 @@ data TestEnv = TestEnv {
, test_nodeStory :: !NodeStoryEnv
, test_usernameGen :: !Counter
, test_logger :: !(Logger (GargM TestEnv BackendInternalError))
, test_settings :: !Settings
}
newtype TestMonad a = TestMonad { runTestMonad :: ReaderT TestEnv IO a }
......@@ -107,16 +105,14 @@ instance HasConnectionPool TestEnv where
instance HasConfig TestEnv where
hasConfig = to test_config
instance HasSettings TestEnv where
settings = to test_settings
instance HasMail TestEnv where
mailSettings = to $ const (MailConfig { _mc_mail_host = "localhost"
, _mc_mail_port = 25
, _mc_mail_user = "test"
, _mc_mail_from = "test@localhost"
, _mc_mail_password = "test"
, _mc_mail_login_type = NoAuth })
mailSettings = to $ const (MailConfig { _mc_mail_host = "localhost"
, _mc_mail_port = 25
, _mc_mail_user = "test"
, _mc_mail_from = "test@localhost"
, _mc_mail_password = "test"
, _mc_mail_login_type = NoAuth
, _mc_send_login_emails = LogEmailToConsole })
instance HasNodeStoryEnv TestEnv where
hasNodeStory = to test_nodeStory
......
This diff is collapsed.
......@@ -17,7 +17,7 @@ import Gargantext.Core.Types.Phylo
import Gargantext.Database.Admin.Types.Node
import Paths_gargantext
import Prelude
import Test.Instances ()
import Test.Instances (genFrontendErr)
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.QuickCheck
......
......@@ -292,10 +292,10 @@ newTestEnv = do
, _gc_jobs = Prelude.error "gc_jobs not needed, but forced somewhere (check StrictData)"
, _gc_secrets = Prelude.error "gc_secrets not needed, but forced somewhere (check StrictData)"
, _gc_apis = Prelude.error "gc_apis not needed, but forced somewhere (check StrictData)"
, _gc_log_level = Prelude.error "gc_log_level not needed, but forced somewhere (check StrictData)"
}
pure $ Env
{ _env_settings = Prelude.error "env_settings not needed, but forced somewhere (check StrictData)"
, _env_logger = Prelude.error "env_logger not needed, but forced somewhere (check StrictData)"
{ _env_logger = Prelude.error "env_logger not needed, but forced somewhere (check StrictData)"
, _env_pool = Prelude.error "env_pool not needed, but forced somewhere (check StrictData)"
, _env_nodeStory = Prelude.error "env_nodeStory not needed, but forced somewhere (check StrictData)"
, _env_manager = testTlsManager
......@@ -305,6 +305,7 @@ newTestEnv = do
, _env_config
, _env_central_exchange = Prelude.error "central exchange not needed, but forced somewhere (check StrictData)"
, _env_dispatcher = Prelude.error "dispatcher not needed, but forced somewhere (check StrictData)"
, _env_jwt_settings = Prelude.error "jwt_settings not needed, but forced somewherer (check StrictData)"
}
testFetchJobStatus :: IO ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment