1- import React from 'react' ;
2- import { CssBaseline , AppBar , Toolbar , Typography } from '@material-ui/core' ;
1+ import { AppBar , CssBaseline , Toolbar , Typography } from '@material-ui/core' ;
32import { MuiThemeProvider } from '@material-ui/core/styles' ;
3+ import React , { ComponentType } from 'react' ;
44import { Observable as obs } from 'rxjs' ;
55import {
6- mount ,
7- withAuthorization ,
86 AuthorizationProvider ,
7+ Loading ,
8+ mount ,
99 NavigationProvider ,
1010 Notifications ,
11- Loading ,
11+ withAuthorization ,
1212} from './components' ;
1313import { SqlStreamStore } from './components/Icons' ;
14+ import { connect , createState } from './reactive' ;
1415import { actions , store , Viewer } from './stream-store' ;
1516import theme from './theme' ;
16- import { createState , connect } from './reactive ' ;
17+ import { HalLink , HalLinks } from './types ' ;
1718import { mediaTypes } from './utils' ;
1819
1920const getSelfAlias = links =>
@@ -27,23 +28,37 @@ const getSelfAlias = links =>
2728 . map ( ( { rel } ) => rel ) ;
2829
2930const self$ = store . hal$ . links$
30- . filter ( links => links . self )
31+ . filter ( links => ! ! links . self )
3132 . map ( getSelfAlias )
3233 . filter ( rel => ! ! rel )
3334 . map ( ( [ link ] ) => link ) ;
3435
35- const state$ = createState (
36+ interface SqlStreamStoreBrowserState {
37+ loading : boolean ;
38+ mediaType : string ;
39+ links : HalLinks ;
40+ self : HalLink ;
41+ }
42+ const state$ = createState < SqlStreamStoreBrowserState > (
3643 obs . merge (
3744 self$ . map ( self => [ 'self' , ( ) => self ] ) ,
3845 store . hal$ . links$ . map ( links => [ 'links' , ( ) => links ] ) ,
3946 store . hal$ . forms$ . map ( forms => [ 'forms' , ( ) => forms ] ) ,
4047 store . hal$ . loading$ . map ( loading => [ 'loading' , ( ) => loading ] ) ,
4148 store . hal$ . mediaType$ . map ( mediaType => [ 'mediaType' , ( ) => mediaType ] ) ,
4249 ) ,
43- obs . of ( { links : { } , forms : { } , loading : false } ) ,
50+ obs . of ( {
51+ forms : { } ,
52+ links : { } ,
53+ loading : false ,
54+ mediaType : mediaTypes . hal ,
55+ self : {
56+ href : '' ,
57+ } ,
58+ } ) ,
4459) ;
4560
46- const onNavigate = ( link , authorization ) =>
61+ const onNavigate = ( link : HalLink , authorization : string | undefined ) =>
4762 link . href . indexOf ( '#' ) === - 1 &&
4863 actions . get . request . next ( { link, headers : { authorization } } ) ;
4964
@@ -64,8 +79,12 @@ const Hero = () => (
6479 </ AppBar >
6580) ;
6681
67- const SqlStreamStoreBrowser = withAuthorization ( ) (
68- mount ( initialNavigation ) ( ( { loading, ...props } ) => (
82+ const SqlStreamStoreBrowser : ComponentType <
83+ SqlStreamStoreBrowserState
84+ > = withAuthorization ( ) (
85+ mount < SqlStreamStoreBrowserState & { authorization : string | undefined } > (
86+ initialNavigation ,
87+ ) ( ( { loading, ...props } ) => (
6988 < MuiThemeProvider theme = { theme } >
7089 < div >
7190 < CssBaseline />
@@ -80,7 +99,9 @@ const SqlStreamStoreBrowser = withAuthorization()(
8099 ) ) ,
81100) ;
82101
83- const AuthorizedSqlStreamStoreBrowser = ( { authorization, ...props } ) => (
102+ const AuthorizedSqlStreamStoreBrowser : ComponentType <
103+ SqlStreamStoreBrowserState & { authorization : string | undefined }
104+ > = ( { authorization, ...props } ) => (
84105 < AuthorizationProvider authorization = { authorization } >
85106 < SqlStreamStoreBrowser { ...props } />
86107 </ AuthorizationProvider >
0 commit comments