]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Types/Node.hs
[REFACTORING] Hyperdata Nodes (Texts for now).
[gargantext.git] / src / Gargantext / Database / Types / Node.hs
1 {-|
2 Module : Gargantext.Database.Types.Nodes
3 Description : Main Types of Nodes in Database
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# OPTIONS_GHC -fno-warn-orphans #-}
13
14 {-# LANGUAGE BangPatterns #-}
15 {-# LANGUAGE DeriveGeneric #-}
16 {-# LANGUAGE FlexibleInstances #-}
17 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
18 {-# LANGUAGE NoImplicitPrelude #-}
19 {-# LANGUAGE OverloadedStrings #-}
20 {-# LANGUAGE TemplateHaskell #-}
21 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
22 -- {-# LANGUAGE DuplicateRecordFields #-}
23
24 module Gargantext.Database.Types.Node
25 where
26
27 import Prelude (Enum, Bounded, minBound, maxBound)
28
29 import GHC.Generics (Generic)
30
31 import Control.Lens hiding (elements, (&))
32 import Control.Applicative ((<*>))
33 import Control.Monad (mzero)
34
35 import Data.Aeson
36 import Data.Aeson.Types (emptyObject)
37 import Data.Aeson (Object, toJSON)
38 import Data.Aeson.TH (deriveJSON)
39 import Data.ByteString.Lazy (ByteString)
40 import Data.Either
41 import Data.Eq (Eq)
42 import Data.Monoid (mempty)
43 import Data.Text (Text, unpack, pack)
44 import Data.Time (UTCTime)
45 import Data.Time.Segment (jour, timesAfter, Granularity(D))
46 import Data.Swagger
47
48 import Text.Read (read)
49 import Text.Show (Show())
50
51 import Database.PostgreSQL.Simple.ToField (ToField, toField, toJSONField)
52 import Database.PostgreSQL.Simple.FromField (FromField, fromField)
53 import Servant
54
55 import Test.QuickCheck.Arbitrary
56 import Test.QuickCheck (elements)
57
58 import Gargantext.Prelude
59 import Gargantext.Core.Utils.Prefix (unPrefix)
60 import Gargantext.Viz.Phylo (Phylo)
61 --import Gargantext.Database.Utils
62 ------------------------------------------------------------------------
63 newtype NodeId = NodeId Int
64 deriving (Show, Read, Generic, Num, Eq, Ord, Enum, ToJSONKey, FromJSONKey, ToJSON, FromJSON)
65
66 instance ToField NodeId where
67 toField (NodeId n) = toField n
68
69
70 instance FromField NodeId where
71 fromField field mdata = do
72 n <- fromField field mdata
73 if (n :: Int) > 0
74 then return $ NodeId n
75 else mzero
76
77 instance ToSchema NodeId
78
79 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
80 type NodeTypeId = Int
81 type NodeName = Text
82 type TSVector = Text
83
84 ------------------------------------------------------------------------
85 data NodePoly id typename userId
86 parentId name date
87 hyperdata = Node { _node_id :: id
88 , _node_typename :: typename
89
90 , _node_userId :: userId
91 , _node_parentId :: parentId
92
93 , _node_name :: name
94 , _node_date :: date
95
96 , _node_hyperdata :: hyperdata
97 } deriving (Show, Generic)
98 $(deriveJSON (unPrefix "_node_") ''NodePoly)
99 $(makeLenses ''NodePoly)
100
101 -- | NodePoly indicates that Node has a Polymorphism Type
102 type Node json = NodePoly NodeId NodeTypeId UserId (Maybe ParentId) NodeName UTCTime json
103
104
105
106 ------------------------------------------------------------------------
107
108
109 instance FromHttpApiData NodeId where
110 parseUrlPiece n = pure $ NodeId $ (read . cs) n
111
112 instance ToParamSchema NodeId
113 instance Arbitrary NodeId where
114 arbitrary = NodeId <$> arbitrary
115
116 type ParentId = NodeId
117 type CorpusId = NodeId
118 type ListId = NodeId
119 type DocumentId = NodeId
120 type DocId = DocumentId -- todo: remove this
121 type RootId = NodeId
122 type MasterCorpusId = CorpusId
123 type UserCorpusId = CorpusId
124
125 type GraphId = NodeId
126 type PhyloId = NodeId
127 type AnnuaireId = NodeId
128 type ContactId = NodeId
129
130 type UserId = Int
131 type MasterUserId = UserId
132
133 id2int :: NodeId -> Int
134 id2int (NodeId n) = n
135
136
137 type UTCTime' = UTCTime
138
139 instance Arbitrary UTCTime' where
140 arbitrary = elements $ timesAfter 100 D (jour 2000 01 01)
141
142 ------------------------------------------------------------------------
143 data Status = Status { status_failed :: !Int
144 , status_succeeded :: !Int
145 , status_remaining :: !Int
146 } deriving (Show, Generic)
147 $(deriveJSON (unPrefix "status_") ''Status)
148
149 instance Arbitrary Status where
150 arbitrary = Status <$> arbitrary <*> arbitrary <*> arbitrary
151
152 ------------------------------------------------------------------------
153 data StatusV3 = StatusV3 { statusV3_error :: !(Maybe Text)
154 , statusV3_action :: !(Maybe Text)
155 } deriving (Show, Generic)
156 $(deriveJSON (unPrefix "statusV3_") ''StatusV3)
157 ------------------------------------------------------------------------
158
159 -- Only Hyperdata types should be member of this type class.
160
161 ------------------------------------------------------------------------
162 data HyperdataDocumentV3 = HyperdataDocumentV3 { hyperdataDocumentV3_publication_day :: !(Maybe Int)
163 , hyperdataDocumentV3_language_iso2 :: !(Maybe Text)
164 , hyperdataDocumentV3_publication_second :: !(Maybe Int)
165 , hyperdataDocumentV3_publication_minute :: !(Maybe Int)
166 , hyperdataDocumentV3_publication_month :: !(Maybe Int)
167 , hyperdataDocumentV3_publication_hour :: !(Maybe Int)
168 , hyperdataDocumentV3_error :: !(Maybe Text)
169 , hyperdataDocumentV3_language_iso3 :: !(Maybe Text)
170 , hyperdataDocumentV3_authors :: !(Maybe Text)
171 , hyperdataDocumentV3_publication_year :: !(Maybe Int)
172 , hyperdataDocumentV3_publication_date :: !(Maybe Text)
173 , hyperdataDocumentV3_language_name :: !(Maybe Text)
174 , hyperdataDocumentV3_statuses :: !(Maybe [StatusV3])
175 , hyperdataDocumentV3_realdate_full_ :: !(Maybe Text)
176 , hyperdataDocumentV3_source :: !(Maybe Text)
177 , hyperdataDocumentV3_abstract :: !(Maybe Text)
178 , hyperdataDocumentV3_title :: !(Maybe Text)
179 } deriving (Show, Generic)
180 $(deriveJSON (unPrefix "hyperdataDocumentV3_") ''HyperdataDocumentV3)
181
182 class Hyperdata a
183 instance Hyperdata HyperdataDocumentV3
184
185 ------------------------------------------------------------------------
186 data HyperdataDocument = HyperdataDocument { _hyperdataDocument_bdd :: !(Maybe Text)
187 , _hyperdataDocument_doi :: !(Maybe Text)
188 , _hyperdataDocument_url :: !(Maybe Text)
189 , _hyperdataDocument_uniqId :: !(Maybe Text)
190 , _hyperdataDocument_uniqIdBdd :: !(Maybe Text)
191 , _hyperdataDocument_page :: !(Maybe Int)
192 , _hyperdataDocument_title :: !(Maybe Text)
193 , _hyperdataDocument_authors :: !(Maybe Text)
194 , _hyperdataDocument_institutes :: !(Maybe Text)
195 , _hyperdataDocument_source :: !(Maybe Text)
196 , _hyperdataDocument_abstract :: !(Maybe Text)
197 , _hyperdataDocument_publication_date :: !(Maybe Text)
198 , _hyperdataDocument_publication_year :: !(Maybe Int)
199 , _hyperdataDocument_publication_month :: !(Maybe Int)
200 , _hyperdataDocument_publication_day :: !(Maybe Int)
201 , _hyperdataDocument_publication_hour :: !(Maybe Int)
202 , _hyperdataDocument_publication_minute :: !(Maybe Int)
203 , _hyperdataDocument_publication_second :: !(Maybe Int)
204 , _hyperdataDocument_language_iso2 :: !(Maybe Text)
205 } deriving (Show, Generic)
206
207 $(deriveJSON (unPrefix "_hyperdataDocument_") ''HyperdataDocument)
208 $(makeLenses ''HyperdataDocument)
209
210 class ToHyperdataDocument a where
211 toHyperdataDocument :: a -> HyperdataDocument
212
213 instance ToHyperdataDocument HyperdataDocument
214 where
215 toHyperdataDocument = identity
216
217 instance Eq HyperdataDocument where
218 (==) h1 h2 = (==) (_hyperdataDocument_uniqId h1) (_hyperdataDocument_uniqId h2)
219
220 instance Ord HyperdataDocument where
221 compare h1 h2 = compare (_hyperdataDocument_publication_date h1) (_hyperdataDocument_publication_date h2)
222
223 instance Hyperdata HyperdataDocument
224
225 instance ToField HyperdataDocument where
226 toField = toJSONField
227
228 instance Arbitrary HyperdataDocument where
229 arbitrary = elements arbitraryHyperdataDocuments
230
231 arbitraryHyperdataDocuments :: [HyperdataDocument]
232 arbitraryHyperdataDocuments =
233 map toHyperdataDocument' ([ ("AI is big but less than crypto", "Troll System journal")
234 , ("Crypto is big but less than AI", "System Troll review" )
235 , ("Science is magic" , "Closed Source review")
236 , ("Open science for all" , "No Time" )
237 , ("Closed science for me" , "No Space" )
238 ] :: [(Text, Text)])
239 where
240 toHyperdataDocument' (t1,t2) =
241 HyperdataDocument Nothing Nothing Nothing Nothing Nothing Nothing (Just t1)
242 Nothing Nothing (Just t2) Nothing Nothing Nothing Nothing Nothing
243 Nothing Nothing Nothing Nothing
244
245 ------------------------------------------------------------------------
246 data LanguageNodes = LanguageNodes { languageNodes___unknown__ :: [Int]}
247 deriving (Show, Generic)
248 $(deriveJSON (unPrefix "languageNodes_") ''LanguageNodes)
249
250 ------------------------------------------------------------------------
251 -- level: debug | dev (fatal = critical)
252 data EventLevel = CRITICAL | FATAL | ERROR | WARNING | INFO | DEBUG
253 deriving (Show, Generic, Enum, Bounded)
254
255 instance FromJSON EventLevel
256 instance ToJSON EventLevel
257
258 instance Arbitrary EventLevel where
259 arbitrary = elements [minBound..maxBound]
260
261 instance ToSchema EventLevel where
262 declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy
263
264 ------------------------------------------------------------------------
265
266 data Event = Event { event_level :: !EventLevel
267 , event_message :: !Text
268 , event_date :: !UTCTime
269 } deriving (Show, Generic)
270 $(deriveJSON (unPrefix "event_") ''Event)
271
272 instance Arbitrary Event where
273 arbitrary = Event <$> arbitrary <*> arbitrary <*> arbitrary
274
275 instance ToSchema Event where
276 declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy
277
278 ------------------------------------------------------------------------
279 instance Arbitrary Text where
280 arbitrary = elements $ map (\c -> pack [c]) ['a'..'z']
281
282 data Resource = Resource { resource_path :: !(Maybe Text)
283 , resource_scraper :: !(Maybe Text)
284 , resource_query :: !(Maybe Text)
285 , resource_events :: !([Event])
286 , resource_status :: !Status
287 , resource_date :: !UTCTime'
288 } deriving (Show, Generic)
289 $(deriveJSON (unPrefix "resource_") ''Resource)
290
291 instance Arbitrary Resource where
292 arbitrary = Resource <$> arbitrary
293 <*> arbitrary
294 <*> arbitrary
295 <*> arbitrary
296 <*> arbitrary
297 <*> arbitrary
298
299 instance ToSchema Resource where
300 declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy
301
302 ------------------------------------------------------------------------
303 data HyperdataUser = HyperdataUser { hyperdataUser_language :: Maybe Text
304 } deriving (Show, Generic)
305 $(deriveJSON (unPrefix "hyperdataUser_") ''HyperdataUser)
306
307 instance Hyperdata HyperdataUser
308 ------------------------------------------------------------------------
309 data HyperdataFolder = HyperdataFolder { hyperdataFolder_desc :: Maybe Text
310 } deriving (Show, Generic)
311 $(deriveJSON (unPrefix "hyperdataFolder_") ''HyperdataFolder)
312
313 instance Hyperdata HyperdataFolder
314 ------------------------------------------------------------------------
315 data HyperdataCorpus = HyperdataCorpus { hyperdataCorpus_title :: !(Maybe Text)
316 , hyperdataCorpus_desc :: !(Maybe Text)
317 , hyperdataCorpus_query :: !(Maybe Text)
318 , hyperdataCorpus_authors :: !(Maybe Text)
319 , hyperdataCorpus_resources :: !(Maybe [Resource])
320 } deriving (Show, Generic)
321 $(deriveJSON (unPrefix "hyperdataCorpus_") ''HyperdataCorpus)
322
323 instance Hyperdata HyperdataCorpus
324
325 corpusExample :: ByteString
326 corpusExample = "" -- TODO
327
328 defaultCorpus :: HyperdataCorpus
329 defaultCorpus = (HyperdataCorpus (Just "Title") (Just "Descr") (Just "Bool query") (Just "Authors") Nothing)
330
331 hyperdataCorpus :: HyperdataCorpus
332 hyperdataCorpus = case decode corpusExample of
333 Just hp -> hp
334 Nothing -> defaultCorpus
335
336 instance Arbitrary HyperdataCorpus where
337 arbitrary = pure hyperdataCorpus -- TODO
338
339 ------------------------------------------------------------------------
340 ------------------------------------------------------------------------
341 data HyperdataAnnuaire = HyperdataAnnuaire { hyperdataAnnuaire_title :: !(Maybe Text)
342 , hyperdataAnnuaire_desc :: !(Maybe Text)
343 } deriving (Show, Generic)
344 $(deriveJSON (unPrefix "hyperdataAnnuaire_") ''HyperdataAnnuaire)
345
346 instance Hyperdata HyperdataAnnuaire
347
348 hyperdataAnnuaire :: HyperdataAnnuaire
349 hyperdataAnnuaire = HyperdataAnnuaire (Just "Annuaire Title") (Just "Annuaire Description")
350
351 instance Arbitrary HyperdataAnnuaire where
352 arbitrary = pure hyperdataAnnuaire -- TODO
353
354 ------------------------------------------------------------------------
355 newtype HyperdataAny = HyperdataAny Object
356 deriving (Show, Generic, ToJSON, FromJSON)
357
358 instance Hyperdata HyperdataAny
359
360 instance Arbitrary HyperdataAny where
361 arbitrary = pure $ HyperdataAny mempty -- TODO produce arbitrary objects
362 ------------------------------------------------------------------------
363
364 data HyperdataList = HyperdataList { hyperdataList_preferences :: !(Maybe Text)
365 } deriving (Show, Generic)
366 $(deriveJSON (unPrefix "hyperdataList_") ''HyperdataList)
367
368 instance Hyperdata HyperdataList
369
370 instance Arbitrary HyperdataList where
371 arbitrary = elements [HyperdataList (Just "from list A")]
372
373 ----
374 data HyperdataListModel = HyperdataListModel { _hlm_params :: !(Int, Int)
375 , _hlm_path :: !Text
376 , _hlm_score :: !(Maybe Double)
377 } deriving (Show, Generic)
378
379 instance Hyperdata HyperdataListModel
380 instance Arbitrary HyperdataListModel where
381 arbitrary = elements [HyperdataListModel (100,100) "models/example.model" Nothing]
382
383 $(deriveJSON (unPrefix "_hlm_") ''HyperdataListModel)
384 $(makeLenses ''HyperdataListModel)
385
386 ------------------------------------------------------------------------
387 data HyperdataScore = HyperdataScore { hyperdataScore_preferences :: !(Maybe Text)
388 } deriving (Show, Generic)
389 $(deriveJSON (unPrefix "hyperdataScore_") ''HyperdataScore)
390
391 instance Hyperdata HyperdataScore
392
393 ------------------------------------------------------------------------
394
395 data HyperdataResource = HyperdataResource { hyperdataResource_preferences :: !(Maybe Text)
396 } deriving (Show, Generic)
397 $(deriveJSON (unPrefix "hyperdataResource_") ''HyperdataResource)
398
399 instance Hyperdata HyperdataResource
400
401 ------------------------------------------------------------------------
402 data HyperdataDashboard = HyperdataDashboard { hyperdataDashboard_preferences :: !(Maybe Text)
403 } deriving (Show, Generic)
404 $(deriveJSON (unPrefix "hyperdataDashboard_") ''HyperdataDashboard)
405
406 instance Hyperdata HyperdataDashboard
407
408 -- TODO add the Graph Structure here
409 data HyperdataGraph = HyperdataGraph { hyperdataGraph_preferences :: !(Maybe Text)
410 } deriving (Show, Generic)
411 $(deriveJSON (unPrefix "hyperdataGraph_") ''HyperdataGraph)
412
413 instance Hyperdata HyperdataGraph
414
415 ------------------------------------------------------------------------
416
417 -- TODO add the Graph Structure here
418 data HyperdataPhylo = HyperdataPhylo { hyperdataPhylo_preferences :: !(Maybe Text)
419 , hyperdataPhylo_data :: !(Maybe Phylo)
420 } deriving (Show, Generic)
421 $(deriveJSON (unPrefix "hyperdataPhylo_") ''HyperdataPhylo)
422
423 instance Hyperdata HyperdataPhylo
424
425 ------------------------------------------------------------------------
426 -- | TODO FEATURE: Notebook saved in the node
427 data HyperdataNotebook = HyperdataNotebook { hyperdataNotebook_preferences :: !(Maybe Text)
428 } deriving (Show, Generic)
429 $(deriveJSON (unPrefix "hyperdataNotebook_") ''HyperdataNotebook)
430
431 instance Hyperdata HyperdataNotebook
432
433
434
435 -- | Then a Node can be either a Folder or a Corpus or a Document
436 type NodeUser = Node HyperdataUser
437 type NodeFolder = Node HyperdataFolder
438
439 type NodeCorpus = Node HyperdataCorpus
440
441
442 data HyperData = HyperdataTexts { hd_texts :: Maybe Text }
443 | HyperdataList' { hd_lists :: Maybe Text}
444 deriving (Show, Generic)
445
446 $(deriveJSON (unPrefix "hd_") ''HyperData)
447
448 instance Hyperdata HyperData
449
450
451 type NodeTexts = Node HyperData
452
453 type NodeCorpusV3 = Node HyperdataCorpus
454 type NodeDocument = Node HyperdataDocument
455
456 type NodeAnnuaire = Node HyperdataAnnuaire
457
458 -- | Any others nodes
459 type NodeAny = Node HyperdataAny
460
461 ---- | Then a Node can be either a Graph or a Phylo or a Notebook
462 type NodeList = Node HyperdataList
463 type NodeGraph = Node HyperdataGraph
464 type NodePhylo = Node HyperdataPhylo
465 type NodeNotebook = Node HyperdataNotebook
466 ------------------------------------------------------------------------
467 data NodeType = NodeUser
468 | NodeFolder
469 | NodeCorpus | NodeCorpusV3 | NodeTexts | NodeDocument
470 | NodeAnnuaire | NodeContact
471 | NodeGraph | NodePhylo
472 | NodeDashboard | NodeChart
473 | NodeList | NodeListModel deriving (Show, Read, Eq, Generic, Bounded, Enum)
474
475
476 {-
477 -- | Metrics
478 -- | NodeOccurrences
479 -- | Classification
480 -}
481
482 allNodeTypes :: [NodeType]
483 allNodeTypes = [minBound ..]
484
485 instance FromJSON NodeType
486 instance ToJSON NodeType
487
488 instance FromHttpApiData NodeType
489 where
490 parseUrlPiece = Right . read . unpack
491
492 instance ToParamSchema NodeType
493 instance ToSchema NodeType
494
495
496 data NodePolySearch id typename userId
497 parentId name date
498 hyperdata search = NodeSearch { _ns_id :: id
499 , _ns_typename :: typename
500 , _ns_userId :: userId
501 -- , nodeUniqId :: hashId
502 , _ns_parentId :: parentId
503 , _ns_name :: name
504 , _ns_date :: date
505
506 , _ns_hyperdata :: hyperdata
507 , _ns_search :: search
508 } deriving (Show, Generic)
509 $(deriveJSON (unPrefix "_ns_") ''NodePolySearch)
510 $(makeLenses ''NodePolySearch)
511
512 type NodeSearch json = NodePolySearch NodeId NodeTypeId UserId (Maybe ParentId) NodeName UTCTime json (Maybe TSVector)
513 ------------------------------------------------------------------------
514
515
516 instance (Arbitrary hyperdata
517 ,Arbitrary nodeId
518 ,Arbitrary nodeTypeId
519 ,Arbitrary userId
520 ,Arbitrary nodeParentId
521 ) => Arbitrary (NodePoly nodeId nodeTypeId userId nodeParentId
522 NodeName UTCTime hyperdata) where
523 --arbitrary = Node 1 1 (Just 1) 1 "name" (jour 2018 01 01) (arbitrary) (Just "")
524 arbitrary = Node <$> arbitrary <*> arbitrary <*> arbitrary
525 <*> arbitrary <*> arbitrary <*> arbitrary
526 <*> arbitrary
527
528 instance (Arbitrary hyperdata
529 ,Arbitrary nodeId
530 ,Arbitrary nodeTypeId
531 ,Arbitrary userId
532 ,Arbitrary nodeParentId
533 ) => Arbitrary (NodePolySearch nodeId nodeTypeId userId nodeParentId
534 NodeName UTCTime hyperdata (Maybe TSVector)) where
535 --arbitrary = Node 1 1 (Just 1) 1 "name" (jour 2018 01 01) (arbitrary) (Just "")
536 arbitrary = NodeSearch <$> arbitrary <*> arbitrary <*> arbitrary
537 <*> arbitrary <*> arbitrary <*> arbitrary
538 <*> arbitrary <*> arbitrary
539
540
541 ------------------------------------------------------------------------
542 hyperdataDocument :: HyperdataDocument
543 hyperdataDocument = case decode docExample of
544 Just hp -> hp
545 Nothing -> HyperdataDocument Nothing Nothing Nothing Nothing
546 Nothing Nothing Nothing Nothing
547 Nothing Nothing Nothing Nothing
548 Nothing Nothing Nothing Nothing
549 Nothing Nothing Nothing
550 docExample :: ByteString
551 docExample = "{\"doi\":\"sdfds\",\"publication_day\":6,\"language_iso2\":\"en\",\"publication_minute\":0,\"publication_month\":7,\"language_iso3\":\"eng\",\"publication_second\":0,\"authors\":\"Nils Hovdenak, Kjell Haram\",\"publication_year\":2012,\"publication_date\":\"2012-07-06 00:00:00+00:00\",\"language_name\":\"English\",\"realdate_full_\":\"2012 01 12\",\"source\":\"European journal of obstetrics, gynecology, and reproductive biology\",\"abstract\":\"The literature was searched for publications on minerals and vitamins during pregnancy and the possible influence of supplements on pregnancy outcome.\",\"title\":\"Influence of mineral and vitamin supplements on pregnancy outcome.\",\"publication_hour\":0}"
552
553 instance ToSchema HyperdataCorpus where
554 declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy
555 & mapped.schema.description ?~ "a corpus"
556 & mapped.schema.example ?~ toJSON hyperdataCorpus
557
558 instance ToSchema HyperdataAnnuaire where
559 declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy
560 & mapped.schema.description ?~ "an annuaire"
561 & mapped.schema.example ?~ toJSON hyperdataAnnuaire
562
563 instance ToSchema HyperdataDocument where
564 declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy
565 & mapped.schema.description ?~ "a document"
566 & mapped.schema.example ?~ toJSON hyperdataDocument
567
568 instance ToSchema HyperdataAny where
569 declareNamedSchema proxy =
570 pure $ genericNameSchema defaultSchemaOptions proxy mempty
571 & schema.description ?~ "a node"
572 & schema.example ?~ emptyObject -- TODO
573
574
575 instance ToSchema hyperdata =>
576 ToSchema (NodePoly NodeId NodeTypeId
577 (Maybe UserId)
578 ParentId NodeName
579 UTCTime hyperdata
580 )
581
582 instance ToSchema hyperdata =>
583 ToSchema (NodePoly NodeId NodeTypeId
584 UserId
585 (Maybe ParentId) NodeName
586 UTCTime hyperdata
587 )
588
589
590 instance ToSchema hyperdata =>
591 ToSchema (NodePolySearch NodeId NodeTypeId
592 (Maybe UserId)
593 ParentId NodeName
594 UTCTime hyperdata (Maybe TSVector)
595 )
596
597 instance ToSchema hyperdata =>
598 ToSchema (NodePolySearch NodeId NodeTypeId
599 UserId
600 (Maybe ParentId) NodeName
601 UTCTime hyperdata (Maybe TSVector)
602 )
603
604
605 instance ToSchema Status
606
607