packages feed

dhscanner-kbapi 3.0.0 → 3.1.0

raw patch · 3 files changed

+96/−2 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ QueryError: BackendInfraProblems :: BackendInfraProblemsContent -> QueryError
+ QueryError: BackendInfraProblemsContent :: String -> BackendInfraProblemsContent
+ QueryError: KBNotFound :: KBNotFoundContent -> QueryError
+ QueryError: KBNotFoundContent :: String -> KBNotFoundContent
+ QueryError: KBResponseInvalidSyntax :: KBResponseInvalidSyntaxContent -> QueryError
+ QueryError: KBResponseInvalidSyntaxContent :: String -> KBResponseInvalidSyntaxContent
+ QueryError: KBSearchToolNotFound :: KBSearchToolNotFoundContent -> QueryError
+ QueryError: KBSearchToolNotFoundContent :: String -> KBSearchToolNotFoundContent
+ QueryError: Timeout :: TimeoutContent -> QueryError
+ QueryError: TimeoutContent :: String -> TimeoutContent
+ QueryError: [backendInfraProblemsDetails] :: BackendInfraProblemsContent -> String
+ QueryError: [kbNotFoundDetails] :: KBNotFoundContent -> String
+ QueryError: [kbResponseInvalidSyntaxDetails] :: KBResponseInvalidSyntaxContent -> String
+ QueryError: [kbSearchToolNotFoundDetails] :: KBSearchToolNotFoundContent -> String
+ QueryError: [timeoutDetails] :: TimeoutContent -> String
+ QueryError: data BackendInfraProblemsContent
+ QueryError: data KBNotFoundContent
+ QueryError: data KBResponseInvalidSyntaxContent
+ QueryError: data KBSearchToolNotFoundContent
+ QueryError: data QueryError
+ QueryError: data TimeoutContent
+ QueryError: httpResponseCodeOf :: QueryError -> Word
+ QueryError: instance Data.Aeson.Types.FromJSON.FromJSON QueryError.BackendInfraProblemsContent
+ QueryError: instance Data.Aeson.Types.FromJSON.FromJSON QueryError.KBNotFoundContent
+ QueryError: instance Data.Aeson.Types.FromJSON.FromJSON QueryError.KBResponseInvalidSyntaxContent
+ QueryError: instance Data.Aeson.Types.FromJSON.FromJSON QueryError.KBSearchToolNotFoundContent
+ QueryError: instance Data.Aeson.Types.FromJSON.FromJSON QueryError.QueryError
+ QueryError: instance Data.Aeson.Types.FromJSON.FromJSON QueryError.TimeoutContent
+ QueryError: instance Data.Aeson.Types.ToJSON.ToJSON QueryError.BackendInfraProblemsContent
+ QueryError: instance Data.Aeson.Types.ToJSON.ToJSON QueryError.KBNotFoundContent
+ QueryError: instance Data.Aeson.Types.ToJSON.ToJSON QueryError.KBResponseInvalidSyntaxContent
+ QueryError: instance Data.Aeson.Types.ToJSON.ToJSON QueryError.KBSearchToolNotFoundContent
+ QueryError: instance Data.Aeson.Types.ToJSON.ToJSON QueryError.QueryError
+ QueryError: instance Data.Aeson.Types.ToJSON.ToJSON QueryError.TimeoutContent
+ QueryError: instance GHC.Internal.Classes.Eq QueryError.BackendInfraProblemsContent
+ QueryError: instance GHC.Internal.Classes.Eq QueryError.KBNotFoundContent
+ QueryError: instance GHC.Internal.Classes.Eq QueryError.KBResponseInvalidSyntaxContent
+ QueryError: instance GHC.Internal.Classes.Eq QueryError.KBSearchToolNotFoundContent
+ QueryError: instance GHC.Internal.Classes.Eq QueryError.QueryError
+ QueryError: instance GHC.Internal.Classes.Eq QueryError.TimeoutContent
+ QueryError: instance GHC.Internal.Classes.Ord QueryError.BackendInfraProblemsContent
+ QueryError: instance GHC.Internal.Classes.Ord QueryError.KBNotFoundContent
+ QueryError: instance GHC.Internal.Classes.Ord QueryError.KBResponseInvalidSyntaxContent
+ QueryError: instance GHC.Internal.Classes.Ord QueryError.KBSearchToolNotFoundContent
+ QueryError: instance GHC.Internal.Classes.Ord QueryError.QueryError
+ QueryError: instance GHC.Internal.Classes.Ord QueryError.TimeoutContent
+ QueryError: instance GHC.Internal.Generics.Generic QueryError.BackendInfraProblemsContent
+ QueryError: instance GHC.Internal.Generics.Generic QueryError.KBNotFoundContent
+ QueryError: instance GHC.Internal.Generics.Generic QueryError.KBResponseInvalidSyntaxContent
+ QueryError: instance GHC.Internal.Generics.Generic QueryError.KBSearchToolNotFoundContent
+ QueryError: instance GHC.Internal.Generics.Generic QueryError.QueryError
+ QueryError: instance GHC.Internal.Generics.Generic QueryError.TimeoutContent
+ QueryError: instance GHC.Internal.Show.Show QueryError.BackendInfraProblemsContent
+ QueryError: instance GHC.Internal.Show.Show QueryError.KBNotFoundContent
+ QueryError: instance GHC.Internal.Show.Show QueryError.KBResponseInvalidSyntaxContent
+ QueryError: instance GHC.Internal.Show.Show QueryError.KBSearchToolNotFoundContent
+ QueryError: instance GHC.Internal.Show.Show QueryError.QueryError
+ QueryError: instance GHC.Internal.Show.Show QueryError.TimeoutContent

Files

dhscanner-kbapi.cabal view
@@ -28,7 +28,7 @@     fundamental modifications to the structure or specification     of code facts. -version:            3.0.0+version:            3.1.0 license:            GPL-3.0-only license-file:       LICENSE author:             OrenGitHub@@ -56,7 +56,8 @@         WithComments,         WithDataFlowPath,         WithSanitizers,-        WithDBReads+        WithDBReads,+        QueryError      build-depends:         aeson >= 2.2 && < 2.4,
json-schema-creator/Main.hs view
@@ -32,6 +32,7 @@ import qualified WithDataFlowPath import qualified WithSanitizers import qualified WithDBReads+import qualified QueryError  -- every query module names its type Features : qualify the schema name qualifiedAs :: String -> SchemaOptions@@ -95,6 +96,13 @@ instance ToSchema WithDBReads.Match where declareNamedSchema = genericDeclareNamedSchema (qualifiedAs "WithDBReads") instance ToSchema WithDBReads.DBRead +instance ToSchema QueryError.QueryError+instance ToSchema QueryError.TimeoutContent+instance ToSchema QueryError.KBNotFoundContent+instance ToSchema QueryError.BackendInfraProblemsContent+instance ToSchema QueryError.KBSearchToolNotFoundContent+instance ToSchema QueryError.KBResponseInvalidSyntaxContent+ -- openapi3 ignores tagSingleConstructors : describe the tagged Sanitizer -- through a mirror ( drop it once Sanitizer has a second constructor ) data SanitizerTag = TopLevelIfThenElse deriving ( Generic )@@ -121,5 +129,7 @@ main = do     BL.writeFile "query.schema.json" (encodePretty (schemaWithDefs (Proxy :: Proxy Query)))     BL.writeFile "query_result.schema.json" (encodePretty (schemaWithDefs (Proxy :: Proxy QueryResult)))+    BL.writeFile "query_error.schema.json" (encodePretty (schemaWithDefs (Proxy :: Proxy QueryError.QueryError)))     putStrLn "wrote query.schema.json"     putStrLn "wrote query_result.schema.json"+    putStrLn "wrote query_error.schema.json"
+ src/QueryError.hs view
@@ -0,0 +1,83 @@+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveAnyClass #-}++-- |+--+-- * The ways a valid 'Kbapi.Query' can fail to produce a 'Kbapi.QueryResult'.+--+-- * An empty answer is /not/ an error : no path, no match, no sink are+--   all 'Kbapi.QueryResult's.+--+-- * A request that is not a valid 'Kbapi.Query' is rejected before it+--   is run, and is not a 'QueryError' either.+--+-- * Each details field is free text, written by the query engine for+--   a human ( or an LLM ) to read : branch on the constructor, never on+--   the text.+--+module QueryError++where++-- general imports+import GHC.Generics+import Data.Aeson++data QueryError+   = Timeout TimeoutContent+   | KBNotFound KBNotFoundContent+   | BackendInfraProblems BackendInfraProblemsContent+   | KBSearchToolNotFound KBSearchToolNotFoundContent+   | KBResponseInvalidSyntax KBResponseInvalidSyntaxContent+   deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )++-- | The HTTP status code a 'QueryError' is returned with.+--+-- One clause per constructor, no wildcard : a new constructor without+-- a code is a compile error ( @-Werror=incomplete-patterns@ ).+httpResponseCodeOf :: QueryError -> Word+httpResponseCodeOf (Timeout _)                 = 504+httpResponseCodeOf (KBNotFound _)              = 404+httpResponseCodeOf (BackendInfraProblems _)    = 500+httpResponseCodeOf (KBSearchToolNotFound _)    = 500+httpResponseCodeOf (KBResponseInvalidSyntax _) = 500++-- | The query did not finish within its time limit.+data TimeoutContent+   = TimeoutContent+     {+         timeoutDetails :: String+     }+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )++-- | No knowledge base was found at the requested location.+data KBNotFoundContent+   = KBNotFoundContent+     {+         kbNotFoundDetails :: String+     }+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )++-- | The search over the knowledge base started, but failed while running.+data BackendInfraProblemsContent+   = BackendInfraProblemsContent+     {+         backendInfraProblemsDetails :: String+     }+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )++-- | The tool that searches the knowledge base could not be started.+data KBSearchToolNotFoundContent+   = KBSearchToolNotFoundContent+     {+         kbSearchToolNotFoundDetails :: String+     }+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )++-- | The search finished, but its answer could not be read back.+data KBResponseInvalidSyntaxContent+   = KBResponseInvalidSyntaxContent+     {+         kbResponseInvalidSyntaxDetails :: String+     }+     deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )