Skip to content

Commit 9e5c8d5

Browse files
committed
Cleanup, bump stack, update client functions
1 parent ffd7753 commit 9e5c8d5

File tree

9 files changed

+65
-68
lines changed

9 files changed

+65
-68
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module Fission.BytesReceived.Types (BytesReceived (..)) where
2+
3+
import Data.Swagger hiding (URL, url)
4+
5+
import Fission.Prelude
6+
7+
newtype BytesReceived = BytesReceived { byteCount :: Natural } -- FIXME is it bytes?
8+
deriving (Show, Eq)
9+
10+
instance ToJSON BytesReceived where
11+
toJSON BytesReceived {..} = object [ "byteCount" .= byteCount ]
12+
13+
instance FromJSON BytesReceived where
14+
parseJSON =
15+
withObject "BytesReceived" \obj -> do
16+
byteCount <- obj .: "byteCount"
17+
return BytesReceived {..}
18+
19+
instance ToSchema BytesReceived where
20+
declareNamedSchema _ = do
21+
bytesSchema <- declareSchemaRef $ Proxy @Natural
22+
23+
mempty
24+
|> type_ ?~ SwaggerObject
25+
|> properties .~ [("byteCount", bytesSchema)]
26+
|> required .~ ["byteCount"]
27+
|> description ?~ "Properties for a registered application"
28+
|> example ?~ toJSON (BytesReceived 42)
29+
|> NamedSchema (Just "BytesReceived")
30+
|> pure
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Fission.Web.API.App.Types (App) where
1+
module Fission.Web.API.App.Types (App, NonStreaming, Streaming) where
22

33
import Fission.Web.API.Prelude
44

@@ -8,5 +8,9 @@ import Fission.Web.API.App.Index.Types
88
import Fission.Web.API.App.Update.Streaming.Types
99
import Fission.Web.API.App.Update.Types
1010

11-
type App = "app" :> API
12-
type API = Index :<|> Create :<|> Update :<|> StreamingUpdate :<|> Destroy
11+
type App = NonStreaming :<|> Streaming
12+
13+
type NonStreaming = "app" :> API
14+
type Streaming = "app" :> StreamingUpdate
15+
16+
type API = Index :<|> Create :<|> Update :<|> Destroy
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,18 @@
11
module Fission.Web.API.App.Update.Streaming.Types where
22

3+
import qualified Network.IPFS.CID.Types as IPFS
34
import Servant.API
4-
import Servant.Types.SourceT
5-
6-
import qualified Network.IPFS.CID.Types as IPFS
75

6+
import Fission.BytesReceived.Types
87
import Fission.URL.Types
9-
10-
import Fission.Prelude
11-
12-
import qualified Fission.Web.API.Auth.Types as Auth
13-
import Fission.Web.API.Prelude
14-
15-
16-
17-
18-
19-
import Data.Swagger hiding (URL, url)
20-
import Servant.Types.SourceT as S
21-
import Streamly.Prelude
8+
import qualified Fission.Web.API.Auth.Types as Auth
229

2310
type StreamingUpdate
24-
= Summary "" -- FIXME
25-
:> Description "" -- FIXME
11+
= Summary "Set app content & stream upload progress"
12+
:> Description "Update the content (CID) of an app & stream the progress"
2613
--
27-
:> Capture "App URL" URL
28-
:> Capture "New CID" IPFS.CID
14+
:> Capture "App URL" URL
15+
:> Capture "New CID" IPFS.CID
2916
--
3017
:> Auth.HigherOrder
3118
:> Stream 'PATCH 200 NewlineFraming JSON (SourceIO BytesReceived)
32-
33-
34-
newtype BytesReceived = BytesReceived { byteCount :: Natural } -- FIXME is it bytes?
35-
deriving (Show, Eq)
36-
37-
instance ToJSON BytesReceived where
38-
toJSON BytesReceived {..} = object [ "bytes" .= byteCount ]
39-
40-
-- ToSchema Fission.Web.API.App.Update.Streaming.Types.BytesReceived
41-
42-
instance ToSchema BytesReceived where -- VERY MUCH FIXME
43-
declareNamedSchema _ = do
44-
urls' <- declareSchemaRef $ Proxy @[URL]
45-
insertedAt' <- declareSchemaRef $ Proxy @UTCTime
46-
modifiedAt' <- declareSchemaRef $ Proxy @UTCTime
47-
48-
mempty
49-
|> type_ ?~ SwaggerObject
50-
|> properties .~
51-
[ ("urls", urls')
52-
, ("insertedAt", insertedAt')
53-
, ("modifiedAt", modifiedAt')
54-
]
55-
|> required .~ ["username", "email"]
56-
|> description ?~ "Properties for a registered application"
57-
|> example ?~ toJSON (BytesReceived 42)
58-
|> NamedSchema (Just "App Index Payload")
59-
|> pure

fission-web-client/library/Fission/Web/Client/App.hs

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ module Fission.Web.Client.App
44
( index
55
, create
66
, update
7+
, streamingUpdate
78
, destroy
89
) where
910

11+
import qualified Servant.Client.Streaming as Streaming
12+
1013
import Fission.Web.API.Prelude
1114

12-
import Fission.Web.API.App.Types
15+
import qualified Fission.Web.API.App.Types as App
1316

14-
index :<|> create :<|> update :<|> destroy = client $ Proxy @App
17+
index :<|> create :<|> update :<|> destroy = client $ Proxy @App.NonStreaming
18+
streamingUpdate = Streaming.client $ Proxy @App.Streaming

fission-web-server/library/Fission/Web/Server/App/Modifier/Class.hs

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import Servant.Server
1212

1313
import Fission.Prelude hiding (on)
1414

15+
import Fission.BytesReceived.Types
1516
import Fission.Error as Error
1617
import Fission.URL
1718

1819
import Fission.Web.Server.Error.ActionNotAuthorized.Types
1920
import Fission.Web.Server.Models
2021

21-
-- FIXME onlu the bytesrecieved; extract out!
22-
import Fission.Web.API.App.Update.Streaming.Types
23-
2422
type Errors' = OpenUnion
2523
'[ NotFound App
2624
, NotFound AppDomain

fission-web-server/library/Fission/Web/Server/Handler/App.hs

+8-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ handler ::
3636
, App.Domain.Retriever t
3737
)
3838
=> ServerT API.App m
39-
handler = Index.index
40-
:<|> Create.create
41-
:<|> Update.update
42-
:<|> Update.updateStreaming
43-
:<|> Destroy.handler
39+
handler =
40+
nonStreaming :<|> Update.updateStreaming
41+
where
42+
nonStreaming =
43+
Index.index
44+
:<|> Create.create
45+
:<|> Update.update
46+
:<|> Destroy.handler

fission-web-server/library/Fission/Web/Server/Types.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import Fission.Prelude
4040

4141
import qualified Fission.Internal.UTF8 as UTF8
4242

43+
import Fission.BytesReceived.Types
4344
import Fission.Error as Error
4445
import Fission.Error.GenericError.Types
4546
import Fission.Time
@@ -56,8 +57,6 @@ import Fission.URL as URL
5657

5758
import Fission.Web.Async
5859

59-
import Fission.Web.API.App.Update.Streaming.Types
60-
6160
import qualified Fission.Web.Server.App as App
6261
import qualified Fission.Web.Server.App.Destroyer as App.Destroyer
6362

stack.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-18.0
1+
resolver: lts-18.4
22

33
packages:
44
- fission-cli

stack.yaml.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ packages:
118118
hackage: http-link-header-1.0.3.1
119119
snapshots:
120120
- completed:
121-
size: 585393
122-
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/0.yaml
123-
sha256: c632012da648385b9fa3c29f4e0afd56ead299f1c5528ee789058be410e883c0
124-
original: lts-18.0
121+
size: 585817
122+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/4.yaml
123+
sha256: ea3a318eafa9e9cc56bfbe46099fd0d54d32641ab7bbe1d182ed8f5de39f804c
124+
original: lts-18.4

0 commit comments

Comments
 (0)