{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} module GitHub.Types.Workflow where import Control.Applicative ((<|>)) import Data.Aeson (FromJSON (..), ToJSON (toJSON), Value (..)) import qualified Data.Aeson.Key as Key import Data.Aeson.KeyMap (KeyMap) import qualified Data.Aeson.KeyMap as KeyMap import Data.Aeson.TH (Options (..), defaultOptions, deriveJSON) import Data.Aeson.Types (parseEither) import Data.HashMap.Strict (HashMap) import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Vector as V import Debug.Trace (trace) import Text.Casing (kebab, quietSnake) data Input = Input { Input -> Maybe Text inputDefault :: Maybe Text , Input -> Bool inputRequired :: Bool , Input -> Text inputType :: Text } deriving (Int -> Input -> ShowS [Input] -> ShowS Input -> String (Int -> Input -> ShowS) -> (Input -> String) -> ([Input] -> ShowS) -> Show Input forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Input] -> ShowS $cshowList :: [Input] -> ShowS show :: Input -> String $cshow :: Input -> String showsPrec :: Int -> Input -> ShowS $cshowsPrec :: Int -> Input -> ShowS Show, Input -> Input -> Bool (Input -> Input -> Bool) -> (Input -> Input -> Bool) -> Eq Input forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Input -> Input -> Bool $c/= :: Input -> Input -> Bool == :: Input -> Input -> Bool $c== :: Input -> Input -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "Input")} ''Input) newtype Secret = Secret { Secret -> Bool secretRequired :: Bool } deriving (Int -> Secret -> ShowS [Secret] -> ShowS Secret -> String (Int -> Secret -> ShowS) -> (Secret -> String) -> ([Secret] -> ShowS) -> Show Secret forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Secret] -> ShowS $cshowList :: [Secret] -> ShowS show :: Secret -> String $cshow :: Secret -> String showsPrec :: Int -> Secret -> ShowS $cshowsPrec :: Int -> Secret -> ShowS Show, Secret -> Secret -> Bool (Secret -> Secret -> Bool) -> (Secret -> Secret -> Bool) -> Eq Secret forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Secret -> Secret -> Bool $c/= :: Secret -> Secret -> Bool == :: Secret -> Secret -> Bool $c== :: Secret -> Secret -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "Secret")} ''Secret) data OnSpec = OnSpec { OnSpec -> Maybe [Text] onSpecBranches :: Maybe [Text] , OnSpec -> Maybe (HashMap Text Input) onSpecInputs :: Maybe (HashMap Text Input) , OnSpec -> Maybe (HashMap Text Secret) onSpecSecrets :: Maybe (HashMap Text Secret) , OnSpec -> Maybe [Text] onSpecTypes :: Maybe [Text] } deriving (Int -> OnSpec -> ShowS [OnSpec] -> ShowS OnSpec -> String (Int -> OnSpec -> ShowS) -> (OnSpec -> String) -> ([OnSpec] -> ShowS) -> Show OnSpec forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [OnSpec] -> ShowS $cshowList :: [OnSpec] -> ShowS show :: OnSpec -> String $cshow :: OnSpec -> String showsPrec :: Int -> OnSpec -> ShowS $cshowsPrec :: Int -> OnSpec -> ShowS Show, OnSpec -> OnSpec -> Bool (OnSpec -> OnSpec -> Bool) -> (OnSpec -> OnSpec -> Bool) -> Eq OnSpec forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: OnSpec -> OnSpec -> Bool $c/= :: OnSpec -> OnSpec -> Bool == :: OnSpec -> OnSpec -> Bool $c== :: OnSpec -> OnSpec -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "OnSpec")} ''OnSpec) newtype OnSchedule = OnSchedule { OnSchedule -> Text onScheduleCron :: Text } deriving (Int -> OnSchedule -> ShowS [OnSchedule] -> ShowS OnSchedule -> String (Int -> OnSchedule -> ShowS) -> (OnSchedule -> String) -> ([OnSchedule] -> ShowS) -> Show OnSchedule forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [OnSchedule] -> ShowS $cshowList :: [OnSchedule] -> ShowS show :: OnSchedule -> String $cshow :: OnSchedule -> String showsPrec :: Int -> OnSchedule -> ShowS $cshowsPrec :: Int -> OnSchedule -> ShowS Show, OnSchedule -> OnSchedule -> Bool (OnSchedule -> OnSchedule -> Bool) -> (OnSchedule -> OnSchedule -> Bool) -> Eq OnSchedule forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: OnSchedule -> OnSchedule -> Bool $c/= :: OnSchedule -> OnSchedule -> Bool == :: OnSchedule -> OnSchedule -> Bool $c== :: OnSchedule -> OnSchedule -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "OnSchedule")} ''OnSchedule) data OnMap = OnMap { OnMap -> Maybe OnSpec onMapPullRequest :: Maybe OnSpec , OnMap -> Maybe OnSpec onMapPullRequestTarget :: Maybe OnSpec , OnMap -> Maybe OnSpec onMapPush :: Maybe OnSpec , OnMap -> Maybe OnSpec onMapRelease :: Maybe OnSpec , OnMap -> Maybe [OnSchedule] onMapSchedule :: Maybe [OnSchedule] , OnMap -> Maybe OnSpec onMapWorkflowCall :: Maybe OnSpec , OnMap -> Maybe OnSpec onMapWorkflowDispatch :: Maybe OnSpec } deriving (Int -> OnMap -> ShowS [OnMap] -> ShowS OnMap -> String (Int -> OnMap -> ShowS) -> (OnMap -> String) -> ([OnMap] -> ShowS) -> Show OnMap forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [OnMap] -> ShowS $cshowList :: [OnMap] -> ShowS show :: OnMap -> String $cshow :: OnMap -> String showsPrec :: Int -> OnMap -> ShowS $cshowsPrec :: Int -> OnMap -> ShowS Show, OnMap -> OnMap -> Bool (OnMap -> OnMap -> Bool) -> (OnMap -> OnMap -> Bool) -> Eq OnMap forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: OnMap -> OnMap -> Bool $c/= :: OnMap -> OnMap -> Bool == :: OnMap -> OnMap -> Bool $c== :: OnMap -> OnMap -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = quietSnake . drop (Text.length "OnMap")} ''OnMap) data OneOf a b = A a | B b deriving (Int -> OneOf a b -> ShowS [OneOf a b] -> ShowS OneOf a b -> String (Int -> OneOf a b -> ShowS) -> (OneOf a b -> String) -> ([OneOf a b] -> ShowS) -> Show (OneOf a b) forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a forall a b. (Show a, Show b) => Int -> OneOf a b -> ShowS forall a b. (Show a, Show b) => [OneOf a b] -> ShowS forall a b. (Show a, Show b) => OneOf a b -> String showList :: [OneOf a b] -> ShowS $cshowList :: forall a b. (Show a, Show b) => [OneOf a b] -> ShowS show :: OneOf a b -> String $cshow :: forall a b. (Show a, Show b) => OneOf a b -> String showsPrec :: Int -> OneOf a b -> ShowS $cshowsPrec :: forall a b. (Show a, Show b) => Int -> OneOf a b -> ShowS Show, OneOf a b -> OneOf a b -> Bool (OneOf a b -> OneOf a b -> Bool) -> (OneOf a b -> OneOf a b -> Bool) -> Eq (OneOf a b) forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a forall a b. (Eq a, Eq b) => OneOf a b -> OneOf a b -> Bool /= :: OneOf a b -> OneOf a b -> Bool $c/= :: forall a b. (Eq a, Eq b) => OneOf a b -> OneOf a b -> Bool == :: OneOf a b -> OneOf a b -> Bool $c== :: forall a b. (Eq a, Eq b) => OneOf a b -> OneOf a b -> Bool Eq) instance (ToJSON a, ToJSON b) => ToJSON (OneOf a b) where toJSON :: OneOf a b -> Value toJSON (A a x) = a -> Value forall a. ToJSON a => a -> Value toJSON a x toJSON (B b x) = b -> Value forall a. ToJSON a => a -> Value toJSON b x instance (FromJSON a, FromJSON b) => FromJSON (OneOf a b) where parseJSON :: Value -> Parser (OneOf a b) parseJSON Value x = a -> OneOf a b forall a b. a -> OneOf a b A (a -> OneOf a b) -> Parser a -> Parser (OneOf a b) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Value -> Parser a forall a. FromJSON a => Value -> Parser a parseJSON Value x Parser (OneOf a b) -> Parser (OneOf a b) -> Parser (OneOf a b) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> b -> OneOf a b forall a b. b -> OneOf a b B (b -> OneOf a b) -> Parser b -> Parser (OneOf a b) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Value -> Parser b forall a. FromJSON a => Value -> Parser a parseJSON Value x data Step = Step { Step -> Maybe Text stepId :: Maybe Text , Step -> Maybe Text stepIf :: Maybe Text , Step -> Maybe Text stepName :: Maybe Text , Step -> Maybe (HashMap Text Text) stepEnv :: Maybe (HashMap Text Text) , Step -> Maybe Text stepRun :: Maybe Text , Step -> Maybe (HashMap Text Value) stepWith :: Maybe (HashMap Text Value) , Step -> Maybe Text stepUses :: Maybe Text } deriving (Int -> Step -> ShowS [Step] -> ShowS Step -> String (Int -> Step -> ShowS) -> (Step -> String) -> ([Step] -> ShowS) -> Show Step forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Step] -> ShowS $cshowList :: [Step] -> ShowS show :: Step -> String $cshow :: Step -> String showsPrec :: Int -> Step -> ShowS $cshowsPrec :: Int -> Step -> ShowS Show, Step -> Step -> Bool (Step -> Step -> Bool) -> (Step -> Step -> Bool) -> Eq Step forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Step -> Step -> Bool $c/= :: Step -> Step -> Bool == :: Step -> Step -> Bool $c== :: Step -> Step -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "Step")} ''Step) newtype RunConfig = RunConfig { RunConfig -> Maybe Text runConfigShell :: Maybe Text } deriving (Int -> RunConfig -> ShowS [RunConfig] -> ShowS RunConfig -> String (Int -> RunConfig -> ShowS) -> (RunConfig -> String) -> ([RunConfig] -> ShowS) -> Show RunConfig forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [RunConfig] -> ShowS $cshowList :: [RunConfig] -> ShowS show :: RunConfig -> String $cshow :: RunConfig -> String showsPrec :: Int -> RunConfig -> ShowS $cshowsPrec :: Int -> RunConfig -> ShowS Show, RunConfig -> RunConfig -> Bool (RunConfig -> RunConfig -> Bool) -> (RunConfig -> RunConfig -> Bool) -> Eq RunConfig forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: RunConfig -> RunConfig -> Bool $c/= :: RunConfig -> RunConfig -> Bool == :: RunConfig -> RunConfig -> Bool $c== :: RunConfig -> RunConfig -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "RunConfig")} ''RunConfig) newtype JobDefaults = JobDefaults { JobDefaults -> Maybe RunConfig jobDefaultsRun :: Maybe RunConfig } deriving (Int -> JobDefaults -> ShowS [JobDefaults] -> ShowS JobDefaults -> String (Int -> JobDefaults -> ShowS) -> (JobDefaults -> String) -> ([JobDefaults] -> ShowS) -> Show JobDefaults forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [JobDefaults] -> ShowS $cshowList :: [JobDefaults] -> ShowS show :: JobDefaults -> String $cshow :: JobDefaults -> String showsPrec :: Int -> JobDefaults -> ShowS $cshowsPrec :: Int -> JobDefaults -> ShowS Show, JobDefaults -> JobDefaults -> Bool (JobDefaults -> JobDefaults -> Bool) -> (JobDefaults -> JobDefaults -> Bool) -> Eq JobDefaults forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: JobDefaults -> JobDefaults -> Bool $c/= :: JobDefaults -> JobDefaults -> Bool == :: JobDefaults -> JobDefaults -> Bool $c== :: JobDefaults -> JobDefaults -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "JobDefaults")} ''JobDefaults) data Permission = PermissionRead | PermissionWrite deriving (Int -> Permission -> ShowS [Permission] -> ShowS Permission -> String (Int -> Permission -> ShowS) -> (Permission -> String) -> ([Permission] -> ShowS) -> Show Permission forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Permission] -> ShowS $cshowList :: [Permission] -> ShowS show :: Permission -> String $cshow :: Permission -> String showsPrec :: Int -> Permission -> ShowS $cshowsPrec :: Int -> Permission -> ShowS Show, Permission -> Permission -> Bool (Permission -> Permission -> Bool) -> (Permission -> Permission -> Bool) -> Eq Permission forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Permission -> Permission -> Bool $c/= :: Permission -> Permission -> Bool == :: Permission -> Permission -> Bool $c== :: Permission -> Permission -> Bool Eq) $(deriveJSON defaultOptions{constructorTagModifier = kebab . drop (Text.length "Permission")} ''Permission) data PermissionsMap = PermissionsMap { PermissionsMap -> Maybe Permission permissionsMapContents :: Maybe Permission , PermissionsMap -> Maybe Permission permissionsMapPullRequests :: Maybe Permission } deriving (Int -> PermissionsMap -> ShowS [PermissionsMap] -> ShowS PermissionsMap -> String (Int -> PermissionsMap -> ShowS) -> (PermissionsMap -> String) -> ([PermissionsMap] -> ShowS) -> Show PermissionsMap forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [PermissionsMap] -> ShowS $cshowList :: [PermissionsMap] -> ShowS show :: PermissionsMap -> String $cshow :: PermissionsMap -> String showsPrec :: Int -> PermissionsMap -> ShowS $cshowsPrec :: Int -> PermissionsMap -> ShowS Show, PermissionsMap -> PermissionsMap -> Bool (PermissionsMap -> PermissionsMap -> Bool) -> (PermissionsMap -> PermissionsMap -> Bool) -> Eq PermissionsMap forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: PermissionsMap -> PermissionsMap -> Bool $c/= :: PermissionsMap -> PermissionsMap -> Bool == :: PermissionsMap -> PermissionsMap -> Bool $c== :: PermissionsMap -> PermissionsMap -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "PermissionsMap")} ''PermissionsMap) data PermissionsString = PermissionsStringReadAll | PermissionsStringWriteAll deriving (Int -> PermissionsString -> ShowS [PermissionsString] -> ShowS PermissionsString -> String (Int -> PermissionsString -> ShowS) -> (PermissionsString -> String) -> ([PermissionsString] -> ShowS) -> Show PermissionsString forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [PermissionsString] -> ShowS $cshowList :: [PermissionsString] -> ShowS show :: PermissionsString -> String $cshow :: PermissionsString -> String showsPrec :: Int -> PermissionsString -> ShowS $cshowsPrec :: Int -> PermissionsString -> ShowS Show, PermissionsString -> PermissionsString -> Bool (PermissionsString -> PermissionsString -> Bool) -> (PermissionsString -> PermissionsString -> Bool) -> Eq PermissionsString forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: PermissionsString -> PermissionsString -> Bool $c/= :: PermissionsString -> PermissionsString -> Bool == :: PermissionsString -> PermissionsString -> Bool $c== :: PermissionsString -> PermissionsString -> Bool Eq) $(deriveJSON defaultOptions{constructorTagModifier = kebab . drop (Text.length "PermissionsString")} ''PermissionsString) type Permissions = OneOf PermissionsMap PermissionsString data Strategy = Strategy { Strategy -> Maybe Bool strategyFailFast :: Maybe Bool , Strategy -> HashMap Text [Value] strategyMatrix :: HashMap Text [Value] } deriving (Int -> Strategy -> ShowS [Strategy] -> ShowS Strategy -> String (Int -> Strategy -> ShowS) -> (Strategy -> String) -> ([Strategy] -> ShowS) -> Show Strategy forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Strategy] -> ShowS $cshowList :: [Strategy] -> ShowS show :: Strategy -> String $cshow :: Strategy -> String showsPrec :: Int -> Strategy -> ShowS $cshowsPrec :: Int -> Strategy -> ShowS Show, Strategy -> Strategy -> Bool (Strategy -> Strategy -> Bool) -> (Strategy -> Strategy -> Bool) -> Eq Strategy forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Strategy -> Strategy -> Bool $c/= :: Strategy -> Strategy -> Bool == :: Strategy -> Strategy -> Bool $c== :: Strategy -> Strategy -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "Strategy")} ''Strategy) data Job = Job { Job -> Maybe JobDefaults jobDefaults :: Maybe JobDefaults , Job -> Maybe (HashMap Text Text) jobEnv :: Maybe (HashMap Text Text) , Job -> Maybe Text jobContainer :: Maybe Text , Job -> Maybe Text jobName :: Maybe Text , Job -> Maybe [Text] jobNeeds :: Maybe [Text] , Job -> Maybe Permissions jobPermissions :: Maybe Permissions , Job -> Maybe Text jobRunsOn :: Maybe Text , Job -> Maybe (HashMap Text Text) jobSecrets :: Maybe (HashMap Text Text) , Job -> Maybe [Step] jobSteps :: Maybe [Step] , Job -> Maybe Strategy jobStrategy :: Maybe Strategy , Job -> Maybe Text jobUses :: Maybe Text } deriving (Int -> Job -> ShowS [Job] -> ShowS Job -> String (Int -> Job -> ShowS) -> (Job -> String) -> ([Job] -> ShowS) -> Show Job forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Job] -> ShowS $cshowList :: [Job] -> ShowS show :: Job -> String $cshow :: Job -> String showsPrec :: Int -> Job -> ShowS $cshowsPrec :: Int -> Job -> ShowS Show, Job -> Job -> Bool (Job -> Job -> Bool) -> (Job -> Job -> Bool) -> Eq Job forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Job -> Job -> Bool $c/= :: Job -> Job -> Bool == :: Job -> Job -> Bool $c== :: Job -> Job -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "Job")} ''Job) data Concurrency = Concurrency { Concurrency -> Text concurrencyGroup :: Text , Concurrency -> Bool concurrencyCancelInProgress :: Bool } deriving (Int -> Concurrency -> ShowS [Concurrency] -> ShowS Concurrency -> String (Int -> Concurrency -> ShowS) -> (Concurrency -> String) -> ([Concurrency] -> ShowS) -> Show Concurrency forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Concurrency] -> ShowS $cshowList :: [Concurrency] -> ShowS show :: Concurrency -> String $cshow :: Concurrency -> String showsPrec :: Int -> Concurrency -> ShowS $cshowsPrec :: Int -> Concurrency -> ShowS Show, Concurrency -> Concurrency -> Bool (Concurrency -> Concurrency -> Bool) -> (Concurrency -> Concurrency -> Bool) -> Eq Concurrency forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Concurrency -> Concurrency -> Bool $c/= :: Concurrency -> Concurrency -> Bool == :: Concurrency -> Concurrency -> Bool $c== :: Concurrency -> Concurrency -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "Concurrency")} ''Concurrency) type On = OneOf OnMap [Text] data Spec = Spec { Spec -> Maybe Concurrency specConcurrency :: Maybe Concurrency , Spec -> Maybe (HashMap Text Text) specEnv :: Maybe (HashMap Text Text) , Spec -> Maybe Text specName :: Maybe Text , Spec -> On specOn :: On , Spec -> Maybe Permissions specPermissions :: Maybe Permissions , Spec -> HashMap Text Job specJobs :: HashMap Text Job } deriving (Int -> Spec -> ShowS [Spec] -> ShowS Spec -> String (Int -> Spec -> ShowS) -> (Spec -> String) -> ([Spec] -> ShowS) -> Show Spec forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Spec] -> ShowS $cshowList :: [Spec] -> ShowS show :: Spec -> String $cshow :: Spec -> String showsPrec :: Int -> Spec -> ShowS $cshowsPrec :: Int -> Spec -> ShowS Show, Spec -> Spec -> Bool (Spec -> Spec -> Bool) -> (Spec -> Spec -> Bool) -> Eq Spec forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Spec -> Spec -> Bool $c/= :: Spec -> Spec -> Bool == :: Spec -> Spec -> Bool $c== :: Spec -> Spec -> Bool Eq) $(deriveJSON defaultOptions{fieldLabelModifier = kebab . drop (Text.length "Spec")} ''Spec) parseSpec :: Value -> Either String Spec parseSpec :: Value -> Either String Spec parseSpec = (Value -> Parser Spec) -> Value -> Either String Spec forall a b. (a -> Parser b) -> a -> Either String b parseEither Value -> Parser Spec forall a. FromJSON a => Value -> Parser a parseJSON removeNulls :: ToJSON a => a -> Value removeNulls :: a -> Value removeNulls = Value -> Value go (Value -> Value) -> (a -> Value) -> a -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . a -> Value forall a. ToJSON a => a -> Value toJSON where go :: Value -> Value go (Array Array x) = Array -> Value Array (Array -> Value) -> (Array -> Array) -> Array -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . (Value -> Value) -> Array -> Array forall a b. (a -> b) -> Vector a -> Vector b V.map Value -> Value go (Array -> Value) -> Array -> Value forall a b. (a -> b) -> a -> b $ Array x go (Object Object x) = Object -> Value Object (Object -> Value) -> (Object -> Object) -> Object -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . (Value -> Value) -> Object -> Object forall a b. (a -> b) -> KeyMap a -> KeyMap b KeyMap.map Value -> Value go (Object -> Object) -> (Object -> Object) -> Object -> Object forall b c a. (b -> c) -> (a -> b) -> a -> c . (Key -> Value -> Bool) -> Object -> Object forall v. (Key -> v -> Bool) -> KeyMap v -> KeyMap v KeyMap.filterWithKey Key -> Value -> Bool validPair (Object -> Value) -> Object -> Value forall a b. (a -> b) -> a -> b $ Object x go Value x = Value x isEmpty :: Value -> Bool isEmpty Value Null = Bool True isEmpty (Array Array x) = Array -> Bool forall (t :: * -> *) a. Foldable t => t a -> Bool null Array x isEmpty Value _ = Bool False validPair :: Key -> Value -> Bool validPair Key k Value v = Bool -> Bool not (Value -> Bool isEmpty Value v Bool -> Bool -> Bool || Text "x-" Text -> Text -> Bool `Text.isPrefixOf` Key -> Text Key.toText Key k) valueIntersection :: Value -> Value -> Value valueIntersection :: Value -> Value -> Value valueIntersection (Object Object x) (Object Object y) = Object -> Value Object (Object -> Value) -> Object -> Value forall a b. (a -> b) -> a -> b $ (Value -> Value -> Value) -> Object -> Object -> Object forall a b c. (a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c KeyMap.intersectionWith Value -> Value -> Value valueIntersection Object x Object y valueIntersection (Array Array x) (Array Array y) = Array -> Value Array (Array -> Value) -> Array -> Value forall a b. (a -> b) -> a -> b $ (Value -> Bool) -> Array -> Array forall a. (a -> Bool) -> Vector a -> Vector a V.filter (Value -> Value -> Bool forall a. Eq a => a -> a -> Bool /= Value Null) (Array -> Array) -> Array -> Array forall a b. (a -> b) -> a -> b $ (Value -> Value -> Value) -> Array -> Array -> Array forall a b c. (a -> b -> c) -> Vector a -> Vector b -> Vector c V.zipWith Value -> Value -> Value valueIntersection Array x Array y valueIntersection Value _ Value y = Value y specIntersection :: Spec -> Spec -> Spec specIntersection :: Spec -> Spec -> Spec specIntersection Spec a Spec b = case Value -> Either String Spec parseSpec (Value -> Either String Spec) -> Value -> Either String Spec forall a b. (a -> b) -> a -> b $ Value -> Value -> Value valueIntersection (Value -> Value forall a. ToJSON a => a -> Value removeNulls (Value -> Value) -> Value -> Value forall a b. (a -> b) -> a -> b $ Spec -> Value forall a. ToJSON a => a -> Value toJSON Spec a) (Value -> Value forall a. ToJSON a => a -> Value removeNulls (Value -> Value) -> Value -> Value forall a b. (a -> b) -> a -> b $ Spec -> Value forall a. ToJSON a => a -> Value toJSON Spec b) of Left String err -> String -> Spec forall a. HasCallStack => String -> a error (String -> Spec) -> String -> Spec forall a b. (a -> b) -> a -> b $ String "workflow spec intersection is not parseable (should not happen): " String -> ShowS forall a. Semigroup a => a -> a -> a <> String err Right Spec ok -> Spec ok