@types/relay-runtime
Advanced tools
Comparing version 6.0.8 to 6.0.9
@@ -189,2 +189,3 @@ // Type definitions for relay-runtime 6.0 | ||
export { RelayProfiler } from './lib/util/RelayProfiler'; | ||
export { getRelayHandleKey } from './lib/util/getRelayHandleKey'; | ||
@@ -191,0 +192,0 @@ // INTERNAL-ONLY |
@@ -21,4 +21,4 @@ import { PayloadError, UploadableMap } from '../network/RelayNetworkTypes'; | ||
optimisticResponse?: TOperation['response']; | ||
optimisticUpdater?: SelectorStoreUpdater | null; | ||
updater?: SelectorStoreUpdater | null; | ||
optimisticUpdater?: SelectorStoreUpdater<TOperation['response']> | null; | ||
updater?: SelectorStoreUpdater<TOperation['response']> | null; | ||
uploadables?: UploadableMap | null; | ||
@@ -25,0 +25,0 @@ variables: TOperation['variables']; |
import { ReaderFragment } from '../util/ReaderNode'; | ||
import { Variables, Disposable, DataID, CacheConfig } from '../util/RelayRuntimeTypes'; | ||
import { ConcreteRequest, RequestParameters } from '../util/RelayConcreteNode'; | ||
import { ConcreteRequest } from '../util/RelayConcreteNode'; | ||
import { RequestIdentifier } from '../util/getRequestIdentifier'; | ||
@@ -303,17 +303,47 @@ import { | ||
*/ | ||
export interface RecordProxy { | ||
export type Unarray<T> = T extends Array<infer U> ? U : T; | ||
export type Primitive = string | number | boolean | null | undefined; | ||
export interface RecordProxy<T = {}> { | ||
copyFieldsFrom(source: RecordProxy): void; | ||
getDataID(): DataID; | ||
getLinkedRecord(name: string, args?: Variables | null): RecordProxy | null | undefined; | ||
getLinkedRecords(name: string, args?: Variables | null): Array<RecordProxy | null | undefined> | null | undefined; | ||
getOrCreateLinkedRecord(name: string, typeName: string, args?: Variables | null): RecordProxy; | ||
// If a parent type is provided, provide the child type | ||
getLinkedRecord<K extends keyof T>(name: K, args?: Variables | null): RecordProxy<NonNullable<T[K]>>; | ||
// If a hint is provided, the return value is guaranteed to be the hint type | ||
getLinkedRecord<H = never>(name: string, args?: Variables | null): [H] extends [never] ? RecordProxy | null : RecordProxy<H>; | ||
getLinkedRecords<K extends keyof T>( | ||
name: K, | ||
args?: Variables | null, | ||
): Array<RecordProxy<Unarray<NonNullable<T[K]>>>>; | ||
getLinkedRecords<H = never>( | ||
name: string, | ||
args?: Variables | null, | ||
): [H] extends [never] ? RecordProxy[] | null : | ||
NonNullable<H> extends Array<infer U> ? | ||
Array<RecordProxy<U>> | (H extends null ? null : never) : | ||
never; | ||
getOrCreateLinkedRecord(name: string, typeName: string, args?: Variables | null): RecordProxy<T>; | ||
getType(): string; | ||
getValue(name: string, args?: Variables | null): unknown; | ||
setLinkedRecord(record: RecordProxy, name: string, args?: Variables | null): RecordProxy; | ||
getValue<K extends keyof T>(name: K, args?: Variables | null): T[K]; | ||
getValue(name: string, args?: Variables | null): Primitive | Primitive[]; | ||
setLinkedRecord<K extends keyof T>( | ||
record: RecordProxy<T[K]> | null, | ||
name: K, | ||
args?: Variables | null): RecordProxy<T>; | ||
setLinkedRecord( | ||
record: RecordProxy | null, | ||
name: string, | ||
args?: Variables | null): RecordProxy; | ||
setLinkedRecords<K extends keyof T>( | ||
records: Array<RecordProxy<Unarray<T[K]>> | null> | null | undefined, | ||
name: K, | ||
args?: Variables | null, | ||
): RecordProxy<T>; | ||
setLinkedRecords( | ||
records: Array<RecordProxy | null | undefined>, | ||
records: Array<RecordProxy | null> | null | undefined, | ||
name: string, | ||
args?: Variables | null, | ||
): RecordProxy; | ||
setValue(value: unknown, name: string, args?: Variables | null): RecordProxy; | ||
): RecordProxy<T>; | ||
setValue<K extends keyof T>(value: T[K], name: K, args?: Variables | null): RecordProxy<T>; | ||
setValue(value: Primitive | Primitive[], name: string, args?: Variables | null): RecordProxy; | ||
} | ||
@@ -335,6 +365,8 @@ | ||
*/ | ||
export interface RecordSourceProxy { | ||
create(dataID: DataID, typeName: string): RecordProxy; | ||
delete(dataID: DataID): void; | ||
get(dataID: DataID): RecordProxy | null | undefined; | ||
// tslint:disable-next-line | ||
get<T = {}>(dataID: DataID): RecordProxy<T> | null | undefined; | ||
getRoot(): RecordProxy; | ||
@@ -352,5 +384,7 @@ } | ||
*/ | ||
export interface RecordSourceSelectorProxy extends RecordSourceProxy { | ||
getRootField(fieldName: string): RecordProxy | null | undefined; | ||
getPluralRootField(fieldName: string): Array<RecordProxy | null | undefined> | null | undefined; | ||
export interface RecordSourceSelectorProxy<T = {}> extends RecordSourceProxy { | ||
getRootField<K extends keyof T>(fieldName: K): RecordProxy<NonNullable<T[K]>>; | ||
getRootField(fieldName: string): RecordProxy | null; | ||
getPluralRootField(fieldName: string): Array<RecordProxy<T> | null> | null; | ||
insertConnectionEdge_UNSTABLE(connectionID: ConnectionID, args: Variables, edge: RecordProxy): void; | ||
@@ -645,7 +679,7 @@ } | ||
*/ | ||
export type SelectorStoreUpdater = ( | ||
store: RecordSourceSelectorProxy, | ||
export type SelectorStoreUpdater<T = object> = ( | ||
store: RecordSourceSelectorProxy<T>, | ||
// Actually SelectorData, but mixed is inconvenient to access deeply in | ||
// product code. | ||
data: any, | ||
data: T, | ||
) => void; | ||
@@ -652,0 +686,0 @@ |
@@ -13,3 +13,3 @@ import { DeclarativeMutationConfig } from '../mutations/RelayDeclarativeMutationConfig'; | ||
onNext?: (response: TSubscriptionPayload | null | undefined) => void; | ||
updater?: SelectorStoreUpdater; | ||
updater?: SelectorStoreUpdater<TSubscriptionPayload>; | ||
} | ||
@@ -16,0 +16,0 @@ |
{ | ||
"name": "@types/relay-runtime", | ||
"version": "6.0.8", | ||
"version": "6.0.9", | ||
"description": "TypeScript definitions for relay-runtime", | ||
@@ -37,4 +37,4 @@ "license": "MIT", | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "6afd6d0ef3c5812137b029ac3689f260f00133b62475d5bfa89b8a5d78f7b0c8", | ||
"typesPublisherContentHash": "ab2142e74188690cc2da05d8a829942e09e0dcfd83822382b64bd1f6531cbcd1", | ||
"typeScriptVersion": "3.0" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Wed, 30 Oct 2019 16:12:00 GMT | ||
* Last updated: Thu, 31 Oct 2019 22:32:01 GMT | ||
* Dependencies: none | ||
@@ -14,0 +14,0 @@ * Global values: none |
99855
46
2490