relay-runtime 0.0.0-main-ff9b2fed → 0.0.0-main-2b59edeb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/experimental.d.ts +34 -0
  2. package/experimental.js +1 -1
  3. package/handlers/RelayDefaultHandlerProvider.d.ts +12 -0
  4. package/handlers/connection/ConnectionHandler.d.ts +51 -0
  5. package/handlers/connection/ConnectionInterface.d.ts +40 -0
  6. package/handlers/connection/MutationHandlers.d.ts +17 -0
  7. package/index.d.ts +274 -0
  8. package/index.js +1 -1
  9. package/multi-actor-environment/ActorIdentifier.d.ts +17 -0
  10. package/multi-actor-environment/MultiActorEnvironment.d.ts +123 -0
  11. package/multi-actor-environment/MultiActorEnvironmentTypes.d.ts +225 -0
  12. package/multi-actor-environment/index.d.ts +14 -0
  13. package/multi-actor-environment.d.ts +8 -0
  14. package/mutations/RelayDeclarativeMutationConfig.d.ts +70 -0
  15. package/mutations/applyOptimisticMutation.d.ts +25 -0
  16. package/mutations/commitLocalUpdate.d.ts +10 -0
  17. package/mutations/commitMutation.d.ts +48 -0
  18. package/network/RelayNetwork.d.ts +12 -0
  19. package/network/RelayNetworkTypes.d.ts +145 -0
  20. package/network/RelayObservable.d.ts +197 -0
  21. package/network/RelayQueryResponseCache.d.ts +16 -0
  22. package/package.json +1 -1
  23. package/query/GraphQLTag.d.ts +45 -0
  24. package/query/fetchQuery.d.ts +21 -0
  25. package/query/fetchQueryInternal.d.ts +26 -0
  26. package/query/fetchQuery_DEPRECATED.d.ts +17 -0
  27. package/store/ClientID.d.ts +14 -0
  28. package/store/OperationExecutor.d.ts +51 -0
  29. package/store/RelayModernEnvironment.d.ts +97 -0
  30. package/store/RelayModernOperationDescriptor.d.ts +28 -0
  31. package/store/RelayModernRecord.d.ts +92 -0
  32. package/store/RelayModernSelector.d.ts +123 -0
  33. package/store/RelayModernStore.d.ts +57 -0
  34. package/store/RelayOperationTracker.d.ts +29 -0
  35. package/store/RelayRecordSource.d.ts +26 -0
  36. package/store/RelayRecordState.d.ts +28 -0
  37. package/store/RelayResponseNormalizer.d.ts +28 -0
  38. package/store/RelayStoreTypes.d.ts +1327 -0
  39. package/store/RelayStoreUtils.d.ts +86 -0
  40. package/store/ResolverFragments.d.ts +43 -0
  41. package/store/ViewerPattern.d.ts +11 -0
  42. package/store/createFragmentSpecResolver.d.ts +16 -0
  43. package/store/isRelayModernEnvironment.d.ts +8 -0
  44. package/store/live-resolvers/resolverDataInjector.d.ts +27 -0
  45. package/store/observeFragmentExperimental.d.ts +46 -0
  46. package/store/observeQueryExperimental.d.ts +30 -0
  47. package/store/readInlineData.d.ts +19 -0
  48. package/store/waitForFragmentExperimental.d.ts +49 -0
  49. package/subscription/requestSubscription.d.ts +27 -0
  50. package/util/NormalizationNode.d.ts +235 -0
  51. package/util/ReaderNode.d.ts +264 -0
  52. package/util/RelayConcreteNode.d.ts +120 -0
  53. package/util/RelayError.d.ts +13 -0
  54. package/util/RelayFeatureFlags.d.ts +40 -0
  55. package/util/RelayProfiler.d.ts +121 -0
  56. package/util/RelayReplaySubject.d.ts +25 -0
  57. package/util/RelayRuntimeTypes.d.ts +59 -0
  58. package/util/createPayloadFor3DField.d.ts +17 -0
  59. package/util/deepFreeze.d.ts +8 -0
  60. package/util/getFragmentIdentifier.d.ts +10 -0
  61. package/util/getPaginationMetadata.d.ts +20 -0
  62. package/util/getPaginationVariables.d.ts +20 -0
  63. package/util/getPendingOperationsForFragment.d.ts +18 -0
  64. package/util/getRefetchMetadata.d.ts +19 -0
  65. package/util/getRelayHandleKey.d.ts +8 -0
  66. package/util/getRequestIdentifier.d.ts +17 -0
  67. package/util/getValueAtPath.d.ts +8 -0
  68. package/util/handlePotentialSnapshotErrors.d.ts +14 -0
  69. package/util/isPromise.d.ts +8 -0
  70. package/util/isScalarAndEqual.d.ts +8 -0
  71. package/util/recycleNodesInto.d.ts +8 -0
  72. package/util/stableCopy.d.ts +8 -0
  73. package/util/withProvidedVariables.d.ts +19 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { DataID } from './util/RelayRuntimeTypes';
9
+
10
+ export { resolverDataInjector } from './store/live-resolvers/resolverDataInjector';
11
+ export { observeFragment } from './store/observeFragmentExperimental';
12
+ export { observeQuery } from './store/observeQueryExperimental';
13
+ export { waitForFragmentData } from './store/waitForFragmentExperimental';
14
+
15
+ export type IdOf<_A extends string, Typename extends undefined | string = undefined> = Typename extends undefined
16
+ ? { id: DataID }
17
+ : { id: DataID; __typename: Typename };
18
+
19
+ interface ErrorResult<E> {
20
+ ok: false;
21
+ errors: readonly E[];
22
+ }
23
+
24
+ interface OkayResult<T> {
25
+ ok: true;
26
+ value: T;
27
+ }
28
+
29
+ // The type returned by fields annotated with `@catch`
30
+ export type Result<T, E> = OkayResult<T> | ErrorResult<E>;
31
+
32
+ export function isValueResult<T = unknown>(input: Result<T, unknown>): input is OkayResult<T>;
33
+
34
+ export function isErrorResult<E = unknown>(input: Result<unknown, E>): input is ErrorResult<E>;
package/experimental.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-2b59edeb
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { Handler } from '../store/RelayStoreTypes';
9
+
10
+ export type HandlerProvider = (handle: string) => Handler | undefined;
11
+
12
+ export default function RelayDefaultHandlerProvider(handle: string): Handler;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import {
9
+ HandleFieldPayload,
10
+ ReadOnlyRecordProxy,
11
+ RecordProxy,
12
+ RecordSourceProxy,
13
+ } from '../../store/RelayStoreTypes';
14
+ import {DataID, Variables} from '../../util/RelayRuntimeTypes';
15
+
16
+ export interface ConnectionMetadata {
17
+ path: readonly string[] | null | undefined;
18
+ direction: string | null | undefined; // 'forward' | 'backward' | 'bidirectional' | null | undefined;
19
+ cursor: string | null | undefined;
20
+ count: string | null | undefined;
21
+ stream?: boolean | undefined;
22
+ }
23
+
24
+ export function buildConnectionEdge(
25
+ store: RecordSourceProxy,
26
+ connection: RecordProxy,
27
+ edge: RecordProxy | null | undefined,
28
+ ): RecordProxy | null | undefined;
29
+
30
+ export function createEdge(
31
+ store: RecordSourceProxy,
32
+ record: RecordProxy,
33
+ node: RecordProxy,
34
+ edgeType: string,
35
+ ): RecordProxy;
36
+
37
+ export function deleteNode(record: RecordProxy, nodeID: DataID): void;
38
+
39
+ export function getConnection(
40
+ record: ReadOnlyRecordProxy,
41
+ key: string,
42
+ filters?: Variables | null,
43
+ ): RecordProxy | null | undefined;
44
+
45
+ export function getConnectionID(recordID: DataID, key: string, filters?: Variables | null): DataID;
46
+
47
+ export function insertEdgeAfter(record: RecordProxy, newEdge: RecordProxy, cursor?: string | null): void;
48
+
49
+ export function insertEdgeBefore(record: RecordProxy, newEdge: RecordProxy, cursor?: string | null): void;
50
+
51
+ export function update(store: RecordSourceProxy, payload: HandleFieldPayload): void;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { DataID } from '../../util/RelayRuntimeTypes';
9
+
10
+ export interface EdgeRecord extends Record<string, unknown> {
11
+ cursor: unknown;
12
+ node: Record<DataID, unknown>;
13
+ }
14
+
15
+ export interface PageInfo {
16
+ endCursor: string | null | undefined;
17
+ hasNextPage: boolean;
18
+ hasPreviousPage: boolean;
19
+ startCursor: string | null | undefined;
20
+ }
21
+
22
+ interface ConnectionConfig {
23
+ CURSOR: string;
24
+ EDGES: string;
25
+ END_CURSOR: string;
26
+ HAS_NEXT_PAGE: string;
27
+ HAS_PREV_PAGE: string;
28
+ NODE: string;
29
+ PAGE_INFO: string;
30
+ PAGE_INFO_TYPE: string;
31
+ START_CURSOR: string;
32
+ }
33
+
34
+ declare const ConnectionInterface: {
35
+ get(): ConnectionConfig;
36
+
37
+ inject(newConfig: ConnectionConfig): void;
38
+ };
39
+
40
+ export default ConnectionInterface;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import type { Handler } from '../../store/RelayStoreTypes';
9
+
10
+ export const MutationHandlers: {
11
+ DeleteRecordHandler: Handler;
12
+ DeleteEdgeHandler: Handler;
13
+ AppendEdgeHandler: Handler;
14
+ PrependEdgeHandler: Handler;
15
+ AppendNodeHandler: Handler;
16
+ PrependNodeHandler: Handler;
17
+ };
package/index.d.ts ADDED
@@ -0,0 +1,274 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import * as ConnectionHandler from './handlers/connection/ConnectionHandler';
9
+ import ConnectionInterface from './handlers/connection/ConnectionInterface';
10
+ // Extensions
11
+ import RelayDefaultHandlerProvider from './handlers/RelayDefaultHandlerProvider';
12
+ import QueryResponseCache from './network/RelayQueryResponseCache';
13
+ import * as fetchQueryInternal from './query/fetchQueryInternal';
14
+ import * as RelayResolverFragments from './store/ResolverFragments';
15
+ import withProvidedVariables from './util/withProvidedVariables';
16
+
17
+ export { ConnectionInterface };
18
+ export { ConnectionMetadata } from './handlers/connection/ConnectionHandler';
19
+ export { EdgeRecord, PageInfo } from './handlers/connection/ConnectionInterface';
20
+ export { OptimisticMutationConfig } from './mutations/applyOptimisticMutation';
21
+ export { MutationConfig, MutationParameters } from './mutations/commitMutation';
22
+ export {
23
+ DeclarativeMutationConfig,
24
+ MutationTypes,
25
+ RangeBehaviors,
26
+ RangeOperations,
27
+ } from './mutations/RelayDeclarativeMutationConfig';
28
+ export {
29
+ MutationTypes as MutationType,
30
+ RangeOperations as RangeOperation,
31
+ } from './mutations/RelayDeclarativeMutationConfig';
32
+ export {
33
+ ExecuteFunction,
34
+ FetchFunction,
35
+ GraphQLResponse,
36
+ GraphQLResponseWithData,
37
+ GraphQLResponseWithoutData,
38
+ GraphQLSingularResponse,
39
+ LogRequestInfoFunction,
40
+ Network as INetwork,
41
+ PayloadData,
42
+ PayloadError,
43
+ ReactFlightPayloadData,
44
+ ReactFlightPayloadQuery,
45
+ ReactFlightServerTree,
46
+ SubscribeFunction,
47
+ Uploadable,
48
+ UploadableMap,
49
+ } from './network/RelayNetworkTypes';
50
+ export { ObservableFromValue, Observer, Subscribable, Subscription } from './network/RelayObservable';
51
+ export {
52
+ getFragment,
53
+ getInlineDataFragment,
54
+ getNode,
55
+ getPaginationFragment,
56
+ getRefetchableFragment,
57
+ getRequest,
58
+ graphql,
59
+ GraphQLTaggedNode,
60
+ isFragment,
61
+ isInlineDataFragment,
62
+ isRequest,
63
+ } from './query/GraphQLTag';
64
+ export { generateClientID, generateUniqueClientID, isClientID } from './store/ClientID';
65
+ export { TaskScheduler } from './store/OperationExecutor';
66
+ export { RecordState } from './store/RelayRecordState';
67
+ export {
68
+ Environment as IEnvironment,
69
+ FragmentMap,
70
+ FragmentPointer,
71
+ FragmentSpecResolver,
72
+ FragmentType,
73
+ /** @deprecated use FragmentType instead of FragmentReference */
74
+ FragmentType as FragmentReference,
75
+ HandleFieldPayload,
76
+ HasUpdatableSpread,
77
+ InvalidationState,
78
+ LiveState,
79
+ LogEvent,
80
+ LogFunction,
81
+ MissingFieldHandler,
82
+ ModuleImportPointer,
83
+ MutableRecordSource,
84
+ NormalizationSelector,
85
+ OperationAvailability,
86
+ OperationDescriptor,
87
+ OperationLoader,
88
+ OperationTracker,
89
+ OptimisticResponseConfig,
90
+ OptimisticUpdate,
91
+ OptimisticUpdateFunction,
92
+ PluralReaderSelector,
93
+ Props,
94
+ PublishQueue,
95
+ ReactFlightClientResponse,
96
+ ReactFlightPayloadDeserializer,
97
+ ReaderSelector,
98
+ ReadOnlyRecordProxy,
99
+ RecordProxy,
100
+ RecordSourceProxy,
101
+ RecordSourceSelectorProxy,
102
+ RelayContext,
103
+ RelayFieldLogger,
104
+ RequestDescriptor,
105
+ SelectorData,
106
+ SelectorStoreUpdater,
107
+ SingularReaderSelector,
108
+ Snapshot,
109
+ StoreUpdater,
110
+ suspenseSentinel,
111
+ UpdatableFragmentData,
112
+ UpdatableQueryData,
113
+ } from './store/RelayStoreTypes';
114
+ export { GraphQLSubscriptionConfig } from './subscription/requestSubscription';
115
+ export {
116
+ NormalizationArgument,
117
+ NormalizationDefer,
118
+ NormalizationField,
119
+ NormalizationFlightField,
120
+ NormalizationLinkedField,
121
+ NormalizationLinkedHandle,
122
+ NormalizationLocalArgumentDefinition,
123
+ NormalizationModuleImport,
124
+ NormalizationOperation,
125
+ NormalizationRootNode,
126
+ NormalizationScalarField,
127
+ NormalizationSelection,
128
+ NormalizationSplitOperation,
129
+ NormalizationStream,
130
+ NormalizationTypeDiscriminator,
131
+ } from './util/NormalizationNode';
132
+ export {
133
+ ReaderArgument,
134
+ ReaderArgumentDefinition,
135
+ ReaderCondition,
136
+ ReaderField,
137
+ ReaderFlightField,
138
+ ReaderFragment,
139
+ ReaderInlineDataFragment,
140
+ ReaderInlineDataFragmentSpread,
141
+ ReaderInlineFragment,
142
+ ReaderLinkedField,
143
+ ReaderModuleImport,
144
+ ReaderPaginationMetadata,
145
+ ReaderRefetchableFragment,
146
+ ReaderRefetchMetadata,
147
+ ReaderRequiredField,
148
+ ReaderScalarField,
149
+ ReaderSelection,
150
+ RequiredFieldAction,
151
+ } from './util/ReaderNode';
152
+ export {
153
+ ConcreteRequest,
154
+ ConcreteUpdatableQuery,
155
+ GeneratedNode,
156
+ PreloadableConcreteRequest,
157
+ RequestParameters,
158
+ } from './util/RelayConcreteNode';
159
+ export { RelayReplaySubject as ReplaySubject } from './util/RelayReplaySubject';
160
+ export * from './util/RelayRuntimeTypes';
161
+ // Core API
162
+ export { RelayNetwork as Network } from './network/RelayNetwork';
163
+ export { RelayObservable as Observable } from './network/RelayObservable';
164
+ export { default as Environment, EnvironmentConfig } from './store/RelayModernEnvironment';
165
+ export { QueryResponseCache };
166
+ export { RelayModernRecord as Record } from './store/RelayModernRecord';
167
+ export { default as Store } from './store/RelayModernStore';
168
+ export { RelayRecordSource as RecordSource } from './store/RelayRecordSource';
169
+ export { type IdOf, isErrorResult, isValueResult, type Result } from './experimental';
170
+ export { createFragmentSpecResolver } from './store/createFragmentSpecResolver';
171
+ export { readInlineData } from './store/readInlineData';
172
+ export { createOperationDescriptor, createRequestDescriptor } from './store/RelayModernOperationDescriptor';
173
+ export {
174
+ areEqualSelectors,
175
+ createNormalizationSelector,
176
+ createReaderSelector,
177
+ getDataIDsFromFragment,
178
+ getDataIDsFromObject,
179
+ getPluralSelector,
180
+ getSelector,
181
+ getSelectorsFromObject,
182
+ getSingularSelector,
183
+ getVariablesFromFragment,
184
+ getVariablesFromObject,
185
+ getVariablesFromPluralFragment,
186
+ getVariablesFromSingularFragment,
187
+ } from './store/RelayModernSelector';
188
+ export {
189
+ FRAGMENT_OWNER_KEY,
190
+ FRAGMENTS_KEY,
191
+ getModuleComponentKey,
192
+ getModuleOperationKey,
193
+ getStorageKey,
194
+ ID_KEY,
195
+ REF_KEY,
196
+ REFS_KEY,
197
+ ROOT_ID,
198
+ ROOT_TYPE,
199
+ TYPENAME_KEY,
200
+ } from './store/RelayStoreUtils';
201
+ export { readFragment } from './store/ResolverFragments';
202
+ export { RelayDefaultHandlerProvider as DefaultHandlerProvider };
203
+ export declare function getDefaultMissingFieldHandlers(): import('./store/RelayStoreTypes').MissingFieldHandler[];
204
+ export { ConnectionHandler };
205
+ export { MutationHandlers } from './handlers/connection/MutationHandlers';
206
+ export { VIEWER_ID, VIEWER_TYPE } from './store/ViewerPattern';
207
+ // Helpers (can be implemented via the above API)
208
+ export { applyOptimisticMutation } from './mutations/applyOptimisticMutation';
209
+ export { commitLocalUpdate } from './mutations/commitLocalUpdate';
210
+ export { commitMutation } from './mutations/commitMutation';
211
+ export { fetchQuery } from './query/fetchQuery';
212
+ export { fetchQuery_DEPRECATED } from './query/fetchQuery_DEPRECATED';
213
+ export { isRelayModernEnvironment } from './store/isRelayModernEnvironment';
214
+ export { requestSubscription } from './subscription/requestSubscription';
215
+ // Utilities
216
+ export { default as createPayloadFor3DField } from './util/createPayloadFor3DField';
217
+ export { default as getFragmentIdentifier } from './util/getFragmentIdentifier';
218
+ export { default as getPaginationMetadata } from './util/getPaginationMetadata';
219
+ export { default as getPaginationVariables } from './util/getPaginationVariables';
220
+ export { Direction } from './util/getPaginationVariables';
221
+ export { default as getRefetchMetadata } from './util/getRefetchMetadata';
222
+ export { default as getRelayHandleKey } from './util/getRelayHandleKey';
223
+ export { default as getRequestIdentifier } from './util/getRequestIdentifier';
224
+ export { default as getValueAtPath } from './util/getValueAtPath';
225
+ export { default as handlePotentialSnapshotErrors } from './util/handlePotentialSnapshotErrors';
226
+ export declare const PreloadableQueryRegistry: {
227
+ set(key: string, value: import('./util/RelayConcreteNode').ConcreteRequest): void;
228
+ get(key: string): import('./util/RelayConcreteNode').ConcreteRequest | null | undefined;
229
+ onLoad(key: string, callback: (concreteRequest: import('./util/RelayConcreteNode').ConcreteRequest) => void): import('./util/RelayRuntimeTypes').Disposable;
230
+ clear(): void;
231
+ };
232
+ export { RelayProfiler } from './util/RelayProfiler';
233
+ // INTERNAL-ONLY
234
+ export { RelayConcreteNode } from './util/RelayConcreteNode';
235
+ export { default as RelayError } from './util/RelayError';
236
+ export { RelayFeatureFlags } from './util/RelayFeatureFlags';
237
+ export const DEFAULT_HANDLE_KEY = '';
238
+ export { default as deepFreeze } from './util/deepFreeze';
239
+ export { default as getPendingOperationsForFragment } from './util/getPendingOperationsForFragment';
240
+ export { default as isPromise } from './util/isPromise';
241
+ export { default as isScalarAndEqual } from './util/isScalarAndEqual';
242
+ export { default as recycleNodesInto } from './util/recycleNodesInto';
243
+ export { default as stableCopy } from './util/stableCopy';
244
+
245
+ interface Internal {
246
+ fetchQuery: typeof fetchQueryInternal.fetchQuery;
247
+ fetchQueryDeduped: typeof fetchQueryInternal.fetchQueryDeduped;
248
+ getPromiseForActiveRequest: typeof fetchQueryInternal.getPromiseForActiveRequest;
249
+ getObservableForActiveRequest: typeof fetchQueryInternal.getObservableForActiveRequest;
250
+ ResolverFragments: typeof RelayResolverFragments;
251
+ withProvidedVariables: typeof withProvidedVariables;
252
+ }
253
+
254
+ export const __internal: Internal;
255
+
256
+ /**
257
+ * relay-compiler-language-typescript support for fragment references
258
+ */
259
+
260
+ export interface _RefType<Ref extends string> {
261
+ ' $fragmentType': Ref;
262
+ }
263
+
264
+ export interface _FragmentRefs<Refs extends string> {
265
+ ' $fragmentSpreads': FragmentRefs<Refs>;
266
+ }
267
+
268
+ // This is used in the actual artifacts to define the various fragment references a container holds.
269
+ export type FragmentRefs<Refs extends string> = {
270
+ [ref in Refs]: true;
271
+ };
272
+
273
+ // This is a utility type for converting from a data type to a fragment reference that will resolve to that data type.
274
+ export type FragmentRef<Fragment> = Fragment extends _RefType<infer U> ? _FragmentRefs<U> : never;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-ff9b2fed
2
+ * Relay v0.0.0-main-2b59edeb
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /**
9
+ * A unique identifier of the current actor.
10
+ */
11
+ export type ActorIdentifier = string;
12
+
13
+ export function assertInternalActorIdentifier(actorIdentifier: ActorIdentifier): void;
14
+
15
+ export function getActorIdentifier(actorID: string): ActorIdentifier;
16
+
17
+ export function getDefaultActorIdentifier(): ActorIdentifier;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { HandlerProvider } from '../handlers/RelayDefaultHandlerProvider';
9
+ import { MutationParameters } from '../mutations/commitMutation';
10
+ import {GraphQLResponse, Network, PayloadData} from '../network/RelayNetworkTypes';
11
+ import { RelayObservable as Observable } from '../network/RelayObservable';
12
+ import { TaskScheduler } from '../store/OperationExecutor';
13
+ import { GetDataID } from '../store/RelayResponseNormalizer';
14
+ import {
15
+ ExecuteMutationConfig,
16
+ LogFunction,
17
+ MissingFieldHandler,
18
+ OperationAvailability,
19
+ OperationDescriptor,
20
+ OperationLoader,
21
+ OptimisticResponseConfig,
22
+ OptimisticUpdateFunction,
23
+ RelayFieldLogger,
24
+ SelectorStoreUpdater,
25
+ SingularReaderSelector,
26
+ Snapshot,
27
+ Store,
28
+ StoreUpdater,
29
+ } from '../store/RelayStoreTypes';
30
+ import {Disposable, RenderPolicy} from '../util/RelayRuntimeTypes';
31
+ import { ActorIdentifier } from './ActorIdentifier';
32
+ import {
33
+ ActorEnvironment,
34
+ MultiActorEnvironment as IMultiActorEnvironment,
35
+ MultiActorStoreUpdater,
36
+ } from './MultiActorEnvironmentTypes';
37
+
38
+ export type MultiActorEnvironmentConfig = Readonly<{
39
+ createConfigNameForActor?: ((actorIdentifier: ActorIdentifier) => string) | null;
40
+ createNetworkForActor: (actorIdentifier: ActorIdentifier) => Network;
41
+ createStoreForActor?: ((actorIdentifier: ActorIdentifier) => Store) | null;
42
+ defaultRenderPolicy?: RenderPolicy | null;
43
+ getDataID?: GetDataID;
44
+ handlerProvider?: HandlerProvider;
45
+ isServer?: boolean | null;
46
+ logFn?: LogFunction | null;
47
+ missingFieldHandlers?: readonly MissingFieldHandler[] | null;
48
+ operationLoader?: OperationLoader | null;
49
+ relayFieldLogger?: RelayFieldLogger | null;
50
+ scheduler?: TaskScheduler | null;
51
+ shouldProcessClientComponents?: boolean | null;
52
+ treatMissingFieldsAsNull?: boolean;
53
+ }>;
54
+
55
+ export class MultiActorEnvironment implements IMultiActorEnvironment {
56
+ constructor(config: MultiActorEnvironmentConfig);
57
+
58
+ forActor(actorIdentifier: string): ActorEnvironment;
59
+
60
+ check(actorEnvironment: ActorEnvironment, operation: OperationDescriptor): OperationAvailability;
61
+
62
+ subscribe(
63
+ actorEnvironment: ActorEnvironment,
64
+ snapshot: Snapshot,
65
+ callback: (snapshot: Snapshot) => void,
66
+ ): Disposable;
67
+
68
+ retain(actorEnvironment: ActorEnvironment, operation: OperationDescriptor): Disposable;
69
+
70
+ applyUpdate(actorEnvironment: ActorEnvironment, optimisticUpdate: OptimisticUpdateFunction): Disposable;
71
+
72
+ revertUpdate(actorEnvironment: ActorEnvironment, update: OptimisticUpdateFunction): void;
73
+
74
+ replaceUpdate(
75
+ actorEnvironment: ActorEnvironment,
76
+ update: OptimisticUpdateFunction,
77
+ replacement: OptimisticUpdateFunction,
78
+ ): void;
79
+
80
+ applyMutation(
81
+ actorEnvironment: ActorEnvironment,
82
+ optimisticConfig: OptimisticResponseConfig<MutationParameters>,
83
+ ): Disposable;
84
+
85
+ commitUpdate(actorEnvironment: ActorEnvironment, updater: StoreUpdater): void;
86
+
87
+ commitMultiActorUpdate(updater: MultiActorStoreUpdater): void;
88
+
89
+ commitPayload(
90
+ actorEnvironment: ActorEnvironment,
91
+ operationDescriptor: OperationDescriptor,
92
+ payload: PayloadData,
93
+ ): void;
94
+
95
+ lookup(actorEnvironment: ActorEnvironment, selector: SingularReaderSelector): Snapshot;
96
+
97
+ execute(
98
+ actorEnvironment: ActorEnvironment,
99
+ config: { operation: OperationDescriptor },
100
+ ): Observable<GraphQLResponse>;
101
+
102
+ executeSubscription(
103
+ actorEnvironment: ActorEnvironment,
104
+ config: {
105
+ operation: OperationDescriptor;
106
+ updater?: SelectorStoreUpdater<MutationParameters['response']> | null | undefined;
107
+ },
108
+ ): Observable<GraphQLResponse>;
109
+
110
+ executeMutation(
111
+ actorEnvironment: ActorEnvironment,
112
+ config: ExecuteMutationConfig<MutationParameters>,
113
+ ): Observable<GraphQLResponse>;
114
+
115
+ executeWithSource(
116
+ actorEnvironment: ActorEnvironment,
117
+ arg: { operation: OperationDescriptor; source: Observable<GraphQLResponse> },
118
+ ): Observable<GraphQLResponse>;
119
+
120
+ isRequestActive(actorEnvironment: ActorEnvironment, requestIdentifier: string): boolean;
121
+
122
+ isServer(): boolean;
123
+ }