-
Notifications
You must be signed in to change notification settings - Fork 64
/
custom.d.ts
129 lines (105 loc) Β· 3.5 KB
/
custom.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
declare module 'react-prism'
declare module 'react-router'
declare module 'react-router-relay'
declare module 'react-router-scroll'
declare module 'commonmark-react-renderer'
declare module 'graphiql'
declare module 'react-copy-to-clipboard'
declare module 'cuid'
declare var Smooch: any
declare var __LAST_UPDATE__: string
declare var __LAMBDA_AUTH__: string
declare var __LAMBDA_DOWNLOAD_EXAMPLE__: string
declare var __GITHUB_OAUTH_CLIENT_ID__: string
declare var __GA_TRACKING_CODE__: string
interface Window {
Smooch: any
}
declare module 'react-relay' {
// fragments are a hash of functions
interface Fragments {
[query: string]: ((variables?: RelayVariables) => string)
}
interface CreateContainerOpts {
initialVariables?: Object
fragments: Fragments
prepareVariables?(prevVariables: RelayVariables): RelayVariables
}
interface RelayVariables {
[name: string]: any
}
// add static getFragment method to the component constructor
interface RelayContainerClass<T> extends React.ComponentClass<T> {
getFragment: ((q: string, vars?: RelayVariables) => string)
}
interface RelayQueryRequestResolve {
response: any
}
interface RelayMutationRequest {
getQueryString(): string
getVariables(): RelayVariables
resolve(result: RelayQueryRequestResolve)
reject(errors: any)
}
interface RelayQueryRequest {
resolve(result: RelayQueryRequestResolve)
reject(errors: any)
getQueryString(): string
getVariables(): RelayVariables
getID(): string
getDebugName(): string
}
interface RelayNetworkLayer {
supports(...options: string[]): boolean
}
class DefaultNetworkLayer implements RelayNetworkLayer {
constructor(host: string, options?: any)
supports(...options: string[]): boolean
}
interface RelayQuery {
query: string
}
function createContainer<T>(component: React.ComponentClass<T>, params?: CreateContainerOpts): RelayContainerClass<any>
function injectNetworkLayer(networkLayer: RelayNetworkLayer)
function isContainer(component: React.ComponentClass<any>): boolean
function QL(...args: any[]): string
function createQuery(query: string, variables: RelayVariables)
class Route {
constructor(params?: RelayVariables)
}
// Relay Mutation class, where T are the props it takes and S is the returned payload from Relay.Store.update.
// S is typically dynamic as it depends on the data the app is currently using, but it's possible to always
// return some data in the payload using REQUIRED_CHILDREN which is where specifying S is the most useful.
class Mutation<T,S> {
props: T
constructor(props: T)
static getFragment(q: string): string
}
interface Transaction {
getError(): Error
Status(): number
}
interface StoreUpdateCallbacks<T> {
onFailure?(transaction: Transaction)
onSuccess?(response: T)
}
interface Store {
commitUpdate(mutation: Mutation<any,any>, callbacks?: StoreUpdateCallbacks<any>)
primeCache(query: RelayQuery, callback: (done: any, error: any)=>void)
readQuery(query: string)
}
var Store: Store
var Renderer: any
class RootContainer extends React.Component<RootContainerProps,any> {}
interface RootContainerProps extends React.Props<RootContainer>{
Component: RelayContainerClass<any>
route: Route
renderLoading?(): JSX.Element
renderFetched?(data: any): JSX.Element
renderFailure?(error: Error, retry: Function): JSX.Element
}
interface RelayProp {
variables: any
setVariables(variables: Object)
}
}