module Ecluse.Core.Osv.Schema (
osvSchemaEpoch,
osvDbFileName,
MetaKey (..),
renderMetaKey,
) where
osvSchemaEpoch :: Int
osvSchemaEpoch :: Int
osvSchemaEpoch = Int
1
osvDbFileName :: Text -> FilePath
osvDbFileName :: Text -> FilePath
osvDbFileName Text
ecosystem =
Text -> FilePath
forall a. ToString a => a -> FilePath
toString Text
ecosystem FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"-osv-schema" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> Int -> FilePath
forall b a. (Show a, IsString b) => a -> b
show Int
osvSchemaEpoch FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
".db"
data MetaKey
=
MetaPilotVersion
|
MetaEcosystem
|
MetaBuiltAt
|
MetaSourceUrl
|
MetaRowCount
deriving stock (MetaKey
MetaKey -> MetaKey -> Bounded MetaKey
forall a. a -> a -> Bounded a
$cminBound :: MetaKey
minBound :: MetaKey
$cmaxBound :: MetaKey
maxBound :: MetaKey
Bounded, Int -> MetaKey
MetaKey -> Int
MetaKey -> [MetaKey]
MetaKey -> MetaKey
MetaKey -> MetaKey -> [MetaKey]
MetaKey -> MetaKey -> MetaKey -> [MetaKey]
(MetaKey -> MetaKey)
-> (MetaKey -> MetaKey)
-> (Int -> MetaKey)
-> (MetaKey -> Int)
-> (MetaKey -> [MetaKey])
-> (MetaKey -> MetaKey -> [MetaKey])
-> (MetaKey -> MetaKey -> [MetaKey])
-> (MetaKey -> MetaKey -> MetaKey -> [MetaKey])
-> Enum MetaKey
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: MetaKey -> MetaKey
succ :: MetaKey -> MetaKey
$cpred :: MetaKey -> MetaKey
pred :: MetaKey -> MetaKey
$ctoEnum :: Int -> MetaKey
toEnum :: Int -> MetaKey
$cfromEnum :: MetaKey -> Int
fromEnum :: MetaKey -> Int
$cenumFrom :: MetaKey -> [MetaKey]
enumFrom :: MetaKey -> [MetaKey]
$cenumFromThen :: MetaKey -> MetaKey -> [MetaKey]
enumFromThen :: MetaKey -> MetaKey -> [MetaKey]
$cenumFromTo :: MetaKey -> MetaKey -> [MetaKey]
enumFromTo :: MetaKey -> MetaKey -> [MetaKey]
$cenumFromThenTo :: MetaKey -> MetaKey -> MetaKey -> [MetaKey]
enumFromThenTo :: MetaKey -> MetaKey -> MetaKey -> [MetaKey]
Enum, MetaKey -> MetaKey -> Bool
(MetaKey -> MetaKey -> Bool)
-> (MetaKey -> MetaKey -> Bool) -> Eq MetaKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MetaKey -> MetaKey -> Bool
== :: MetaKey -> MetaKey -> Bool
$c/= :: MetaKey -> MetaKey -> Bool
/= :: MetaKey -> MetaKey -> Bool
Eq, Int -> MetaKey -> FilePath -> FilePath
[MetaKey] -> FilePath -> FilePath
MetaKey -> FilePath
(Int -> MetaKey -> FilePath -> FilePath)
-> (MetaKey -> FilePath)
-> ([MetaKey] -> FilePath -> FilePath)
-> Show MetaKey
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> MetaKey -> FilePath -> FilePath
showsPrec :: Int -> MetaKey -> FilePath -> FilePath
$cshow :: MetaKey -> FilePath
show :: MetaKey -> FilePath
$cshowList :: [MetaKey] -> FilePath -> FilePath
showList :: [MetaKey] -> FilePath -> FilePath
Show)
renderMetaKey :: MetaKey -> Text
renderMetaKey :: MetaKey -> Text
renderMetaKey = \case
MetaKey
MetaPilotVersion -> Text
"pilot_version"
MetaKey
MetaEcosystem -> Text
"ecosystem"
MetaKey
MetaBuiltAt -> Text
"built_at"
MetaKey
MetaSourceUrl -> Text
"source_url"
MetaKey
MetaRowCount -> Text
"row_count"