{-|
Module      : Gargantext.Database.Admin.Types.Hyperdata.Texts
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.Texts
  where

import Gargantext.Prelude
import Gargantext.Database.Admin.Types.Hyperdata.Prelude

------------------------------------------------------------------------

data HyperdataTexts =
  HyperdataTexts { HyperdataTexts -> Maybe Text
_ht_preferences :: !(Maybe Text)
                 }
  deriving (Int -> HyperdataTexts -> ShowS
[HyperdataTexts] -> ShowS
HyperdataTexts -> String
(Int -> HyperdataTexts -> ShowS)
-> (HyperdataTexts -> String)
-> ([HyperdataTexts] -> ShowS)
-> Show HyperdataTexts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperdataTexts] -> ShowS
$cshowList :: [HyperdataTexts] -> ShowS
show :: HyperdataTexts -> String
$cshow :: HyperdataTexts -> String
showsPrec :: Int -> HyperdataTexts -> ShowS
$cshowsPrec :: Int -> HyperdataTexts -> ShowS
Show, (forall x. HyperdataTexts -> Rep HyperdataTexts x)
-> (forall x. Rep HyperdataTexts x -> HyperdataTexts)
-> Generic HyperdataTexts
forall x. Rep HyperdataTexts x -> HyperdataTexts
forall x. HyperdataTexts -> Rep HyperdataTexts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HyperdataTexts x -> HyperdataTexts
$cfrom :: forall x. HyperdataTexts -> Rep HyperdataTexts x
Generic)

defaultHyperdataTexts :: HyperdataTexts
defaultHyperdataTexts :: HyperdataTexts
defaultHyperdataTexts = Maybe Text -> HyperdataTexts
HyperdataTexts Maybe Text
forall a. Maybe a
Nothing

------------------------------------------------------------------------
-- Instances
------------------------------------------------------------------------
instance Hyperdata HyperdataTexts

$(makeLenses ''HyperdataTexts)
$(deriveJSON (unPrefix "_ht_") ''HyperdataTexts)

instance Arbitrary HyperdataTexts where
    arbitrary :: Gen HyperdataTexts
arbitrary = HyperdataTexts -> Gen HyperdataTexts
forall (f :: * -> *) a. Applicative f => a -> f a
pure HyperdataTexts
defaultHyperdataTexts

instance ToSchema HyperdataTexts where
  declareNamedSchema :: Proxy HyperdataTexts -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy HyperdataTexts
proxy =
    SchemaOptions
-> Proxy HyperdataTexts -> 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
"_ht_") Proxy HyperdataTexts
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
"Texts 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
?~ HyperdataTexts -> Value
forall a. ToJSON a => a -> Value
toJSON HyperdataTexts
defaultHyperdataTexts

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

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