{-|
Module      : Gargantext.Database.Admin.Types.Hyperdata.Document
Description :
Copyright   : (c) CNRS, 2017-Present
License     : AGPL + CECILL v3
Maintainer  : team@gargantext.org
Stability   : experimental
Portability : POSIX

-}

{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE NoImplicitPrelude          #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE TemplateHaskell            #-}

module Gargantext.Database.Admin.Types.Hyperdata.Document where

import Data.Maybe (catMaybes)
import Gargantext.Prelude
import Gargantext.Core.Text (HasText(..))
import Gargantext.Core.Utils.Prefix (unCapitalize, dropPrefix)
import Gargantext.Database.Admin.Types.Hyperdata.Prelude

------------------------------------------------------------------------
data HyperdataDocument = HyperdataDocument { HyperdataDocument -> Maybe Text
_hd_bdd                :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_doi                :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_url                :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_uniqId             :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_uniqIdBdd          :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Int
_hd_page               :: !(Maybe Int)
                                           , HyperdataDocument -> Maybe Text
_hd_title              :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_authors            :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_institutes         :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_source             :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_abstract           :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Text
_hd_publication_date   :: !(Maybe Text)
                                           , HyperdataDocument -> Maybe Int
_hd_publication_year   :: !(Maybe Int)
                                           , HyperdataDocument -> Maybe Int
_hd_publication_month  :: !(Maybe Int)
                                           , HyperdataDocument -> Maybe Int
_hd_publication_day    :: !(Maybe Int)
                                           , HyperdataDocument -> Maybe Int
_hd_publication_hour   :: !(Maybe Int)
                                           , HyperdataDocument -> Maybe Int
_hd_publication_minute :: !(Maybe Int)
                                           , HyperdataDocument -> Maybe Int
_hd_publication_second :: !(Maybe Int)
                                           , HyperdataDocument -> Maybe Text
_hd_language_iso2      :: !(Maybe Text)
                                           }
  deriving (Int -> HyperdataDocument -> ShowS
[HyperdataDocument] -> ShowS
HyperdataDocument -> String
(Int -> HyperdataDocument -> ShowS)
-> (HyperdataDocument -> String)
-> ([HyperdataDocument] -> ShowS)
-> Show HyperdataDocument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperdataDocument] -> ShowS
$cshowList :: [HyperdataDocument] -> ShowS
show :: HyperdataDocument -> String
$cshow :: HyperdataDocument -> String
showsPrec :: Int -> HyperdataDocument -> ShowS
$cshowsPrec :: Int -> HyperdataDocument -> ShowS
Show, (forall x. HyperdataDocument -> Rep HyperdataDocument x)
-> (forall x. Rep HyperdataDocument x -> HyperdataDocument)
-> Generic HyperdataDocument
forall x. Rep HyperdataDocument x -> HyperdataDocument
forall x. HyperdataDocument -> Rep HyperdataDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HyperdataDocument x -> HyperdataDocument
$cfrom :: forall x. HyperdataDocument -> Rep HyperdataDocument x
Generic)


instance HasText HyperdataDocument
  where
    hasText :: HyperdataDocument -> [Text]
hasText HyperdataDocument
h = [Maybe Text] -> [Text]
forall a. [Maybe a] -> [a]
catMaybes [ HyperdataDocument -> Maybe Text
_hd_title    HyperdataDocument
h
                          , HyperdataDocument -> Maybe Text
_hd_abstract HyperdataDocument
h
                          ]

defaultHyperdataDocument :: HyperdataDocument
defaultHyperdataDocument :: HyperdataDocument
defaultHyperdataDocument = case ByteString -> Maybe HyperdataDocument
forall a. FromJSON a => ByteString -> Maybe a
decode ByteString
docExample of
  Just HyperdataDocument
hp -> HyperdataDocument
hp
  Maybe HyperdataDocument
Nothing -> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Text
-> HyperdataDocument
HyperdataDocument Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing
                               Maybe Text
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing
                               Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing
                               Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing
                               Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing

  where
    docExample :: ByteString
    docExample :: ByteString
docExample = ByteString
"{\"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}"

------------------------------------------------------------------------
-- | Legacy Garg V3 compatibility (to be removed one year after release)
data StatusV3  = StatusV3 { StatusV3 -> Maybe Text
statusV3_error  :: !(Maybe Text)
                          , StatusV3 -> Maybe Text
statusV3_action :: !(Maybe Text)
                      } deriving (Int -> StatusV3 -> ShowS
[StatusV3] -> ShowS
StatusV3 -> String
(Int -> StatusV3 -> ShowS)
-> (StatusV3 -> String) -> ([StatusV3] -> ShowS) -> Show StatusV3
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatusV3] -> ShowS
$cshowList :: [StatusV3] -> ShowS
show :: StatusV3 -> String
$cshow :: StatusV3 -> String
showsPrec :: Int -> StatusV3 -> ShowS
$cshowsPrec :: Int -> StatusV3 -> ShowS
Show, (forall x. StatusV3 -> Rep StatusV3 x)
-> (forall x. Rep StatusV3 x -> StatusV3) -> Generic StatusV3
forall x. Rep StatusV3 x -> StatusV3
forall x. StatusV3 -> Rep StatusV3 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatusV3 x -> StatusV3
$cfrom :: forall x. StatusV3 -> Rep StatusV3 x
Generic)
$(deriveJSON (unPrefix "statusV3_") ''StatusV3)


------------------------------------------------------------------------
data HyperdataDocumentV3 = HyperdataDocumentV3 { HyperdataDocumentV3 -> Maybe Int
_hdv3_publication_day    :: !(Maybe Int)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_language_iso2      :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Int
_hdv3_publication_second :: !(Maybe Int)
                                               , HyperdataDocumentV3 -> Maybe Int
_hdv3_publication_minute :: !(Maybe Int)
                                               , HyperdataDocumentV3 -> Maybe Int
_hdv3_publication_month  :: !(Maybe Int)
                                               , HyperdataDocumentV3 -> Maybe Int
_hdv3_publication_hour   :: !(Maybe Int)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_error              :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_language_iso3      :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_authors            :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Int
_hdv3_publication_year   :: !(Maybe Int)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_publication_date   :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_language_name      :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe [StatusV3]
_hdv3_statuses           :: !(Maybe [StatusV3])
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_realdate_full_     :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_source             :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_abstract           :: !(Maybe Text)
                                               , HyperdataDocumentV3 -> Maybe Text
_hdv3_title              :: !(Maybe Text)
                                               } deriving (Int -> HyperdataDocumentV3 -> ShowS
[HyperdataDocumentV3] -> ShowS
HyperdataDocumentV3 -> String
(Int -> HyperdataDocumentV3 -> ShowS)
-> (HyperdataDocumentV3 -> String)
-> ([HyperdataDocumentV3] -> ShowS)
-> Show HyperdataDocumentV3
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperdataDocumentV3] -> ShowS
$cshowList :: [HyperdataDocumentV3] -> ShowS
show :: HyperdataDocumentV3 -> String
$cshow :: HyperdataDocumentV3 -> String
showsPrec :: Int -> HyperdataDocumentV3 -> ShowS
$cshowsPrec :: Int -> HyperdataDocumentV3 -> ShowS
Show, (forall x. HyperdataDocumentV3 -> Rep HyperdataDocumentV3 x)
-> (forall x. Rep HyperdataDocumentV3 x -> HyperdataDocumentV3)
-> Generic HyperdataDocumentV3
forall x. Rep HyperdataDocumentV3 x -> HyperdataDocumentV3
forall x. HyperdataDocumentV3 -> Rep HyperdataDocumentV3 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HyperdataDocumentV3 x -> HyperdataDocumentV3
$cfrom :: forall x. HyperdataDocumentV3 -> Rep HyperdataDocumentV3 x
Generic)


------------------------------------------------------------------------
-- | Instances for Analysis
------------------------------------------------------------------------
class ToHyperdataDocument a where
  toHyperdataDocument :: a -> HyperdataDocument

instance ToHyperdataDocument HyperdataDocument
  where
    toHyperdataDocument :: HyperdataDocument -> HyperdataDocument
toHyperdataDocument = HyperdataDocument -> HyperdataDocument
forall a. a -> a
identity

------------------------------------------------------------------------
instance Eq HyperdataDocument where
  == :: HyperdataDocument -> HyperdataDocument -> Bool
(==) HyperdataDocument
h1 HyperdataDocument
h2 = Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
(==) (HyperdataDocument -> Maybe Text
_hd_uniqId HyperdataDocument
h1) (HyperdataDocument -> Maybe Text
_hd_uniqId HyperdataDocument
h2)

------------------------------------------------------------------------
instance Ord HyperdataDocument where
  compare :: HyperdataDocument -> HyperdataDocument -> Ordering
compare HyperdataDocument
h1 HyperdataDocument
h2 = Maybe Text -> Maybe Text -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (HyperdataDocument -> Maybe Text
_hd_publication_date HyperdataDocument
h1) (HyperdataDocument -> Maybe Text
_hd_publication_date HyperdataDocument
h2)
------------------------------------------------------------------------
instance Arbitrary HyperdataDocument where
    arbitrary :: Gen HyperdataDocument
arbitrary = [HyperdataDocument] -> Gen HyperdataDocument
forall a. [a] -> Gen a
elements [HyperdataDocument]
arbitraryHyperdataDocuments

arbitraryHyperdataDocuments :: [HyperdataDocument]
arbitraryHyperdataDocuments :: [HyperdataDocument]
arbitraryHyperdataDocuments =
  ((Text, Text) -> HyperdataDocument)
-> [(Text, Text)] -> [HyperdataDocument]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (Text, Text) -> HyperdataDocument
toHyperdataDocument' ([ (Text
"AI is big but less than crypto", Text
"Troll System journal")
                            , (Text
"Crypto is big but less than AI", Text
"System Troll review" )
                            , (Text
"Science is magic"              , Text
"Closed Source review")
                            , (Text
"Open science for all"          , Text
"No Time"             )
                            , (Text
"Closed science for me"         , Text
"No Space"            )
                            ] :: [(Text, Text)])
  where
    toHyperdataDocument' :: (Text, Text) -> HyperdataDocument
toHyperdataDocument' (Text
t1,Text
t2) =
      Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Text
-> HyperdataDocument
HyperdataDocument Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
t1)
                      Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
t2) Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing
                      Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing Maybe Int
forall a. Maybe a
Nothing   Maybe Text
forall a. Maybe a
Nothing



------------------------------------------------------------------------
-- | Common Instances of Hyperdata
------------------------------------------------------------------------
instance Hyperdata HyperdataDocument
instance Hyperdata HyperdataDocumentV3
------------------------------------------------------------------------
$(makeLenses ''HyperdataDocument)
makePrisms ''HyperdataDocument

$(makeLenses ''HyperdataDocumentV3)

-- $(deriveJSON (unPrefix "_hd_") ''HyperdataDocument)

instance FromJSON HyperdataDocument
  where
    parseJSON :: Value -> Parser HyperdataDocument
parseJSON = Options -> Value -> Parser HyperdataDocument
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
genericParseJSON
            ( Options
defaultOptions { sumEncoding :: SumEncoding
sumEncoding = SumEncoding
ObjectWithSingleField 
                            , fieldLabelModifier :: ShowS
fieldLabelModifier = ShowS
unCapitalize ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
dropPrefix String
"_hd_"
                            , omitNothingFields :: Bool
omitNothingFields = Bool
True
                            }
            )

instance ToJSON HyperdataDocument
  where
    toJSON :: HyperdataDocument -> Value
toJSON = Options -> HyperdataDocument -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON
           ( Options
defaultOptions { sumEncoding :: SumEncoding
sumEncoding = SumEncoding
ObjectWithSingleField 
                            , fieldLabelModifier :: ShowS
fieldLabelModifier = ShowS
unCapitalize ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
dropPrefix String
"_hd_"
                            , omitNothingFields :: Bool
omitNothingFields = Bool
True
                            }
           )



$(deriveJSON (unPrefix "_hdv3_") ''HyperdataDocumentV3)

instance ToSchema HyperdataDocument where
  declareNamedSchema :: Proxy HyperdataDocument -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy HyperdataDocument
proxy =
    SchemaOptions
-> Proxy HyperdataDocument
-> Declare (Definitions Schema) NamedSchema
forall a.
(Generic a, GToSchema (Rep a),
 TypeHasSimpleShape a "genericDeclareNamedSchemaUnrestricted") =>
SchemaOptions
-> Proxy a -> Declare (Definitions Schema) NamedSchema
genericDeclareNamedSchema (String -> SchemaOptions
unPrefixSwagger String
"_hd_") Proxy HyperdataDocument
proxy
    Declare (Definitions Schema) NamedSchema
-> (Declare (Definitions Schema) NamedSchema
    -> Declare (Definitions Schema) NamedSchema)
-> Declare (Definitions Schema) NamedSchema
forall a b. a -> (a -> b) -> b
& (NamedSchema -> Identity NamedSchema)
-> Declare (Definitions Schema) NamedSchema
-> Identity (Declare (Definitions Schema) NamedSchema)
forall (f :: * -> *) a b. Functor f => Setter (f a) (f b) a b
mapped((NamedSchema -> Identity NamedSchema)
 -> Declare (Definitions Schema) NamedSchema
 -> Identity (Declare (Definitions Schema) NamedSchema))
-> ((Maybe Text -> Identity (Maybe Text))
    -> NamedSchema -> Identity NamedSchema)
-> (Maybe Text -> Identity (Maybe Text))
-> Declare (Definitions Schema) NamedSchema
-> Identity (Declare (Definitions Schema) NamedSchema)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Schema -> Identity Schema) -> NamedSchema -> Identity NamedSchema
forall s a. HasSchema s a => Lens' s a
schema((Schema -> Identity Schema)
 -> NamedSchema -> Identity NamedSchema)
-> ((Maybe Text -> Identity (Maybe Text))
    -> Schema -> Identity Schema)
-> (Maybe Text -> Identity (Maybe Text))
-> NamedSchema
-> Identity NamedSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Maybe Text -> Identity (Maybe Text)) -> Schema -> Identity Schema
forall s a. HasDescription s a => Lens' s a
description ((Maybe Text -> Identity (Maybe Text))
 -> Declare (Definitions Schema) NamedSchema
 -> Identity (Declare (Definitions Schema) NamedSchema))
-> Text
-> Declare (Definitions Schema) NamedSchema
-> Declare (Definitions Schema) NamedSchema
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ Text
"Document Hyperdata"
    Declare (Definitions Schema) NamedSchema
-> (Declare (Definitions Schema) NamedSchema
    -> Declare (Definitions Schema) NamedSchema)
-> Declare (Definitions Schema) NamedSchema
forall a b. a -> (a -> b) -> b
& (NamedSchema -> Identity NamedSchema)
-> Declare (Definitions Schema) NamedSchema
-> Identity (Declare (Definitions Schema) NamedSchema)
forall (f :: * -> *) a b. Functor f => Setter (f a) (f b) a b
mapped((NamedSchema -> Identity NamedSchema)
 -> Declare (Definitions Schema) NamedSchema
 -> Identity (Declare (Definitions Schema) NamedSchema))
-> ((Maybe Value -> Identity (Maybe Value))
    -> NamedSchema -> Identity NamedSchema)
-> (Maybe Value -> Identity (Maybe Value))
-> Declare (Definitions Schema) NamedSchema
-> Identity (Declare (Definitions Schema) NamedSchema)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Schema -> Identity Schema) -> NamedSchema -> Identity NamedSchema
forall s a. HasSchema s a => Lens' s a
schema((Schema -> Identity Schema)
 -> NamedSchema -> Identity NamedSchema)
-> ((Maybe Value -> Identity (Maybe Value))
    -> Schema -> Identity Schema)
-> (Maybe Value -> Identity (Maybe Value))
-> NamedSchema
-> Identity NamedSchema
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Maybe Value -> Identity (Maybe Value))
-> Schema -> Identity Schema
forall s a. HasExample s a => Lens' s a
example ((Maybe Value -> Identity (Maybe Value))
 -> Declare (Definitions Schema) NamedSchema
 -> Identity (Declare (Definitions Schema) NamedSchema))
-> Value
-> Declare (Definitions Schema) NamedSchema
-> Declare (Definitions Schema) NamedSchema
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ HyperdataDocument -> Value
forall a. ToJSON a => a -> Value
toJSON HyperdataDocument
defaultHyperdataDocument

{-
-- | For now HyperdataDocumentV3 is not exposed with the API
instance ToSchema HyperdataDocumentV3 where
  declareNamedSchema proxy =
    genericDeclareNamedSchema (unPrefixSwagger "hyperdataDocumentV3_") proxy
    & mapped.schema.description ?~ "Document Hyperdata for Garg V3"
    & mapped.schema.example ?~ toJSON defaultHyperdataDocumentV3
-}

------------------------------------------------------------------------
instance FromField HyperdataDocument
  where
    fromField :: FieldParser HyperdataDocument
fromField = FieldParser HyperdataDocument
forall b.
(Typeable b, FromJSON b) =>
Field -> Maybe ByteString -> Conversion b
fromField'

instance FromField HyperdataDocumentV3
  where
    fromField :: FieldParser HyperdataDocumentV3
fromField = FieldParser HyperdataDocumentV3
forall b.
(Typeable b, FromJSON b) =>
Field -> Maybe ByteString -> Conversion b
fromField'

-------
instance ToField HyperdataDocument where
  toField :: HyperdataDocument -> Action
toField = HyperdataDocument -> Action
forall a. ToJSON a => a -> Action
toJSONField

instance ToField HyperdataDocumentV3 where
  toField :: HyperdataDocumentV3 -> Action
toField = HyperdataDocumentV3 -> Action
forall a. ToJSON a => a -> Action
toJSONField

------------------------------------------------------------------------
instance DefaultFromField PGJsonb HyperdataDocument
  where
    defaultFromField :: FromField PGJsonb HyperdataDocument
defaultFromField = FromField PGJsonb HyperdataDocument
forall haskell pgType.
FromField haskell =>
FromField pgType haskell
fieldQueryRunnerColumn

instance DefaultFromField PGJsonb HyperdataDocumentV3
  where
    defaultFromField :: FromField PGJsonb HyperdataDocumentV3
defaultFromField = FromField PGJsonb HyperdataDocumentV3
forall haskell pgType.
FromField haskell =>
FromField pgType haskell
fieldQueryRunnerColumn
------------------------------------------------------------------------