• Przemyslaw Kaminski's avatar
    Squashed commit of the following: · 03b33383
    Przemyslaw Kaminski authored
    commit be879b1e
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Thu Jan 30 18:22:44 2025 +0100
    
        [ngrams] code fixes according to review
    
        Related MR:
        !378
    
    commit bf89561b
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Wed Jan 22 21:11:47 2025 +0100
    
        [test] notification on node move
    
        Also, some small refactorings.
    
    commit 3d5d74ab
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Wed Jan 22 20:13:44 2025 +0100
    
        [tests] add notifications func comment, fix core/notifications indent
    
    commit b8ea3af2
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Wed Jan 22 19:13:35 2025 +0100
    
        [update-project-dependencies]
    
    commit 1217baf4
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Wed Jan 22 19:09:17 2025 +0100
    
        [tests] notifications: test async notifications for update tree
    
        Related to
        #418
    
    commit 874785e9
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 21 06:06:27 2025 +0100
    
        [refactor] unify Database & ExternalIDs
    
        These types are the same, except for Database.Empty
    
        I managed to have backwards compatibility with the frontend format,
        hence the frontend doesn't need any changes.
    
    commit e7b16520
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 21 06:05:57 2025 +0100
    
        [cabal] upgrade haskell-bee to fix TSRetry and ESRepeat issues
    
    commit ad045ae0
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Jan 20 06:32:49 2025 +0100
    
        [cabal] upgrade haskell-bee tag
    
    commit b3910bb4
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 14 10:56:12 2025 +0100
    
        [test] move some Arbitrary instances to Test/Instances.hs
    
    commit bb282d02
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 14 09:17:23 2025 +0100
    
        [test] WithQuery offline test (with EPO constructor)
    
    commit c0fe2e51
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 14 06:59:45 2025 +0100
    
        [query] move EPO user/token into the datafield
    
        This simplifies the WithQuery structure even more
    
    commit 93586adc
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Jan 13 17:45:42 2025 +0100
    
        [tests] fix WithQuery frontend serialization test
    
        Also, add WithQuery pubmed test (with api_key)
    
    commit bc29319c
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Jan 13 10:13:15 2025 +0100
    
        [ngrams] simplify WithQuery json structure
    
        There is now only a 'datafield' field, no need for duplicated
        'database'.
    
        Related to #441
    
    commit e6fdbee4
    Merge: 95dc32b3 13457ca8
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Fri Jan 10 12:03:59 2025 +0100
    
        Merge branch 'dev' into 224-dev-understanding-ngrams
    
    commit 95dc32b3
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 7 20:01:11 2025 +0100
    
        [ngrams] refactor PubMed DB type (to include Maybe APIKey)
    
    commit baa2491f
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 7 18:09:04 2025 +0100
    
        [refactor] searx search refactoring
    
    commit fcf83bf7
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Tue Jan 7 11:14:03 2025 +0100
    
        [ngrams] more types annotations
    
    commit 0d8a77c4
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 30 16:15:07 2024 +0100
    
        [ngrams, test] refactor: Count -> Terms
    
    commit 85f1dffe
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 30 14:35:05 2024 +0100
    
        [ngrams] refactor opaque Int into TermsWeight newtype
    
    commit a81ea049
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 30 14:34:39 2024 +0100
    
        [CLI] fix limit removal
    
        It wasn't used anyways.
    
    commit d1dfbf79
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 30 11:35:41 2024 +0100
    
        [ngrams] one more simplification in ngramsByDoc'
    
    commit fcb48b8f
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 30 11:33:33 2024 +0100
    
        [ngrams] some more simplification of ngramsByDoc'
    
    commit ab7c1766
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 30 11:00:19 2024 +0100
    
        [ngrams, tests] understanding ngramsByDoc better
    
    commit 35c2d0b0
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 23 21:20:29 2024 +0100
    
        [ngrams] small simplification to docNgrams function
    
    commit 161ac077
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Mon Dec 23 18:35:59 2024 +0100
    
        [ngrams] annotate types of ngrams algorithms
    
    commit 08c7c91c
    Author: Przemysław Kaminski <pk@intrepidus.pl>
    Date:   Sat Dec 21 09:45:00 2024 +0100
    
        [ngrams] improve function documentation, add types, add unit tests
    
        I want to understand ngrams algorithms better.
    03b33383
Types.hs 3.36 KB
{-|
Module      : CLI.Types
Description : CLI types
Copyright   : (c) CNRS, 2017-Present
License     : AGPL + CECILL v3
Maintainer  : team@gargantext.org
Stability   : experimental
Portability : POSIX

-}


{-# LANGUAGE DuplicateRecordFields #-}

module CLI.Types where

import Data.String
import Data.Text (Text)
import Gargantext.API.Admin.EnvTypes (Mode)
import Gargantext.Core.Config.Types (SettingsFile(..))
import Gargantext.Core.Types (NodeId)
import Prelude

newtype CorpusFile = CorpusFile { _CorpusFile :: FilePath }
  deriving (Show, Eq, IsString)

newtype TermListFile = TermListFile { _TermsListFile :: FilePath }
  deriving (Show, Eq, IsString)

newtype OutputFile = OutputFile { _OutputFile :: FilePath }
  deriving (Show, Eq, IsString)

data ObfuscateDBArgs = ObfuscateDBArgs {
    dbHost     :: !Text
  , dbPort     :: !Int
  , dbName     :: !Text
  , dbUser     :: !Text
  , dbPassword :: !Text
  } deriving (Show, Eq)

data AdminArgs = AdminArgs
  { settingsPath :: !SettingsFile
  , emails       :: [String]
  } deriving (Show, Eq)

data ImportFunction
  = IF_corpus
  | IF_corpusTsvHal
  | IF_annuaire
  deriving (Show, Eq, Enum, Bounded)

data ImportArgs = ImportArgs
  { imp_function :: !ImportFunction
  , imp_user     :: !Text
  , imp_name     :: !Text
  , imp_settings :: !SettingsFile
  , imp_corpus_path :: !FilePath
  } deriving (Show, Eq)

data IniArgs = IniArgs
  { ini_path  :: !(Maybe FilePath)
  , toml_path :: !(Maybe FilePath)
  , dry_run   :: !Bool
  } deriving (Show, Eq)

data InitArgs = InitArgs
  { init_settings :: !SettingsFile
  } deriving (Show, Eq)

data InvitationsArgs = InvitationsArgs
  { inv_settings :: !SettingsFile
  , inv_user    :: !Text
  , inv_node_id :: !NodeId
  , inv_email   :: !Text
  } deriving (Show, Eq)

data PhyloArgs = PhyloArgs
  { phylo_config :: !FilePath
  } deriving (Show, Eq)

data UpgradeArgs = UpgradeArgs
  { upgrade_settings :: !SettingsFile
  } deriving (Show, Eq)

data GoldenFileDiffArgs = GoldenFileDiffArgs
  { gdf_expected :: !FilePath
  , gdf_actual   :: !FilePath
  } deriving (Show, Eq)

data CLIRoutes
  = CLIR_list
  | CLIR_export FilePath
  deriving (Show, Eq)

data CLIServer
  = CLIS_start ServerArgs
  | CLIS_startAll ServerArgs
  | CLIS_version
  deriving (Show, Eq)

data ServerArgs = ServerArgs
  { server_mode :: !Mode
  , server_port :: !Int
  , server_toml :: !SettingsFile }
  deriving (Show, Eq)

data CLIWorker
  = CLIW_run WorkerArgs
  | CLIW_runAll WorkerAllArgs
  | CLIW_stats WorkerStatsArgs
  deriving (Show, Eq)

data WorkerArgs = WorkerArgs
  { worker_toml       :: !SettingsFile
  , worker_name       :: !Text
  , worker_run_single :: !Bool
  } deriving (Show, Eq)

data WorkerAllArgs = WorkerAllArgs
  { worker_toml       :: !SettingsFile
  } deriving (Show, Eq)

data WorkerStatsArgs = WorkerStatsArgs
  { ws_toml       :: !SettingsFile
  } deriving (Show, Eq)

data CLICmd
  = CCMD_admin !AdminArgs
  | CCMD_clean_csv_corpus
  | CCMD_filter_terms_and_cooc !CorpusFile !TermListFile !OutputFile
  | CCMD_golden_file_diff !GoldenFileDiffArgs
  | CCMD_import !ImportArgs
  | CCMD_ini !IniArgs
  | CCMD_init !InitArgs
  | CCMD_invitations !InvitationsArgs
  | CCMD_obfuscate_db !ObfuscateDBArgs
  | CCMD_phylo !PhyloArgs
  | CCMD_phylo_profile
  | CCMD_routes !CLIRoutes
  | CCMD_server !CLIServer
  | CCMD_upgrade !UpgradeArgs
  | CCMD_worker !CLIWorker
  deriving (Show, Eq)

data CLI =
  CLISub CLICmd
  deriving (Show, Eq)