Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Przemyslaw Kaminski
haskell-gargantext
Commits
27cd8cf4
Commit
27cd8cf4
authored
Sep 29, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIXME] Api_Node type error
parent
8f4ae06a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
8 deletions
+42
-8
API.hs
src/Gargantext/API.hs
+1
-1
Public.hs
src/Gargantext/API/Public.hs
+40
-6
Routes.hs
src/Gargantext/API/Routes.hs
+1
-1
No files found.
src/Gargantext/API.hs
View file @
27cd8cf4
...
@@ -246,7 +246,7 @@ serverGargAPI baseUrl -- orchestrator
...
@@ -246,7 +246,7 @@ serverGargAPI baseUrl -- orchestrator
:<|>
gargVersion
:<|>
gargVersion
:<|>
serverPrivateGargAPI
:<|>
serverPrivateGargAPI
:<|>
(
Public
.
api
baseUrl
)
:<|>
(
Public
.
api
baseUrl
)
-- :<|> orchestrator
-- :<|> orchestrator
where
where
gargVersion
::
GargServer
GargVersion
gargVersion
::
GargServer
GargVersion
...
...
src/Gargantext/API/Public.hs
View file @
27cd8cf4
...
@@ -16,6 +16,7 @@ Portability : POSIX
...
@@ -16,6 +16,7 @@ Portability : POSIX
module
Gargantext.API.Public
module
Gargantext.API.Public
where
where
import
Data.Set
(
Set
)
import
Control.Lens
((
^?
),
(
^.
),
_Just
)
import
Control.Lens
((
^?
),
(
^.
),
_Just
)
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
catMaybes
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
...
@@ -23,6 +24,8 @@ import Data.List (replicate, null)
...
@@ -23,6 +24,8 @@ import Data.List (replicate, null)
import
Data.Aeson
import
Data.Aeson
import
Data.Swagger
import
Data.Swagger
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Prelude
import
Gargantext.API.Node.File
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Prelude
import
Gargantext.Database.Prelude
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
...
@@ -34,22 +37,44 @@ import Gargantext.Prelude
...
@@ -34,22 +37,44 @@ import Gargantext.Prelude
import
Servant
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck.Arbitrary
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
------------------------------------------------------------------------
------------------------------------------------------------------------
type
API
=
Summary
" Public API"
type
API
=
API_Home
-- :<|> API_Node
api
::
Text
->
GargServer
API
api
baseUrl
=
(
api_home
baseUrl
)
-- :<|> api_node
-------------------------------------------------------------------------
type
API_Home
=
Summary
" Public API"
:>
Get
'[
J
SON
]
[
PublicData
]
:>
Get
'[
J
SON
]
[
PublicData
]
api
::
HasNodeError
err
api_home
::
Text
->
GargServer
API_Home
=>
Text
->
Cmd
err
[
PublicData
]
api_home
baseUrl
=
catMaybes
api
base
=
catMaybes
<$>
map
(
toPublicData
baseUrl
)
<$>
map
(
toPublicData
base
)
<$>
filterPublicDatas
<$>
filterPublicDatas
<$>
selectPublic
<$>
selectPublic
-------------------------------------------------------------------------
type
API_Node
=
Summary
" Public Node API"
:>
FileApi
api_node
::
UserId
->
NodeId
->
GargServer
FileApi
api_node
uid
nId
=
do
pubNodes
<-
publicNodes
case
Set
.
member
nId
pubNodes
of
False
->
panic
"Not allowed"
-- TODO throwErr
True
->
fileApi
uid
nId
-------------------------------------------------------------------------
selectPublic
::
HasNodeError
err
selectPublic
::
HasNodeError
err
=>
Cmd
err
[(
Node
HyperdataFolder
,
Maybe
Int
)]
=>
Cmd
err
[(
Node
HyperdataFolder
,
Maybe
Int
)]
selectPublic
=
selectPublicNodes
selectPublic
=
selectPublicNodes
-- For tests only
-- For tests only
...
@@ -66,6 +91,15 @@ filterPublicDatas datas =
...
@@ -66,6 +91,15 @@ filterPublicDatas datas =
&
Map
.
filter
(
not
.
null
.
snd
)
&
Map
.
filter
(
not
.
null
.
snd
)
&
Map
.
elems
&
Map
.
elems
publicNodes
::
HasNodeError
err
=>
Cmd
err
(
Set
NodeId
)
publicNodes
=
do
candidates
<-
filterPublicDatas
<$>
selectPublicNodes
pure
$
Set
.
fromList
$
List
.
concat
$
map
(
\
(
n
,
ns
)
->
(
_node_id
n
)
:
ns
)
candidates
-- http://localhost:8008/api/v1.0/node/23543/file/download<Paste>
-- http://localhost:8008/api/v1.0/node/23543/file/download<Paste>
-- http://localhost:8000/images/Gargantextuel-212x300.jpg
-- http://localhost:8000/images/Gargantextuel-212x300.jpg
toPublicData
::
Text
->
(
Node
HyperdataFolder
,
[
NodeId
])
->
Maybe
PublicData
toPublicData
::
Text
->
(
Node
HyperdataFolder
,
[
NodeId
])
->
Maybe
PublicData
...
...
src/Gargantext/API/Routes.hs
View file @
27cd8cf4
...
@@ -74,7 +74,7 @@ type GargAPI' =
...
@@ -74,7 +74,7 @@ type GargAPI' =
-- TODO-ACCESS here we want to request a particular header for
-- TODO-ACCESS here we want to request a particular header for
-- auth and capabilities.
-- auth and capabilities.
:<|>
GargPrivateAPI
:<|>
GargPrivateAPI
:<|>
"public"
:>
Public
.
API
:<|>
"public"
:>
Public
.
API
type
GargPrivateAPI
=
SA
.
Auth
'[
S
A
.
JWT
,
SA
.
Cookie
]
AuthenticatedUser
type
GargPrivateAPI
=
SA
.
Auth
'[
S
A
.
JWT
,
SA
.
Cookie
]
AuthenticatedUser
...
...
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