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

-}

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


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

import Data.Morpheus.Types (GQLType(typeOptions))
import qualified Gargantext.API.GraphQL.Utils as GAGU
import Gargantext.Core (Lang(..))
import Gargantext.Database.Admin.Types.Hyperdata.Prelude
import Gargantext.Database.Admin.Types.Hyperdata.Contact
import Gargantext.Database.Admin.Types.Node (DocumentId)
import Gargantext.Prelude

-- import Gargantext.Database.Schema.Node -- (Node(..))

data HyperdataUser =
     HyperdataUser { HyperdataUser -> Maybe HyperdataPrivate
_hu_private   :: !(Maybe HyperdataPrivate)
                   , HyperdataUser -> Maybe HyperdataContact
_hu_shared    :: !(Maybe HyperdataContact)
                   , HyperdataUser -> Maybe HyperdataPublic
_hu_public    :: !(Maybe HyperdataPublic)
                   } deriving (HyperdataUser -> HyperdataUser -> Bool
(HyperdataUser -> HyperdataUser -> Bool)
-> (HyperdataUser -> HyperdataUser -> Bool) -> Eq HyperdataUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperdataUser -> HyperdataUser -> Bool
$c/= :: HyperdataUser -> HyperdataUser -> Bool
== :: HyperdataUser -> HyperdataUser -> Bool
$c== :: HyperdataUser -> HyperdataUser -> Bool
Eq, Int -> HyperdataUser -> ShowS
[HyperdataUser] -> ShowS
HyperdataUser -> String
(Int -> HyperdataUser -> ShowS)
-> (HyperdataUser -> String)
-> ([HyperdataUser] -> ShowS)
-> Show HyperdataUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperdataUser] -> ShowS
$cshowList :: [HyperdataUser] -> ShowS
show :: HyperdataUser -> String
$cshow :: HyperdataUser -> String
showsPrec :: Int -> HyperdataUser -> ShowS
$cshowsPrec :: Int -> HyperdataUser -> ShowS
Show, (forall x. HyperdataUser -> Rep HyperdataUser x)
-> (forall x. Rep HyperdataUser x -> HyperdataUser)
-> Generic HyperdataUser
forall x. Rep HyperdataUser x -> HyperdataUser
forall x. HyperdataUser -> Rep HyperdataUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HyperdataUser x -> HyperdataUser
$cfrom :: forall x. HyperdataUser -> Rep HyperdataUser x
Generic)

instance GQLType HyperdataUser where
  typeOptions :: f HyperdataUser -> GQLTypeOptions -> GQLTypeOptions
typeOptions f HyperdataUser
_ = Text -> GQLTypeOptions -> GQLTypeOptions
GAGU.unPrefix Text
"_hu_"

data HyperdataPrivate =
     HyperdataPrivate { HyperdataPrivate -> Text
_hpr_password :: !Text
                      , HyperdataPrivate -> Lang
_hpr_lang     :: !Lang
                      }
     deriving (HyperdataPrivate -> HyperdataPrivate -> Bool
(HyperdataPrivate -> HyperdataPrivate -> Bool)
-> (HyperdataPrivate -> HyperdataPrivate -> Bool)
-> Eq HyperdataPrivate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperdataPrivate -> HyperdataPrivate -> Bool
$c/= :: HyperdataPrivate -> HyperdataPrivate -> Bool
== :: HyperdataPrivate -> HyperdataPrivate -> Bool
$c== :: HyperdataPrivate -> HyperdataPrivate -> Bool
Eq, Int -> HyperdataPrivate -> ShowS
[HyperdataPrivate] -> ShowS
HyperdataPrivate -> String
(Int -> HyperdataPrivate -> ShowS)
-> (HyperdataPrivate -> String)
-> ([HyperdataPrivate] -> ShowS)
-> Show HyperdataPrivate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperdataPrivate] -> ShowS
$cshowList :: [HyperdataPrivate] -> ShowS
show :: HyperdataPrivate -> String
$cshow :: HyperdataPrivate -> String
showsPrec :: Int -> HyperdataPrivate -> ShowS
$cshowsPrec :: Int -> HyperdataPrivate -> ShowS
Show, (forall x. HyperdataPrivate -> Rep HyperdataPrivate x)
-> (forall x. Rep HyperdataPrivate x -> HyperdataPrivate)
-> Generic HyperdataPrivate
forall x. Rep HyperdataPrivate x -> HyperdataPrivate
forall x. HyperdataPrivate -> Rep HyperdataPrivate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HyperdataPrivate x -> HyperdataPrivate
$cfrom :: forall x. HyperdataPrivate -> Rep HyperdataPrivate x
Generic)

instance GQLType HyperdataPrivate where
  typeOptions :: f HyperdataPrivate -> GQLTypeOptions -> GQLTypeOptions
typeOptions f HyperdataPrivate
_ = Text -> GQLTypeOptions -> GQLTypeOptions
GAGU.unPrefix Text
"_hpr_"


data HyperdataPublic =
     HyperdataPublic { HyperdataPublic -> Text
_hpu_pseudo       :: !Text
                     , HyperdataPublic -> [DocumentId]
_hpu_publications :: ![DocumentId]
                     }
     deriving (HyperdataPublic -> HyperdataPublic -> Bool
(HyperdataPublic -> HyperdataPublic -> Bool)
-> (HyperdataPublic -> HyperdataPublic -> Bool)
-> Eq HyperdataPublic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperdataPublic -> HyperdataPublic -> Bool
$c/= :: HyperdataPublic -> HyperdataPublic -> Bool
== :: HyperdataPublic -> HyperdataPublic -> Bool
$c== :: HyperdataPublic -> HyperdataPublic -> Bool
Eq, Int -> HyperdataPublic -> ShowS
[HyperdataPublic] -> ShowS
HyperdataPublic -> String
(Int -> HyperdataPublic -> ShowS)
-> (HyperdataPublic -> String)
-> ([HyperdataPublic] -> ShowS)
-> Show HyperdataPublic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperdataPublic] -> ShowS
$cshowList :: [HyperdataPublic] -> ShowS
show :: HyperdataPublic -> String
$cshow :: HyperdataPublic -> String
showsPrec :: Int -> HyperdataPublic -> ShowS
$cshowsPrec :: Int -> HyperdataPublic -> ShowS
Show, (forall x. HyperdataPublic -> Rep HyperdataPublic x)
-> (forall x. Rep HyperdataPublic x -> HyperdataPublic)
-> Generic HyperdataPublic
forall x. Rep HyperdataPublic x -> HyperdataPublic
forall x. HyperdataPublic -> Rep HyperdataPublic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HyperdataPublic x -> HyperdataPublic
$cfrom :: forall x. HyperdataPublic -> Rep HyperdataPublic x
Generic)

instance GQLType HyperdataPublic where
  typeOptions :: f HyperdataPublic -> GQLTypeOptions -> GQLTypeOptions
typeOptions f HyperdataPublic
_ = Text -> GQLTypeOptions -> GQLTypeOptions
GAGU.unPrefix Text
"_hpu_"

-- | Default
defaultHyperdataUser :: HyperdataUser
defaultHyperdataUser :: HyperdataUser
defaultHyperdataUser =
  HyperdataUser :: Maybe HyperdataPrivate
-> Maybe HyperdataContact -> Maybe HyperdataPublic -> HyperdataUser
HyperdataUser
    { _hu_private :: Maybe HyperdataPrivate
_hu_private = HyperdataPrivate -> Maybe HyperdataPrivate
forall a. a -> Maybe a
Just HyperdataPrivate
defaultHyperdataPrivate
    , _hu_shared :: Maybe HyperdataContact
_hu_shared = HyperdataContact -> Maybe HyperdataContact
forall a. a -> Maybe a
Just HyperdataContact
defaultHyperdataContact
    , _hu_public :: Maybe HyperdataPublic
_hu_public = HyperdataPublic -> Maybe HyperdataPublic
forall a. a -> Maybe a
Just HyperdataPublic
defaultHyperdataPublic }

defaultHyperdataPublic :: HyperdataPublic
defaultHyperdataPublic :: HyperdataPublic
defaultHyperdataPublic = Text -> [DocumentId] -> HyperdataPublic
HyperdataPublic Text
"pseudo" [DocumentId
1..DocumentId
10]

defaultHyperdataPrivate :: HyperdataPrivate
defaultHyperdataPrivate :: HyperdataPrivate
defaultHyperdataPrivate = Text -> Lang -> HyperdataPrivate
HyperdataPrivate Text
"password" Lang
EN


------------------------------------------------------------------------
-- Instances
------------------------------------------------------------------------
-- | Specific Gargantext instance
instance Hyperdata HyperdataUser
instance Hyperdata HyperdataPrivate
instance Hyperdata HyperdataPublic

-- | All lenses
makeLenses ''HyperdataUser
makeLenses ''HyperdataPrivate
makeLenses ''HyperdataPublic

-- | All Json instances
$(deriveJSON (unPrefix "_hu_")  ''HyperdataUser)
$(deriveJSON (unPrefix "_hpr_") ''HyperdataPrivate)
$(deriveJSON (unPrefix "_hpu_") ''HyperdataPublic)

-- | Arbitrary instances
instance Arbitrary HyperdataUser where
  arbitrary :: Gen HyperdataUser
arbitrary = Maybe HyperdataPrivate
-> Maybe HyperdataContact -> Maybe HyperdataPublic -> HyperdataUser
HyperdataUser (Maybe HyperdataPrivate
 -> Maybe HyperdataContact
 -> Maybe HyperdataPublic
 -> HyperdataUser)
-> Gen (Maybe HyperdataPrivate)
-> Gen
     (Maybe HyperdataContact -> Maybe HyperdataPublic -> HyperdataUser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Maybe HyperdataPrivate)
forall a. Arbitrary a => Gen a
arbitrary Gen
  (Maybe HyperdataContact -> Maybe HyperdataPublic -> HyperdataUser)
-> Gen (Maybe HyperdataContact)
-> Gen (Maybe HyperdataPublic -> HyperdataUser)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe HyperdataContact)
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe HyperdataPublic -> HyperdataUser)
-> Gen (Maybe HyperdataPublic) -> Gen HyperdataUser
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe HyperdataPublic)
forall a. Arbitrary a => Gen a
arbitrary

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

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

-- | ToSchema instances
instance ToSchema HyperdataUser where
  declareNamedSchema :: Proxy HyperdataUser -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy HyperdataUser
proxy =
    SchemaOptions
-> Proxy HyperdataUser -> 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
"_hu_") Proxy HyperdataUser
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
"User 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
?~ HyperdataUser -> Value
forall a. ToJSON a => a -> Value
toJSON HyperdataUser
defaultHyperdataUser

instance ToSchema HyperdataPrivate where
  declareNamedSchema :: Proxy HyperdataPrivate -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy HyperdataPrivate
proxy =
    SchemaOptions
-> Proxy HyperdataPrivate
-> 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
"_hpr_") Proxy HyperdataPrivate
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
"User Private 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
?~ HyperdataPrivate -> Value
forall a. ToJSON a => a -> Value
toJSON HyperdataPrivate
defaultHyperdataPrivate


instance ToSchema HyperdataPublic where
  declareNamedSchema :: Proxy HyperdataPublic -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy HyperdataPublic
proxy =
    SchemaOptions
-> Proxy HyperdataPublic
-> 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
"_hpu_") Proxy HyperdataPublic
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
"User Public 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
?~ HyperdataPublic -> Value
forall a. ToJSON a => a -> Value
toJSON HyperdataPublic
defaultHyperdataPublic


-- | Database (Posgresql-simple instance)
instance FromField HyperdataUser where
  fromField :: FieldParser HyperdataUser
fromField = FieldParser HyperdataUser
forall b.
(Typeable b, FromJSON b) =>
Field -> Maybe ByteString -> Conversion b
fromField'
instance FromField HyperdataPrivate where
  fromField :: FieldParser HyperdataPrivate
fromField = FieldParser HyperdataPrivate
forall b.
(Typeable b, FromJSON b) =>
Field -> Maybe ByteString -> Conversion b
fromField'
instance FromField HyperdataPublic where
  fromField :: FieldParser HyperdataPublic
fromField = FieldParser HyperdataPublic
forall b.
(Typeable b, FromJSON b) =>
Field -> Maybe ByteString -> Conversion b
fromField'

-- | Database (Opaleye instance)
instance DefaultFromField PGJsonb HyperdataUser   where
  defaultFromField :: FromField PGJsonb HyperdataUser
defaultFromField = FromField PGJsonb HyperdataUser
forall haskell pgType.
FromField haskell =>
FromField pgType haskell
fieldQueryRunnerColumn

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

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