Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
hlint:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

env:
HLINT_VERSION: '3.5'
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
hlint wizard-server

fourmolu:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

env:
FOURMOLU_VERSION: '0.8.2.0'
Expand Down
7 changes: 4 additions & 3 deletions registry-public/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: registry-public
version: '4.15.0'
version: '4.16.0'
synopsis: Registry Public
description: Registry Public
category: Web
Expand Down Expand Up @@ -33,15 +33,18 @@ library:
default-extensions:
- DataKinds
- DeriveGeneric
- DisambiguateRecordFields
- DuplicateRecordFields
- ExistentialQuantification
- ExtendedDefaultRules
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GeneralizedNewtypeDeriving
- LambdaCase
- MultiParamTypeClasses
- OverloadedStrings
- OverloadedRecordDot
- QuasiQuotes
- RankNTypes
- RecordWildCards
Expand All @@ -52,5 +55,3 @@ default-extensions:
- TypeOperators
- TypeSynonymInstances
- UnicodeSyntax
- OverloadedRecordDot
- DisambiguateRecordFields
7 changes: 4 additions & 3 deletions registry-server/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: registry-server
version: '4.15.0'
version: '4.16.0'
synopsis: Engine Registry
description: Engine Registry
category: Web
Expand Down Expand Up @@ -140,15 +140,18 @@ tests:
default-extensions:
- DataKinds
- DeriveGeneric
- DisambiguateRecordFields
- DuplicateRecordFields
- ExistentialQuantification
- ExtendedDefaultRules
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GeneralizedNewtypeDeriving
- LambdaCase
- MultiParamTypeClasses
- OverloadedStrings
- OverloadedRecordDot
- QuasiQuotes
- RankNTypes
- RecordWildCards
Expand All @@ -159,5 +162,3 @@ default-extensions:
- TypeOperators
- TypeSynonymInstances
- UnicodeSyntax
- OverloadedRecordDot
- DisambiguateRecordFields
2 changes: 1 addition & 1 deletion registry-server/src/Registry/Api/Handler/Swagger/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ swagger =
s._swaggerInfo
{ _infoTitle = "Registry API"
, _infoDescription = Just "API specification for Registry"
, _infoVersion = "4.15.0"
, _infoVersion = "4.16.0"
, _infoLicense =
Just $
License
Expand Down
7 changes: 4 additions & 3 deletions shared-common/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: shared-common
version: '4.15.0'
version: '4.16.0'
synopsis: Engine Shared
description: Engine Shared
category: Web
Expand Down Expand Up @@ -120,15 +120,18 @@ tests:
default-extensions:
- DataKinds
- DeriveGeneric
- DisambiguateRecordFields
- DuplicateRecordFields
- ExistentialQuantification
- ExtendedDefaultRules
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GeneralizedNewtypeDeriving
- LambdaCase
- MultiParamTypeClasses
- OverloadedStrings
- OverloadedRecordDot
- QuasiQuotes
- RankNTypes
- RecordWildCards
Expand All @@ -139,5 +142,3 @@ default-extensions:
- TypeOperators
- TypeSynonymInstances
- UnicodeSyntax
- OverloadedRecordDot
- DisambiguateRecordFields
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Shared.Common.Api.Resource.Common.FromHttpApiData where

import qualified Data.Text as T
import qualified Data.UUID as U
import Servant.API
import Text.Read (readMaybe)

import Shared.Common.Util.String

instance FromHttpApiData [String] where
parseQueryParam = Right . splitOn "," . T.unpack

instance FromHttpApiData [U.UUID] where
parseQueryParam = genericParseQueryParams

genericParseQueryParam :: Read a => T.Text -> Either T.Text a
genericParseQueryParam x =
case readMaybe (T.unpack x) of
Just phase -> Right phase
Nothing -> Left . T.pack . f' "Unable to parse %s" $ [T.unpack x]

genericParseQueryParams :: Read a => T.Text -> Either T.Text [a]
genericParseQueryParams xs =
let foldFn :: Read a => Either T.Text [a] -> String -> Either T.Text [a]
foldFn (Left err) _ = Left err
foldFn (Right acc) x =
case readMaybe x of
Just sharing -> Right $ sharing : acc
Nothing -> Left . T.pack . f' "Unable to parse %s" $ [x]
in foldl foldFn (Right []) . splitOn "," . T.unpack $ xs
9 changes: 7 additions & 2 deletions shared-common/src/Shared/Common/Database/DAO/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ createDeleteEntitiesByFn entityName queryParams = do
let action conn = execute conn sql params
runDB action

createDeleteEntityLikeFn :: AppContextC s sc m => String -> String -> [String] -> m Int64
createDeleteEntityLikeFn entityName key params = do
createDeleteEntityWhereInFn :: AppContextC s sc m => String -> String -> [String] -> m Int64
createDeleteEntityWhereInFn entityName key params = do
let sql = fromString $ f' "DELETE FROM %s WHERE %s IN (%s)" [entityName, key, generateQuestionMarks params]
logQuery sql params
let action conn = execute conn sql params
Expand Down Expand Up @@ -445,6 +445,11 @@ generateQuestionMarks fields =
generateQuestionMarks' :: ToRow entity => entity -> String
generateQuestionMarks' = generateQuestionMarks . fmap show . toRow

generateQuestionMarksForEntities :: ToRow entity => [entity] -> String
generateQuestionMarksForEntities entities =
let oneRow entity = "(" ++ generateQuestionMarks' entity ++ ")"
in L.intercalate "," . fmap oneRow $ entities

regex :: String -> String
regex query = ".*" ++ query ++ ".*"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ _ERROR_API_COMMON__UNABLE_TO_GET_TOKEN = LocaleRecord "error.api.common.unable_t

_ERROR_VALIDATION__TENANT_OR_ACTIVE_PLAN_ABSENCE host = LocaleRecord "error.validation.tenant_or_active_plan_absence" "Tenant ('%s') doesn't exist or does not have any active plan" [host]

_ERROR_VALIDATION__NOT_SEEDED_TENANT host = LocaleRecord "error.validation.not_seeded_tenant" "Tenant ('%s') is not seeded" [host]

-- Websocket
_ERROR_API_WEBSOCKET__DESERIALIZATION_FAILED =
LocaleRecord "error.api.websocket.cant_deserialize_obj" "Deserialization failed" []
Expand Down
14 changes: 14 additions & 0 deletions shared-common/src/Shared/Common/Util/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ takeWhileInclusive p (x : xs) =
then takeWhileInclusive p xs
else []

dropWhileInclusive :: (a -> Bool) -> [a] -> [a]
dropWhileInclusive _ [] = []
dropWhileInclusive p (x : xs) =
if p x
then dropWhileInclusive p xs
else x : xs

dropWhileExclusive :: (a -> Bool) -> [a] -> [a]
dropWhileExclusive _ [] = []
dropWhileExclusive p (x : xs) =
if p x
then dropWhileExclusive p xs
else xs

generateList :: Int -> [Int]
generateList size = [0 .. (size - 1)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ deletePersistentCommands :: AppContextC s sc m => m Int64
deletePersistentCommands = createDeleteEntitiesFn entityName

deletePersistentCommandsByCreatedBy :: AppContextC s sc m => [U.UUID] -> m Int64
deletePersistentCommandsByCreatedBy createdBys = createDeleteEntityLikeFn entityName "created_by" (fmap U.toString createdBys)
deletePersistentCommandsByCreatedBy createdBys = createDeleteEntityWhereInFn entityName "created_by" (fmap U.toString createdBys)

deletePersistentCommandByUuid :: AppContextC s sc m => U.UUID -> m Int64
deletePersistentCommandByUuid uuid = createDeleteEntityByFn entityName [("uuid", U.toString uuid)]
Expand Down
8 changes: 8 additions & 0 deletions shared-common/test/Shared/Specs/Common/Util/ListSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ listSpec =
it "[1,2] -> [1,2]" $ [1, 2] `elems` [1, 2] `shouldBe` True
it "[2,1] -> [1,2]" $ [2, 1] `elems` [1, 2] `shouldBe` True
it "[1,2] -> [1]" $ [1, 2] `elems` [1] `shouldBe` False
describe "dropWhileInclusive" $ do
it "(<= 3) [] -> []" $ dropWhileInclusive (<= 3) [] `shouldBe` []
it "(<= 3) [1,2,3,4,5,6] -> [4,5,6]" $ dropWhileInclusive (<= 3) [1, 2, 3, 4, 5, 6] `shouldBe` [4, 5, 6]
it "(/= 3) [1,2,3,4,5,6] -> [3,4,5,6]" $ dropWhileInclusive (/= 3) [1, 2, 3, 4, 5, 6] `shouldBe` [3, 4, 5, 6]
describe "dropWhileExclusive" $ do
it "(<= 3) [] -> []" $ dropWhileExclusive (<= 3) [] `shouldBe` []
it "(<= 3) [1,2,3,4,5,6] -> [5,6]" $ dropWhileExclusive (<= 3) [1, 2, 3, 4, 5, 6] `shouldBe` [5, 6]
it "(/= 3) [1,2,3,4,5,6] -> [4,5,6]" $ dropWhileExclusive (/= 3) [1, 2, 3, 4, 5, 6] `shouldBe` [4, 5, 6]
describe "generateList" $ do
it "0 -> []" $ generateList 0 `shouldBe` []
it "1 -> [0]" $ generateList 1 `shouldBe` [0]
Expand Down
5 changes: 3 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ extra-deps:
commit: 83446d193f9bba02b758d2f1bd34a642f575238c
- github: JonathanLorimer/hs-connection
commit: 1dc000d38963de0e4c3954b27d4fe0e5f1d9cee2
- github: endgame/amazonka
commit: 0c1813fe8e48d726a91e7dcf239ac9e6db64dff3
- github: brendanhay/amazonka
commit: f3a7fca02fdbb832cc348e991983b1465225d50c
subdirs:
- lib/amazonka
- lib/amazonka-core
- lib/services/amazonka-lambda
- lib/services/amazonka-sso
- lib/services/amazonka-sts
- microlens-pro-0.2.0.2
- base64-1.0
- fsutils-0.1.2
- ginger-0.10.5.2
Expand Down
59 changes: 33 additions & 26 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,68 +84,75 @@ packages:
- completed:
name: amazonka
pantry-tree:
sha256: ca46d1e434972635cc1a5fdced6a33b1203227edd4614e09b3f59134c65b8983
size: 1528
sha256: a678b4c468ed87aad953b4c62eaae4a60a78c099f353e42439008fe33f5e67b2
size: 34732126
sha256: cd18f37f7578d8b48e4c625df28753a644f204933a7e665541b9878876f4e05e
size: 1529
sha256: 06f5e8430080e5a46e4489e12978725f4b01cfb896450a12a01bcde88168c7f2
size: 34855734
subdir: lib/amazonka
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
version: '2.0'
original:
subdir: lib/amazonka
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
- completed:
name: amazonka-core
pantry-tree:
sha256: b86f40dfb68a3f20032c595300fc4a7ba1c0769615dd707edb105349cc41908e
sha256: fbd62e7df53cf2f5b944a99d0ef024c77a10e3bde2e519fb95bcb262aed29fc4
size: 3222
sha256: a678b4c468ed87aad953b4c62eaae4a60a78c099f353e42439008fe33f5e67b2
size: 34732126
sha256: 06f5e8430080e5a46e4489e12978725f4b01cfb896450a12a01bcde88168c7f2
size: 34855734
subdir: lib/amazonka-core
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
version: '2.0'
original:
subdir: lib/amazonka-core
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
- completed:
name: amazonka-lambda
pantry-tree:
sha256: e99dc2ab8f03c47702d3ba13cd416942e2143b4e494136d482749d2d47ee09ac
sha256: 249b7557046e64a2fae70acd3e7d7e20422ef7b3db49bf01d56c619e1d0a4470
size: 21343
sha256: a678b4c468ed87aad953b4c62eaae4a60a78c099f353e42439008fe33f5e67b2
size: 34732126
sha256: 06f5e8430080e5a46e4489e12978725f4b01cfb896450a12a01bcde88168c7f2
size: 34855734
subdir: lib/services/amazonka-lambda
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
version: '2.0'
original:
subdir: lib/services/amazonka-lambda
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
- completed:
name: amazonka-sso
pantry-tree:
sha256: f8897d82072d662605f60dc3d18e921c04bbb337b5d7caaeaece36fc8aee7fb9
sha256: c4575f7b7cf61c3de65e43d0d77a14dfa14c47ebff5f1a3dcd2f6e1313aaaf0a
size: 1817
sha256: a678b4c468ed87aad953b4c62eaae4a60a78c099f353e42439008fe33f5e67b2
size: 34732126
sha256: 06f5e8430080e5a46e4489e12978725f4b01cfb896450a12a01bcde88168c7f2
size: 34855734
subdir: lib/services/amazonka-sso
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
version: '2.0'
original:
subdir: lib/services/amazonka-sso
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
- completed:
name: amazonka-sts
pantry-tree:
sha256: b2a18c0a04c999f9f32e114ad94bf76a89e463dbb16063ebf0899ee28808f898
sha256: e0cb89013938230d257a2e546a78170dfdb6d507f37c6cb763a6cdf6290edb66
size: 2880
sha256: a678b4c468ed87aad953b4c62eaae4a60a78c099f353e42439008fe33f5e67b2
size: 34732126
sha256: 06f5e8430080e5a46e4489e12978725f4b01cfb896450a12a01bcde88168c7f2
size: 34855734
subdir: lib/services/amazonka-sts
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
version: '2.0'
original:
subdir: lib/services/amazonka-sts
url: https://github.com/endgame/amazonka/archive/0c1813fe8e48d726a91e7dcf239ac9e6db64dff3.tar.gz
url: https://github.com/brendanhay/amazonka/archive/f3a7fca02fdbb832cc348e991983b1465225d50c.tar.gz
- completed:
hackage: microlens-pro-0.2.0.2@sha256:2fd14b7f87d6aa76700dabf65fcdda835aa329a4fdd8a44eebdf399e798af7ab,3377
pantry-tree:
sha256: be8ac1093c45ec46d640c56c06d8826d364ad1243d601e731e37581e8579e9c3
size: 430
original:
hackage: microlens-pro-0.2.0.2
- completed:
hackage: base64-1.0@sha256:ab8084608505f30d6cf7dd790271f927fd8a00956c5e7f5546f5cf56b298022c,2991
pantry-tree:
Expand Down
7 changes: 4 additions & 3 deletions wizard-common/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wizard-common
version: '4.15.0'
version: '4.16.0'
synopsis: Wizard Engine
description: Wizard Engine
category: Web
Expand Down Expand Up @@ -100,15 +100,18 @@ tests:
default-extensions:
- DataKinds
- DeriveGeneric
- DisambiguateRecordFields
- DuplicateRecordFields
- ExistentialQuantification
- ExtendedDefaultRules
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GeneralizedNewtypeDeriving
- LambdaCase
- MultiParamTypeClasses
- OverloadedStrings
- OverloadedRecordDot
- QuasiQuotes
- RankNTypes
- RecordWildCards
Expand All @@ -119,5 +122,3 @@ default-extensions:
- TypeOperators
- TypeSynonymInstances
- UnicodeSyntax
- OverloadedRecordDot
- DisambiguateRecordFields
Loading
Loading