Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
157
Issues
157
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
0d62c786
Commit
0d62c786
authored
May 19, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BUG] route with bug simplified.
parent
aa2add79
Pipeline
#852
failed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
291 additions
and
4 deletions
+291
-4
API.hs
src/Gargantext/API.hs
+1
-1
BugRoutes.hs
src/Gargantext/API/BugRoutes.hs
+285
-0
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+2
-0
stack.yaml
stack.yaml
+3
-3
No files found.
src/Gargantext/API.hs
View file @
0d62c786
...
...
@@ -66,7 +66,7 @@ import Gargantext.API.Admin.FrontEnd (frontEndServer)
import
Gargantext.API.Admin.Settings
import
Gargantext.API.Ngrams
(
HasRepoSaver
(
..
),
saveRepo
)
import
Gargantext.API.Prelude
import
Gargantext.API.Routes
import
Gargantext.API.
Bug
Routes
import
Gargantext.Prelude
import
Network.HTTP.Types
hiding
(
Query
)
import
Network.Wai
...
...
src/Gargantext/API/BugRoutes.hs
0 → 100644
View file @
0d62c786
{-|
Module : Gargantext.API.Routes
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
---------------------------------------------------------------------
module
Gargantext.API.BugRoutes
where
---------------------------------------------------------------------
import
Control.Concurrent
(
threadDelay
)
import
Data.Text
(
Text
)
import
Data.Validity
import
Gargantext.API.Admin.Auth
(
AuthRequest
,
AuthResponse
,
AuthenticatedUser
(
..
))
import
Gargantext.API.Admin.FrontEnd
(
FrontEndAPI
)
import
Gargantext.API.Prelude
import
Gargantext.API.Node
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Prelude
import
Servant
import
Servant.Auth
as
SA
import
Servant.Auth.Swagger
()
import
Servant.Job.Async
import
Servant.Swagger.UI
import
qualified
Gargantext.API.Node.Corpus.Annuaire
as
Annuaire
import
qualified
Gargantext.API.Node.Corpus.New
as
New
type
GargAPI
=
"api"
:>
Summary
"API "
:>
GargAPIVersion
-- | TODO :<|> Summary "Latest API" :> GargAPI'
type
GargAPIVersion
=
"v1.0"
:>
Summary
"Garg API Version "
:>
GargAPI'
type
GargVersion
=
"version"
:>
Summary
"Backend version"
:>
Get
'[
J
SON
]
Text
type
GargAPI'
=
-- Auth endpoint
"auth"
:>
Summary
"AUTH API"
:>
ReqBody
'[
J
SON
]
AuthRequest
:>
Post
'[
J
SON
]
AuthResponse
:<|>
GargVersion
-- TODO-ACCESS here we want to request a particular header for
-- auth and capabilities.
:<|>
GargPrivateAPI
type
GargPrivateAPI
=
SA
.
Auth
'[
S
A
.
JWT
,
SA
.
Cookie
]
AuthenticatedUser
:>
GargPrivateAPI'
type
GargAdminAPI
-- Roots endpoint
=
"user"
:>
Summary
"First user endpoint"
:>
Roots
:<|>
"nodes"
:>
Summary
"Nodes endpoint"
:>
ReqBody
'[
J
SON
]
[
NodeId
]
:>
NodesAPI
type
GargPrivateAPI'
=
GargAdminAPI
{-
-- Node endpoint
:<|> "node" :> Summary "Node endpoint"
:> Capture "node_id" NodeId
:> NodeAPI HyperdataAny
-- Corpus endpoints
:<|> "corpus" :> Summary "Corpus endpoint"
:> Capture "corpus_id" CorpusId
:> NodeAPI HyperdataCorpus
:<|> "corpus" :> Summary "Corpus endpoint"
:> Capture "node1_id" NodeId
:> "document"
:> Capture "node2_id" NodeId
:> NodeNodeAPI HyperdataAny
:<|> "corpus" :> Capture "node_id" CorpusId
:> Export.API
-- Annuaire endpoint
:<|> "annuaire" :> Summary "Annuaire endpoint"
:> Capture "annuaire_id" AnnuaireId
:> NodeAPI HyperdataAnnuaire
:<|> "annuaire" :> Summary "Contact endpoint"
:> Capture "annuaire_id" NodeId
:> "contact"
:> Capture "contact_id" NodeId
:> NodeNodeAPI HyperdataContact
-- Document endpoint
:<|> "document" :> Summary "Document endpoint"
:> Capture "doc_id" DocId
:> "ngrams" :> TableNgramsApi
-- :<|> "counts" :> Stream GET NewLineFraming '[JSON] Count :> CountAPI
-- TODO-SECURITY
:<|> "count" :> Summary "Count endpoint"
:> ReqBody '[JSON] Query
:> CountAPI
-- Corpus endpoint --> TODO rename s/search/filter/g
:<|> "search" :> Capture "corpus" NodeId
:> SearchPairsAPI
-- TODO move to NodeAPI?
:<|> "graph" :> Summary "Graph endpoint"
:> Capture "graph_id" NodeId
:> GraphAPI
-- TODO move to NodeAPI?
-- Tree endpoint
:<|> "tree" :> Summary "Tree endpoint"
:> Capture "tree_id" NodeId
:> TreeAPI
-- :<|> New.Upload
-}
:<|>
New
.
AddWithQuery
:<|>
New
.
AddWithForm
{-
-- :<|> "annuaire" :> Annuaire.AddWithForm
-- :<|> New.AddWithFile
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
:<|> "lists" :> Summary "List export API"
:> Capture "listId" ListId
:> List.API
:<|> "wait" :> Summary "Wait test"
:> Capture "x" Int
:> WaitAPI -- Get '[JSON] Int
-}
-- /mv/<id>/<id>
-- /merge/<id>/<id>
-- /rename/<id>
-- :<|> "static"
-- :<|> "list" :> Capture "node_id" Int :> NodeAPI
-- :<|> "ngrams" :> Capture "node_id" Int :> NodeAPI
-- :<|> "auth" :> Capture "node_id" Int :> NodeAPI
---------------------------------------------------------------------
type
API
=
SwaggerAPI
:<|>
GargAPI
:<|>
FrontEndAPI
-- | API for serving @swagger.json@
type
SwaggerAPI
=
SwaggerSchemaUI
"swagger-ui"
"swagger.json"
-- | API for serving main operational routes of @gargantext.org@
-- TODO
-- /mv/<id>/<id>
-- /merge/<id>/<id>
-- /rename/<id>
-- :<|> "static"
-- :<|> "list" :> Capture "node_id" Int :> NodeAPI
-- :<|> "ngrams" :> Capture "node_id" Int :> NodeAPI
-- :<|> "auth" :> Capture "node_id" Int :> NodeAPI
---------------------------------------------------------------------
---------------------------------------------------------------------
-- | Server declarations
-- TODO-SECURITY admin only: withAdmin
-- Question: How do we mark admins?
serverGargAdminAPI
::
GargServer
GargAdminAPI
serverGargAdminAPI
=
roots
:<|>
nodesAPI
serverPrivateGargAPI'
::
AuthenticatedUser
->
GargServer
GargPrivateAPI'
serverPrivateGargAPI'
(
AuthenticatedUser
(
NodeId
uid
))
=
serverGargAdminAPI
{-
:<|> nodeAPI (Proxy :: Proxy HyperdataAny) uid
:<|> nodeAPI (Proxy :: Proxy HyperdataCorpus) uid
:<|> nodeNodeAPI (Proxy :: Proxy HyperdataAny) uid
:<|> Export.getCorpus -- uid
:<|> nodeAPI (Proxy :: Proxy HyperdataAnnuaire) uid
:<|> nodeNodeAPI (Proxy :: Proxy HyperdataContact) uid
:<|> withAccess (Proxy :: Proxy TableNgramsApi) Proxy uid
<$> PathNode <*> apiNgramsTableDoc
:<|> count -- TODO: undefined
:<|> withAccess (Proxy :: Proxy SearchPairsAPI) Proxy uid
<$> PathNode <*> searchPairs -- TODO: move elsewhere
:<|> withAccess (Proxy :: Proxy GraphAPI) Proxy uid
<$> PathNode <*> graphAPI uid -- TODO: mock
:<|> withAccess (Proxy :: Proxy TreeAPI) Proxy uid
<$> PathNode <*> treeAPI
-- TODO access
-}
:<|>
addCorpusWithQuery
(
RootId
(
NodeId
uid
))
:<|>
addCorpusWithForm
(
UserDBId
uid
)
{-
-- :<|> addAnnuaireWithForm
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
:<|> List.api
:<|> waitAPI
-}
----------------------------------------------------------------------
-- For Tests
type
WaitAPI
=
Get
'[
J
SON
]
Text
waitAPI
::
Int
->
GargServer
WaitAPI
waitAPI
n
=
do
let
m
=
(
10
::
Int
)
^
(
6
::
Int
)
_
<-
liftBase
$
threadDelay
(
m
*
n
)
pure
$
"Waited: "
<>
(
cs
$
show
n
)
----------------------------------------
addCorpusWithQuery
::
User
->
GargServer
New
.
AddWithQuery
addCorpusWithQuery
user
cid
=
serveJobsAPI
$
JobFunction
(
\
q
log
->
let
log'
x
=
do
printDebug
"addToCorpusWithQuery"
x
liftBase
$
log
x
in
New
.
addToCorpusWithQuery
user
cid
q
log'
)
{-
addWithFile :: GargServer New.AddWithFile
addWithFile cid i f =
serveJobsAPI $
JobFunction (\_i log -> New.addToCorpusWithFile cid i f (liftBase . log))
-}
addCorpusWithForm
::
User
->
GargServer
New
.
AddWithForm
addCorpusWithForm
user
cid
=
serveJobsAPI
$
JobFunction
(
\
i
log
->
let
log'
x
=
do
printDebug
"addToCorpusWithForm"
x
liftBase
$
log
x
in
New
.
addToCorpusWithForm
user
cid
i
log'
)
addAnnuaireWithForm
::
GargServer
Annuaire
.
AddWithForm
addAnnuaireWithForm
cid
=
serveJobsAPI
$
JobFunction
(
\
i
log
->
Annuaire
.
addToAnnuaireWithForm
cid
i
(
liftBase
.
log
))
src/Gargantext/API/Node/Corpus/New.hs
View file @
0d62c786
...
...
@@ -117,6 +117,8 @@ instance Arbitrary ApiInfo where
deriveJSON
(
unPrefix
""
)
'A
p
iInfo
instance
ToSchema
ApiInfo
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"api_"
)
info
::
FlowCmdM
env
err
m
=>
UserId
->
m
ApiInfo
info
_u
=
pure
$
ApiInfo
API
.
externalAPIs
...
...
stack.yaml
View file @
0d62c786
...
...
@@ -3,7 +3,7 @@ flags: {}
extra-package-dbs
:
[]
packages
:
-
.
#
- 'deps/servant-job'
-
'
deps/servant-job'
#- 'deps/clustering-louvain'
docker
:
...
...
@@ -46,8 +46,8 @@ extra-deps:
commit
:
746b4ce0af8f9e600d555ad7e5b2973a940cdad9
#- git: https://github.com/delanoe/servant-job.git
#commit: 7a7b7100e6d132adb4c11b25b2128e6309690ac0
-
git
:
https://github.com/np/servant-job.git
commit
:
3b3270532e04887c6b658670e846a5ef07ef90e5
#
- git: https://github.com/np/servant-job.git
#
commit: 3b3270532e04887c6b658670e846a5ef07ef90e5
-
git
:
https://gitlab.iscpif.fr/gargantext/clustering-louvain.git
commit
:
7d74f96dfea8e51fbab1793cc0429b2fe741f73d
-
git
:
https://github.com/np/patches-map
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment