@types/react-relay
Advanced tools
Comparing version 0.9.13 to 1.3.0
@@ -1,160 +0,162 @@ | ||
// Type definitions for react-relay 0.9.2 | ||
// Type definitions for react-relay 1.3 | ||
// Project: https://github.com/facebook/relay | ||
// Definitions by: Johannes Schickling <https://github.com/graphcool> | ||
// Matt Martin <https://github.com/voxmatt> | ||
// Eloy Durán <https://github.com/alloy> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.3 | ||
// TypeScript Version: 2.4 | ||
declare module "react-relay" { | ||
import * as React from "react"; | ||
export { | ||
commitLocalUpdate, | ||
commitRelayModernMutation as commitMutation, | ||
fetchRelayModernQuery as fetchQuery, | ||
requestRelaySubscription as requestSubscription, | ||
} from "relay-runtime"; | ||
type ClientMutationID = string; | ||
import * as React from "react"; | ||
import * as RelayRuntimeTypes from "relay-runtime"; | ||
/** Fragments are a hash of functions */ | ||
interface Fragments { | ||
[query: string]: ((variables?: RelayVariables) => string) | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// Maybe Fix | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export type ConcreteFragment = any; | ||
export type ConcreteBatch = any; | ||
export type ConcreteFragmentDefinition = object; | ||
export type ConcreteOperationDefinition = object; | ||
export type ReactBaseComponent<T> = React.ComponentClass<T> | React.StatelessComponent<T>; | ||
interface CreateContainerOpts { | ||
initialVariables?: any | ||
fragments: Fragments | ||
prepareVariables?(prevVariables: RelayVariables): RelayVariables | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// RelayProp | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// note: refetch and pagination containers augment this | ||
export interface RelayProp { | ||
environment: RelayRuntimeTypes.Environment; | ||
} | ||
interface RelayVariables { | ||
[name: string]: any | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// RelayQL | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export function RelayQL(strings: string[], ...substitutions: any[]): RelayRuntimeTypes.RelayConcreteNode; | ||
/** add static getFragment method to the component constructor */ | ||
interface RelayContainerClass<T> extends React.ComponentClass<T> { | ||
getFragment: ((q: string, v?: RelayVariables) => string) | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// RelayModernGraphQLTag | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface GeneratedNodeMap { | ||
[key: string]: GraphQLTaggedNode; | ||
} | ||
export type GraphQLTaggedNode = | ||
| (() => ConcreteFragment | ConcreteBatch) | ||
| { | ||
modern(): ConcreteFragment | ConcreteBatch; | ||
classic(relayQL: typeof RelayQL): ConcreteFragmentDefinition | ConcreteOperationDefinition; | ||
}; | ||
/** | ||
* Runtime function to correspond to the `graphql` tagged template function. | ||
* All calls to this function should be transformed by the plugin. | ||
*/ | ||
export interface GraphqlInterface { | ||
(strings: string[] | TemplateStringsArray): GraphQLTaggedNode; | ||
experimental(strings: string[] | TemplateStringsArray): GraphQLTaggedNode; | ||
} | ||
export const graphql: GraphqlInterface; | ||
interface RelayQueryRequestResolve { | ||
response: any | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// ReactRelayQueryRenderer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface QueryRendererProps { | ||
cacheConfig?: RelayRuntimeTypes.CacheConfig; | ||
environment: RelayRuntimeTypes.Environment; | ||
query: GraphQLTaggedNode; | ||
render(readyState: ReadyState): React.ReactElement<any> | undefined | null; | ||
variables: RelayRuntimeTypes.Variables; | ||
rerunParamExperimental?: RelayRuntimeTypes.RerunParam; | ||
} | ||
export interface ReadyState { | ||
error: Error | undefined | null; | ||
props: { [propName: string]: any } | undefined | null; | ||
retry?(): void; | ||
} | ||
export interface QueryRendererState { | ||
readyState: ReadyState; | ||
} | ||
export class ReactRelayQueryRenderer extends React.Component<QueryRendererProps, QueryRendererState> {} | ||
export class QueryRenderer extends ReactRelayQueryRenderer {} | ||
type RelayMutationStatus = | ||
'UNCOMMITTED' | // Transaction hasn't yet been sent to the server. Transaction can be committed or rolled back. | ||
'COMMIT_QUEUED' | // Transaction was committed but another transaction with the same collision key is pending, so the transaction has been queued to send to the server. | ||
'COLLISION_COMMIT_FAILED' | //Transaction was queued for commit but another transaction with the same collision key failed. All transactions in the collision queue, including this one, have been failed. Transaction can be recommitted or rolled back. | ||
'COMMITTING' | // Transaction is waiting for the server to respond. | ||
'COMMIT_FAILED'; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// createFragmentContainer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export function createFragmentContainer<T>( | ||
Component: ReactBaseComponent<T>, | ||
fragmentSpec: GraphQLTaggedNode | GeneratedNodeMap | ||
): ReactBaseComponent<T>; | ||
class RelayMutationTransaction { | ||
applyOptimistic(): RelayMutationTransaction; | ||
commit(): RelayMutationTransaction | null; | ||
recommit(): void; | ||
rollback(): void; | ||
getError(): Error; | ||
getStatus(): RelayMutationStatus; | ||
getHash(): string; | ||
getID(): ClientMutationID; | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// createPaginationContainer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface PageInfo { | ||
endCursor: string | undefined | null; | ||
hasNextPage: boolean; | ||
hasPreviousPage: boolean; | ||
startCursor: string | undefined | null; | ||
} | ||
export interface ConnectionData { | ||
edges?: any[]; | ||
pageInfo?: PageInfo; | ||
} | ||
export type RelayPaginationProp = RelayProp & { | ||
hasMore(): boolean; | ||
isLoading(): boolean; | ||
loadMore( | ||
pageSize: number, | ||
callback: (error?: Error) => void, | ||
options?: RefetchOptions | ||
): RelayRuntimeTypes.Disposable | undefined | null; | ||
refetchConnection( | ||
totalCount: number, | ||
callback: (error?: Error) => void, | ||
refetchVariables?: RelayRuntimeTypes.Variables | ||
): RelayRuntimeTypes.Disposable | undefined | null; | ||
}; | ||
export function FragmentVariablesGetter( | ||
prevVars: RelayRuntimeTypes.Variables, | ||
totalCount: number | ||
): RelayRuntimeTypes.Variables; | ||
export interface ConnectionConfig<T> { | ||
direction?: "backward" | "forward"; | ||
getConnectionFromProps?(props: T): ConnectionData | undefined | null; | ||
getFragmentVariables?: typeof FragmentVariablesGetter; | ||
getVariables( | ||
props: { [propName: string]: any }, | ||
paginationInfo: { count: number; cursor?: string }, | ||
fragmentVariables: RelayRuntimeTypes.Variables | ||
): RelayRuntimeTypes.Variables; | ||
query: GraphQLTaggedNode; | ||
} | ||
export function createPaginationContainer<T>( | ||
Component: ReactBaseComponent<T>, | ||
fragmentSpec: GraphQLTaggedNode | GeneratedNodeMap, | ||
connectionConfig: ConnectionConfig<T> | ||
): ReactBaseComponent<T>; | ||
interface RelayMutationRequest { | ||
getQueryString(): string | ||
getVariables(): RelayVariables | ||
resolve(result: RelayQueryRequestResolve): any | ||
reject(errors: any): any | ||
} | ||
interface RelayQueryRequest { | ||
resolve(result: RelayQueryRequestResolve): any | ||
reject(errors: any): 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 | ||
} | ||
function createContainer<T>(component: React.ComponentClass<T> | React.StatelessComponent<T>, params?: CreateContainerOpts): RelayContainerClass<T> | ||
function injectNetworkLayer(networkLayer: RelayNetworkLayer): any | ||
function isContainer(component: React.ComponentClass<any>): boolean | ||
function QL(...args: any[]): string | ||
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): any | ||
onSuccess?(response: T): any | ||
} | ||
interface Store { | ||
commitUpdate(mutation: Mutation<any,any>, callbacks?: StoreUpdateCallbacks<any>): any | ||
} | ||
var Store: Store | ||
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 | ||
} | ||
type ReadyStateEvent = | ||
'ABORT' | | ||
'CACHE_RESTORED_REQUIRED' | | ||
'CACHE_RESTORE_FAILED' | | ||
'CACHE_RESTORE_START' | | ||
'NETWORK_QUERY_ERROR' | | ||
'NETWORK_QUERY_RECEIVED_ALL' | | ||
'NETWORK_QUERY_RECEIVED_REQUIRED' | | ||
'NETWORK_QUERY_START' | | ||
'STORE_FOUND_ALL' | | ||
'STORE_FOUND_REQUIRED'; | ||
interface OnReadyStateChange { | ||
(readyState: { | ||
ready: boolean, | ||
done: boolean, | ||
stale: boolean, | ||
error?: Error, | ||
events: Array<ReadyStateEvent>, | ||
aborted: boolean | ||
}): void | ||
} | ||
interface RelayProp { | ||
readonly route: { name: string; }; // incomplete, also has params and queries | ||
readonly variables: any; | ||
readonly pendingVariables?: any | null; | ||
setVariables(variables: any, onReadyStateChange?: OnReadyStateChange): void; | ||
forceFetch(variables: any, onReadyStateChange?: OnReadyStateChange): void; | ||
hasOptimisticUpdate(record: any): boolean; | ||
getPendingTransactions(record: any): RelayMutationTransaction[]; | ||
commitUpdate: (mutation: Mutation<any,any>, callbacks?: StoreUpdateCallbacks<any>) => any; | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// createFragmentContainer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface RefetchOptions { | ||
force?: boolean; | ||
rerunParamExperimental?: RelayRuntimeTypes.RerunParam; | ||
} | ||
export type RelayRefetchProp = RelayProp & { | ||
refetch( | ||
refetchVariables: | ||
| RelayRuntimeTypes.Variables | ||
| ((fragmentVariables: RelayRuntimeTypes.Variables) => RelayRuntimeTypes.Variables), | ||
renderVariables?: RelayRuntimeTypes.Variables, | ||
callback?: (error?: Error) => void, | ||
options?: RefetchOptions | ||
): RelayRuntimeTypes.Disposable; | ||
}; | ||
export function createRefetchContainer<T>( | ||
Component: ReactBaseComponent<T>, | ||
fragmentSpec: GraphQLTaggedNode | GeneratedNodeMap, | ||
taggedNode: GraphQLTaggedNode | ||
): ReactBaseComponent<T>; |
{ | ||
"name": "@types/react-relay", | ||
"version": "0.9.13", | ||
"version": "1.3.0", | ||
"description": "TypeScript definitions for react-relay", | ||
@@ -9,3 +9,14 @@ "license": "MIT", | ||
"name": "Johannes Schickling", | ||
"url": "https://github.com/graphcool" | ||
"url": "https://github.com/graphcool", | ||
"githubUsername": "graphcool" | ||
}, | ||
{ | ||
"name": "Matt Martin", | ||
"url": "https://github.com/voxmatt", | ||
"githubUsername": "voxmatt" | ||
}, | ||
{ | ||
"name": "Eloy Durán", | ||
"url": "https://github.com/alloy", | ||
"githubUsername": "alloy" | ||
} | ||
@@ -20,7 +31,7 @@ ], | ||
"dependencies": { | ||
"@types/relay-runtime": "*", | ||
"@types/react": "*" | ||
}, | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "87363408e855fc4db444db0f5349d68f01269ad225d36ff40077bf1cac9a7572", | ||
"typeScriptVersion": "2.3" | ||
"typesPublisherContentHash": "96e95115164a0c629320c57547de3a06d24f5f35fe9e6a34194936e6ee044a0e", | ||
"typeScriptVersion": "2.4" | ||
} |
@@ -11,7 +11,7 @@ # Installation | ||
Additional Details | ||
* Last updated: Fri, 23 Jun 2017 17:37:20 GMT | ||
* Dependencies: react | ||
* Last updated: Thu, 19 Oct 2017 15:06:27 GMT | ||
* Dependencies: relay-runtime, react | ||
* Global values: none | ||
# Credits | ||
These definitions were written by Johannes Schickling <https://github.com/graphcool>. | ||
These definitions were written by Johannes Schickling <https://github.com/graphcool>, Matt Martin <https://github.com/voxmatt>, Eloy Durán <https://github.com/alloy>. |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18549
6
403
1
2
1
+ Added@types/relay-runtime@*
+ Added@types/relay-runtime@18.2.5(transitive)