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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
65750c75
Commit
65750c75
authored
May 28, 2024
by
Alfredo Di Napoli
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old (unnamed) API
This beefy commit removes the old (unnamed) Servant API.
parent
6240e820
Changes
50
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
322 additions
and
918 deletions
+322
-918
Main.hs
bin/gargantext-invitations/Main.hs
+2
-1
cabal.project.freeze
cabal.project.freeze
+1
-1
gargantext.cabal
gargantext.cabal
+6
-1
Auth.hs
src/Gargantext/API/Admin/Auth.hs
+1
-14
Context.hs
src/Gargantext/API/Context.hs
+0
-3
Members.hs
src/Gargantext/API/Members.hs
+0
-3
Metrics.hs
src/Gargantext/API/Metrics.hs
+0
-53
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+2
-47
List.hs
src/Gargantext/API/Ngrams/List.hs
+1
-34
Node.hs
src/Gargantext/API/Node.hs
+10
-120
Contact.hs
src/Gargantext/API/Node/Contact.hs
+1
-11
Export.hs
src/Gargantext/API/Node/Corpus/Export.hs
+2
-9
Types.hs
src/Gargantext/API/Node/Document/Export/Types.hs
+1
-10
DocumentUpload.hs
src/Gargantext/API/Node/DocumentUpload.hs
+5
-43
Types.hs
src/Gargantext/API/Node/DocumentUpload/Types.hs
+39
-0
DocumentsFromWriteNodes.hs
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
+5
-24
Types.hs
src/Gargantext/API/Node/DocumentsFromWriteNodes/Types.hs
+23
-0
FrameCalcUpload.hs
src/Gargantext/API/Node/FrameCalcUpload.hs
+5
-25
Types.hs
src/Gargantext/API/Node/FrameCalcUpload/Types.hs
+20
-0
Get.hs
src/Gargantext/API/Node/Get.hs
+0
-16
Types.hs
src/Gargantext/API/Node/Phylo/Export/Types.hs
+1
-10
Share.hs
src/Gargantext/API/Node/Share.hs
+5
-33
Types.hs
src/Gargantext/API/Node/Share/Types.hs
+25
-0
ShareURL.hs
src/Gargantext/API/Node/ShareURL.hs
+0
-6
Update.hs
src/Gargantext/API/Node/Update.hs
+6
-86
Types.hs
src/Gargantext/API/Node/Update/Types.hs
+85
-0
Routes.hs
src/Gargantext/API/Routes.hs
+1
-201
Named.hs
src/Gargantext/API/Routes/Named.hs
+1
-1
Document.hs
src/Gargantext/API/Routes/Named/Document.hs
+2
-2
FrameCalc.hs
src/Gargantext/API/Routes/Named/FrameCalc.hs
+1
-1
Node.hs
src/Gargantext/API/Routes/Named/Node.hs
+1
-1
Private.hs
src/Gargantext/API/Routes/Named/Private.hs
+0
-1
Share.hs
src/Gargantext/API/Routes/Named/Share.hs
+1
-1
Viz.hs
src/Gargantext/API/Routes/Named/Viz.hs
+2
-0
Search.hs
src/Gargantext/API/Search.hs
+1
-17
Viz.hs
src/Gargantext/API/Server/Named/Viz.hs
+1
-1
Swagger.hs
src/Gargantext/API/Swagger.hs
+6
-3
Table.hs
src/Gargantext/API/Table.hs
+0
-19
Types.hs
src/Gargantext/API/Viz/Types.hs
+1
-1
API.hs
src/Gargantext/Core/Viz/Graph/API.hs
+4
-28
API.hs
src/Gargantext/Core/Viz/Phylo/API.hs
+0
-34
Authentication.hs
test/Test/API/Authentication.hs
+3
-3
Errors.hs
test/Test/API/Errors.hs
+10
-8
Private.hs
test/Test/API/Private.hs
+10
-11
Routes.hs
test/Test/API/Routes.hs
+24
-25
UpdateList.hs
test/Test/API/UpdateList.hs
+4
-4
Distance.hs
test/Test/Graph/Distance.hs
+0
-2
Types.hs
test/Test/Types.hs
+1
-1
Utils.hs
test/Test/Utils.hs
+0
-1
Crypto.hs
test/Test/Utils/Crypto.hs
+2
-2
No files found.
bin/gargantext-invitations/Main.hs
View file @
65750c75
...
@@ -24,7 +24,8 @@ import Gargantext.Database.Prelude (CmdRandom)
...
@@ -24,7 +24,8 @@ import Gargantext.Database.Prelude (CmdRandom)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Prelude.Config
(
readConfig
)
import
Gargantext.Prelude.Config
(
readConfig
)
import
Prelude
(
read
)
import
Prelude
(
read
)
import
qualified
Gargantext.API.Node.Share
as
Share
import
Gargantext.API.Node.Share.Types
qualified
as
Share
import
Gargantext.API.Node.Share
qualified
as
Share
main
::
IO
()
main
::
IO
()
main
=
do
main
=
do
...
...
cabal.project.freeze
View file @
65750c75
...
@@ -499,7 +499,7 @@ constraints: any.Cabal ==3.8.1.0,
...
@@ -499,7 +499,7 @@ constraints: any.Cabal ==3.8.1.0,
any.servant-multipart ==0.12.1,
any.servant-multipart ==0.12.1,
any.servant-multipart-api ==0.12.1,
any.servant-multipart-api ==0.12.1,
any.servant-server ==0.20,
any.servant-server ==0.20,
any.servant-swagger ==1.
1.11
,
any.servant-swagger ==1.
2
,
any.servant-swagger-ui ==0.3.5.5.0.0,
any.servant-swagger-ui ==0.3.5.5.0.0,
any.servant-swagger-ui-core ==0.3.5,
any.servant-swagger-ui-core ==0.3.5,
any.servant-xml-conduit ==0.1.0.4,
any.servant-xml-conduit ==0.1.0.4,
...
...
gargantext.cabal
View file @
65750c75
...
@@ -134,9 +134,11 @@ library
...
@@ -134,9 +134,11 @@ library
Gargantext.API.Node.Corpus.Update
Gargantext.API.Node.Corpus.Update
Gargantext.API.Node.File
Gargantext.API.Node.File
Gargantext.API.Node.Share
Gargantext.API.Node.Share
Gargantext.API.Node.Share.Types
Gargantext.API.Node.ShareURL
Gargantext.API.Node.ShareURL
Gargantext.API.Node.Types
Gargantext.API.Node.Types
Gargantext.API.Node.Update
Gargantext.API.Node.Update
Gargantext.API.Node.Update.Types
Gargantext.API.Prelude
Gargantext.API.Prelude
Gargantext.API.Routes
Gargantext.API.Routes
Gargantext.API.Routes.Named
Gargantext.API.Routes.Named
...
@@ -304,8 +306,11 @@ library
...
@@ -304,8 +306,11 @@ library
Gargantext.API.Node.Phylo.Export
Gargantext.API.Node.Phylo.Export
Gargantext.API.Node.Phylo.Export.Types
Gargantext.API.Node.Phylo.Export.Types
Gargantext.API.Node.DocumentUpload
Gargantext.API.Node.DocumentUpload
Gargantext.API.Node.DocumentUpload.Types
Gargantext.API.Node.DocumentsFromWriteNodes
Gargantext.API.Node.DocumentsFromWriteNodes
Gargantext.API.Node.DocumentsFromWriteNodes.Types
Gargantext.API.Node.FrameCalcUpload
Gargantext.API.Node.FrameCalcUpload
Gargantext.API.Node.FrameCalcUpload.Types
Gargantext.API.Node.Get
Gargantext.API.Node.Get
Gargantext.API.Node.New
Gargantext.API.Node.New
Gargantext.API.Node.New.Types
Gargantext.API.Node.New.Types
...
@@ -635,7 +640,7 @@ library
...
@@ -635,7 +640,7 @@ library
, servant-job >= 0.2.0.0
, servant-job >= 0.2.0.0
, servant-multipart ^>= 0.12.1
, servant-multipart ^>= 0.12.1
, servant-server >= 0.18.3 && < 0.20
, servant-server >= 0.18.3 && < 0.20
, servant-swagger
^>= 1.1.10
, servant-swagger
>= 1.2
, servant-swagger-ui ^>= 0.3.5.3.5.0
, servant-swagger-ui ^>= 0.3.5.3.5.0
, servant-xml-conduit >= 0.1.0.4
, servant-xml-conduit >= 0.1.0.4
, simple-reflect ^>= 0.3.3
, simple-reflect ^>= 0.3.3
...
...
src/Gargantext/API/Admin/Auth.hs
View file @
65750c75
...
@@ -38,9 +38,8 @@ module Gargantext.API.Admin.Auth
...
@@ -38,9 +38,8 @@ module Gargantext.API.Admin.Auth
,
forgotPasswordAsync
,
forgotPasswordAsync
,
withAccess
,
withAccess
,
withNamedAccess
,
withNamedAccess
,
ForgotPasswordAPI
,
ForgotPasswordAsyncParams
,
ForgotPasswordAsyncParams
,
ForgotPasswordAsyncAPI
)
)
where
where
...
@@ -51,7 +50,6 @@ import Data.UUID (UUID, fromText, toText)
...
@@ -51,7 +50,6 @@ import Data.UUID (UUID, fromText, toText)
import
Data.UUID.V4
(
nextRandom
)
import
Data.UUID.V4
(
nextRandom
)
import
Gargantext.API.Admin.Auth.Types
import
Gargantext.API.Admin.Auth.Types
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Admin.Types
import
Gargantext.API.Admin.Types
import
Gargantext.API.Auth.PolicyCheck
import
Gargantext.API.Auth.PolicyCheck
import
Gargantext.API.Prelude
(
authenticationError
,
HasServerError
,
GargServerC
,
_ServerError
,
GargM
,
IsGargServer
)
import
Gargantext.API.Prelude
(
authenticationError
,
HasServerError
,
GargServerC
,
_ServerError
,
GargM
,
IsGargServer
)
...
@@ -232,14 +230,6 @@ User can invite User in Team as NodeNode only if Team in his parents.
...
@@ -232,14 +230,6 @@ User can invite User in Team as NodeNode only if Team in his parents.
All users can access to the Team folder as if they were owner.
All users can access to the Team folder as if they were owner.
-}
-}
type
ForgotPasswordAPI
=
Summary
"Forgot password POST API"
:>
ReqBody
'[
J
SON
]
ForgotPasswordRequest
:>
Post
'[
J
SON
]
ForgotPasswordResponse
:<|>
Summary
"Forgot password GET API"
:>
QueryParam
"uuid"
Text
:>
Get
'[
J
SON
]
ForgotPasswordGet
forgotPassword
::
IsGargServer
env
err
m
=>
Named
.
ForgotPasswordAPI
(
AsServerT
m
)
forgotPassword
::
IsGargServer
env
err
m
=>
Named
.
ForgotPasswordAPI
(
AsServerT
m
)
-- => ForgotPasswordRequest -> Cmd' env err ForgotPasswordResponse
-- => ForgotPasswordRequest -> Cmd' env err ForgotPasswordResponse
forgotPassword
=
Named
.
ForgotPasswordAPI
forgotPassword
=
Named
.
ForgotPasswordAPI
...
@@ -334,9 +324,6 @@ generateForgotPasswordUUID = do
...
@@ -334,9 +324,6 @@ generateForgotPasswordUUID = do
-- NOTE THe async endpoint is better for the "forget password"
-- NOTE THe async endpoint is better for the "forget password"
-- request, because the delay in email sending etc won't reveal to
-- request, because the delay in email sending etc won't reveal to
-- malicious users emails of our users in the db
-- malicious users emails of our users in the db
type
ForgotPasswordAsyncAPI
=
Summary
"Forgot password asnc"
:>
AsyncJobs
JobLog
'[
J
SON
]
ForgotPasswordAsyncParams
JobLog
forgotPasswordAsync
::
Named
.
ForgotPasswordAsyncAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
forgotPasswordAsync
::
Named
.
ForgotPasswordAsyncAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
forgotPasswordAsync
=
Named
.
ForgotPasswordAsyncAPI
$
forgotPasswordAsync
=
Named
.
ForgotPasswordAsyncAPI
$
serveJobsAPI
ForgotPasswordJob
$
\
jHandle
p
->
forgotPasswordAsync'
p
jHandle
serveJobsAPI
ForgotPasswordJob
$
\
jHandle
p
->
forgotPasswordAsync'
p
jHandle
...
...
src/Gargantext/API/Context.hs
View file @
65750c75
...
@@ -34,9 +34,6 @@ import Gargantext.API.Routes.Named.Context qualified as Named
...
@@ -34,9 +34,6 @@ import Gargantext.API.Routes.Named.Context qualified as Named
-------------------------------------------------------------------
-------------------------------------------------------------------
-- TODO use Context instead of Node
-- TODO use Context instead of Node
type
ContextAPI
a
=
Get
'[
J
SON
]
(
Node
a
)
------------------------------------------------------------------------
-- TODO NodeAPI -> ContextAPI
-- TODO NodeAPI -> ContextAPI
contextAPI
::
(
IsGargServer
env
err
m
contextAPI
::
(
IsGargServer
env
err
m
,
JSONB
a
,
JSONB
a
...
...
src/Gargantext/API/Members.hs
View file @
65750c75
...
@@ -16,11 +16,8 @@ import Gargantext.Database.Action.Share (membersOf)
...
@@ -16,11 +16,8 @@ import Gargantext.Database.Action.Share (membersOf)
import
Gargantext.Database.Admin.Types.Node
(
NodeType
(
NodeTeam
))
import
Gargantext.Database.Admin.Types.Node
(
NodeType
(
NodeTeam
))
import
Gargantext.Database.Query.Table.Node
(
getNodesIdWithType
)
import
Gargantext.Database.Query.Table.Node
(
getNodesIdWithType
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Servant
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
type
MembersAPI
=
Get
'[
J
SON
]
[
Text
]
members
::
IsGargServer
err
env
m
=>
Named
.
MembersAPI
(
AsServerT
m
)
members
::
IsGargServer
err
env
m
=>
Named
.
MembersAPI
(
AsServerT
m
)
members
=
Named
.
MembersAPI
getMembers
members
=
Named
.
MembersAPI
getMembers
...
...
src/Gargantext/API/Metrics.hs
View file @
65750c75
...
@@ -47,22 +47,6 @@ import Servant
...
@@ -47,22 +47,6 @@ import Servant
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
-------------------------------------------------------------
-------------------------------------------------------------
-- | Scatter metrics API
type
ScatterAPI
=
Summary
"SepGen IncExc metrics"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParam
"limit"
Limit
:>
Get
'[
J
SON
]
(
HashedResponse
Metrics
)
:<|>
Summary
"Scatter update"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParam
"limit"
Limit
:>
Post
'[
J
SON
]
()
:<|>
"hash"
:>
Summary
"Scatter Hash"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
Get
'[
J
SON
]
Text
scatterApi
::
IsGargServer
err
env
m
=>
NodeId
->
Named
.
ScatterAPI
(
AsServerT
m
)
scatterApi
::
IsGargServer
err
env
m
=>
NodeId
->
Named
.
ScatterAPI
(
AsServerT
m
)
scatterApi
id'
=
Named
.
ScatterAPI
scatterApi
id'
=
Named
.
ScatterAPI
{
sepGenEp
=
getScatter
id'
{
sepGenEp
=
getScatter
id'
...
@@ -143,23 +127,6 @@ getScatterHash cId maybeListId tabType = do
...
@@ -143,23 +127,6 @@ getScatterHash cId maybeListId tabType = do
-------------------------------------------------------------
-------------------------------------------------------------
-- | Chart metrics API
type
ChartApi
=
Summary
" Chart API"
:>
QueryParam
"from"
UTCTime
:>
QueryParam
"to"
UTCTime
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
Get
'[
J
SON
]
(
HashedResponse
(
ChartMetrics
Histo
))
:<|>
Summary
"Chart update"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParam
"limit"
Limit
:>
Post
'[
J
SON
]
()
:<|>
"hash"
:>
Summary
"Chart Hash"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
Get
'[
J
SON
]
Text
chartApi
::
IsGargServer
err
env
m
=>
NodeId
->
Named
.
ChartAPI
(
AsServerT
m
)
chartApi
::
IsGargServer
err
env
m
=>
NodeId
->
Named
.
ChartAPI
(
AsServerT
m
)
chartApi
id'
=
Named
.
ChartAPI
chartApi
id'
=
Named
.
ChartAPI
{
getChartEp
=
getChart
id'
{
getChartEp
=
getChart
id'
...
@@ -321,26 +288,6 @@ getPieHash cId maybeListId tabType = do
...
@@ -321,26 +288,6 @@ getPieHash cId maybeListId tabType = do
-------------------------------------------------------------
-------------------------------------------------------------
-- | Tree metrics API
-- | Tree metrics API
type
TreeApi
=
Summary
" Tree API"
:>
QueryParam
"from"
UTCTime
:>
QueryParam
"to"
UTCTime
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"listType"
ListType
:>
Get
'[
J
SON
]
(
HashedResponse
(
ChartMetrics
(
Vector
NgramsTree
)))
:<|>
Summary
"Tree Chart update"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"listType"
ListType
:>
Post
'[
J
SON
]
()
:<|>
"hash"
:>
Summary
"Tree Hash"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"listType"
ListType
:>
Get
'[
J
SON
]
Text
treeApi
::
IsGargServer
err
env
m
=>
NodeId
->
Named
.
TreeAPI
(
AsServerT
m
)
treeApi
::
IsGargServer
err
env
m
=>
NodeId
->
Named
.
TreeAPI
(
AsServerT
m
)
treeApi
id'
=
Named
.
TreeAPI
treeApi
id'
=
Named
.
TreeAPI
{
treeChartEp
=
getTree
id'
{
treeChartEp
=
getTree
id'
...
...
src/Gargantext/API/Ngrams.hs
View file @
65750c75
...
@@ -26,11 +26,8 @@ add get
...
@@ -26,11 +26,8 @@ add get
module
Gargantext.API.Ngrams
module
Gargantext.API.Ngrams
(
TableNgramsApi
(
,
TableNgramsApiGet
commitStatePatch
,
TableNgramsApiPut
,
commitStatePatch
,
searchTableNgrams
,
searchTableNgrams
,
getTableNgrams
,
getTableNgrams
...
@@ -94,7 +91,6 @@ import Data.Set qualified as Set
...
@@ -94,7 +91,6 @@ import Data.Set qualified as Set
import
Data.Text
(
isInfixOf
,
toLower
,
unpack
)
import
Data.Text
(
isInfixOf
,
toLower
,
unpack
)
import
Data.Text.Lazy.IO
as
DTL
(
writeFile
)
import
Data.Text.Lazy.IO
as
DTL
(
writeFile
)
import
Formatting
(
hprint
,
int
,
(
%
))
import
Formatting
(
hprint
,
int
,
(
%
))
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Ngrams.Tools
(
getNodeStory
)
import
Gargantext.API.Ngrams.Tools
(
getNodeStory
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.NodeStory
(
ArchiveList
,
HasNodeStory
,
HasNodeArchiveStoryImmediateSaver
(
..
),
HasNodeStoryImmediateSaver
(
..
),
NgramsStatePatch
'
,
a_history
,
a_state
,
a_version
,
currentVersion
)
import
Gargantext.Core.NodeStory
(
ArchiveList
,
HasNodeStory
,
HasNodeArchiveStoryImmediateSaver
(
..
),
HasNodeStoryImmediateSaver
(
..
),
NgramsStatePatch
'
,
a_history
,
a_state
,
a_version
,
currentVersion
)
...
@@ -106,7 +102,6 @@ import Gargantext.Database.Query.Table.Ngrams ( text2ngrams, insertNgrams )
...
@@ -106,7 +102,6 @@ import Gargantext.Database.Query.Table.Ngrams ( text2ngrams, insertNgrams )
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Prelude
hiding
(
log
,
to
,
toLower
,
(
%
),
isInfixOf
)
import
Gargantext.Prelude
hiding
(
log
,
to
,
toLower
,
(
%
),
isInfixOf
)
import
Gargantext.Prelude.Clock
(
hasTime
,
getTime
)
import
Gargantext.Prelude.Clock
(
hasTime
,
getTime
)
import
Servant
hiding
(
Patch
)
import
Text.Collate
qualified
as
Unicode
import
Text.Collate
qualified
as
Unicode
...
@@ -591,46 +586,6 @@ needsScores (Just ScoreAsc) = True
...
@@ -591,46 +586,6 @@ needsScores (Just ScoreAsc) = True
needsScores
(
Just
ScoreDesc
)
=
True
needsScores
(
Just
ScoreDesc
)
=
True
needsScores
_
=
False
needsScores
_
=
False
type
TableNgramsApiGet
=
Summary
" Table Ngrams API Get"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
QueryParamR
"limit"
Limit
:>
QueryParam
"offset"
Offset
:>
QueryParam
"listType"
ListType
:>
QueryParam
"minTermSize"
MinSize
:>
QueryParam
"maxTermSize"
MaxSize
:>
QueryParam
"orderBy"
OrderBy
:>
QueryParam
"search"
Text
:>
Get
'[
J
SON
]
(
VersionedWithCount
NgramsTable
)
type
TableNgramsApiPut
=
Summary
" Table Ngrams API Change"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
ReqBody
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
:>
Put
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
type
RecomputeScoresNgramsApiGet
=
Summary
" Recompute scores for ngrams table"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
"recompute"
:>
Post
'[
J
SON
]
Int
type
TableNgramsApiGetVersion
=
Summary
" Table Ngrams API Get Version"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
Get
'[
J
SON
]
Version
type
TableNgramsApi
=
TableNgramsApiGet
:<|>
TableNgramsApiPut
:<|>
RecomputeScoresNgramsApiGet
:<|>
"version"
:>
TableNgramsApiGetVersion
:<|>
TableNgramsAsyncApi
type
TableNgramsAsyncApi
=
Summary
"Table Ngrams Async API"
:>
"async"
:>
"charts"
:>
"update"
:>
AsyncJobs
JobLog
'[
J
SON
]
UpdateTableNgramsCharts
JobLog
getTableNgramsCorpus
::
(
HasNodeStory
env
err
m
getTableNgramsCorpus
::
(
HasNodeStory
env
err
m
,
HasNodeError
err
)
,
HasNodeError
err
)
=>
NodeId
=>
NodeId
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
65750c75
...
@@ -28,15 +28,13 @@ import Data.Text (concat, pack, splitOn)
...
@@ -28,15 +28,13 @@ import Data.Text (concat, pack, splitOn)
import
Data.Vector
(
Vector
)
import
Data.Vector
(
Vector
)
import
Data.Vector
qualified
as
Vec
import
Data.Vector
qualified
as
Vec
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.Orchestrator.Types
(
AsyncJobs
,
JobLog
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Ngrams
(
setListNgrams
)
import
Gargantext.API.Ngrams
(
setListNgrams
)
import
Gargantext.API.Ngrams.List.Types
import
Gargantext.API.Ngrams.List.Types
import
Gargantext.API.Ngrams.Prelude
(
getNgramsList
)
import
Gargantext.API.Ngrams.Prelude
(
getNgramsList
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Prelude
(
Garg
Server
,
Garg
M
,
serverError
,
HasServerError
)
import
Gargantext.API.Prelude
(
GargM
,
serverError
,
HasServerError
)
import
Gargantext.API.Routes.Named.List
qualified
as
Named
import
Gargantext.API.Routes.Named.List
qualified
as
Named
import
Gargantext.API.Types
(
HTML
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeStory
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeStory
)
import
Gargantext.Core.Text.Ngrams
(
Ngrams
,
NgramsType
(
NgramsTerms
))
import
Gargantext.Core.Text.Ngrams
(
Ngrams
,
NgramsType
(
NgramsTerms
))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
...
@@ -48,24 +46,12 @@ import Gargantext.Database.Schema.Node (_node_parent_id)
...
@@ -48,24 +46,12 @@ import Gargantext.Database.Schema.Node (_node_parent_id)
import
Gargantext.Database.Types
(
Indexed
(
..
))
import
Gargantext.Database.Types
(
Indexed
(
..
))
import
Gargantext.Prelude
hiding
(
concat
,
toList
)
import
Gargantext.Prelude
hiding
(
concat
,
toList
)
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Servant
qualified
as
GUS
import
Prelude
qualified
import
Prelude
qualified
import
Protolude
qualified
as
P
import
Protolude
qualified
as
P
import
Servant
import
Servant
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
------------------------------------------------------------------------
type
GETAPI
=
Summary
"Get List"
:>
"lists"
:>
Capture
"listId"
ListId
:>
(
"json"
:>
Get
'[
J
SON
,
HTML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
:<|>
"json.zip"
:>
Get
'[
G
US
.
ZIP
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsListZIP
)
:<|>
"csv"
:>
Get
'[
G
US
.
CSV
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsTableMap
)
)
getAPI
::
Named
.
GETAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
getAPI
::
Named
.
GETAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
getAPI
=
Named
.
GETAPI
$
\
listId
->
Named
.
ListEndpoints
getAPI
=
Named
.
GETAPI
$
\
listId
->
Named
.
ListEndpoints
{
listJSONEp
=
getJson
listId
{
listJSONEp
=
getJson
listId
...
@@ -77,15 +63,6 @@ getAPI = Named.GETAPI $ \listId -> Named.ListEndpoints
...
@@ -77,15 +63,6 @@ getAPI = Named.GETAPI $ \listId -> Named.ListEndpoints
-- JSON API
-- JSON API
--
--
----------------------
type
JSONAPI
=
Summary
"Update List"
:>
"lists"
:>
Capture
"listId"
ListId
:>
"add"
:>
"form"
:>
"async"
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithJsonFile
JobLog
jsonAPI
::
Named
.
JSONAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
jsonAPI
::
Named
.
JSONAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
jsonAPI
=
jsonPostAsync
jsonAPI
=
jsonPostAsync
...
@@ -165,16 +142,6 @@ postAsyncJSON l ngramsList jobHandle = do
...
@@ -165,16 +142,6 @@ postAsyncJSON l ngramsList jobHandle = do
-- CSV API
-- CSV API
--
--
----------------------
type
CSVAPI
=
Summary
"Update List (legacy v3 CSV)"
:>
"lists"
:>
Capture
"listId"
ListId
:>
"csv"
:>
"add"
:>
"form"
:>
"async"
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithTextFile
JobLog
csvAPI
::
Named
.
CSVAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
csvAPI
::
Named
.
CSVAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
csvAPI
=
csvPostAsync
csvAPI
=
csvPostAsync
...
...
src/Gargantext/API/Node.hs
View file @
65750c75
This diff is collapsed.
Click to expand it.
src/Gargantext/API/Node/Contact.hs
View file @
65750c75
...
@@ -23,10 +23,9 @@ module Gargantext.API.Node.Contact
...
@@ -23,10 +23,9 @@ module Gargantext.API.Node.Contact
import
Conduit
(
yield
)
import
Conduit
(
yield
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
(
AuthenticatedUser
)
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
(
AuthenticatedUser
)
)
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Node
(
nodeNodeAPI
,
NodeNodeAPI
)
import
Gargantext.API.Node
(
nodeNodeAPI
)
import
Gargantext.API.Node.Contact.Types
import
Gargantext.API.Node.Contact.Types
import
Gargantext.API.Prelude
(
GargM
,
simuLogs
)
import
Gargantext.API.Prelude
(
GargM
,
simuLogs
)
import
Gargantext.API.Routes.Named.Contact
qualified
as
Named
import
Gargantext.API.Routes.Named.Contact
qualified
as
Named
...
@@ -44,21 +43,12 @@ import Gargantext.Utils.Jobs (serveJobsAPI, MonadJobStatus(..))
...
@@ -44,21 +43,12 @@ import Gargantext.Utils.Jobs (serveJobsAPI, MonadJobStatus(..))
import
Servant
import
Servant
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
------------------------------------------------------------------------
type
API
=
"contact"
:>
Summary
"Contact endpoint"
:>
API_Async
:<|>
Capture
"contact_id"
NodeId
:>
NodeNodeAPI
HyperdataContact
contactAPI
::
AuthenticatedUser
->
CorpusId
->
Named
.
ContactAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
contactAPI
::
AuthenticatedUser
->
CorpusId
->
Named
.
ContactAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
contactAPI
authUser
@
(
AuthenticatedUser
userNodeId
_userUserId
)
cid
=
Named
.
ContactAPI
contactAPI
authUser
@
(
AuthenticatedUser
userNodeId
_userUserId
)
cid
=
Named
.
ContactAPI
{
contactAsyncAPI
=
api_async
(
RootId
userNodeId
)
cid
{
contactAsyncAPI
=
api_async
(
RootId
userNodeId
)
cid
,
getContactEp
=
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataContact
)
authUser
cid
,
getContactEp
=
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataContact
)
authUser
cid
}
}
type
API_Async
=
AsyncJobs
JobLog
'[
J
SON
]
AddContactParams
JobLog
----------------------------------------------------------------------
----------------------------------------------------------------------
api_async
::
User
->
NodeId
->
Named
.
ContactAsyncAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
api_async
::
User
->
NodeId
->
Named
.
ContactAsyncAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
api_async
u
nId
=
Named
.
ContactAsyncAPI
$
api_async
u
nId
=
Named
.
ContactAsyncAPI
$
...
...
src/Gargantext/API/Node/Corpus/Export.hs
View file @
65750c75
...
@@ -26,7 +26,7 @@ import Gargantext.API.Ngrams.Tools (filterListWithRoot, mapTermListRoot, getRepo
...
@@ -26,7 +26,7 @@ import Gargantext.API.Ngrams.Tools (filterListWithRoot, mapTermListRoot, getRepo
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
unNgramsTerm
)
)
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
unNgramsTerm
)
)
import
Gargantext.API.Node.Corpus.Export.Types
(
Corpus
(
..
)
)
import
Gargantext.API.Node.Corpus.Export.Types
(
Corpus
(
..
)
)
import
Gargantext.API.Node.Document.Export.Types
qualified
as
DocumentExport
import
Gargantext.API.Node.Document.Export.Types
qualified
as
DocumentExport
import
Gargantext.API.Prelude
(
GargNoServer
,
IsGargServer
)
import
Gargantext.API.Prelude
(
IsGargServer
)
import
Gargantext.Core.NodeStory.Types
(
NodeListStory
)
import
Gargantext.Core.NodeStory.Types
(
NodeListStory
)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Core.Types.Main
(
ListType
(
MapTerm
)
)
import
Gargantext.Core.Types.Main
(
ListType
(
MapTerm
)
)
...
@@ -42,17 +42,10 @@ import Gargantext.Database.Query.Table.NodeContext (selectDocNodes)
...
@@ -42,17 +42,10 @@ import Gargantext.Database.Query.Table.NodeContext (selectDocNodes)
import
Gargantext.Database.Schema.Context
(
_context_id
)
import
Gargantext.Database.Schema.Context
(
_context_id
)
import
Gargantext.Prelude
hiding
(
hash
)
import
Gargantext.Prelude
hiding
(
hash
)
import
Gargantext.Prelude.Crypto.Hash
(
hash
)
import
Gargantext.Prelude.Crypto.Hash
(
hash
)
import
Servant
(
Headers
,
Header
,
addHeader
,
Summary
,
(
:>
),
JSON
,
Get
,
QueryParam
)
import
Servant
(
Headers
,
Header
,
addHeader
)
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
import
qualified
Gargantext.API.Routes.Named.Corpus
as
Named
import
qualified
Gargantext.API.Routes.Named.Corpus
as
Named
--------------------------------------------------
type
API
=
Summary
"Corpus Export"
:>
"export"
:>
QueryParam
"listId"
ListId
:>
QueryParam
"ngramsType"
NgramsType
:>
Get
'[
J
SON
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Corpus
)
--------------------------------------------------
--------------------------------------------------
-- | Hashes are ordered by Set
-- | Hashes are ordered by Set
getCorpus
::
forall
env
err
m
.
IsGargServer
env
err
m
getCorpus
::
forall
env
err
m
.
IsGargServer
env
err
m
...
...
src/Gargantext/API/Node/Document/Export/Types.hs
View file @
65750c75
...
@@ -27,7 +27,7 @@ import Gargantext.Database.Schema.Node (NodePoly(..))
...
@@ -27,7 +27,7 @@ import Gargantext.Database.Schema.Node (NodePoly(..))
import
Gargantext.Utils.Servant
(
ZIP
)
import
Gargantext.Utils.Servant
(
ZIP
)
import
Gargantext.Utils.Zip
(
zipContentsPureWithLastModified
)
import
Gargantext.Utils.Zip
(
zipContentsPureWithLastModified
)
import
Protolude
import
Protolude
import
Servant
(
(
:>
),
(
:<|>
),
Get
,
Header
,
Headers
(
..
),
JSON
,
MimeRender
(
..
),
PlainText
,
Summary
)
import
Servant
(
MimeRender
(
..
)
)
-- | Document Export
-- | Document Export
...
@@ -101,15 +101,6 @@ instance ToParamSchema Document where
...
@@ -101,15 +101,6 @@ instance ToParamSchema Document where
instance
ToParamSchema
Ngrams
where
instance
ToParamSchema
Ngrams
where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
--------------------------------------------------
type
API
=
Summary
"Document Export"
:>
"export"
:>
(
"json"
:>
Get
'[
J
SON
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
DocumentExport
)
:<|>
"json.zip"
:>
Get
'[
Z
IP
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
DocumentExportZIP
)
:<|>
"csv"
:>
Get
'[
P
lainText
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Text
)
)
$
(
deriveJSON
(
unPrefix
"_ng_"
)
''
N
grams
)
$
(
deriveJSON
(
unPrefix
"_ng_"
)
''
N
grams
)
$
(
deriveJSON
(
unPrefix
"_d_"
)
''
D
ocument
)
$
(
deriveJSON
(
unPrefix
"_d_"
)
''
D
ocument
)
...
...
src/Gargantext/API/Node/DocumentUpload.hs
View file @
65750c75
...
@@ -17,18 +17,16 @@ Portability : POSIX
...
@@ -17,18 +17,16 @@ Portability : POSIX
module
Gargantext.API.Node.DocumentUpload
where
module
Gargantext.API.Node.DocumentUpload
where
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Data.Aeson
(
Options
(
..
),
genericParseJSON
,
defaultOptions
,
genericToJSON
,
SumEncoding
(
..
)
)
import
Data.Swagger
(
ToSchema
)
import
Data.Text
qualified
as
T
import
Data.Text
qualified
as
T
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Node.DocumentUpload.Types
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Routes.Named.Document
qualified
as
Named
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.NLP
(
nlpServerGet
)
import
Gargantext.Core.NLP
(
nlpServerGet
)
import
Gargantext.Core.Text.Corpus.Parsers.Date
(
mDateSplit
)
import
Gargantext.Core.Text.Corpus.Parsers.Date
(
mDateSplit
)
import
Gargantext.Core.Text.Terms
(
TermType
(
..
))
import
Gargantext.Core.Text.Terms
(
TermType
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unCapitalize
,
dropPrefix
)
import
Gargantext.Database.Action.Flow
(
addDocumentsToHyperCorpus
)
import
Gargantext.Database.Action.Flow
(
addDocumentsToHyperCorpus
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Admin.Types.Hyperdata.Corpus
(
HyperdataCorpus
)
import
Gargantext.Database.Admin.Types.Hyperdata.Corpus
(
HyperdataCorpus
)
...
@@ -37,47 +35,11 @@ import Gargantext.Database.Admin.Types.Node ( DocId, NodeId, NodeType(NodeCorpus
...
@@ -37,47 +35,11 @@ import Gargantext.Database.Admin.Types.Node ( DocId, NodeId, NodeType(NodeCorpus
import
Gargantext.Database.Query.Table.Node
(
getClosestParentIdByType'
)
import
Gargantext.Database.Query.Table.Node
(
getClosestParentIdByType'
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Servant
(
JSON
,
Summary
,
type
(
:>
),
HasServer
(
ServerT
)
)
import
Servant
.Server.Generic
(
AsServerT
)
data
DocumentUpload
=
DocumentUpload
api
::
NodeId
->
Named
.
DocumentUploadAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
{
_du_abstract
::
T
.
Text
api
nId
=
Named
.
DocumentUploadAPI
$
,
_du_authors
::
T
.
Text
,
_du_sources
::
T
.
Text
,
_du_title
::
T
.
Text
,
_du_date
::
T
.
Text
,
_du_language
::
T
.
Text
}
deriving
(
Generic
)
$
(
makeLenses
''
D
ocumentUpload
)
instance
ToSchema
DocumentUpload
instance
FromJSON
DocumentUpload
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
,
fieldLabelModifier
=
unCapitalize
.
dropPrefix
"_du_"
,
omitNothingFields
=
True
}
)
instance
ToJSON
DocumentUpload
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
,
fieldLabelModifier
=
unCapitalize
.
dropPrefix
"_du_"
,
omitNothingFields
=
True
}
)
type
API
=
Summary
" Document upload"
:>
"document"
:>
"upload"
:>
"async"
:>
AsyncJobs
JobLog
'[
J
SON
]
DocumentUpload
JobLog
api
::
NodeId
->
ServerT
API
(
GargM
Env
BackendInternalError
)
api
nId
=
serveJobsAPI
UploadDocumentJob
$
\
jHandle
q
->
do
serveJobsAPI
UploadDocumentJob
$
\
jHandle
q
->
do
documentUploadAsync
nId
q
jHandle
documentUploadAsync
nId
q
jHandle
...
...
src/Gargantext/API/Node/DocumentUpload/Types.hs
0 → 100644
View file @
65750c75
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.API.Node.DocumentUpload.Types
where
import
Data.Aeson
(
Options
(
..
),
genericParseJSON
,
defaultOptions
,
genericToJSON
,
SumEncoding
(
..
)
)
import
Data.Swagger
(
ToSchema
)
import
Data.Text
qualified
as
T
import
Gargantext.Core.Utils.Prefix
(
unCapitalize
,
dropPrefix
)
import
Gargantext.Prelude
data
DocumentUpload
=
DocumentUpload
{
_du_abstract
::
T
.
Text
,
_du_authors
::
T
.
Text
,
_du_sources
::
T
.
Text
,
_du_title
::
T
.
Text
,
_du_date
::
T
.
Text
,
_du_language
::
T
.
Text
}
deriving
(
Generic
)
$
(
makeLenses
''
D
ocumentUpload
)
instance
ToSchema
DocumentUpload
instance
FromJSON
DocumentUpload
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
,
fieldLabelModifier
=
unCapitalize
.
dropPrefix
"_du_"
,
omitNothingFields
=
True
}
)
instance
ToJSON
DocumentUpload
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
,
fieldLabelModifier
=
unCapitalize
.
dropPrefix
"_du_"
,
omitNothingFields
=
True
}
)
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
View file @
65750c75
...
@@ -17,22 +17,20 @@ module Gargantext.API.Node.DocumentsFromWriteNodes
...
@@ -17,22 +17,20 @@ module Gargantext.API.Node.DocumentsFromWriteNodes
where
where
import
Conduit
(
yieldMany
)
import
Conduit
(
yieldMany
)
import
Data.Aeson
(
genericParseJSON
,
defaultOptions
,
genericToJSON
)
import
Data.List
qualified
as
List
import
Data.List
qualified
as
List
import
Data.Swagger
(
ToSchema
)
import
Data.Text
qualified
as
T
import
Data.Text
qualified
as
T
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
,
auth_node_id
,
auth_user_id
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
,
auth_node_id
,
auth_user_id
)
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Ngrams
(
commitStatePatch
,
Versioned
(
..
))
import
Gargantext.API.Ngrams
(
commitStatePatch
,
Versioned
(
..
))
import
Gargantext.API.Node.DocumentsFromWriteNodes.Types
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Routes.Named.Document
qualified
as
Named
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.NodeStory
(
HasNodeStoryImmediateSaver
,
HasNodeArchiveStoryImmediateSaver
,
currentVersion
)
import
Gargantext.Core.NodeStory
(
HasNodeStoryImmediateSaver
,
HasNodeArchiveStoryImmediateSaver
,
currentVersion
)
import
Gargantext.Core.Text.Corpus.Parsers.Date
(
split'
)
import
Gargantext.Core.Text.Corpus.Parsers.Date
(
split'
)
import
Gargantext.Core.Text.Corpus.Parsers.FrameWrite
import
Gargantext.Core.Text.Corpus.Parsers.FrameWrite
import
Gargantext.Core.Text.List.Social
(
FlowSocialListWith
)
import
Gargantext.Core.Text.Terms
(
TermType
(
..
))
import
Gargantext.Core.Text.Terms
(
TermType
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Action.Flow
(
flowDataText
,
DataText
(
..
))
import
Gargantext.Database.Action.Flow
(
flowDataText
,
DataText
(
..
))
...
@@ -46,30 +44,13 @@ import Gargantext.Prelude
...
@@ -46,30 +44,13 @@ import Gargantext.Prelude
import
Gargantext.System.Logging
import
Gargantext.System.Logging
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs.Error
import
Gargantext.Utils.Jobs.Error
import
Servant
(
JSON
,
Summary
,
type
(
:>
),
HasServer
(
ServerT
)
)
import
Servant
.Server.Generic
(
AsServerT
)
------------------------------------------------------------------------
type
API
=
Summary
" Documents from Write nodes."
:>
AsyncJobs
JobLog
'[
J
SON
]
Params
JobLog
------------------------------------------------------------------------
data
Params
=
Params
{
id
::
Int
,
paragraphs
::
Text
,
lang
::
Lang
,
selection
::
FlowSocialListWith
}
deriving
(
Generic
,
Show
)
instance
FromJSON
Params
where
parseJSON
=
genericParseJSON
defaultOptions
instance
ToJSON
Params
where
toJSON
=
genericToJSON
defaultOptions
instance
ToSchema
Params
------------------------------------------------------------------------
api
::
AuthenticatedUser
api
::
AuthenticatedUser
-- ^ The logged-in user
-- ^ The logged-in user
->
NodeId
->
NodeId
->
ServerT
API
(
GargM
Env
BackendInternalError
)
->
Named
.
DocumentsFromWriteNodesAPI
(
AsServerT
(
GargM
Env
BackendInternalError
)
)
api
authenticatedUser
nId
=
api
authenticatedUser
nId
=
Named
.
DocumentsFromWriteNodesAPI
$
serveJobsAPI
DocumentFromWriteNodeJob
$
\
jHandle
p
->
serveJobsAPI
DocumentFromWriteNodeJob
$
\
jHandle
p
->
documentsFromWriteNodes
authenticatedUser
nId
p
jHandle
documentsFromWriteNodes
authenticatedUser
nId
p
jHandle
...
...
src/Gargantext/API/Node/DocumentsFromWriteNodes/Types.hs
0 → 100644
View file @
65750c75
module
Gargantext.API.Node.DocumentsFromWriteNodes.Types
where
import
Data.Aeson
(
genericParseJSON
,
defaultOptions
,
genericToJSON
)
import
Data.Swagger
(
ToSchema
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Text.List.Social
(
FlowSocialListWith
)
import
Gargantext.Prelude
------------------------------------------------------------------------
data
Params
=
Params
{
id
::
Int
,
paragraphs
::
Text
,
lang
::
Lang
,
selection
::
FlowSocialListWith
}
deriving
(
Generic
,
Show
)
instance
FromJSON
Params
where
parseJSON
=
genericParseJSON
defaultOptions
instance
ToJSON
Params
where
toJSON
=
genericToJSON
defaultOptions
instance
ToSchema
Params
------------------------------------------------------------------------
src/Gargantext/API/Node/FrameCalcUpload.hs
View file @
65750c75
...
@@ -17,19 +17,17 @@ module Gargantext.API.Node.FrameCalcUpload where
...
@@ -17,19 +17,17 @@ module Gargantext.API.Node.FrameCalcUpload where
import
Data.ByteString.Lazy
qualified
as
BSL
import
Data.ByteString.Lazy
qualified
as
BSL
import
Data.ByteString.UTF8
qualified
as
BSU8
import
Data.ByteString.UTF8
qualified
as
BSU8
import
Data.Swagger
(
ToSchema
)
import
Data.Text
qualified
as
T
import
Data.Text
qualified
as
T
import
Gargantext.API.Admin.Auth.Types
(
auth_node_id
,
AuthenticatedUser
)
import
Gargantext.API.Admin.Auth.Types
(
auth_node_id
,
AuthenticatedUser
)
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Node.Corpus.New
(
addToCorpusWithForm
)
import
Gargantext.API.Node.Corpus.New
(
addToCorpusWithForm
)
import
Gargantext.API.Node.Corpus.New.Types
(
FileFormat
(
..
),
FileType
(
..
))
import
Gargantext.API.Node.Corpus.New.Types
(
FileFormat
(
..
),
FileType
(
..
))
import
Gargantext.API.Node.FrameCalcUpload.Types
import
Gargantext.API.Node.Types
(
NewWithForm
(
..
))
import
Gargantext.API.Node.Types
(
NewWithForm
(
..
))
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.
Core
(
Lang
)
import
Gargantext.
API.Routes.Named.FrameCalc
qualified
as
Named
import
Gargantext.Core.NodeStory.Types
(
HasNodeArchiveStoryImmediateSaver
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeArchiveStoryImmediateSaver
)
import
Gargantext.Core.Text.List.Social
(
FlowSocialListWith
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Admin.Types.Hyperdata.Frame
(
HyperdataFrame
(
..
)
)
import
Gargantext.Database.Admin.Types.Hyperdata.Frame
(
HyperdataFrame
(
..
)
)
...
@@ -41,29 +39,11 @@ import Gargantext.Prelude
...
@@ -41,29 +39,11 @@ import Gargantext.Prelude
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
),
markFailureNoErr
)
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
),
markFailureNoErr
)
import
Network.HTTP.Client
(
newManager
,
httpLbs
,
parseRequest
,
responseBody
)
import
Network.HTTP.Client
(
newManager
,
httpLbs
,
parseRequest
,
responseBody
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Servant
(
type
(
:>
),
JSON
,
Summary
,
HasServer
(
ServerT
)
)
import
Servant.Server.Generic
(
AsServerT
)
import
Web.FormUrlEncoded
(
FromForm
)
data
FrameCalcUpload
=
FrameCalcUpload
{
api
::
AuthenticatedUser
->
NodeId
->
Named
.
FrameCalcAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
_wf_lang
::
!
(
Maybe
Lang
)
api
authenticatedUser
nId
=
Named
.
FrameCalcAPI
$
,
_wf_selection
::
!
FlowSocialListWith
}
deriving
(
Generic
)
instance
FromForm
FrameCalcUpload
instance
FromJSON
FrameCalcUpload
instance
ToJSON
FrameCalcUpload
instance
ToSchema
FrameCalcUpload
type
API
=
Summary
" FrameCalc upload"
:>
"add"
:>
"framecalc"
:>
"async"
:>
AsyncJobs
JobLog
'[
J
SON
]
FrameCalcUpload
JobLog
api
::
AuthenticatedUser
->
NodeId
->
ServerT
API
(
GargM
Env
BackendInternalError
)
api
authenticatedUser
nId
=
serveJobsAPI
UploadFrameCalcJob
$
\
jHandle
p
->
serveJobsAPI
UploadFrameCalcJob
$
\
jHandle
p
->
frameCalcUploadAsync
authenticatedUser
nId
p
jHandle
frameCalcUploadAsync
authenticatedUser
nId
p
jHandle
...
...
src/Gargantext/API/Node/FrameCalcUpload/Types.hs
0 → 100644
View file @
65750c75
module
Gargantext.API.Node.FrameCalcUpload.Types
where
import
Data.Swagger
(
ToSchema
)
import
Gargantext.Core
(
Lang
)
import
Gargantext.Core.Text.List.Social
(
FlowSocialListWith
(
..
))
import
Gargantext.Prelude
import
Web.FormUrlEncoded
(
FromForm
)
data
FrameCalcUpload
=
FrameCalcUpload
{
_wf_lang
::
!
(
Maybe
Lang
)
,
_wf_selection
::
!
FlowSocialListWith
}
deriving
(
Generic
)
instance
FromForm
FrameCalcUpload
instance
FromJSON
FrameCalcUpload
instance
ToJSON
FrameCalcUpload
instance
ToSchema
FrameCalcUpload
src/Gargantext/API/Node/Get.hs
View file @
65750c75
...
@@ -22,32 +22,16 @@ module Gargantext.API.Node.Get
...
@@ -22,32 +22,16 @@ module Gargantext.API.Node.Get
import
Data.Aeson
import
Data.Aeson
import
Data.Swagger
import
Data.Swagger
import
Gargantext.API.Prelude
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
JSONB
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Servant
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck.Arbitrary
------------------------------------------------------------------------
type
API
a
=
Summary
"Polymorphic Get Node Endpoint"
:>
ReqBody
'[
J
SON
]
GetNodeParams
:>
Get
'[
J
SON
]
(
Node
a
)
------------------------------------------------------------------------
------------------------------------------------------------------------
data
GetNodeParams
=
GetNodeParams
{
node_id
::
NodeId
data
GetNodeParams
=
GetNodeParams
{
node_id
::
NodeId
,
nodetype
::
NodeType
,
nodetype
::
NodeType
}
}
deriving
(
Generic
)
deriving
(
Generic
)
----------------------------------------------------------------------
api
::
forall
proxy
a
.
(
JSONB
a
,
FromJSON
a
,
ToJSON
a
)
=>
proxy
a
->
UserId
->
NodeId
->
GargServer
(
API
a
)
api
_p
_uId
_nId
(
GetNodeParams
_nId'
_nt
)
=
undefined
------------------------------------------------------------------------
------------------------------------------------------------------------
instance
FromJSON
GetNodeParams
where
instance
FromJSON
GetNodeParams
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
...
...
src/Gargantext/API/Node/Phylo/Export/Types.hs
View file @
65750c75
...
@@ -13,7 +13,6 @@ Portability : POSIX
...
@@ -13,7 +13,6 @@ Portability : POSIX
module
Gargantext.API.Node.Phylo.Export.Types
where
module
Gargantext.API.Node.Phylo.Export.Types
where
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
-- import Data.Csv (DefaultOrdered(..), ToNamedRecord(..), (.=), header, namedRecord)
-- import Data.Csv (DefaultOrdered(..), ToNamedRecord(..), (.=), header, namedRecord)
import
Data.Swagger
(
genericDeclareNamedSchema
,
ToParamSchema
(
..
),
ToSchema
(
..
)
)
import
Data.Swagger
(
genericDeclareNamedSchema
,
ToParamSchema
(
..
),
ToSchema
(
..
)
)
...
@@ -27,7 +26,7 @@ import Gargantext.Database.Admin.Types.Node (PhyloId)
...
@@ -27,7 +26,7 @@ import Gargantext.Database.Admin.Types.Node (PhyloId)
-- import Gargantext.Utils.Servant (ZIP)
-- import Gargantext.Utils.Servant (ZIP)
-- import Gargantext.Utils.Zip (zipContentsPure)
-- import Gargantext.Utils.Zip (zipContentsPure)
import
Protolude
import
Protolude
import
Servant
((
:>
),
(
:<|>
),
Get
,
Header
,
Headers
(
..
),
JSON
,
Summary
)
--, PlainText, MimeRender(..)
--, PlainText, MimeRender(..)
-- | Phylo Export
-- | Phylo Export
...
@@ -97,14 +96,6 @@ instance ToParamSchema Phylo where
...
@@ -97,14 +96,6 @@ instance ToParamSchema Phylo where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
--------------------------------------------------
--------------------------------------------------
type
API
=
Summary
"Phylo Export"
:>
"export"
:>
(
"json"
:>
Get
'[
J
SON
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Value
)
:<|>
"dot"
:>
Get
'[
J
SON
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Text
)
)
-- type API = Summary "Phylo Export"
-- type API = Summary "Phylo Export"
-- :> "export"
-- :> "export"
-- :> Get '[JSON,DOT] (Headers '[Servant.Header "Content-Disposition" Text] Value)
-- :> Get '[JSON,DOT] (Headers '[Servant.Header "Content-Disposition" Text] Value)
...
...
src/Gargantext/API/Node/Share.hs
View file @
65750c75
...
@@ -15,11 +15,11 @@ Portability : POSIX
...
@@ -15,11 +15,11 @@ Portability : POSIX
module
Gargantext.API.Node.Share
module
Gargantext.API.Node.Share
where
where
import
Data.Aeson
import
Data.List
qualified
as
List
import
Data.List
qualified
as
List
import
Data.Swagger
import
Data.Text
qualified
as
Text
import
Data.Text
qualified
as
Text
import
Gargantext.API.Node.Share.Types
import
Gargantext.API.Prelude
import
Gargantext.API.Prelude
import
Gargantext.API.Routes.Named.Share
qualified
as
Named
import
Gargantext.Core.NLP
(
HasNLPServer
)
import
Gargantext.Core.NLP
(
HasNLPServer
)
import
Gargantext.Core.Types.Individu
(
User
(
..
),
arbitraryUsername
)
import
Gargantext.Core.Types.Individu
(
User
(
..
),
arbitraryUsername
)
import
Gargantext.Database.Action.Share
(
ShareNodeWith
(
..
))
import
Gargantext.Database.Action.Share
(
ShareNodeWith
(
..
))
...
@@ -31,26 +31,8 @@ import Gargantext.Database.Prelude (CmdRandom)
...
@@ -31,26 +31,8 @@ import Gargantext.Database.Prelude (CmdRandom)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Query.Tree
(
findNodesWithType
)
import
Gargantext.Database.Query.Tree
(
findNodesWithType
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Utils.Aeson
qualified
as
GUA
import
Servant.Server.Generic
(
AsServerT
)
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
------------------------------------------------------------------------
data
ShareNodeParams
=
ShareTeamParams
{
username
::
Text
}
|
SharePublicParams
{
node_id
::
NodeId
}
deriving
(
Generic
)
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance
FromJSON
ShareNodeParams
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToJSON
ShareNodeParams
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToSchema
ShareNodeParams
instance
Arbitrary
ShareNodeParams
where
arbitrary
=
elements
[
ShareTeamParams
"user1"
,
SharePublicParams
(
UnsafeMkNodeId
1
)
]
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO permission
-- TODO permission
-- TODO refactor userId which is used twice
-- TODO refactor userId which is used twice
...
@@ -98,15 +80,5 @@ api _uId nId2 (SharePublicParams nId1) =
...
@@ -98,15 +80,5 @@ api _uId nId2 (SharePublicParams nId1) =
fromIntegral
<$>
DB
.
shareNodeWith
(
ShareNodeWith_Node
NodeFolderPublic
nId1
)
nId2
fromIntegral
<$>
DB
.
shareNodeWith
(
ShareNodeWith_Node
NodeFolderPublic
nId1
)
nId2
------------------------------------------------------------------------
unPublish
::
IsGargServer
env
err
m
=>
NodeId
->
Named
.
Unpublish
(
AsServerT
m
)
type
API
=
Summary
" Share Node with username"
unPublish
n
=
Named
.
Unpublish
$
DB
.
unPublish
n
:>
ReqBody
'[
J
SON
]
ShareNodeParams
:>
Post
'[
J
SON
]
Int
------------------------------------------------------------------------
type
Unpublish
=
Summary
" Unpublish Node"
:>
Capture
"node_id"
NodeId
:>
Put
'[
J
SON
]
Int
unPublish
::
NodeId
->
GargServer
Unpublish
unPublish
n
=
DB
.
unPublish
n
src/Gargantext/API/Node/Share/Types.hs
0 → 100644
View file @
65750c75
module
Gargantext.API.Node.Share.Types
where
import
Data.Aeson
import
Data.Swagger
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Prelude
import
Gargantext.Utils.Aeson
qualified
as
GUA
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
data
ShareNodeParams
=
ShareTeamParams
{
username
::
Text
}
|
SharePublicParams
{
node_id
::
NodeId
}
deriving
(
Generic
)
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance
FromJSON
ShareNodeParams
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToJSON
ShareNodeParams
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToSchema
ShareNodeParams
instance
Arbitrary
ShareNodeParams
where
arbitrary
=
elements
[
ShareTeamParams
"user1"
,
SharePublicParams
(
UnsafeMkNodeId
1
)
]
src/Gargantext/API/Node/ShareURL.hs
View file @
65750c75
...
@@ -6,7 +6,6 @@ module Gargantext.API.Node.ShareURL where
...
@@ -6,7 +6,6 @@ module Gargantext.API.Node.ShareURL where
import
Data.Text
import
Data.Text
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.API.Prelude
import
Gargantext.API.Prelude
import
Servant
import
Gargantext.Core.Types
(
NodeType
,
NodeId
,
unNodeId
)
import
Gargantext.Core.Types
(
NodeType
,
NodeId
,
unNodeId
)
import
Gargantext.Database.Prelude
(
HasConfig
(
hasConfig
),
CmdCommon
)
import
Gargantext.Database.Prelude
(
HasConfig
(
hasConfig
),
CmdCommon
)
import
Control.Lens.Getter
(
view
)
import
Control.Lens.Getter
(
view
)
...
@@ -14,11 +13,6 @@ import Gargantext.Prelude.Config (gc_url)
...
@@ -14,11 +13,6 @@ import Gargantext.Prelude.Config (gc_url)
import
Gargantext.API.Routes.Named.Share
qualified
as
Named
import
Gargantext.API.Routes.Named.Share
qualified
as
Named
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
type
API
=
Summary
"Fetch URL for sharing a node"
:>
QueryParam
"type"
NodeType
:>
QueryParam
"id"
NodeId
:>
Get
'[
J
SON
]
Text
shareURL
::
IsGargServer
env
err
m
=>
Named
.
ShareURL
(
AsServerT
m
)
shareURL
::
IsGargServer
env
err
m
=>
Named
.
ShareURL
(
AsServerT
m
)
shareURL
=
Named
.
ShareURL
getUrl
shareURL
=
Named
.
ShareURL
getUrl
...
...
src/Gargantext/API/Node/Update.hs
View file @
65750c75
...
@@ -16,24 +16,20 @@ module Gargantext.API.Node.Update
...
@@ -16,24 +16,20 @@ module Gargantext.API.Node.Update
where
where
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Data.Aeson
import
Data.Set
qualified
as
Set
import
Data.Set
qualified
as
Set
import
Data.Swagger
(
ToSchema
)
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Metrics
qualified
as
Metrics
import
Gargantext.API.Metrics
qualified
as
Metrics
import
Gargantext.API.Ngrams.Types
qualified
as
NgramsTypes
import
Gargantext.API.Ngrams.Types
qualified
as
NgramsTypes
import
Gargantext.API.Node.Update.Types
import
Gargantext.API.Prelude
(
GargM
,
simuLogs
)
import
Gargantext.API.Prelude
(
GargM
,
simuLogs
)
import
Gargantext.
Core.Methods.Similarities
(
GraphMetric
(
..
))
import
Gargantext.
API.Routes.Named.Node
qualified
as
Named
import
Gargantext.Core.NodeStory.Types
(
HasNodeStory
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeStory
)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
NgramsTerms
))
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
NgramsTerms
))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
import
Gargantext.Core.Viz.Graph.API
(
recomputeGraph
)
import
Gargantext.Core.Viz.Graph.API
(
recomputeGraph
)
import
Gargantext.Core.Viz.Graph.Tools
(
PartitionMethod
(
..
),
BridgenessMethod
(
..
))
import
Gargantext.Core.Viz.Phylo
(
subConfigAPI2config
)
import
Gargantext.Core.Viz.Graph.Types
(
Strength
)
import
Gargantext.Core.Viz.Phylo
(
PhyloSubConfigAPI
(
..
),
subConfigAPI2config
)
import
Gargantext.Core.Viz.Phylo.API.Tools
(
flowPhyloAPI
)
import
Gargantext.Core.Viz.Phylo.API.Tools
(
flowPhyloAPI
)
import
Gargantext.Database.Action.Flow
(
reIndexWith
)
import
Gargantext.Database.Action.Flow
(
reIndexWith
)
import
Gargantext.Database.Action.Flow.Pairing
(
pairing
)
import
Gargantext.Database.Action.Flow.Pairing
(
pairing
)
...
@@ -45,53 +41,13 @@ import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
...
@@ -45,53 +41,13 @@ import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
import
Gargantext.Database.Schema.Node
(
node_parent_id
)
import
Gargantext.Database.Schema.Node
(
node_parent_id
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.System.Logging
(
MonadLogger
)
import
Gargantext.System.Logging
(
MonadLogger
)
import
Gargantext.Utils.Aeson
qualified
as
GUA
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.UTCTime
(
timeMeasured
)
import
Gargantext.Utils.UTCTime
(
timeMeasured
)
import
Servant
import
Servant.Server.Generic
(
AsServerT
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
(
arbitrary
)
)
------------------------------------------------------------------------
------------------------------------------------------------------------
type
API
=
Summary
" Update node according to NodeType params"
api
::
NodeId
->
Named
.
UpdateAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
:>
AsyncJobs
JobLog
'[
J
SON
]
UpdateNodeParams
JobLog
api
nId
=
Named
.
UpdateAPI
$
------------------------------------------------------------------------
data
UpdateNodeParams
=
UpdateNodeParamsList
{
methodList
::
!
Method
}
|
UpdateNodeParamsGraph
{
methodGraphMetric
::
!
GraphMetric
,
methodGraphClustering
::
!
PartitionMethod
,
methodGraphBridgeness
::
!
BridgenessMethod
,
methodGraphEdgesStrength
::
!
Strength
,
methodGraphNodeType1
::
!
NgramsType
,
methodGraphNodeType2
::
!
NgramsType
}
|
UpdateNodeParamsTexts
{
methodTexts
::
!
Granularity
}
|
UpdateNodeParamsBoard
{
methodBoard
::
!
Charts
}
|
LinkNodeReq
{
nodeType
::
!
NodeType
,
id
::
!
NodeId
}
|
UpdateNodePhylo
{
config
::
!
PhyloSubConfigAPI
}
deriving
(
Generic
)
----------------------------------------------------------------------
data
Method
=
Basic
|
Advanced
|
WithModel
deriving
(
Generic
,
Eq
,
Ord
,
Enum
,
Bounded
)
----------------------------------------------------------------------
data
Granularity
=
NewNgrams
|
NewTexts
|
Both
deriving
(
Generic
,
Eq
,
Ord
,
Enum
,
Bounded
)
----------------------------------------------------------------------
data
Charts
=
Sources
|
Authors
|
Institutes
|
Ngrams
|
All
deriving
(
Generic
,
Eq
,
Ord
,
Enum
,
Bounded
)
------------------------------------------------------------------------
api
::
NodeId
->
ServerT
API
(
GargM
Env
BackendInternalError
)
api
nId
=
serveJobsAPI
UpdateNodeJob
$
\
jHandle
p
->
serveJobsAPI
UpdateNodeJob
$
\
jHandle
p
->
updateNode
nId
p
jHandle
updateNode
nId
p
jHandle
...
@@ -206,39 +162,3 @@ updateDocs cId = do
...
@@ -206,39 +162,3 @@ updateDocs cId = do
-- printDebug "updateContextsScore" (cId, lId, u)
-- printDebug "updateContextsScore" (cId, lId, u)
pure
()
pure
()
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance
FromJSON
UpdateNodeParams
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToJSON
UpdateNodeParams
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToSchema
UpdateNodeParams
instance
Arbitrary
UpdateNodeParams
where
arbitrary
=
do
l
<-
UpdateNodeParamsList
<$>
arbitrary
g
<-
UpdateNodeParamsGraph
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
t
<-
UpdateNodeParamsTexts
<$>
arbitrary
b
<-
UpdateNodeParamsBoard
<$>
arbitrary
elements
[
l
,
g
,
t
,
b
]
instance
FromJSON
Method
instance
ToJSON
Method
instance
ToSchema
Method
instance
Arbitrary
Method
where
arbitrary
=
elements
[
minBound
..
maxBound
]
instance
FromJSON
Granularity
instance
ToJSON
Granularity
instance
ToSchema
Granularity
instance
Arbitrary
Granularity
where
arbitrary
=
elements
[
minBound
..
maxBound
]
instance
FromJSON
Charts
instance
ToJSON
Charts
instance
ToSchema
Charts
instance
Arbitrary
Charts
where
arbitrary
=
elements
[
minBound
..
maxBound
]
------------------------------------------------------------------------
src/Gargantext/API/Node/Update/Types.hs
0 → 100644
View file @
65750c75
module
Gargantext.API.Node.Update.Types
where
import
Data.Aeson
import
Data.Swagger
(
ToSchema
)
import
Gargantext.Core.Methods.Similarities
(
GraphMetric
(
..
))
import
Gargantext.Core.Text.Ngrams
(
NgramsType
)
import
Gargantext.Core.Viz.Graph.Tools
(
PartitionMethod
(
..
),
BridgenessMethod
(
..
))
import
Gargantext.Core.Viz.Graph.Types
(
Strength
)
import
Gargantext.Core.Viz.Phylo
(
PhyloSubConfigAPI
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
)
import
Gargantext.Prelude
import
Gargantext.Utils.Aeson
qualified
as
GUA
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
(
arbitrary
)
)
------------------------------------------------------------------------
data
UpdateNodeParams
=
UpdateNodeParamsList
{
methodList
::
!
Method
}
|
UpdateNodeParamsGraph
{
methodGraphMetric
::
!
GraphMetric
,
methodGraphClustering
::
!
PartitionMethod
,
methodGraphBridgeness
::
!
BridgenessMethod
,
methodGraphEdgesStrength
::
!
Strength
,
methodGraphNodeType1
::
!
NgramsType
,
methodGraphNodeType2
::
!
NgramsType
}
|
UpdateNodeParamsTexts
{
methodTexts
::
!
Granularity
}
|
UpdateNodeParamsBoard
{
methodBoard
::
!
Charts
}
|
LinkNodeReq
{
nodeType
::
!
NodeType
,
id
::
!
NodeId
}
|
UpdateNodePhylo
{
config
::
!
PhyloSubConfigAPI
}
deriving
(
Generic
)
----------------------------------------------------------------------
data
Method
=
Basic
|
Advanced
|
WithModel
deriving
(
Generic
,
Eq
,
Ord
,
Enum
,
Bounded
)
----------------------------------------------------------------------
data
Granularity
=
NewNgrams
|
NewTexts
|
Both
deriving
(
Generic
,
Eq
,
Ord
,
Enum
,
Bounded
)
----------------------------------------------------------------------
data
Charts
=
Sources
|
Authors
|
Institutes
|
Ngrams
|
All
deriving
(
Generic
,
Eq
,
Ord
,
Enum
,
Bounded
)
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance
FromJSON
UpdateNodeParams
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToJSON
UpdateNodeParams
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToSchema
UpdateNodeParams
instance
Arbitrary
UpdateNodeParams
where
arbitrary
=
do
l
<-
UpdateNodeParamsList
<$>
arbitrary
g
<-
UpdateNodeParamsGraph
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
t
<-
UpdateNodeParamsTexts
<$>
arbitrary
b
<-
UpdateNodeParamsBoard
<$>
arbitrary
elements
[
l
,
g
,
t
,
b
]
instance
FromJSON
Method
instance
ToJSON
Method
instance
ToSchema
Method
instance
Arbitrary
Method
where
arbitrary
=
elements
[
minBound
..
maxBound
]
instance
FromJSON
Granularity
instance
ToJSON
Granularity
instance
ToSchema
Granularity
instance
Arbitrary
Granularity
where
arbitrary
=
elements
[
minBound
..
maxBound
]
instance
FromJSON
Charts
instance
ToJSON
Charts
instance
ToSchema
Charts
instance
Arbitrary
Charts
where
arbitrary
=
elements
[
minBound
..
maxBound
]
------------------------------------------------------------------------
src/Gargantext/API/Routes.hs
View file @
65750c75
...
@@ -23,221 +23,21 @@ module Gargantext.API.Routes
...
@@ -23,221 +23,21 @@ module Gargantext.API.Routes
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Data.Validity
import
Data.Validity
import
Gargantext.API.Admin.Auth
(
ForgotPasswordAPI
,
ForgotPasswordAsyncAPI
)
import
Gargantext.API.Admin.Auth.Types
(
AuthRequest
,
AuthResponse
,
AuthenticatedUser
(
..
))
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.EnvTypes
(
Env
,
GargJob
(
..
))
import
Gargantext.API.Admin.FrontEnd
(
FrontEndAPI
)
import
Gargantext.API.Auth.PolicyCheck
import
Gargantext.API.Context
import
Gargantext.API.Count.Types
(
Query
,
Counts
)
import
Gargantext.API.Errors.Types
import
Gargantext.API.Errors.Types
import
Gargantext.API.GraphQL
qualified
as
GraphQL
import
Gargantext.API.Members
(
MembersAPI
)
import
Gargantext.API.Ngrams
(
TableNgramsApi
)
import
Gargantext.API.Ngrams.List
qualified
as
List
import
Gargantext.API.Node
import
Gargantext.API.Node.Contact
qualified
as
Contact
import
Gargantext.API.Node.Corpus.Annuaire
qualified
as
Annuaire
import
Gargantext.API.Node.Corpus.Annuaire
qualified
as
Annuaire
import
Gargantext.API.Node.Corpus.Export
qualified
as
CorpusExport
import
Gargantext.API.Node.Corpus.New
qualified
as
New
import
Gargantext.API.Node.Corpus.New
qualified
as
New
import
Gargantext.API.Node.Document.Export.Types
qualified
as
DocumentExport
import
Gargantext.API.Node.Phylo.Export.Types
qualified
as
PhyloExport
import
Gargantext.API.Node.ShareURL
qualified
as
ShareURL
import
Gargantext.API.Prelude
import
Gargantext.API.Prelude
import
Gargantext.API.Routes.Named.Annuaire
qualified
as
Named
import
Gargantext.API.Routes.Named.Corpus
qualified
as
Named
import
Gargantext.API.Routes.Named.Corpus
qualified
as
Named
import
Gargantext.API.Routes.Types
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Viz.Graph.API
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
HasConfig
(
..
))
import
Gargantext.Database.Prelude
(
HasConfig
(
..
))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Prelude.Config
(
gc_max_docs_scrapers
)
import
Gargantext.Prelude.Config
(
gc_max_docs_scrapers
)
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Servant
import
Servant
import
Servant.Auth
as
SA
import
Servant.Auth.Swagger
()
import
Servant.Auth.Swagger
()
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Swagger
import
Servant.Swagger.UI
import
Gargantext.API.Routes.Named.Annuaire
qualified
as
Named
type
GargAPI
=
MkGargAPI
(
GargAPIVersion
GargAPI'
)
instance
HasSwagger
(
WithCustomErrorScheme
GargAPI
)
where
toSwagger
_
=
toSwagger
(
Proxy
::
Proxy
GargAPI
)
type
MkGargAPI
sub
=
"api"
:>
Summary
"API "
:>
sub
--- | TODO :<|> Summary "Latest API" :> GargAPI'
type
GargAPIVersion
sub
=
"v1.0"
:>
Summary
"Garg API Version "
:>
sub
type
GargVersion
=
"version"
:>
Summary
"Backend version"
:>
Get
'[
J
SON
]
Text
type
AuthAPI
=
-- Auth endpoint
"auth"
:>
Summary
"AUTH API"
:>
ReqBody
'[
J
SON
]
AuthRequest
:>
Post
'[
J
SON
]
AuthResponse
type
GargAPI'
=
AuthAPI
:<|>
"forgot-password"
:>
ForgotPasswordAPI
:<|>
"async"
:>
"forgot-password"
:>
ForgotPasswordAsyncAPI
:<|>
GargVersion
-- TODO-ACCESS here we want to request a particular header for
-- auth and capabilities.
:<|>
GargPrivateAPI
-- :<|> "public" :> Public.API
type
MkProtectedAPI
private
=
SA
.
Auth
'[
S
A
.
JWT
,
SA
.
Cookie
]
AuthenticatedUser
:>
private
type
GargPrivateAPI
=
MkProtectedAPI
GargPrivateAPI'
type
GargAdminAPI
-- Roots endpoint
=
"user"
:>
Summary
"First user endpoint"
:>
Roots
:<|>
"nodes"
:>
Summary
"Nodes endpoint"
:>
ReqBody
'[
J
SON
]
[
NodeId
]
:>
NodesAPI
-- Node endpoint
type
NodeEndpoint
=
"node"
:>
Summary
"Node endpoint"
:>
Capture
"node_id"
NodeId
:>
NodeAPI
HyperdataAny
type
GargPrivateAPI'
=
GargAdminAPI
:<|>
NodeEndpoint
-- Context endpoint
:<|>
"context"
:>
Summary
"Node endpoint"
:>
Capture
"node_id"
ContextId
:>
ContextAPI
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
:>
CorpusExport
.
API
-- Annuaire endpoint
{-
:<|> "contact" :> Summary "Contact endpoint"
:> Capture "contact_id" ContactId
:> NodeAPI HyperdataContact
--}
:<|>
"annuaire"
:>
Summary
"Annuaire endpoint"
:>
Capture
"annuaire_id"
AnnuaireId
:>
NodeAPI
HyperdataAnnuaire
:<|>
"annuaire"
:>
Summary
"Contact endpoint"
:>
Capture
"annuaire_id"
NodeId
:>
Contact
.
API
-- Document endpoint
:<|>
"document"
:>
Summary
"Document endpoint"
:>
Capture
"doc_id"
DocId
:>
"ngrams"
:>
TableNgramsApi
:<|>
"texts"
:>
Capture
"node_id"
DocId
:>
DocumentExport
.
API
:<|>
"phylo"
:>
Capture
"node_id"
DocId
:>
PhyloExport
.
API
-- :<|> "counts" :> Stream GET NewLineFraming '[JSON] Count :> CountAPI
-- TODO-SECURITY
:<|>
"count"
:>
Summary
"Count endpoint"
:>
ReqBody
'[
J
SON
]
Query
:>
Post
'[
J
SON
]
Counts
-- Corpus endpoint --> TODO rename s/search/filter/g
-- :<|> "search" :> Capture "corpus" NodeId
-- :> (Search.API Search.SearchResult)
-- TODO move to NodeAPI?
:<|>
"graph"
:>
Summary
"Graph endpoint"
:>
Capture
"graph_id"
NodeId
:>
GraphAPI
-- :<|> "phylo" :> Summary "Phylo endpoint"
-- :> Capture "pylo_id" NodeId
-- :>
-- TODO move to NodeAPI?
-- Tree endpoint
:<|>
"tree"
:>
Summary
"Tree endpoint"
:>
Capture
"tree_id"
NodeId
:>
PolicyChecked
TreeAPI
-- Flat tree endpoint
:<|>
"treeflat"
:>
Summary
"Flat tree endpoint"
:>
Capture
"tree_id"
NodeId
:>
TreeFlatAPI
:<|>
"members"
:>
Summary
"Team node members"
:>
MembersAPI
-- :<|> New.Upload
:<|>
New
.
AddWithForm
-- :<|> New.AddWithFile
:<|>
New
.
AddWithQuery
-- :<|> "annuaire" :> Annuaire.AddWithForm
-- :<|> New.AddWithFile
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
-- TODO refactor the 3 routes below
:<|>
List
.
GETAPI
:<|>
List
.
JSONAPI
:<|>
List
.
CSVAPI
:<|>
"shareurl"
:>
ShareURL
.
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
=
WithCustomErrorScheme
(
SwaggerAPI
:<|>
GargAPI
:<|>
GraphQL
.
API
:<|>
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
---------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
-- For Tests
-- For Tests
...
...
src/Gargantext/API/Routes/Named.hs
View file @
65750c75
...
@@ -77,7 +77,7 @@ data GargAPI' mode = GargAPI'
...
@@ -77,7 +77,7 @@ data GargAPI' mode = GargAPI'
}
deriving
Generic
}
deriving
Generic
data
AuthAPI
mode
=
AuthAPI
newtype
AuthAPI
mode
=
AuthAPI
{
authEp
::
mode
:-
"auth"
:>
Summary
"AUTH API"
{
authEp
::
mode
:-
"auth"
:>
Summary
"AUTH API"
:>
ReqBody
'[
J
SON
]
AuthRequest
:>
ReqBody
'[
J
SON
]
AuthRequest
:>
Post
'[
J
SON
]
AuthResponse
:>
Post
'[
J
SON
]
AuthResponse
...
...
src/Gargantext/API/Routes/Named/Document.hs
View file @
65750c75
...
@@ -17,8 +17,8 @@ import Data.Text (Text)
...
@@ -17,8 +17,8 @@ import Data.Text (Text)
import
GHC.Generics
import
GHC.Generics
import
Gargantext.API.Admin.Orchestrator.Types
import
Gargantext.API.Admin.Orchestrator.Types
import
Gargantext.API.Node.Document.Export.Types
import
Gargantext.API.Node.Document.Export.Types
import
Gargantext.API.Node.DocumentsFromWriteNodes
(
Params
(
..
)
)
import
Gargantext.API.Node.DocumentsFromWriteNodes
.Types
(
Params
(
..
)
)
import
Gargantext.API.Node.DocumentUpload
(
DocumentUpload
(
..
),
)
import
Gargantext.API.Node.DocumentUpload
.Types
(
DocumentUpload
(
..
),
)
import
Gargantext.Utils.Servant
(
ZIP
)
import
Gargantext.Utils.Servant
(
ZIP
)
import
Servant
import
Servant
...
...
src/Gargantext/API/Routes/Named/FrameCalc.hs
View file @
65750c75
...
@@ -8,7 +8,7 @@ module Gargantext.API.Routes.Named.FrameCalc (
...
@@ -8,7 +8,7 @@ module Gargantext.API.Routes.Named.FrameCalc (
import
Servant
import
Servant
import
GHC.Generics
import
GHC.Generics
import
Gargantext.API.Node.FrameCalcUpload
(
FrameCalcUpload
)
import
Gargantext.API.Node.FrameCalcUpload
.Types
(
FrameCalcUpload
)
import
Gargantext.API.Admin.Orchestrator.Types
import
Gargantext.API.Admin.Orchestrator.Types
...
...
src/Gargantext/API/Routes/Named/Node.hs
View file @
65750c75
...
@@ -42,7 +42,7 @@ import Gargantext.API.Routes.Named.Share as Share
...
@@ -42,7 +42,7 @@ import Gargantext.API.Routes.Named.Share as Share
import
Gargantext.API.Routes.Named.Table
import
Gargantext.API.Routes.Named.Table
import
Gargantext.API.Node.Types
(
RenameNode
(
..
),
NodesToScore
(
..
),
NodesToCategory
(
..
)
)
import
Gargantext.API.Node.Types
(
RenameNode
(
..
),
NodesToScore
(
..
),
NodesToCategory
(
..
)
)
import
Gargantext.API.Node.New.Types
(
PostNode
(
..
)
)
import
Gargantext.API.Node.New.Types
(
PostNode
(
..
)
)
import
Gargantext.API.Node.Update
(
UpdateNodeParams
(
..
),
Charts
(
..
),
Granularity
(
..
),
Method
(
..
)
)
import
Gargantext.API.Node.Update
.Types
(
UpdateNodeParams
(
..
),
Charts
(
..
),
Granularity
(
..
),
Method
(
..
)
)
import
Gargantext.Core.Types
import
Gargantext.Core.Types
import
Gargantext.Core.Types.Query
import
Gargantext.Core.Types.Query
import
Gargantext.Database.Admin.Types.Hyperdata.User
(
HyperdataUser
)
import
Gargantext.Database.Admin.Types.Hyperdata.User
(
HyperdataUser
)
...
...
src/Gargantext/API/Routes/Named/Private.hs
View file @
65750c75
...
@@ -25,7 +25,6 @@ import Gargantext.API.Routes.Named.Context
...
@@ -25,7 +25,6 @@ import Gargantext.API.Routes.Named.Context
import
Gargantext.API.Routes.Named.Corpus
import
Gargantext.API.Routes.Named.Corpus
import
Gargantext.API.Routes.Named.Count
import
Gargantext.API.Routes.Named.Count
import
Gargantext.API.Routes.Named.Document
import
Gargantext.API.Routes.Named.Document
import
Gargantext.API.Routes.Named.Metrics
import
Gargantext.API.Routes.Named.Node
import
Gargantext.API.Routes.Named.Node
import
Gargantext.API.Routes.Named.List
qualified
as
List
import
Gargantext.API.Routes.Named.List
qualified
as
List
import
Gargantext.API.Routes.Named.Share
import
Gargantext.API.Routes.Named.Share
...
...
src/Gargantext/API/Routes/Named/Share.hs
View file @
65750c75
...
@@ -13,7 +13,7 @@ module Gargantext.API.Routes.Named.Share (
...
@@ -13,7 +13,7 @@ module Gargantext.API.Routes.Named.Share (
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
GHC.Generics
import
GHC.Generics
import
Gargantext.API.Node.Share
(
ShareNodeParams
(
..
)
)
import
Gargantext.API.Node.Share
.Types
(
ShareNodeParams
(
..
)
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Prelude
import
Prelude
import
Servant
import
Servant
...
...
src/Gargantext/API/Routes/Named/Viz.hs
View file @
65750c75
...
@@ -50,6 +50,8 @@ newtype PostPhylo mode = PostPhylo
...
@@ -50,6 +50,8 @@ newtype PostPhylo mode = PostPhylo
}
deriving
Generic
}
deriving
Generic
-- | There is no Delete specific API for Graph since it can be deleted
-- as simple Node.
data
GraphAPI
mode
=
GraphAPI
data
GraphAPI
mode
=
GraphAPI
{
getGraphEp
::
mode
:-
Get
'[
J
SON
]
HyperdataGraphAPI
{
getGraphEp
::
mode
:-
Get
'[
J
SON
]
HyperdataGraphAPI
,
getGraphAsyncEp
::
mode
:-
"async"
:>
NamedRoutes
GraphAsyncAPI
,
getGraphAsyncEp
::
mode
:-
"async"
:>
NamedRoutes
GraphAsyncAPI
...
...
src/Gargantext/API/Search.hs
View file @
65750c75
...
@@ -19,38 +19,22 @@ Count API part of Gargantext.
...
@@ -19,38 +19,22 @@ Count API part of Gargantext.
module
Gargantext.API.Search
module
Gargantext.API.Search
where
where
import
Data.Aeson
hiding
(
defaultTaggedObject
)
import
Data.Swagger
hiding
(
fieldLabelModifier
,
Contact
)
import
Data.Text
qualified
as
T
import
Data.Text
qualified
as
T
import
Gargantext.API.Prelude
(
GargServer
,
IsGargServer
)
import
Gargantext.API.Prelude
(
IsGargServer
)
import
Gargantext.API.Routes.Named.Search
qualified
as
Named
import
Gargantext.API.Routes.Named.Search
qualified
as
Named
import
Gargantext.API.Search.Types
import
Gargantext.API.Search.Types
import
Gargantext.Core.Text.Corpus.Query
(
RawQuery
(
..
),
parseQuery
)
import
Gargantext.Core.Text.Corpus.Query
(
RawQuery
(
..
),
parseQuery
)
import
Gargantext.Core.Types.Query
(
Limit
,
Offset
)
import
Gargantext.Core.Types.Search
import
Gargantext.Core.Types.Search
import
Gargantext.Core.Utils.Prefix
(
unPrefixSwagger
)
import
Gargantext.Database.Action.Flow.Pairing
(
isPairedWith
)
import
Gargantext.Database.Action.Flow.Pairing
(
isPairedWith
)
import
Gargantext.Database.Action.Search
import
Gargantext.Database.Action.Search
import
Gargantext.Database.Admin.Types.Node
hiding
(
DEBUG
)
import
Gargantext.Database.Admin.Types.Node
hiding
(
DEBUG
)
import
Gargantext.Database.Query.Facet
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.System.Logging
import
Gargantext.System.Logging
import
Gargantext.Utils.Aeson
(
defaultTaggedObject
)
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-- TODO-ACCESS: CanSearch? or is it part of CanGetNode
-- TODO-ACCESS: CanSearch? or is it part of CanGetNode
-- TODO-EVENTS: No event, this is a read-only query.
-- TODO-EVENTS: No event, this is a read-only query.
type
API
results
=
Summary
"Search endpoint"
:>
ReqBody
'[
J
SON
]
SearchQuery
:>
QueryParam
"offset"
Offset
:>
QueryParam
"limit"
Limit
:>
QueryParam
"order"
OrderBy
:>
Post
'[
J
SON
]
results
-----------------------------------------------------------------------
-- | Api search function
-- | Api search function
api
::
IsGargServer
env
err
m
=>
NodeId
->
Named
.
SearchAPI
SearchResult
(
AsServerT
m
)
api
::
IsGargServer
env
err
m
=>
NodeId
->
Named
.
SearchAPI
SearchResult
(
AsServerT
m
)
api
nId
=
Named
.
SearchAPI
$
\
query
o
l
order
->
case
query
of
api
nId
=
Named
.
SearchAPI
$
\
query
o
l
order
->
case
query
of
...
...
src/Gargantext/API/Server/Named/Viz.hs
View file @
65750c75
...
@@ -20,7 +20,7 @@ import Servant.Server.Generic (AsServerT)
...
@@ -20,7 +20,7 @@ import Servant.Server.Generic (AsServerT)
graphAPI
::
AuthenticatedUser
->
UserId
->
NodeId
->
Named
.
GraphAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
graphAPI
::
AuthenticatedUser
->
UserId
->
NodeId
->
Named
.
GraphAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
graphAPI
authenticatedUser
userId
n
=
withNamedAccess
authenticatedUser
(
PathNode
n
)
$
Named
.
GraphAPI
graphAPI
authenticatedUser
userId
n
=
withNamedAccess
authenticatedUser
(
PathNode
n
)
$
Named
.
GraphAPI
{
getGraphEp
=
getGraph
n
{
getGraphEp
=
getGraph
n
,
getGraphAsyncEp
=
Named
.
GraphAsyncAPI
$
graphAsync
n
,
getGraphAsyncEp
=
graphAsync
n
,
cloneGraphEp
=
graphClone
userId
n
,
cloneGraphEp
=
graphClone
userId
n
,
gexfEp
=
getGraphGexf
n
,
gexfEp
=
getGraphGexf
n
,
graphVersionsAPI
=
graphVersionsAPI
userId
n
,
graphVersionsAPI
=
graphVersionsAPI
userId
n
...
...
src/Gargantext/API/Swagger.hs
View file @
65750c75
...
@@ -21,18 +21,21 @@ import Servant
...
@@ -21,18 +21,21 @@ import Servant
import
Servant.Swagger
import
Servant.Swagger
import
qualified
Paths_gargantext
as
PG
-- cabal magic build module
import
qualified
Paths_gargantext
as
PG
-- cabal magic build module
import
Gargantext.API.Routes
import
Gargantext.API.Routes
.Named
qualified
as
Named
import
Gargantext.Prelude
import
Gargantext.Prelude
backendApiProxy
::
Proxy
(
ToServantApi
Named
.
BackEndAPI
)
backendApiProxy
=
Proxy
-- | Swagger Specifications
-- | Swagger Specifications
swaggerDoc
::
Swagger
swaggerDoc
::
Swagger
swaggerDoc
=
toSwagger
(
Proxy
::
Proxy
GargAPI
)
swaggerDoc
=
toSwagger
backendApiProxy
&
info
.
title
.~
"GarganText"
&
info
.
title
.~
"GarganText"
&
info
.
version
.~
(
cs
$
showVersion
PG
.
version
)
&
info
.
version
.~
(
cs
$
showVersion
PG
.
version
)
-- & info.base_url ?~ (URL "http://gargantext.org/")
-- & info.base_url ?~ (URL "http://gargantext.org/")
&
info
.
description
?~
"REST API specifications"
&
info
.
description
?~
"REST API specifications"
-- & tags .~ Set.fromList [Tag "Garg" (Just "Main perations") Nothing]
-- & tags .~ Set.fromList [Tag "Garg" (Just "Main perations") Nothing]
&
applyTagsFor
(
subOperations
(
Proxy
::
Proxy
GargAPI
)(
Proxy
::
Proxy
GargAPI
))
&
applyTagsFor
(
subOperations
backendApiProxy
backendApiProxy
)
[
"Gargantext"
&
description
?~
"Main operations"
]
[
"Gargantext"
&
description
?~
"Main operations"
]
&
info
.
license
?~
(
"AGPLV3 (English) and CECILL (French)"
&
url
?~
URL
urlLicence
)
&
info
.
license
?~
(
"AGPLV3 (English) and CECILL (French)"
&
url
?~
URL
urlLicence
)
where
where
...
...
src/Gargantext/API/Table.hs
View file @
65750c75
...
@@ -48,27 +48,8 @@ import Gargantext.Database.Query.Facet (FacetDoc , runViewDocuments, runCountDoc
...
@@ -48,27 +48,8 @@ import Gargantext.Database.Query.Facet (FacetDoc , runViewDocuments, runCountDoc
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.System.Logging
import
Gargantext.System.Logging
import
Servant
import
Servant.Server.Generic
import
Servant.Server.Generic
------------------------------------------------------------------------
type
TableApi
=
Summary
"Table API"
:>
QueryParam
"tabType"
TabType
:>
QueryParam
"limit"
Limit
:>
QueryParam
"offset"
Offset
:>
QueryParam
"orderBy"
OrderBy
:>
QueryParam
"query"
RawQuery
:>
QueryParam
"year"
Text
:>
Get
'[
J
SON
]
(
HashedResponse
FacetTableResult
)
:<|>
Summary
"Table API (POST)"
:>
ReqBody
'[
J
SON
]
TableQuery
:>
Post
'[
J
SON
]
FacetTableResult
:<|>
"hash"
:>
Summary
"Hash Table"
:>
QueryParam
"tabType"
TabType
:>
Get
'[
J
SON
]
Text
tableApi
::
IsGargServer
env
err
m
=>
NodeId
->
Named
.
TableAPI
(
AsServerT
m
)
tableApi
::
IsGargServer
env
err
m
=>
NodeId
->
Named
.
TableAPI
(
AsServerT
m
)
tableApi
id'
=
Named
.
TableAPI
tableApi
id'
=
Named
.
TableAPI
{
getTableEp
=
getTableApi
id'
{
getTableEp
=
getTableApi
id'
...
...
src/Gargantext/API/Viz/Types.hs
View file @
65750c75
{-# OPTIONS_GHC -Wno-orphans #-}
--instance ToSchema Value
module
Gargantext.API.Viz.Types
(
module
Gargantext.API.Viz.Types
(
SVG
(
..
)
SVG
(
..
)
,
PhyloData
(
..
)
,
PhyloData
(
..
)
...
...
src/Gargantext/Core/Viz/Graph/API.hs
View file @
65750c75
...
@@ -21,10 +21,10 @@ module Gargantext.Core.Viz.Graph.API
...
@@ -21,10 +21,10 @@ module Gargantext.Core.Viz.Graph.API
import
Control.Lens
(
set
,
_Just
,
(
^?
),
at
)
import
Control.Lens
(
set
,
_Just
,
(
^?
),
at
)
import
Data.HashMap.Strict
qualified
as
HashMap
import
Data.HashMap.Strict
qualified
as
HashMap
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Routes.Named.Viz
qualified
as
Named
import
Gargantext.Core.Methods.Similarities
(
Similarity
(
..
),
GraphMetric
(
..
),
withMetric
)
import
Gargantext.Core.Methods.Similarities
(
Similarity
(
..
),
GraphMetric
(
..
),
withMetric
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeStory
,
a_version
,
unNodeStory
,
NodeListStory
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeStory
,
a_version
,
unNodeStory
,
NodeListStory
)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
..
))
...
@@ -45,19 +45,7 @@ import Gargantext.Database.Schema.Node (node_hyperdata, node_name)
...
@@ -45,19 +45,7 @@ import Gargantext.Database.Schema.Node (node_hyperdata, node_name)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Servant
import
Servant
import
Servant.Job.Async
(
AsyncJobsAPI
)
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.XML.Conduit
(
XML
)
------------------------------------------------------------------------
-- | There is no Delete specific API for Graph since it can be deleted
-- as simple Node.
type
GraphAPI
=
Get
'[
J
SON
]
HyperdataGraphAPI
:<|>
"async"
:>
GraphAsyncAPI
:<|>
"clone"
:>
ReqBody
'[
J
SON
]
HyperdataGraphAPI
:>
Post
'[
J
SON
]
NodeId
:<|>
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
:<|>
"versions"
:>
GraphVersionsAPI
------------------------------------------------------------------------
------------------------------------------------------------------------
--getGraph :: UserId -> NodeId -> GargServer HyperdataGraphAPI
--getGraph :: UserId -> NodeId -> GargServer HyperdataGraphAPI
...
@@ -224,14 +212,8 @@ defaultGraphMetadata cId lId t repo gm str = do
...
@@ -224,14 +212,8 @@ defaultGraphMetadata cId lId t repo gm str = do
}
}
-- (map (\n -> LegendField n "#FFFFFF" (pack $ show n)) [1..10])
-- (map (\n -> LegendField n "#FFFFFF" (pack $ show n)) [1..10])
------------------------------------------------------------
graphAsync
::
NodeId
->
Named
.
GraphAsyncAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
type
GraphAsyncAPI
=
Summary
"Recompute graph"
graphAsync
n
=
Named
.
GraphAsyncAPI
$
:>
"recompute"
:>
AsyncJobsAPI
JobLog
()
JobLog
graphAsync
::
NodeId
->
ServerT
GraphAsyncAPI
(
GargM
Env
BackendInternalError
)
graphAsync
n
=
serveJobsAPI
RecomputeGraphJob
$
\
jHandle
_
->
graphRecompute
n
jHandle
serveJobsAPI
RecomputeGraphJob
$
\
jHandle
_
->
graphRecompute
n
jHandle
...
@@ -249,12 +231,6 @@ graphRecompute n jobHandle = do
...
@@ -249,12 +231,6 @@ graphRecompute n jobHandle = do
_g
<-
recomputeGraph
n
Spinglass
BridgenessMethod_Basic
Nothing
Nothing
NgramsTerms
NgramsTerms
False
_g
<-
recomputeGraph
n
Spinglass
BridgenessMethod_Basic
Nothing
Nothing
NgramsTerms
NgramsTerms
False
markComplete
jobHandle
markComplete
jobHandle
------------------------------------------------------------
type
GraphVersionsAPI
=
Summary
"Graph versions"
:>
Get
'[
J
SON
]
GraphVersions
:<|>
Summary
"Recompute graph version"
:>
Post
'[
J
SON
]
Graph
graphVersions
::
(
HasNodeStory
env
err
m
)
graphVersions
::
(
HasNodeStory
env
err
m
)
=>
UserId
=>
UserId
->
NodeId
->
NodeId
...
...
src/Gargantext/Core/Viz/Phylo/API.hs
View file @
65750c75
...
@@ -29,7 +29,6 @@ import Gargantext.Core.Viz.LegacyPhylo hiding (Phylo(..))
...
@@ -29,7 +29,6 @@ import Gargantext.Core.Viz.LegacyPhylo hiding (Phylo(..))
import
Gargantext.Core.Viz.Phylo
(
PhyloConfig
(
..
),
defaultConfig
,
_phylo_param
,
_phyloParam_config
)
import
Gargantext.Core.Viz.Phylo
(
PhyloConfig
(
..
),
defaultConfig
,
_phylo_param
,
_phyloParam_config
)
import
Gargantext.Core.Viz.Phylo.API.Tools
import
Gargantext.Core.Viz.Phylo.API.Tools
import
Gargantext.Core.Viz.Phylo.Example
(
phyloCleopatre
)
import
Gargantext.Core.Viz.Phylo.Example
(
phyloCleopatre
)
import
Gargantext.Core.Viz.Phylo.Legacy.LegacyMain
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
-- (PhyloId, ListId, CorpusId, UserId, NodeId(..))
import
Gargantext.Database.Admin.Types.Node
-- (PhyloId, ListId, CorpusId, UserId, NodeId(..))
import
Gargantext.Database.Query.Table.Node
(
getClosestParentIdByType
,
defaultList
)
import
Gargantext.Database.Query.Table.Node
(
getClosestParentIdByType
,
defaultList
)
...
@@ -40,13 +39,6 @@ import Servant
...
@@ -40,13 +39,6 @@ import Servant
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
import
Web.HttpApiData
(
readTextData
)
import
Web.HttpApiData
(
readTextData
)
------------------------------------------------------------------------
type
PhyloAPI
=
Summary
"Phylo API"
:>
GetPhylo
-- :<|> PutPhylo
:<|>
PostPhylo
phyloAPI
::
IsGargServer
err
env
m
=>
PhyloId
->
Named
.
PhyloAPI
(
AsServerT
m
)
phyloAPI
::
IsGargServer
err
env
m
=>
PhyloId
->
Named
.
PhyloAPI
(
AsServerT
m
)
phyloAPI
n
=
Named
.
PhyloAPI
phyloAPI
n
=
Named
.
PhyloAPI
{
getPhyloEp
=
getPhylo
n
{
getPhyloEp
=
getPhylo
n
...
@@ -55,27 +47,6 @@ phyloAPI n = Named.PhyloAPI
...
@@ -55,27 +47,6 @@ phyloAPI n = Named.PhyloAPI
-- :<|> putPhylo n
-- :<|> putPhylo n
-- :<|> deletePhylo n
-- :<|> deletePhylo n
type
GetPhylo
=
QueryParam
"listId"
ListId
:>
QueryParam
"level"
Level
:>
QueryParam
"minSizeBranch"
MinSizeBranch
{- :> QueryParam "filiation" Filiation
:> QueryParam "childs" Bool
:> QueryParam "depth" Level
:> QueryParam "metrics" [Metric]
:> QueryParam "periodsInf" Int
:> QueryParam "periodsSup" Int
:> QueryParam "minNodes" Int
:> QueryParam "taggers" [Tagger]
:> QueryParam "sort" Sort
:> QueryParam "order" Order
:> QueryParam "export" ExportMode
:> QueryParam "display" DisplayMode
:> QueryParam "verbose" Bool
-}
-- :> Get '[SVG] SVG
:>
Get
'[
J
SON
]
PhyloData
-- | TODO
-- | TODO
-- Add real text processing
-- Add real text processing
-- Fix Filter parameters
-- Fix Filter parameters
...
@@ -116,11 +87,6 @@ getPhyloDataJson phyloId = do
...
@@ -116,11 +87,6 @@ getPhyloDataJson phyloId = do
-- pure (SVG p)
-- pure (SVG p)
------------------------------------------------------------------------
type
PostPhylo
=
QueryParam
"listId"
ListId
-- :> ReqBody '[JSON] PhyloQueryBuild
:>
(
Post
'[
J
SON
]
NodeId
)
postPhylo
::
IsGargServer
err
env
m
=>
PhyloId
->
Named
.
PostPhylo
(
AsServerT
m
)
postPhylo
::
IsGargServer
err
env
m
=>
PhyloId
->
Named
.
PostPhylo
(
AsServerT
m
)
postPhylo
phyloId
=
Named
.
PostPhylo
$
\
_lId
->
do
postPhylo
phyloId
=
Named
.
PostPhylo
$
\
_lId
->
do
-- TODO get Reader settings
-- TODO get Reader settings
...
...
test/Test/API/Authentication.hs
View file @
65750c75
...
@@ -9,10 +9,8 @@ module Test.API.Authentication (
...
@@ -9,10 +9,8 @@ module Test.API.Authentication (
)
where
)
where
import
Control.Lens
import
Control.Lens
import
Data.Proxy
import
Data.Text
as
T
import
Data.Text
as
T
import
Gargantext.API.Admin.Auth.Types
import
Gargantext.API.Admin.Auth.Types
import
Gargantext.API.Routes
import
Gargantext.Core.Types
import
Gargantext.Core.Types
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Individu
import
Gargantext.Database.Action.User.New
import
Gargantext.Database.Action.User.New
...
@@ -25,6 +23,8 @@ import Test.API.Routes (auth_api)
...
@@ -25,6 +23,8 @@ import Test.API.Routes (auth_api)
import
Test.API.Setup
(
withTestDBAndPort
,
setupEnvironment
)
import
Test.API.Setup
(
withTestDBAndPort
,
setupEnvironment
)
import
Test.Database.Types
import
Test.Database.Types
import
Test.Hspec
import
Test.Hspec
import
Gargantext.API.Routes.Named
import
Servant.Client.Generic
(
genericClient
)
cannedToken
::
T
.
Text
cannedToken
::
T
.
Text
cannedToken
=
"eyJhbGciOiJIUzUxMiJ9.eyJkYXQiOnsiaWQiOjF9fQ.t49zZSqkPAulEkYEh4pW17H2uwrkyPTdZKwHyG3KUJ0hzU2UUoPBNj8vdv087RCVBJ4tXgxNbP4j0RBv3gxdqg"
cannedToken
=
"eyJhbGciOiJIUzUxMiJ9.eyJkYXQiOnsiaWQiOjF9fQ.t49zZSqkPAulEkYEh4pW17H2uwrkyPTdZKwHyG3KUJ0hzU2UUoPBNj8vdv087RCVBJ4tXgxNbP4j0RBv3gxdqg"
...
@@ -40,7 +40,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
...
@@ -40,7 +40,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
-- testing scenarios start here
-- testing scenarios start here
describe
"GET /api/v1.0/version"
$
do
describe
"GET /api/v1.0/version"
$
do
let
version_api
=
client
(
Proxy
::
Proxy
(
MkGargAPI
(
GargAPIVersion
GargVersion
)))
let
version_api
=
gargVersionEp
genericClient
it
"requires no auth and returns the current version"
$
\
((
_testEnv
,
port
),
_
)
->
do
it
"requires no auth and returns the current version"
$
\
((
_testEnv
,
port
),
_
)
->
do
result
<-
runClientM
version_api
(
clientEnv
port
)
result
<-
runClientM
version_api
(
clientEnv
port
)
case
result
of
case
result
of
...
...
test/Test/API/Errors.hs
View file @
65750c75
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeApplications #-}
module
Test.API.Errors
(
tests
)
where
module
Test.API.Errors
(
tests
)
where
import
Gargantext.API.Routes
import
Gargantext.API.Routes.Named.Node
import
Gargantext.API.Routes.Named.Private
import
Gargantext.Core.Types
(
Node
)
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Individu
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataUser
)
import
Gargantext.Prelude
hiding
(
get
)
import
Gargantext.Prelude
hiding
(
get
)
import
Network.HTTP.Client
hiding
(
Proxy
)
import
Network.HTTP.Client
hiding
(
Proxy
)
import
Network.HTTP.Types
import
Network.HTTP.Types
import
Network.Wai.Test
import
Network.Wai.Test
import
Servant
import
Servant.Auth.Client
()
import
Servant.Auth.Client
()
import
Servant.Auth.Client
qualified
as
SA
import
Servant.Client
import
Servant.Client
import
Servant.Client.Generic
(
genericClient
)
import
Test.API.Routes
(
mkUrl
)
import
Test.API.Routes
(
mkUrl
)
import
Test.API.Setup
(
withTestDBAndPort
,
setupEnvironment
,
createAliceAndBob
)
import
Test.API.Setup
(
withTestDBAndPort
,
setupEnvironment
,
createAliceAndBob
)
import
Test.Hspec
import
Test.Hspec
...
@@ -18,6 +21,7 @@ import Test.Hspec.Wai.Internal (withApplication)
...
@@ -18,6 +21,7 @@ import Test.Hspec.Wai.Internal (withApplication)
import
Test.Utils
(
protected
,
withValidLogin
,
protectedNewError
)
import
Test.Utils
(
protected
,
withValidLogin
,
protectedNewError
)
import
Text.RawString.QQ
(
r
)
import
Text.RawString.QQ
(
r
)
tests
::
Spec
tests
::
Spec
tests
=
sequential
$
aroundAll
withTestDBAndPort
$
do
tests
=
sequential
$
aroundAll
withTestDBAndPort
$
do
describe
"Errors API"
$
do
describe
"Errors API"
$
do
...
@@ -30,11 +34,9 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
...
@@ -30,11 +34,9 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
createAliceAndBob
testEnv
createAliceAndBob
testEnv
let
(
roots_api
:<|>
_nodes_api
let
gargAdminClient
=
(
genericClient
::
GargAdminAPI
(
AsClientT
ClientM
))
)
=
client
(
Proxy
::
Proxy
(
MkProtectedAPI
GargAdminAPI
))
(
SA
.
Token
"bogus"
)
roots
=
(
getRootsEp
.
rootsEp
$
gargAdminClient
::
ClientM
[
Node
HyperdataUser
])
let
(
admin_user_api_get
:<|>
_
)
=
roots_api
result
<-
liftIO
$
runClientM
roots
(
clientEnv
port
)
result
<-
runClientM
admin_user_api_get
(
clientEnv
port
)
length
result
`
shouldBe
`
0
length
result
`
shouldBe
`
0
describe
"GET /api/v1.0/node"
$
do
describe
"GET /api/v1.0/node"
$
do
...
...
test/Test/API/Private.hs
View file @
65750c75
...
@@ -7,14 +7,10 @@ module Test.API.Private (
...
@@ -7,14 +7,10 @@ module Test.API.Private (
tests
tests
)
where
)
where
import
Data.Text.Encoding
qualified
as
TE
import
Gargantext.API.Routes
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Individu
import
Gargantext.Prelude
hiding
(
get
)
import
Gargantext.Prelude
hiding
(
get
)
import
Network.HTTP.Client
hiding
(
Proxy
)
import
Network.HTTP.Client
hiding
(
Proxy
)
import
Servant
import
Servant.Auth.Client
()
import
Servant.Auth.Client
()
import
Servant.Auth.Client
qualified
as
SA
import
Servant.Client
import
Servant.Client
import
Test.API.Routes
(
mkUrl
)
import
Test.API.Routes
(
mkUrl
)
import
Test.API.Setup
(
withTestDBAndPort
,
setupEnvironment
,
createAliceAndBob
)
import
Test.API.Setup
(
withTestDBAndPort
,
setupEnvironment
,
createAliceAndBob
)
...
@@ -23,6 +19,11 @@ import Test.Hspec.Wai hiding (pendingWith)
...
@@ -23,6 +19,11 @@ import Test.Hspec.Wai hiding (pendingWith)
import
Test.Hspec.Wai.Internal
(
withApplication
)
import
Test.Hspec.Wai.Internal
(
withApplication
)
import
Test.Hspec.Wai.JSON
(
json
)
import
Test.Hspec.Wai.JSON
(
json
)
import
Test.Utils
(
protected
,
shouldRespondWithFragment
,
withValidLogin
)
import
Test.Utils
(
protected
,
shouldRespondWithFragment
,
withValidLogin
)
import
Gargantext.API.Routes.Named.Private
import
Gargantext.Core.Types
(
Node
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataUser
)
import
Servant.Client.Generic
(
genericClient
)
import
Gargantext.API.Routes.Named.Node
tests
::
Spec
tests
::
Spec
...
@@ -41,9 +42,8 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
...
@@ -41,9 +42,8 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
createAliceAndBob
testEnv
createAliceAndBob
testEnv
let
(
roots_api
:<|>
_nodes_api
let
gargAdminClient
=
(
genericClient
::
GargAdminAPI
(
AsClientT
ClientM
))
)
=
client
(
Proxy
::
Proxy
(
MkProtectedAPI
GargAdminAPI
))
(
SA
.
Token
"bogus"
)
admin_user_api_get
=
(
getRootsEp
.
rootsEp
$
gargAdminClient
::
ClientM
[
Node
HyperdataUser
])
let
(
admin_user_api_get
:<|>
_
)
=
roots_api
result
<-
runClientM
admin_user_api_get
(
clientEnv
port
)
result
<-
runClientM
admin_user_api_get
(
clientEnv
port
)
length
result
`
shouldBe
`
0
length
result
`
shouldBe
`
0
...
@@ -51,10 +51,9 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
...
@@ -51,10 +51,9 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
-- FIXME(adn): unclear if this is useful at all. Doesn't do permission checking.
-- FIXME(adn): unclear if this is useful at all. Doesn't do permission checking.
it
"allows 'alice' to see the results"
$
\
((
_testEnv
,
port
),
_
)
->
do
it
"allows 'alice' to see the results"
$
\
((
_testEnv
,
port
),
_
)
->
do
withValidLogin
port
"alice"
(
GargPassword
"alice"
)
$
\
token
->
do
withValidLogin
port
"alice"
(
GargPassword
"alice"
)
$
\
_token
->
do
let
(
roots_api
:<|>
_nodes_api
let
gargAdminClient
=
(
genericClient
::
GargAdminAPI
(
AsClientT
ClientM
))
)
=
client
(
Proxy
::
Proxy
(
MkProtectedAPI
GargAdminAPI
))
(
SA
.
Token
$
TE
.
encodeUtf8
$
token
)
admin_user_api_get
=
(
getRootsEp
.
rootsEp
$
gargAdminClient
::
ClientM
[
Node
HyperdataUser
])
let
(
admin_user_api_get
:<|>
_
)
=
roots_api
_nodes
<-
runClientM
admin_user_api_get
(
clientEnv
port
)
_nodes
<-
runClientM
admin_user_api_get
(
clientEnv
port
)
pendingWith
"currently useless"
pendingWith
"currently useless"
...
...
test/Test/API/Routes.hs
View file @
65750c75
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
module
Test.API.Routes
where
module
Test.API.Routes
where
import
Fmt
(
Builder
,
(
+|
),
(
|+
))
import
Fmt
(
Builder
,
(
+|
),
(
|+
))
import
Gargantext.API.Admin.Auth.Types
(
AuthRequest
,
AuthResponse
)
import
Gargantext.API.Admin.Auth.Types
(
AuthRequest
,
AuthResponse
)
import
Gargantext.API.Ngrams
(
TableNgramsApiGet
,
TableNgramsApiPut
)
import
Gargantext.API.Ngrams.Types
(
NgramsTable
,
NgramsTablePatch
,
OrderBy
,
TabType
,
Versioned
,
VersionedWithCount
)
import
Gargantext.API.Ngrams.Types
(
NgramsTable
,
NgramsTablePatch
,
OrderBy
,
TabType
,
Versioned
,
VersionedWithCount
)
import
Gargantext.API.Routes
(
AuthAPI
,
GargAPIVersion
,
MkGargAPI
)
import
Gargantext.API.Routes.Named
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Core.Types.Main
(
ListType
)
import
Gargantext.Core.Types.Main
(
ListType
)
import
Gargantext.Core.Types.Query
(
Limit
,
MaxSize
,
MinSize
,
Offset
)
import
Gargantext.Core.Types.Query
(
Limit
,
MaxSize
,
MinSize
,
Offset
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Network.Wai.Handler.Warp
(
Port
)
import
Network.Wai.Handler.Warp
(
Port
)
import
Servant
((
:>
),
Capture
)
import
Servant.Client
(
ClientM
)
import
Servant.Client
(
ClientM
,
client
)
import
Servant.Client.Generic
(
genericClient
,
AsClientT
)
import
Gargantext.API.Routes.Named.Table
import
Gargantext.Core.Types
(
ListId
)
-- This is for requests made by http.client directly to hand-crafted URLs
-- This is for requests made by http.client directly to hand-crafted URLs
...
@@ -29,18 +30,14 @@ mkUrl _port urlPiece =
...
@@ -29,18 +30,14 @@ mkUrl _port urlPiece =
-- This is for Servant.Client requests
-- This is for Servant.Client requests
auth_api
::
AuthRequest
->
ClientM
AuthResponse
auth_api
::
AuthRequest
->
ClientM
AuthResponse
auth_api
=
client
(
Proxy
::
Proxy
(
MkGargAPI
(
GargAPIVersion
AuthAPI
)))
auth_api
=
authEp
cliRoutes
where
-- | Shortcut for TableNgramsApiGet full path
cliRoutes
::
AuthAPI
(
AsClientT
ClientM
)
type
APITableNgramsGet
=
MkGargAPI
(
GargAPIVersion
(
"node"
cliRoutes
=
genericClient
@
AuthAPI
:>
Capture
"node_id"
NodeId
:>
"ngrams"
table_ngrams_get_api
::
TabType
:>
TableNgramsApiGet
)
)
->
ListId
table_ngrams_get_api
::
NodeId
->
TabType
->
NodeId
->
Limit
->
Limit
->
Maybe
Offset
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
ListType
...
@@ -49,14 +46,16 @@ table_ngrams_get_api :: NodeId
...
@@ -49,14 +46,16 @@ table_ngrams_get_api :: NodeId
->
Maybe
OrderBy
->
Maybe
OrderBy
->
Maybe
Text
->
Maybe
Text
->
ClientM
(
VersionedWithCount
NgramsTable
)
->
ClientM
(
VersionedWithCount
NgramsTable
)
table_ngrams_get_api
=
client
(
Proxy
::
Proxy
APITableNgramsGet
)
table_ngrams_get_api
=
getNgramsTableEp
cliRoutes
type
APITableNgramsPut
=
MkGargAPI
(
GargAPIVersion
(
"node"
where
:>
Capture
"node_id"
NodeId
cliRoutes
::
TableNgramsApiGet
(
AsClientT
ClientM
)
:>
"ngrams"
cliRoutes
=
genericClient
@
(
TableNgramsApiGet
)
:>
TableNgramsApiPut
)
)
table_ngrams_put_api
::
NodeId
table_ngrams_put_api
::
TabType
->
TabType
->
ListId
->
NodeId
->
Versioned
NgramsTablePatch
->
Versioned
NgramsTablePatch
->
ClientM
(
Versioned
NgramsTablePatch
)
->
ClientM
(
Versioned
NgramsTablePatch
)
table_ngrams_put_api
=
client
(
Proxy
::
Proxy
APITableNgramsPut
)
table_ngrams_put_api
=
putNgramsTableEp
cliRoutes
where
cliRoutes
::
TableNgramsApiPut
(
AsClientT
ClientM
)
cliRoutes
=
genericClient
@
TableNgramsApiPut
test/Test/API/UpdateList.hs
View file @
65750c75
...
@@ -13,7 +13,7 @@ module Test.API.UpdateList (
...
@@ -13,7 +13,7 @@ module Test.API.UpdateList (
,
pollUntilFinished
,
pollUntilFinished
)
where
)
where
import
Control.Lens
(
(
^.
),
mapped
,
over
)
import
Control.Lens
(
mapped
,
over
)
import
Control.Monad.Fail
(
fail
)
import
Control.Monad.Fail
(
fail
)
import
Data.Aeson.QQ
import
Data.Aeson.QQ
import
Data.Map.Strict
qualified
as
Map
import
Data.Map.Strict
qualified
as
Map
...
@@ -136,7 +136,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
...
@@ -136,7 +136,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
listId
<-
uploadJSONList
port
token
cId
listId
<-
uploadJSONList
port
token
cId
let
checkNgrams
expected
=
do
let
checkNgrams
expected
=
do
eng
<-
liftIO
$
runClientM
(
table_ngrams_get_api
cId
APINgrams
.
Terms
listId
10
Nothing
(
Just
MapTerm
)
Nothing
Nothing
Nothing
Nothing
)
clientEnv
eng
<-
liftIO
$
runClientM
(
table_ngrams_get_api
APINgrams
.
Terms
listId
10
Nothing
(
Just
MapTerm
)
Nothing
Nothing
Nothing
Nothing
)
clientEnv
case
eng
of
case
eng
of
Left
err
->
fail
(
show
err
)
Left
err
->
fail
(
show
err
)
Right
r
->
Right
r
->
...
@@ -155,7 +155,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
...
@@ -155,7 +155,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
,
NgramsReplace
{
_patch_old
=
Nothing
,
NgramsReplace
{
_patch_old
=
Nothing
,
_patch_new
=
Just
nre
}
)
,
_patch_new
=
Just
nre
}
)
]
]
_
<-
liftIO
$
runClientM
(
table_ngrams_put_api
cId
APINgrams
.
Terms
listId
(
Versioned
1
$
NgramsTablePatch
$
fst
patch
))
clientEnv
_
<-
liftIO
$
runClientM
(
table_ngrams_put_api
APINgrams
.
Terms
listId
(
Versioned
1
$
NgramsTablePatch
$
fst
patch
))
clientEnv
-- check that new term is added (with no parent)
-- check that new term is added (with no parent)
checkNgrams
[
(
newTerm
,
[]
)
checkNgrams
[
(
newTerm
,
[]
)
...
@@ -166,7 +166,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
...
@@ -166,7 +166,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
(
newTerm
(
newTerm
,
toNgramsPatch
[
importedTerm
]
)
,
toNgramsPatch
[
importedTerm
]
)
]
]
_
<-
liftIO
$
runClientM
(
table_ngrams_put_api
cId
APINgrams
.
Terms
listId
(
Versioned
32
$
NgramsTablePatch
$
fst
patchChildren
))
clientEnv
_
<-
liftIO
$
runClientM
(
table_ngrams_put_api
APINgrams
.
Terms
listId
(
Versioned
32
$
NgramsTablePatch
$
fst
patchChildren
))
clientEnv
-- check that new term is parent of old one
-- check that new term is parent of old one
checkNgrams
[
(
newTerm
,
[
importedTerm
])
]
checkNgrams
[
(
newTerm
,
[
importedTerm
])
]
...
...
test/Test/Graph/Distance.hs
View file @
65750c75
...
@@ -15,8 +15,6 @@ commentary with @some markup@.
...
@@ -15,8 +15,6 @@ commentary with @some markup@.
module
Test.Graph.Distance
where
module
Test.Graph.Distance
where
import
Test.Hspec
{-
{-
import Gargantext.Core.Methods.Matrix.Accelerate.Utils (cross', matrix)
import Gargantext.Core.Methods.Matrix.Accelerate.Utils (cross', matrix)
import Gargantext.Prelude
import Gargantext.Prelude
...
...
test/Test/Types.hs
View file @
65750c75
module
Test.Types
where
module
Test.Types
where
import
Data.Aeson
((
.:
),
(
.:?
),
(
.=
),
FromJSON
(
..
),
ToJSON
(
..
),
object
,
withObject
)
import
Data.Aeson
((
.:
),
(
.:?
),
(
.=
),
object
,
withObject
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
))
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
))
import
Gargantext.Prelude
import
Gargantext.Prelude
...
...
test/Test/Utils.hs
View file @
65750c75
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
module
Test.Utils
where
module
Test.Utils
where
import
Control.Exception
()
import
Control.Exception
()
import
Control.Lens
((
^.
))
import
Control.Monad
()
import
Control.Monad
()
import
Data.Aeson
qualified
as
JSON
import
Data.Aeson
qualified
as
JSON
import
Data.Aeson.KeyMap
qualified
as
KM
import
Data.Aeson.KeyMap
qualified
as
KM
...
...
test/Test/Utils/Crypto.hs
View file @
65750c75
...
@@ -27,11 +27,11 @@ test = do
...
@@ -27,11 +27,11 @@ test = do
hash
text
`
shouldBe
`
hashed
hash
text
`
shouldBe
`
hashed
describe
"Hash List with backend works"
$
do
describe
"Hash List with backend works"
$
do
let
l
i
st
=
[
"a"
,
"b"
]
::
[
Text
]
let
lst
=
[
"a"
,
"b"
]
::
[
Text
]
let
hashed
=
"ab19ec537f09499b26f0f62eed7aefad46ab9f498e06a7328ce8e8ef90da6d86"
::
Hash
let
hashed
=
"ab19ec537f09499b26f0f62eed7aefad46ab9f498e06a7328ce8e8ef90da6d86"
::
Hash
-- ^ hash from frontend with text above
-- ^ hash from frontend with text above
it
"compare"
$
do
it
"compare"
$
do
hash
l
i
st
`
shouldBe
`
hashed
hash
lst
`
shouldBe
`
hashed
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | TODO property based tests
-- | TODO property based tests
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
5660aec0
·
Oct 08, 2024
mentioned in commit
5660aec0
mentioned in commit 5660aec07ec5a0a0a5468f440092c1a8f57a864e
Toggle commit list
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