]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Types/Node.hs
max cliques with apax to 2
[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
23 -- {-# LANGUAGE DuplicateRecordFields #-}
24
25 module Gargantext.Database.Types.Node
26 where
27
28 import Prelude (Enum, Bounded, minBound, maxBound)
29
30 import GHC.Generics (Generic)
31
32 import Control.Lens hiding (elements, (&))
33 import Control.Applicative ((<*>))
34 import Control.Monad (mzero)
35
36 import Data.Aeson
37 import Data.Aeson.Types (emptyObject)
38 import Data.Aeson (Object, toJSON)
39 import Data.Aeson.TH (deriveJSON)
40 import Data.ByteString.Lazy (ByteString)
41 import Data.Either
42 import Data.Eq (Eq)
43 import Data.Monoid (mempty)
44 import Data.Text (Text, unpack)
45 import Data.Time (UTCTime)
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 import Test.QuickCheck.Instances.Time ()
58 import Test.QuickCheck.Instances.Text ()
59
60 import Gargantext.Prelude
61 import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
62 import Gargantext.Viz.Phylo (Phylo)
63 --import Gargantext.Database.Utils
64 ------------------------------------------------------------------------
65
66 newtype NodeId = NodeId Int
67 deriving (Show, Read, Generic, Num, Eq, Ord, Enum, ToJSONKey, FromJSONKey, ToJSON, FromJSON)
68
69 instance ToField NodeId where
70 toField (NodeId n) = toField n
71
72 instance FromField NodeId where
73 fromField field mdata = do
74 n <- fromField field mdata
75 if (n :: Int) > 0
76 then return $ NodeId n
77 else mzero
78
79 instance ToSchema NodeId
80
81
82 type NodeTypeId = Int
83 type NodeName = Text
84 type TSVector = Text
85
86 ------------------------------------------------------------------------
87 data NodePoly id typename userId
88 parentId name date
89 hyperdata = Node { _node_id :: id
90 , _node_typename :: typename
91
92 , _node_userId :: userId
93 , _node_parentId :: parentId
94
95 , _node_name :: name
96 , _node_date :: date
97
98 , _node_hyperdata :: hyperdata
99 } deriving (Show, Generic)
100 $(deriveJSON (unPrefix "_node_") ''NodePoly)
101 $(makeLenses ''NodePoly)
102
103 -- | NodePoly indicates that Node has a Polymorphism Type
104 type Node json = NodePoly NodeId NodeTypeId UserId (Maybe ParentId) NodeName UTCTime json
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 = NodeId
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 data Status = Status { status_failed :: !Int
138 , status_succeeded :: !Int
139 , status_remaining :: !Int
140 } deriving (Show, Generic)
141 $(deriveJSON (unPrefix "status_") ''Status)
142
143 instance Arbitrary Status where
144 arbitrary = Status <$> arbitrary <*> arbitrary <*> arbitrary
145
146 ------------------------------------------------------------------------
147 data StatusV3 = StatusV3 { statusV3_error :: !(Maybe Text)
148 , statusV3_action :: !(Maybe Text)
149 } deriving (Show, Generic)
150 $(deriveJSON (unPrefix "statusV3_") ''StatusV3)
151 ------------------------------------------------------------------------
152
153 -- Only Hyperdata types should be member of this type class.
154
155 ------------------------------------------------------------------------
156 data HyperdataDocumentV3 = HyperdataDocumentV3 { hyperdataDocumentV3_publication_day :: !(Maybe Int)
157 , hyperdataDocumentV3_language_iso2 :: !(Maybe Text)
158 , hyperdataDocumentV3_publication_second :: !(Maybe Int)
159 , hyperdataDocumentV3_publication_minute :: !(Maybe Int)
160 , hyperdataDocumentV3_publication_month :: !(Maybe Int)
161 , hyperdataDocumentV3_publication_hour :: !(Maybe Int)
162 , hyperdataDocumentV3_error :: !(Maybe Text)
163 , hyperdataDocumentV3_language_iso3 :: !(Maybe Text)
164 , hyperdataDocumentV3_authors :: !(Maybe Text)
165 , hyperdataDocumentV3_publication_year :: !(Maybe Int)
166 , hyperdataDocumentV3_publication_date :: !(Maybe Text)
167 , hyperdataDocumentV3_language_name :: !(Maybe Text)
168 , hyperdataDocumentV3_statuses :: !(Maybe [StatusV3])
169 , hyperdataDocumentV3_realdate_full_ :: !(Maybe Text)
170 , hyperdataDocumentV3_source :: !(Maybe Text)
171 , hyperdataDocumentV3_abstract :: !(Maybe Text)
172 , hyperdataDocumentV3_title :: !(Maybe Text)
173 } deriving (Show, Generic)
174 $(deriveJSON (unPrefix "hyperdataDocumentV3_") ''HyperdataDocumentV3)
175
176 class Hyperdata a
177 instance Hyperdata HyperdataDocumentV3
178
179 ------------------------------------------------------------------------
180 data HyperdataDocument = HyperdataDocument { _hyperdataDocument_bdd :: !(Maybe Text)
181 , _hyperdataDocument_doi :: !(Maybe Text)
182 , _hyperdataDocument_url :: !(Maybe Text)
183 , _hyperdataDocument_uniqId :: !(Maybe Text)
184 , _hyperdataDocument_uniqIdBdd :: !(Maybe Text)
185 , _hyperdataDocument_page :: !(Maybe Int)
186 , _hyperdataDocument_title :: !(Maybe Text)
187 , _hyperdataDocument_authors :: !(Maybe Text)
188 , _hyperdataDocument_institutes :: !(Maybe Text)
189 , _hyperdataDocument_source :: !(Maybe Text)
190 , _hyperdataDocument_abstract :: !(Maybe Text)
191 , _hyperdataDocument_publication_date :: !(Maybe Text)
192 , _hyperdataDocument_publication_year :: !(Maybe Int)
193 , _hyperdataDocument_publication_month :: !(Maybe Int)
194 , _hyperdataDocument_publication_day :: !(Maybe Int)
195 , _hyperdataDocument_publication_hour :: !(Maybe Int)
196 , _hyperdataDocument_publication_minute :: !(Maybe Int)
197 , _hyperdataDocument_publication_second :: !(Maybe Int)
198 , _hyperdataDocument_language_iso2 :: !(Maybe Text)
199 } deriving (Show, Generic)
200
201 $(deriveJSON (unPrefix "_hyperdataDocument_") ''HyperdataDocument)
202 $(makeLenses ''HyperdataDocument)
203
204 class ToHyperdataDocument a where
205 toHyperdataDocument :: a -> HyperdataDocument
206
207 instance ToHyperdataDocument HyperdataDocument
208 where
209 toHyperdataDocument = identity
210
211 instance Eq HyperdataDocument where
212 (==) h1 h2 = (==) (_hyperdataDocument_uniqId h1) (_hyperdataDocument_uniqId h2)
213
214 instance Ord HyperdataDocument where
215 compare h1 h2 = compare (_hyperdataDocument_publication_date h1) (_hyperdataDocument_publication_date h2)
216
217 instance Hyperdata HyperdataDocument
218
219 instance ToField HyperdataDocument where
220 toField = toJSONField
221
222 instance Arbitrary HyperdataDocument where
223 arbitrary = elements arbitraryHyperdataDocuments
224
225 arbitraryHyperdataDocuments :: [HyperdataDocument]
226 arbitraryHyperdataDocuments =
227 map toHyperdataDocument' ([ ("AI is big but less than crypto", "Troll System journal")
228 , ("Crypto is big but less than AI", "System Troll review" )
229 , ("Science is magic" , "Closed Source review")
230 , ("Open science for all" , "No Time" )
231 , ("Closed science for me" , "No Space" )
232 ] :: [(Text, Text)])
233 where
234 toHyperdataDocument' (t1,t2) =
235 HyperdataDocument Nothing Nothing Nothing Nothing Nothing Nothing (Just t1)
236 Nothing Nothing (Just t2) Nothing Nothing Nothing Nothing Nothing
237 Nothing Nothing Nothing Nothing
238
239 ------------------------------------------------------------------------
240 data LanguageNodes = LanguageNodes { languageNodes___unknown__ :: [Int]}
241 deriving (Show, Generic)
242 $(deriveJSON (unPrefix "languageNodes_") ''LanguageNodes)
243
244 ------------------------------------------------------------------------
245 -- level: debug | dev (fatal = critical)
246 data EventLevel = CRITICAL | FATAL | ERROR | WARNING | INFO | DEBUG
247 deriving (Show, Generic, Enum, Bounded)
248
249 instance FromJSON EventLevel
250 instance ToJSON EventLevel
251
252 instance Arbitrary EventLevel where
253 arbitrary = elements [minBound..maxBound]
254
255 instance ToSchema EventLevel where
256 declareNamedSchema proxy = genericDeclareNamedSchema defaultSchemaOptions proxy
257
258 ------------------------------------------------------------------------
259
260 data Event = Event { event_level :: !EventLevel
261 , event_message :: !Text
262 , event_date :: !UTCTime
263 } deriving (Show, Generic)
264 $(deriveJSON (unPrefix "event_") ''Event)
265
266 instance Arbitrary Event where
267 arbitrary = Event <$> arbitrary <*> arbitrary <*> arbitrary
268
269 instance ToSchema Event where
270 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "event_")
271
272 ------------------------------------------------------------------------
273
274 data Resource = Resource { resource_path :: !(Maybe Text)
275 , resource_scraper :: !(Maybe Text)
276 , resource_query :: !(Maybe Text)
277 , resource_events :: !([Event])
278 , resource_status :: !Status
279 , resource_date :: !UTCTime
280 } deriving (Show, Generic)
281 $(deriveJSON (unPrefix "resource_") ''Resource)
282
283 instance Arbitrary Resource where
284 arbitrary = Resource <$> arbitrary
285 <*> arbitrary
286 <*> arbitrary
287 <*> arbitrary
288 <*> arbitrary
289 <*> arbitrary
290
291 instance ToSchema Resource where
292 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "resource_")
293
294 ------------------------------------------------------------------------
295 data HyperdataUser = HyperdataUser { hyperdataUser_language :: !(Maybe Text)
296 } deriving (Show, Generic)
297 $(deriveJSON (unPrefix "hyperdataUser_") ''HyperdataUser)
298
299 instance Hyperdata HyperdataUser
300 ------------------------------------------------------------------------
301 ------------------------------------------------------------------------
302 ------------------------------------------------------------------------
303 ------------------------------------------------------------------------
304
305 data Chart =
306 CDocsHistogram
307 | CAuthorsPie
308 | CInstitutesTree
309 | CTermsMetrics
310 deriving (Generic, Show, Eq)
311 instance ToJSON Chart
312 instance FromJSON Chart
313 instance ToSchema Chart
314
315
316 data CodeType = JSON | Markdown | Haskell
317 deriving (Generic)
318 instance ToJSON CodeType
319 instance FromJSON CodeType
320 instance ToSchema CodeType
321
322 ------------------------------------------------------------------------
323 data CorpusField = MarkdownField { _cf_text :: !Text }
324 | JsonField { _cf_title :: !Text
325 , _cf_desc :: !Text
326 , _cf_query :: !Text
327 , _cf_authors :: !Text
328 -- , _cf_resources :: ![Resource]
329 }
330 | HaskellField { _cf_haskell :: !Text }
331 deriving (Generic)
332
333 $(deriveJSON (unPrefix "_cf_") ''CorpusField)
334 $(makeLenses ''CorpusField)
335
336 defaultCorpusField :: CorpusField
337 defaultCorpusField = MarkdownField "# title"
338
339 instance ToSchema CorpusField where
340 declareNamedSchema proxy =
341 genericDeclareNamedSchema (unPrefixSwagger "_cf_") proxy
342 & mapped.schema.description ?~ "CorpusField"
343 & mapped.schema.example ?~ toJSON defaultCorpusField
344
345 ------------------------------------------------------------------------
346 data HyperdataField a =
347 HyperdataField { _hf_type :: !CodeType
348 , _hf_name :: !Text
349 , _hf_data :: !a
350 } deriving (Generic)
351 $(deriveJSON (unPrefix "_hf_") ''HyperdataField)
352 $(makeLenses ''HyperdataField)
353
354 defaultHyperdataField :: HyperdataField CorpusField
355 defaultHyperdataField = HyperdataField Markdown "name" defaultCorpusField
356
357 instance (ToSchema a) => ToSchema (HyperdataField a) where
358 declareNamedSchema =
359 genericDeclareNamedSchema (unPrefixSwagger "_hf_")
360 -- & mapped.schema.description ?~ "HyperdataField"
361 -- & mapped.schema.example ?~ toJSON defaultHyperdataField
362
363 ------------------------------------------------------------------------
364 data HyperdataCorpus =
365 HyperdataCorpus { _hc_fields :: ![HyperdataField CorpusField] }
366 deriving (Generic)
367 $(deriveJSON (unPrefix "_hc_") ''HyperdataCorpus)
368 $(makeLenses ''HyperdataCorpus)
369
370 instance Hyperdata HyperdataCorpus
371
372 corpusExample :: ByteString
373 corpusExample = "" -- TODO
374
375 defaultCorpus :: HyperdataCorpus
376 defaultCorpus = HyperdataCorpus [
377 HyperdataField JSON "Mandatory fields" (JsonField "Title" "Descr" "Bool query" "Authors")
378 , HyperdataField Markdown "Optional Text" (MarkdownField "# title\n## subtitle")
379 ]
380
381 hyperdataCorpus :: HyperdataCorpus
382 hyperdataCorpus = case decode corpusExample of
383 Just hp -> hp
384 Nothing -> defaultCorpus
385
386 instance Arbitrary HyperdataCorpus where
387 arbitrary = pure hyperdataCorpus -- TODO
388
389 ------------------------------------------------------------------------
390
391 data HyperdataList = HyperdataList {hd_list :: !(Maybe Text)
392 } deriving (Show, Generic)
393 $(deriveJSON (unPrefix "hd_") ''HyperdataList)
394
395 instance Hyperdata HyperdataList
396
397 ------------------------------------------------------------------------
398 data HyperdataAnnuaire = HyperdataAnnuaire { hyperdataAnnuaire_title :: !(Maybe Text)
399 , hyperdataAnnuaire_desc :: !(Maybe Text)
400 } deriving (Show, Generic)
401 $(deriveJSON (unPrefix "hyperdataAnnuaire_") ''HyperdataAnnuaire)
402
403 instance Hyperdata HyperdataAnnuaire
404
405 hyperdataAnnuaire :: HyperdataAnnuaire
406 hyperdataAnnuaire = HyperdataAnnuaire (Just "Annuaire Title") (Just "Annuaire Description")
407
408 instance Arbitrary HyperdataAnnuaire where
409 arbitrary = pure hyperdataAnnuaire -- TODO
410
411 ------------------------------------------------------------------------
412 newtype HyperdataAny = HyperdataAny Object
413 deriving (Show, Generic, ToJSON, FromJSON)
414
415 instance Hyperdata HyperdataAny
416
417 instance Arbitrary HyperdataAny where
418 arbitrary = pure $ HyperdataAny mempty -- TODO produce arbitrary objects
419 ------------------------------------------------------------------------
420
421 {-
422 instance Arbitrary HyperdataList' where
423 arbitrary = elements [HyperdataList' (Just "from list A")]
424 -}
425
426 ----
427 data HyperdataListModel = HyperdataListModel { _hlm_params :: !(Int, Int)
428 , _hlm_path :: !Text
429 , _hlm_score :: !(Maybe Double)
430 } deriving (Show, Generic)
431
432 instance Hyperdata HyperdataListModel
433 instance Arbitrary HyperdataListModel where
434 arbitrary = elements [HyperdataListModel (100,100) "models/example.model" Nothing]
435
436 $(deriveJSON (unPrefix "_hlm_") ''HyperdataListModel)
437 $(makeLenses ''HyperdataListModel)
438
439 ------------------------------------------------------------------------
440 data HyperdataScore = HyperdataScore { hyperdataScore_preferences :: !(Maybe Text)
441 } deriving (Show, Generic)
442 $(deriveJSON (unPrefix "hyperdataScore_") ''HyperdataScore)
443
444 instance Hyperdata HyperdataScore
445
446 ------------------------------------------------------------------------
447
448 data HyperdataResource = HyperdataResource { hyperdataResource_preferences :: !(Maybe Text)
449 } deriving (Show, Generic)
450 $(deriveJSON (unPrefix "hyperdataResource_") ''HyperdataResource)
451
452 instance Hyperdata HyperdataResource
453
454 ------------------------------------------------------------------------
455 data HyperdataDashboard = HyperdataDashboard { hyperdataDashboard_preferences :: !(Maybe Text)
456 , hyperdataDashboard_charts :: ![Chart]
457 } deriving (Show, Generic)
458 $(deriveJSON (unPrefix "hyperdataDashboard_") ''HyperdataDashboard)
459
460 instance Hyperdata HyperdataDashboard
461
462 ------------------------------------------------------------------------
463
464 -- TODO add the Graph Structure here
465 data HyperdataPhylo = HyperdataPhylo { hyperdataPhylo_preferences :: !(Maybe Text)
466 , hyperdataPhylo_data :: !(Maybe Phylo)
467 } deriving (Show, Generic)
468 $(deriveJSON (unPrefix "hyperdataPhylo_") ''HyperdataPhylo)
469
470 instance Hyperdata HyperdataPhylo
471
472 ------------------------------------------------------------------------
473 -- | TODO FEATURE: Notebook saved in the node
474 data HyperdataNotebook = HyperdataNotebook { hyperdataNotebook_preferences :: !(Maybe Text)
475 } deriving (Show, Generic)
476 $(deriveJSON (unPrefix "hyperdataNotebook_") ''HyperdataNotebook)
477
478 instance Hyperdata HyperdataNotebook
479
480
481 -- | TODO CLEAN
482 data HyperData = HyperdataTexts { hd_preferences :: Maybe Text }
483 | HyperdataList' { hd_preferences :: Maybe Text}
484 deriving (Show, Generic)
485
486 $(deriveJSON (unPrefix "hd_") ''HyperData)
487
488 instance Hyperdata HyperData
489
490
491
492 ------------------------------------------------------------------------
493 -- | Then a Node can be either a Folder or a Corpus or a Document
494 data NodeType = NodeUser
495 | NodeFolderPrivate
496 | NodeFolderShared | NodeTeam
497 | NodeFolderPublic
498 | NodeFolder
499
500 | NodeCorpus | NodeCorpusV3 | NodeTexts | NodeDocument
501 | NodeAnnuaire | NodeContact
502 | NodeGraph | NodePhylo
503 | NodeDashboard | NodeChart | NodeNoteBook
504 | NodeList | NodeListModel
505 | NodeListCooc
506 deriving (Show, Read, Eq, Generic, Bounded, Enum)
507
508
509 {-
510 -- | Metrics
511 -- | NodeOccurrences
512 -- | Classification
513 -}
514
515 allNodeTypes :: [NodeType]
516 allNodeTypes = [minBound ..]
517
518 instance FromJSON NodeType
519 instance ToJSON NodeType
520
521 instance FromHttpApiData NodeType
522 where
523 parseUrlPiece = Right . read . unpack
524
525 instance ToParamSchema NodeType
526 instance ToSchema NodeType
527
528
529 data NodePolySearch id typename userId
530 parentId name date
531 hyperdata search = NodeSearch { _ns_id :: id
532 , _ns_typename :: typename
533 , _ns_userId :: userId
534 -- , nodeUniqId :: shaId
535 , _ns_parentId :: parentId
536 , _ns_name :: name
537 , _ns_date :: date
538
539 , _ns_hyperdata :: hyperdata
540 , _ns_search :: search
541 } deriving (Show, Generic)
542 $(deriveJSON (unPrefix "_ns_") ''NodePolySearch)
543 $(makeLenses ''NodePolySearch)
544
545 type NodeSearch json = NodePolySearch NodeId NodeTypeId UserId (Maybe ParentId) NodeName UTCTime json (Maybe TSVector)
546 ------------------------------------------------------------------------
547
548
549 instance (Arbitrary hyperdata
550 ,Arbitrary nodeId
551 ,Arbitrary nodeTypeId
552 ,Arbitrary userId
553 ,Arbitrary nodeParentId
554 ) => Arbitrary (NodePoly nodeId nodeTypeId userId nodeParentId
555 NodeName UTCTime hyperdata) where
556 --arbitrary = Node 1 1 (Just 1) 1 "name" (jour 2018 01 01) (arbitrary) (Just "")
557 arbitrary = Node <$> arbitrary <*> arbitrary <*> arbitrary
558 <*> arbitrary <*> arbitrary <*> arbitrary
559 <*> arbitrary
560
561 instance (Arbitrary hyperdata
562 ,Arbitrary nodeId
563 ,Arbitrary nodeTypeId
564 ,Arbitrary userId
565 ,Arbitrary nodeParentId
566 ) => Arbitrary (NodePolySearch nodeId nodeTypeId userId nodeParentId
567 NodeName UTCTime hyperdata (Maybe TSVector)) where
568 --arbitrary = Node 1 1 (Just 1) 1 "name" (jour 2018 01 01) (arbitrary) (Just "")
569 arbitrary = NodeSearch <$> arbitrary <*> arbitrary <*> arbitrary
570 <*> arbitrary <*> arbitrary <*> arbitrary
571 <*> arbitrary <*> arbitrary
572
573
574 ------------------------------------------------------------------------
575 hyperdataDocument :: HyperdataDocument
576 hyperdataDocument = case decode docExample of
577 Just hp -> hp
578 Nothing -> HyperdataDocument Nothing Nothing Nothing Nothing
579 Nothing Nothing Nothing Nothing
580 Nothing Nothing Nothing Nothing
581 Nothing Nothing Nothing Nothing
582 Nothing Nothing Nothing
583 docExample :: ByteString
584 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}"
585
586 instance ToSchema HyperdataCorpus where
587 declareNamedSchema proxy =
588 genericDeclareNamedSchema (unPrefixSwagger "_hc_") proxy
589 & mapped.schema.description ?~ "Corpus"
590 & mapped.schema.example ?~ toJSON hyperdataCorpus
591
592 instance ToSchema HyperdataAnnuaire where
593 declareNamedSchema proxy =
594 genericDeclareNamedSchema (unPrefixSwagger "hyperdataAnnuaire_") proxy
595 & mapped.schema.description ?~ "an annuaire"
596 & mapped.schema.example ?~ toJSON hyperdataAnnuaire
597
598 instance ToSchema HyperdataDocument where
599 declareNamedSchema proxy =
600 genericDeclareNamedSchema (unPrefixSwagger "_hyperdataDocument_") proxy
601 & mapped.schema.description ?~ "a document"
602 & mapped.schema.example ?~ toJSON hyperdataDocument
603
604 instance ToSchema HyperdataAny where
605 declareNamedSchema proxy =
606 pure $ genericNameSchema defaultSchemaOptions proxy mempty
607 & schema.description ?~ "a node"
608 & schema.example ?~ emptyObject -- TODO
609
610
611 instance ToSchema hyperdata =>
612 ToSchema (NodePoly NodeId NodeTypeId
613 (Maybe UserId)
614 ParentId NodeName
615 UTCTime hyperdata
616 ) where
617 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_node_")
618
619 instance ToSchema hyperdata =>
620 ToSchema (NodePoly NodeId NodeTypeId
621 UserId
622 (Maybe ParentId) NodeName
623 UTCTime hyperdata
624 ) where
625 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_node_")
626
627
628 instance ToSchema hyperdata =>
629 ToSchema (NodePolySearch NodeId NodeTypeId
630 (Maybe UserId)
631 ParentId NodeName
632 UTCTime hyperdata (Maybe TSVector)
633 ) where
634 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_ns_")
635
636 instance ToSchema hyperdata =>
637 ToSchema (NodePolySearch NodeId NodeTypeId
638 UserId
639 (Maybe ParentId) NodeName
640 UTCTime hyperdata (Maybe TSVector)
641 ) where
642 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_ns_")
643
644
645 instance ToSchema Status where
646 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "status_")
647
648