@nkzw/fate 1.3.3 → 1.5.0
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.
- package/README.md +326 -0
- package/docs/api/classes/FateClient.md +51 -199
- package/docs/api/functions/clientRoot.md +1 -1
- package/docs/api/functions/createClient.md +1 -1
- package/docs/api/functions/createGraphQLTransport.md +1 -1
- package/docs/api/functions/createHTTPTransport.md +1 -1
- package/docs/api/functions/createTRPCTransport.md +5 -1
- package/docs/api/functions/defer.md +1 -1
- package/docs/api/functions/getDeferredMetadata.md +1 -1
- package/docs/api/functions/getListEntries.md +1 -1
- package/docs/api/functions/getSelectionPlan.md +1 -1
- package/docs/api/functions/graphqlMutation.md +1 -1
- package/docs/api/functions/isDeferred.md +1 -1
- package/docs/api/functions/isRecord.md +1 -1
- package/docs/api/functions/isViewTag.md +1 -1
- package/docs/api/functions/liveConnectionTopic.md +1 -1
- package/docs/api/functions/liveEntityTopic.md +1 -1
- package/docs/api/functions/liveGlobalConnectionTopic.md +1 -1
- package/docs/api/functions/mutation.md +1 -1
- package/docs/api/functions/toEntityId.md +1 -1
- package/docs/api/functions/view.md +1 -1
- package/docs/api/index.md +4 -1
- package/docs/api/interfaces/FateThenable.md +3 -3
- package/docs/api/interfaces/Persistence.md +23 -0
- package/docs/api/interfaces/PersistenceSession.md +109 -0
- package/docs/api/interfaces/Transport.md +46 -7
- package/docs/api/server/classes/FateRequestError.md +5 -5
- package/docs/api/server/drizzle/functions/createDrizzleFate.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceAdapter.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceRegistry.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyConfig.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyInput.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleQueryExtra.md +3 -3
- package/docs/api/server/drizzle/type-aliases/DrizzleSourceAdapter.md +9 -9
- package/docs/api/server/drizzle/type-aliases/DrizzleViewConfig.md +1 -1
- package/docs/api/server/functions/bindSourceProcedures.md +1 -1
- package/docs/api/server/functions/computed.md +1 -1
- package/docs/api/server/functions/count.md +1 -1
- package/docs/api/server/functions/createFateFetchHandler.md +1 -1
- package/docs/api/server/functions/createFateServer.md +1 -1
- package/docs/api/server/functions/createHonoFateHandler.md +1 -1
- package/docs/api/server/functions/createLiveEventBus.md +1 -1
- package/docs/api/server/functions/createNestedSourcePlan.md +1 -1
- package/docs/api/server/functions/createResolver.md +1 -1
- package/docs/api/server/functions/createSourcePlan.md +1 -1
- package/docs/api/server/functions/createSourceProcedures.md +1 -1
- package/docs/api/server/functions/dataView.md +1 -1
- package/docs/api/server/functions/field.md +1 -1
- package/docs/api/server/functions/getNestedSelection.md +1 -1
- package/docs/api/server/functions/getScopedArgs.md +1 -1
- package/docs/api/server/functions/hasNestedSelection.md +1 -1
- package/docs/api/server/functions/list.md +1 -1
- package/docs/api/server/functions/refetchSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceByIds.md +1 -1
- package/docs/api/server/functions/resolveSourceConnection.md +1 -1
- package/docs/api/server/functions/resolver.md +1 -1
- package/docs/api/server/functions/toPrismaSelect.md +1 -1
- package/docs/api/server/functions/withConnection.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaFate.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceAdapter.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceRegistry.md +1 -1
- package/docs/api/server/prisma/functions/prismaConnectionArgs.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaDelegate.md +4 -4
- package/docs/api/server/prisma/type-aliases/PrismaQueryExtra.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaSourceAdapter.md +9 -9
- package/docs/api/server/prisma/type-aliases/PrismaViewConfig.md +1 -1
- package/docs/api/server/type-aliases/ComputedField.md +5 -5
- package/docs/api/server/type-aliases/ComputedSelection.md +1 -1
- package/docs/api/server/type-aliases/ConnectionItem.md +3 -3
- package/docs/api/server/type-aliases/ConnectionPagination.md +5 -5
- package/docs/api/server/type-aliases/ConnectionResult.md +3 -3
- package/docs/api/server/type-aliases/CountSelection.md +4 -4
- package/docs/api/server/type-aliases/CountWhere.md +1 -1
- package/docs/api/server/type-aliases/DataViewListOptions.md +2 -2
- package/docs/api/server/type-aliases/DataViewOrderBy.md +1 -1
- package/docs/api/server/type-aliases/DataViewOrderDirection.md +1 -1
- package/docs/api/server/type-aliases/DataViewResult.md +1 -1
- package/docs/api/server/type-aliases/Entity.md +1 -1
- package/docs/api/server/type-aliases/FateServer.md +5 -5
- package/docs/api/server/type-aliases/FateServerManifest.md +1 -1
- package/docs/api/server/type-aliases/FieldSelection.md +3 -3
- package/docs/api/server/type-aliases/LiveConnectionEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveConnectionSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/LiveEventBus.md +1 -1
- package/docs/api/server/type-aliases/LiveEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/NativeFateAPI.md +4 -4
- package/docs/api/server/type-aliases/OrderDirection.md +1 -1
- package/docs/api/server/type-aliases/SourceConfig.md +6 -6
- package/docs/api/server/type-aliases/SourceDefinition.md +6 -6
- package/docs/api/server/type-aliases/SourceOrder.md +1 -1
- package/docs/api/server/type-aliases/SourceOrderField.md +3 -3
- package/docs/api/server/type-aliases/SourcePlan.md +1 -1
- package/docs/api/server/type-aliases/SourcePlanNode.md +1 -1
- package/docs/api/server/type-aliases/SourceRegistry.md +1 -1
- package/docs/api/server/type-aliases/SourceRelation.md +1 -1
- package/docs/api/server/type-aliases/SourceRelationConfig.md +1 -1
- package/docs/api/server/variables/byIdInput.md +1 -1
- package/docs/api/server/variables/connectionArgs.md +1 -1
- package/docs/api/type-aliases/ConnectionMetadata.md +1 -1
- package/docs/api/type-aliases/ConnectionRef.md +1 -1
- package/docs/api/type-aliases/Deferred.md +1 -1
- package/docs/api/type-aliases/DeferredMetadata.md +1 -1
- package/docs/api/type-aliases/DeferredSelection.md +1 -1
- package/docs/api/type-aliases/DeferredSnapshot.md +1 -1
- package/docs/api/type-aliases/Entity.md +2 -2
- package/docs/api/type-aliases/EntityId.md +1 -1
- package/docs/api/type-aliases/FateDehydratedState.md +1 -1
- package/docs/api/type-aliases/FateLiveConnectionEvent.md +1 -1
- package/docs/api/type-aliases/FateLiveEvent.md +1 -1
- package/docs/api/type-aliases/FateMutations.md +1 -1
- package/docs/api/type-aliases/FateOperation.md +2 -2
- package/docs/api/type-aliases/FateProtocolRequest.md +1 -1
- package/docs/api/type-aliases/FateProtocolResponse.md +1 -1
- package/docs/api/type-aliases/FateRecord.md +1 -1
- package/docs/api/type-aliases/FateRoots.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationDefinition.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationInput.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationMap.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationOutput.md +1 -1
- package/docs/api/type-aliases/GraphQLTransportOptions.md +19 -11
- package/docs/api/type-aliases/HydrateOptions.md +1 -1
- package/docs/api/type-aliases/HydrationLimits.md +1 -1
- package/docs/api/type-aliases/InferFateAPI.md +1 -1
- package/docs/api/type-aliases/List.md +1 -1
- package/docs/api/type-aliases/ListEntry.md +1 -1
- package/docs/api/type-aliases/ListItem.md +1 -1
- package/docs/api/type-aliases/Mask.md +1 -1
- package/docs/api/type-aliases/MutationDefinition.md +1 -1
- package/docs/api/type-aliases/MutationEntity.md +1 -1
- package/docs/api/type-aliases/MutationIdentifier.md +1 -1
- package/docs/api/type-aliases/MutationIdentity.md +7 -0
- package/docs/api/type-aliases/MutationInput.md +1 -1
- package/docs/api/type-aliases/MutationResult.md +1 -1
- package/docs/api/type-aliases/NodesItem.md +1 -1
- package/docs/api/type-aliases/Pagination.md +5 -5
- package/docs/api/type-aliases/PersistenceSnapshot.md +5 -0
- package/docs/api/type-aliases/Request.md +1 -1
- package/docs/api/type-aliases/RequestMode.md +1 -1
- package/docs/api/type-aliases/RequestOptions.md +2 -2
- package/docs/api/type-aliases/RequestResult.md +1 -1
- package/docs/api/type-aliases/Selection.md +1 -1
- package/docs/api/type-aliases/TypeConfig.md +4 -4
- package/docs/api/type-aliases/View.md +1 -1
- package/docs/api/type-aliases/ViewData.md +1 -1
- package/docs/api/type-aliases/ViewEntity.md +1 -1
- package/docs/api/type-aliases/ViewEntityName.md +1 -1
- package/docs/api/type-aliases/ViewRef.md +1 -1
- package/docs/api/type-aliases/ViewSelection.md +1 -1
- package/docs/api/type-aliases/ViewSnapshot.md +1 -1
- package/docs/api/type-aliases/ViewTag.md +1 -1
- package/docs/api/variables/ConnectionTag.md +1 -1
- package/docs/api/variables/DeferTag.md +1 -1
- package/docs/api/variables/DeferredTag.md +1 -1
- package/docs/guide/getting-started.md +2 -0
- package/docs/guide/persistence.md +323 -0
- package/lib/{liveTopics-uVP0LG-Q.mjs → args-CRLIRl_v.mjs} +1 -59
- package/lib/cli.d.mts +1 -1
- package/lib/{executor-C8HNogYG.d.mts → executor-DoiTBiVv.d.mts} +18 -65
- package/lib/{graphqlTransport-DskuXeUP.d.mts → graphqlTransport-DGLYyRxL.d.mts} +4 -14
- package/lib/{graphqlTransport-DSBVS2Fq.mjs → graphqlTransport-DmheG3AO.mjs} +3 -2
- package/lib/graphqlTransport.d.mts +1 -1
- package/lib/graphqlTransport.mjs +1 -1
- package/lib/hydration-DPZRJgnu.mjs +273 -0
- package/lib/idempotency-types-CqA-BFpn.d.mts +15 -0
- package/lib/idempotency.d.mts +26 -0
- package/lib/idempotency.mjs +34 -0
- package/lib/index.d.mts +6 -15
- package/lib/index.mjs +560 -1774
- package/lib/{list-sI2UPhHc.d.mts → list-BRT1VtiT.d.mts} +1 -2
- package/lib/list.d.mts +1 -1
- package/lib/liveTopics-DuFkDZQm.mjs +17 -0
- package/lib/persistence.d.mts +38 -0
- package/lib/persistence.mjs +1529 -0
- package/lib/protocol-DS5sf6sd.mjs +44 -0
- package/lib/{record-CZyyeLa3.d.mts → record-DITM4zb_.d.mts} +14 -19
- package/lib/server/drizzle.d.mts +45 -114
- package/lib/server/drizzle.mjs +2 -2
- package/lib/server/prisma.d.mts +52 -127
- package/lib/server/prisma.mjs +9 -8
- package/lib/server.d.mts +4 -16
- package/lib/server.mjs +21 -35
- package/lib/sortObjectKeys-yhuitEQZ.mjs +9 -0
- package/lib/{sourceRouter-DSaADXSf.mjs → sourceRouter-51POBlEE.mjs} +9 -6
- package/lib/store-CeatPJeK.mjs +1350 -0
- package/lib/{transport-DhaVVq4P.d.mts → transport-DqjhjLfC.d.mts} +672 -517
- package/lib/vite.d.mts +0 -1
- package/lib/vite.mjs +19 -11
- package/package.json +15 -5
- package/docs/api/type-aliases/Snapshot.md +0 -7
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TRPCClient } from "@trpc/client";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.18.0_typescript@6.0.3/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
|
|
2
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.18.0_typescript@7.0.2/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
|
|
4
3
|
//#region src/observable/types.d.ts
|
|
5
4
|
interface Unsubscribable {
|
|
6
5
|
unsubscribe(): void;
|
|
@@ -24,7 +23,7 @@ interface Observer<TValue, TError> {
|
|
|
24
23
|
type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
25
24
|
type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
|
|
26
25
|
//#endregion
|
|
27
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.18.0_typescript@
|
|
26
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.18.0_typescript@7.0.2/node_modules/@trpc/server/dist/unstable-core-do-not-import.d-BdVSvUCr.d.mts
|
|
28
27
|
/**
|
|
29
28
|
* @public
|
|
30
29
|
*/
|
|
@@ -75,10 +74,6 @@ declare const TRPC_ERROR_CODES_BY_KEY: {
|
|
|
75
74
|
};
|
|
76
75
|
type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
|
|
77
76
|
type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
|
|
78
|
-
/**
|
|
79
|
-
* tRPC error codes that are considered retryable
|
|
80
|
-
* With out of the box SSE, the client will reconnect when these errors are encountered
|
|
81
|
-
*/
|
|
82
77
|
declare class TRPCError extends Error {
|
|
83
78
|
readonly cause?: Error;
|
|
84
79
|
readonly code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "UNPROCESSABLE_CONTENT" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
|
|
@@ -87,7 +82,7 @@ declare class TRPCError extends Error {
|
|
|
87
82
|
code: TRPC_ERROR_CODE_KEY;
|
|
88
83
|
cause?: unknown;
|
|
89
84
|
});
|
|
90
|
-
}
|
|
85
|
+
}
|
|
91
86
|
//#endregion
|
|
92
87
|
//#region src/vendor/standard-schema-v1/spec.d.ts
|
|
93
88
|
/**
|
|
@@ -148,7 +143,7 @@ declare namespace StandardSchemaV1 {
|
|
|
148
143
|
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
149
144
|
/** Infers the output type of a Standard Schema. */
|
|
150
145
|
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
151
|
-
}
|
|
146
|
+
}
|
|
152
147
|
//#endregion
|
|
153
148
|
//#region src/unstable-core-do-not-import/parser.d.ts
|
|
154
149
|
type ParserZodEsque<TInput, TParsedInput> = {
|
|
@@ -198,7 +193,8 @@ interface ProcedureCallOptions<TContext> {
|
|
|
198
193
|
* The index of this call in a batch request.
|
|
199
194
|
*/
|
|
200
195
|
batchIndex: number;
|
|
201
|
-
}
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
202
198
|
//#region src/unstable-core-do-not-import/procedure.d.ts
|
|
203
199
|
declare const procedureTypes: readonly ["query", "mutation", "subscription"];
|
|
204
200
|
/**
|
|
@@ -268,11 +264,7 @@ interface ErrorHandlerOptions<TContext> {
|
|
|
268
264
|
path: string | undefined;
|
|
269
265
|
input: unknown;
|
|
270
266
|
ctx: TContext | undefined;
|
|
271
|
-
}
|
|
272
|
-
//#region src/unstable-core-do-not-import/http/types.d.ts
|
|
273
|
-
/**
|
|
274
|
-
* @deprecated use `Headers` instead, this will be removed in v12
|
|
275
|
-
*/
|
|
267
|
+
}
|
|
276
268
|
//#endregion
|
|
277
269
|
//#region src/unstable-core-do-not-import/rpc/envelopes.d.ts
|
|
278
270
|
/**
|
|
@@ -283,10 +275,6 @@ interface TRPCErrorShape<TData extends object = object> {
|
|
|
283
275
|
message: string;
|
|
284
276
|
data: TData;
|
|
285
277
|
}
|
|
286
|
-
/**
|
|
287
|
-
* JSON-RPC 2.0 Specification
|
|
288
|
-
*/
|
|
289
|
-
//# sourceMappingURL=envelopes.d.ts.map
|
|
290
278
|
//#endregion
|
|
291
279
|
//#region src/unstable-core-do-not-import/transformer.d.ts
|
|
292
280
|
/**
|
|
@@ -329,10 +317,6 @@ interface CombinedDataTransformer {
|
|
|
329
317
|
*/
|
|
330
318
|
output: OutputDataTransformer;
|
|
331
319
|
}
|
|
332
|
-
/**
|
|
333
|
-
* @public
|
|
334
|
-
*/
|
|
335
|
-
//# sourceMappingURL=parseTRPCMessage.d.ts.map
|
|
336
320
|
//#endregion
|
|
337
321
|
//#region src/unstable-core-do-not-import/error/formatter.d.ts
|
|
338
322
|
/**
|
|
@@ -390,11 +374,6 @@ interface JSONLProducerOptions {
|
|
|
390
374
|
*/
|
|
391
375
|
pingMs?: number;
|
|
392
376
|
}
|
|
393
|
-
/**
|
|
394
|
-
* JSON Lines stream producer
|
|
395
|
-
* @see https://jsonlines.org/
|
|
396
|
-
*/
|
|
397
|
-
//# sourceMappingURL=sse.types.d.ts.map
|
|
398
377
|
//#endregion
|
|
399
378
|
//#region src/unstable-core-do-not-import/stream/sse.d.ts
|
|
400
379
|
type Serialize$1 = (value: any) => any;
|
|
@@ -445,10 +424,6 @@ interface SSEStreamProducerOptions<TValue = unknown> {
|
|
|
445
424
|
*/
|
|
446
425
|
client?: SSEClientOptions;
|
|
447
426
|
}
|
|
448
|
-
/**
|
|
449
|
-
*
|
|
450
|
-
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
451
|
-
*/
|
|
452
427
|
//#endregion
|
|
453
428
|
//#region src/unstable-core-do-not-import/rootConfig.d.ts
|
|
454
429
|
/**
|
|
@@ -461,9 +436,6 @@ interface RootTypes {
|
|
|
461
436
|
errorShape: DefaultErrorShape;
|
|
462
437
|
transformer: boolean;
|
|
463
438
|
}
|
|
464
|
-
/**
|
|
465
|
-
* The default check to see if we're in a server
|
|
466
|
-
*/
|
|
467
439
|
/**
|
|
468
440
|
* The tRPC root config
|
|
469
441
|
* @internal
|
|
@@ -540,7 +512,7 @@ type DecorateProcedure<TProcedure extends AnyProcedure> = (input: inferProcedure
|
|
|
540
512
|
/**
|
|
541
513
|
* @internal
|
|
542
514
|
*/
|
|
543
|
-
type DecorateRouterRecord<TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedure<$Value> : $Value extends RouterRecord ? DecorateRouterRecord<$Value> : never : never };
|
|
515
|
+
type DecorateRouterRecord<TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? DecorateProcedure<$Value> : $Value extends RouterRecord ? DecorateRouterRecord<$Value> : never : never; };
|
|
544
516
|
/**
|
|
545
517
|
* @internal
|
|
546
518
|
*/
|
|
@@ -563,10 +535,6 @@ type LazyLoader<TAny> = {
|
|
|
563
535
|
load: () => Promise<void>;
|
|
564
536
|
ref: Lazy<TAny>;
|
|
565
537
|
};
|
|
566
|
-
/**
|
|
567
|
-
* Lazy load a router
|
|
568
|
-
* @see https://trpc.io/docs/server/merging-routers#lazy-load
|
|
569
|
-
*/
|
|
570
538
|
/**
|
|
571
539
|
* @internal
|
|
572
540
|
*/
|
|
@@ -587,421 +555,82 @@ interface Router<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
|
|
|
587
555
|
}
|
|
588
556
|
type AnyRouter = Router<any, any>;
|
|
589
557
|
//#endregion
|
|
590
|
-
//#region src/
|
|
591
|
-
type FieldMask = {
|
|
592
|
-
all: boolean;
|
|
593
|
-
children: Map<string, FieldMask>;
|
|
594
|
-
};
|
|
595
|
-
//#endregion
|
|
596
|
-
//#region src/cache.d.ts
|
|
597
|
-
declare class ViewDataCache {
|
|
598
|
-
private cache;
|
|
599
|
-
private rootDependencies;
|
|
600
|
-
private dependencyIndex;
|
|
601
|
-
clear(): void;
|
|
602
|
-
get<T extends Entity, S extends Selection<T>, V extends View<T, S>>(entityId: EntityId, view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>> | null;
|
|
603
|
-
set<T extends Entity, S extends Selection<T>, V extends View<T, S>>(entityId: EntityId, view: V, ref: ViewRef<T['__typename']>, thenable: FateThenable<ViewSnapshot<T, S>>, dependencies: ReadonlySet<EntityId>): void;
|
|
604
|
-
invalidate(entityId: EntityId): void;
|
|
605
|
-
private invalidateDependents;
|
|
606
|
-
private delete;
|
|
607
|
-
}
|
|
608
|
-
//#endregion
|
|
609
|
-
//#region src/store.d.ts
|
|
610
|
-
type List = Readonly<{
|
|
611
|
-
backwardPageLimit?: number;
|
|
612
|
-
cursors?: ReadonlyArray<string | undefined>;
|
|
613
|
-
forwardPageLimit?: number;
|
|
614
|
-
ids: ReadonlyArray<EntityId>;
|
|
615
|
-
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
616
|
-
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
617
|
-
pagination?: Pagination;
|
|
618
|
-
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
619
|
-
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
620
|
-
}>;
|
|
621
|
-
type StoreHydrationState = Readonly<{
|
|
622
|
-
coverage: ReadonlyArray<readonly [EntityId, ReadonlyArray<string>]>;
|
|
623
|
-
lists: ReadonlyArray<readonly [string, List]>;
|
|
624
|
-
records: ReadonlyArray<readonly [EntityId, AnyRecord]>;
|
|
625
|
-
}>;
|
|
626
|
-
declare class Store {
|
|
627
|
-
private coverage;
|
|
628
|
-
private listKeysByOwnerField;
|
|
629
|
-
private listKeysByReferencedEntity;
|
|
630
|
-
private lists;
|
|
631
|
-
private recordReferenceFields;
|
|
632
|
-
private recordReferencesByTarget;
|
|
633
|
-
private records;
|
|
634
|
-
private subscriptions;
|
|
635
|
-
private listSubscriptions;
|
|
636
|
-
dehydrate(): StoreHydrationState;
|
|
637
|
-
hydrate(state: StoreHydrationState, mode: 'preserve-existing' | 'replace', options?: {
|
|
638
|
-
deferNotifications?: boolean;
|
|
639
|
-
}): () => void;
|
|
640
|
-
private rebuildIndexes;
|
|
641
|
-
read(id: EntityId): AnyRecord | undefined;
|
|
642
|
-
merge(id: EntityId, partial: AnyRecord, paths: Iterable<string>): void;
|
|
643
|
-
private mergeInternal;
|
|
644
|
-
deleteRecord(id: EntityId): void;
|
|
645
|
-
missingForSelection(id: EntityId, paths: Iterable<string>): Set<string>;
|
|
646
|
-
subscribe(id: EntityId, selection: ReadonlySet<string> | null, fn: () => void): () => void;
|
|
647
|
-
subscribe(id: EntityId, fn: () => void): () => void;
|
|
648
|
-
private notify;
|
|
649
|
-
private notifyListSubscribers;
|
|
650
|
-
getList(key: string): ReadonlyArray<EntityId> | undefined;
|
|
651
|
-
getListState(key: string): List | undefined;
|
|
652
|
-
getListsForField(ownerId: EntityId, field: string): Array<readonly [string, List]>;
|
|
653
|
-
setList(key: string, state: List): void;
|
|
654
|
-
replaceListEntityId(previousId: EntityId, nextId: EntityId): void;
|
|
655
|
-
restoreList(key: string, list?: List): void;
|
|
656
|
-
collectGarbage(markedRecords: ReadonlySet<EntityId>, markedLists: ReadonlySet<string>, options?: {
|
|
657
|
-
onRecordDeleted?: (id: EntityId) => void;
|
|
658
|
-
}): {
|
|
659
|
-
lists: Set<string>;
|
|
660
|
-
records: Set<EntityId>;
|
|
661
|
-
};
|
|
662
|
-
private deleteList;
|
|
663
|
-
subscribeList(key: string, fn: () => void): () => void;
|
|
664
|
-
removeReferencesTo(targetId: EntityId, viewDataCache: ViewDataCache, snapshots?: Map<EntityId, Snapshot>, listSnapshots?: Map<string, List>): void;
|
|
665
|
-
snapshot(id: EntityId): Snapshot;
|
|
666
|
-
restore(id: EntityId, snapshot: Snapshot): void;
|
|
667
|
-
private addListIndexes;
|
|
668
|
-
private removeListIndexes;
|
|
669
|
-
private getListReferencedEntityIds;
|
|
670
|
-
private getRecordFieldReferences;
|
|
671
|
-
private addRecordFieldReferenceIndex;
|
|
672
|
-
private removeRecordFieldReferenceIndex;
|
|
673
|
-
private addRecordReferenceIndexes;
|
|
674
|
-
private removeRecordReferenceIndexes;
|
|
675
|
-
private updateRecordReferenceIndexes;
|
|
676
|
-
}
|
|
677
|
-
//#endregion
|
|
678
|
-
//#region src/hydration.d.ts
|
|
679
|
-
/** JSON-safe opaque value contained in a dehydrated fate snapshot. */
|
|
680
|
-
type FateSerializedValue = null | boolean | number | string | ReadonlyArray<FateSerializedValue> | Readonly<{
|
|
681
|
-
[key: string]: FateSerializedValue;
|
|
682
|
-
}>;
|
|
683
|
-
/** Versioned, JSON-safe durable cache snapshot produced by `FateClient.dehydrate()`. */
|
|
684
|
-
declare const hydrationScopeBrand: unique symbol;
|
|
685
|
-
type FateDehydratedState<Scope extends string = string> = Readonly<{
|
|
686
|
-
data: FateSerializedValue;
|
|
687
|
-
readonly [hydrationScopeBrand]?: Scope;
|
|
688
|
-
scope: Scope;
|
|
689
|
-
version: 1;
|
|
690
|
-
}>;
|
|
691
|
-
/** Controls how `FateClient.hydrate()` reconciles a snapshot with browser cache state. */
|
|
692
|
-
type HydrateOptions = Readonly<{
|
|
693
|
-
/**
|
|
694
|
-
* `preserve-existing` keeps browser values and list windows when conflicts
|
|
695
|
-
* occur. `replace` treats the snapshot as authoritative.
|
|
696
|
-
*
|
|
697
|
-
* @defaultValue 'preserve-existing'
|
|
698
|
-
*/
|
|
699
|
-
merge?: 'preserve-existing' | 'replace';
|
|
700
|
-
}>;
|
|
701
|
-
/** Resource limits applied while encoding and decoding hydration snapshots. */
|
|
702
|
-
type HydrationLimits = Readonly<{
|
|
703
|
-
/** Maximum number of entries in any encoded array or object. */maxCollectionLength: number; /** Maximum number of encoded values in a hydration snapshot. */
|
|
704
|
-
maxNodes: number; /** Maximum length of an encoded string, object key, or bigint payload. */
|
|
705
|
-
maxStringLength: number;
|
|
706
|
-
}>;
|
|
707
|
-
//#endregion
|
|
708
|
-
//#region src/selection.d.ts
|
|
558
|
+
//#region src/mutation.d.ts
|
|
709
559
|
/**
|
|
710
|
-
*
|
|
711
|
-
*
|
|
560
|
+
* Defines a mutation for a given entity type, preserving the input and output
|
|
561
|
+
* types for transports.
|
|
712
562
|
*/
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
563
|
+
declare function mutation<T extends Entity, I, R>(entity: T['__typename']): MutationDefinition<T, I, R>;
|
|
564
|
+
/** Where (or if) to insert the resulting record into relevant lists. */
|
|
565
|
+
type InsertPosition = 'after' | 'before' | 'none';
|
|
566
|
+
/**
|
|
567
|
+
* Options accepted by a mutation invocation, including optimistic updates and
|
|
568
|
+
* optional selection for the returned payload.
|
|
569
|
+
*/
|
|
570
|
+
type MutationOptions<Identifier extends MutationIdentifier<any, any, any>> = {
|
|
571
|
+
/** Optional arguments to pass to the mutation resolver. */
|
|
572
|
+
args?: Record<string, unknown>;
|
|
573
|
+
/** If true, deletes the record with the ID specified in the input. */
|
|
574
|
+
delete?: boolean;
|
|
575
|
+
/** Input data for the mutation. */
|
|
576
|
+
input: Omit<MutationInput<Identifier>, 'select'>;
|
|
577
|
+
insert?: InsertPosition;
|
|
578
|
+
/** Optional optimistic update to apply immediately. */
|
|
579
|
+
optimistic?: OptimisticUpdate<MutationResult<Identifier>>;
|
|
580
|
+
/** Skip durable delivery for this call, even when persistence is configured. */
|
|
581
|
+
persist?: boolean;
|
|
582
|
+
/** Optional view specifying which fields to select from the server. */
|
|
583
|
+
view?: View<MutationEntity<Identifier>, Selection<MutationEntity<Identifier>>>;
|
|
721
584
|
};
|
|
722
585
|
/**
|
|
723
|
-
*
|
|
724
|
-
*
|
|
586
|
+
* Callable mutation entry point returned on the client that resolves to either
|
|
587
|
+
* a successful result or an error.
|
|
725
588
|
*/
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
589
|
+
type MutationFunction<I extends MutationIdentifier<any, any, any>> = (options: MutationOptions<I>) => Promise<{
|
|
590
|
+
error: undefined;
|
|
591
|
+
result: MutationResult<I>;
|
|
592
|
+
} | {
|
|
593
|
+
error: Error;
|
|
594
|
+
result: undefined;
|
|
731
595
|
}>;
|
|
732
|
-
//#endregion
|
|
733
|
-
//#region src/client.d.ts
|
|
734
596
|
/**
|
|
735
|
-
*
|
|
597
|
+
* React action-compatible wrapper that can be passed directly to form actions
|
|
598
|
+
* or transitions.
|
|
736
599
|
*/
|
|
737
|
-
type
|
|
600
|
+
type MutationAction<I extends MutationIdentifier<any, any, any>> = (previousState: unknown,
|
|
738
601
|
/**
|
|
739
|
-
*
|
|
602
|
+
* Mutation options or 'reset' to reset the action state.
|
|
740
603
|
*/
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
604
|
+
options: MutationOptions<I> | 'reset') => Promise<{
|
|
605
|
+
error: undefined;
|
|
606
|
+
result: MutationResult<I>;
|
|
607
|
+
} | {
|
|
608
|
+
error: Error;
|
|
609
|
+
result: undefined;
|
|
747
610
|
}>;
|
|
748
|
-
type
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
* @defaultValue 10
|
|
754
|
-
*/
|
|
755
|
-
gcReleaseBufferSize?: number;
|
|
756
|
-
/**
|
|
757
|
-
* Bounds hydration snapshot encoding and decoding work.
|
|
758
|
-
*/
|
|
759
|
-
hydrationLimits?: Partial<HydrationLimits>;
|
|
760
|
-
/**
|
|
761
|
-
* Identifies snapshots compatible with this client. Change this value when
|
|
762
|
-
* deploying an incompatible cache schema or separating cache namespaces.
|
|
763
|
-
*/
|
|
764
|
-
hydrationScope?: HydrationScope;
|
|
765
|
-
mutations?: Mutations;
|
|
766
|
-
onLiveError?: (error: unknown) => void;
|
|
767
|
-
roots: Roots;
|
|
768
|
-
transport: Transport<MutationMapFromDefinitions<Mutations>>;
|
|
769
|
-
types: ReadonlyArray<Omit<TypeConfig, 'getId'> & Partial<{
|
|
770
|
-
getId: TypeConfig['getId'];
|
|
771
|
-
}>>;
|
|
772
|
-
};
|
|
611
|
+
type MutationIdentifierFor<K extends string, Def extends MutationDefinition<any, any, any>> = Def extends MutationDefinition<infer T, infer I, infer R> ? MutationIdentifier<T, I, R> & Readonly<{
|
|
612
|
+
key: K;
|
|
613
|
+
}> : never;
|
|
614
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
615
|
+
type NestedValue<Path extends string, Value> = Path extends `${infer Head}.${infer Tail}` ? { [K in Head]: NestedValue<Tail, Value>; } : { [K in Path]: Value; };
|
|
773
616
|
/**
|
|
774
|
-
*
|
|
775
|
-
* data fetching.
|
|
776
|
-
*/
|
|
777
|
-
declare class FateClient<Roots extends FateRoots, Mutations extends FateMutations, HydrationScope extends string = string> {
|
|
778
|
-
private readonly mutationMap;
|
|
779
|
-
private readonly parentLists;
|
|
780
|
-
private readonly rootLists;
|
|
781
|
-
private readonly pending;
|
|
782
|
-
private readonly pendingDeferred;
|
|
783
|
-
private readonly pendingOptimisticMutations;
|
|
784
|
-
private readonly optimisticMasks;
|
|
785
|
-
private readonly optimisticByEntity;
|
|
786
|
-
private readonly optimisticEntityResolutions;
|
|
787
|
-
private optimisticTokenCounter;
|
|
788
|
-
private readonly onLiveError;
|
|
789
|
-
private readonly liveSubscriptions;
|
|
790
|
-
private readonly liveConnectionInvalidations;
|
|
791
|
-
private readonly stableRefs;
|
|
792
|
-
private readonly requests;
|
|
793
|
-
private readonly rootRequests;
|
|
794
|
-
private readonly stalledRequests;
|
|
795
|
-
private gcPending;
|
|
796
|
-
private gcScheduled;
|
|
797
|
-
private pendingNetworkRequests;
|
|
798
|
-
readonly store: Store;
|
|
799
|
-
private readonly operationLifetime;
|
|
800
|
-
private readonly hydrationLimits;
|
|
801
|
-
private readonly hydrationScope;
|
|
802
|
-
private readonly types;
|
|
803
|
-
private readonly transport;
|
|
804
|
-
private readonly viewDataCache;
|
|
805
|
-
private liveConnectionInvalidationToken;
|
|
806
|
-
readonly actions: MutationActionsFor<Mutations>;
|
|
807
|
-
readonly mutations: MutationFunctionsFor<Mutations>;
|
|
808
|
-
readonly roots: Roots;
|
|
809
|
-
constructor(options: FateClientOptions<Roots, Mutations, HydrationScope>);
|
|
810
|
-
private initializeParentLists;
|
|
811
|
-
/**
|
|
812
|
-
* Exports the durable normalized cache as an opaque JSON-safe value for SSR
|
|
813
|
-
* transfer or persistence. Runtime requests, subscriptions, retainers, and
|
|
814
|
-
* optimistic state are intentionally excluded.
|
|
815
|
-
*/
|
|
816
|
-
dehydrate(): FateDehydratedState<HydrationScope>;
|
|
817
|
-
/**
|
|
818
|
-
* Restores a durable normalized cache snapshot without restoring runtime
|
|
819
|
-
* request handles, retainers, subscriptions, or optimistic update state.
|
|
820
|
-
* Hydrate before rendering SSR content. Replaying the same snapshot is safe.
|
|
821
|
-
*/
|
|
822
|
-
hydrate(state: FateDehydratedState<HydrationScope>, options?: HydrateOptions): void;
|
|
823
|
-
private registerRootList;
|
|
824
|
-
private snapshotList;
|
|
825
|
-
private applyListInsert;
|
|
826
|
-
private insertIntoRootLists;
|
|
827
|
-
getTypeConfig(type: string): TypeConfig;
|
|
828
|
-
private getListNodeType;
|
|
829
|
-
executeMutation(key: string, input: unknown, select: Set<string>, options?: {
|
|
830
|
-
args?: AnyRecord;
|
|
831
|
-
plan?: SelectionPlan;
|
|
832
|
-
}): Promise<unknown>;
|
|
833
|
-
write(type: string, data: AnyRecord, select: ReadonlySet<string>, snapshots?: Map<EntityId, Snapshot>, plan?: SelectionPlan, pathPrefix?: string | null, blockedMask?: FieldMask | null, insert?: InsertPosition, listSnapshots?: Map<string, List>): string;
|
|
834
|
-
deleteRecord(type: string, id: string | number, snapshots?: Map<EntityId, Snapshot>, listSnapshots?: Map<string, List>): void;
|
|
835
|
-
restore(id: EntityId, snapshot: Snapshot): void;
|
|
836
|
-
restoreList(name: string, list?: List): void;
|
|
837
|
-
private stableRefWithViewNames;
|
|
838
|
-
ref<T extends Entity>(type: T['__typename'], id: string | number, view: View<T, Selection<T>>): ViewRef<T['__typename']>;
|
|
839
|
-
rootListRef(entityId: EntityId, rootView: View<any, any>): Readonly<{
|
|
840
|
-
__typename: string;
|
|
841
|
-
id: string | number;
|
|
842
|
-
[ViewsTag]: Set<string>;
|
|
843
|
-
}>;
|
|
844
|
-
readView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>>;
|
|
845
|
-
readDeferred<T>(deferred: Deferred<T>): PromiseLike<DeferredSnapshot<T>>;
|
|
846
|
-
assertLiveViewSupport(): void;
|
|
847
|
-
assertLiveConnectionSupport(): void;
|
|
848
|
-
subscribeLiveView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): () => void;
|
|
849
|
-
subscribeLiveListView<V extends View<any, any>>(view: V, connection: ConnectionMetadata): () => void;
|
|
850
|
-
private applyLiveConnectionEvent;
|
|
851
|
-
private invalidateLiveConnection;
|
|
852
|
-
private deleteConnectionEdge;
|
|
853
|
-
private insertConnectionEdge;
|
|
854
|
-
private syncNestedConnectionOwnerField;
|
|
855
|
-
private getConnectionInsertIndex;
|
|
856
|
-
private removeEntityFromListState;
|
|
857
|
-
private mergeListState;
|
|
858
|
-
registerPendingOptimisticMutation(entityId: EntityId, promise: Promise<unknown>): void;
|
|
859
|
-
resolveOptimisticEntity(optimisticEntityId: EntityId, resolvedEntityId: EntityId): void;
|
|
860
|
-
registerOptimisticUpdate(entityId: EntityId | null, select: ReadonlySet<string>): number | null;
|
|
861
|
-
clearOptimisticUpdate(token: number | null): void;
|
|
862
|
-
getPendingOptimisticMask(entityId: EntityId | null, options?: {
|
|
863
|
-
excludeToken?: number | null;
|
|
864
|
-
}): FieldMask | null;
|
|
865
|
-
private getPendingOptimisticMutations;
|
|
866
|
-
filterSelectionForPendingOptimistics(entityId: EntityId | null, select: Set<string>, options?: {
|
|
867
|
-
excludeToken?: number | null;
|
|
868
|
-
}): Set<string>;
|
|
869
|
-
loadConnection<V extends View<any, any>>(view: V, connection: ConnectionMetadata, args: Record<string, unknown>, options?: {
|
|
870
|
-
direction?: 'forward' | 'backward';
|
|
871
|
-
}): Promise<Readonly<{
|
|
872
|
-
backwardPageLimit?: number;
|
|
873
|
-
cursors?: ReadonlyArray<string | undefined>;
|
|
874
|
-
forwardPageLimit?: number;
|
|
875
|
-
ids: ReadonlyArray<EntityId>;
|
|
876
|
-
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
877
|
-
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
878
|
-
pagination?: Pagination;
|
|
879
|
-
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
880
|
-
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
881
|
-
}> | undefined>;
|
|
882
|
-
private loadConnectionInternal;
|
|
883
|
-
request<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
884
|
-
requestForRender<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
885
|
-
prepareRequestForRender<R extends Request$1>(request: R, options: RequestOptions | undefined): Readonly<{
|
|
886
|
-
promise: Promise<RequestResult<Roots, R>>;
|
|
887
|
-
requestKey: string;
|
|
888
|
-
}>;
|
|
889
|
-
private requestWithDescriptor;
|
|
890
|
-
releaseRequest(request: Request$1, mode: RequestMode): void;
|
|
891
|
-
releaseRequestKey(requestKey: string, mode: RequestMode): void;
|
|
892
|
-
retainRequestKey(requestKey: string, mode?: RequestMode): RetainHandle;
|
|
893
|
-
/**
|
|
894
|
-
* Keeps the records and lists reachable from a request alive until the
|
|
895
|
-
* returned handle is disposed.
|
|
896
|
-
*
|
|
897
|
-
* `useRequest` calls this automatically while the component is mounted.
|
|
898
|
-
* Use it directly for non-React request lifetimes, tests, or preloaded data
|
|
899
|
-
* that must survive manual garbage collection.
|
|
900
|
-
*/
|
|
901
|
-
retain(request: Request$1): RetainHandle;
|
|
902
|
-
private scheduleGarbageCollection;
|
|
903
|
-
/**
|
|
904
|
-
* Removes records and lists that are not reachable from retained requests or
|
|
905
|
-
* the release buffer.
|
|
906
|
-
*
|
|
907
|
-
* Garbage collection is scheduled automatically when retained requests are
|
|
908
|
-
* released. Calling this method manually is mainly useful in tests and custom
|
|
909
|
-
* memory-management flows.
|
|
910
|
-
*/
|
|
911
|
-
gc(): void;
|
|
912
|
-
private executeRequestHandle;
|
|
913
|
-
private markRecordReferences;
|
|
914
|
-
private hasActiveOptimisticUpdates;
|
|
915
|
-
private hasPendingRequests;
|
|
916
|
-
trackPendingRequest<T>(request: () => Promise<T>): Promise<T>;
|
|
917
|
-
private runPendingGarbageCollection;
|
|
918
|
-
private handleStoreAndNetworkRequest;
|
|
919
|
-
private getRootType;
|
|
920
|
-
private createRequestDescriptor;
|
|
921
|
-
getRequestKey(request: Request$1): string;
|
|
922
|
-
private hasRootListData;
|
|
923
|
-
private executeRequest;
|
|
924
|
-
private hasRequestData;
|
|
925
|
-
getRequestResult<R extends Request$1>(request: R): RequestResult<Roots, R>;
|
|
926
|
-
private getRequestResultFromDescriptor;
|
|
927
|
-
private fetchByIdAndNormalize;
|
|
928
|
-
private fetchQueryAndNormalize;
|
|
929
|
-
private fetchListAndNormalize;
|
|
930
|
-
private writeEntity;
|
|
931
|
-
private linkParentLists;
|
|
932
|
-
private readViewSelection;
|
|
933
|
-
private clearStalledRequestsForEntity;
|
|
934
|
-
private pendingPrefix;
|
|
935
|
-
private pendingKey;
|
|
936
|
-
private deferredPendingKey;
|
|
937
|
-
private deferredSelectionSignature;
|
|
938
|
-
private hasMissingDeferredList;
|
|
939
|
-
private liveSubscriptionKey;
|
|
940
|
-
private liveConnectionSubscriptionKey;
|
|
941
|
-
private releaseLiveSubscription;
|
|
942
|
-
private reportLiveError;
|
|
943
|
-
}
|
|
944
|
-
declare function createClient<T extends [FateRoots, FateMutations] = [Record<never, RootDefinition<any, any>>, Record<never, MutationDefinition<any, any, any>>], HydrationScope extends string = string>(options: FateClientOptions<T[0], T[1], HydrationScope>): FateClient<T[0], T[1], HydrationScope>;
|
|
945
|
-
//#endregion
|
|
946
|
-
//#region src/mutation.d.ts
|
|
947
|
-
/**
|
|
948
|
-
* Defines a mutation for a given entity type, preserving the input and output
|
|
949
|
-
* types for transports.
|
|
950
|
-
*/
|
|
951
|
-
declare function mutation<T extends Entity, I, R>(entity: T['__typename']): MutationDefinition<T, I, R>;
|
|
952
|
-
/** Where (or if) to insert the resulting record into relevant lists. */
|
|
953
|
-
type InsertPosition = 'after' | 'before' | 'none';
|
|
954
|
-
/**
|
|
955
|
-
* Options accepted by a mutation invocation, including optimistic updates and
|
|
956
|
-
* optional selection for the returned payload.
|
|
957
|
-
*/
|
|
958
|
-
type MutationOptions<Identifier extends MutationIdentifier<any, any, any>> = {
|
|
959
|
-
/** Optional arguments to pass to the mutation resolver. */args?: Record<string, unknown>; /** If true, deletes the record with the ID specified in the input. */
|
|
960
|
-
delete?: boolean; /** Input data for the mutation. */
|
|
961
|
-
input: Omit<MutationInput<Identifier>, 'select'>;
|
|
962
|
-
insert?: InsertPosition; /** Optional optimistic update to apply immediately. */
|
|
963
|
-
optimistic?: OptimisticUpdate<MutationResult<Identifier>>; /** Optional view specifying which fields to select from the server. */
|
|
964
|
-
view?: View<MutationEntity<Identifier>, Selection<MutationEntity<Identifier>>>;
|
|
965
|
-
};
|
|
966
|
-
/**
|
|
967
|
-
* Callable mutation entry point returned on the client that resolves to either
|
|
968
|
-
* a successful result or an error.
|
|
969
|
-
*/
|
|
970
|
-
type MutationFunction<I extends MutationIdentifier<any, any, any>> = (options: MutationOptions<I>) => Promise<{
|
|
971
|
-
error: undefined;
|
|
972
|
-
result: MutationResult<I>;
|
|
973
|
-
} | {
|
|
974
|
-
error: Error;
|
|
975
|
-
result: undefined;
|
|
976
|
-
}>;
|
|
977
|
-
/**
|
|
978
|
-
* React action-compatible wrapper that can be passed directly to form actions
|
|
979
|
-
* or transitions.
|
|
980
|
-
*/
|
|
981
|
-
type MutationAction<I extends MutationIdentifier<any, any, any>> = (previousState: unknown,
|
|
982
|
-
/**
|
|
983
|
-
* Mutation options or 'reset' to reset the action state.
|
|
984
|
-
*/
|
|
985
|
-
|
|
986
|
-
options: MutationOptions<I> | 'reset') => Promise<{
|
|
987
|
-
error: undefined;
|
|
988
|
-
result: MutationResult<I>;
|
|
989
|
-
} | {
|
|
990
|
-
error: Error;
|
|
991
|
-
result: undefined;
|
|
992
|
-
}>;
|
|
993
|
-
type MutationIdentifierFor<K extends string, Def extends MutationDefinition<any, any, any>> = Def extends MutationDefinition<infer T, infer I, infer R> ? MutationIdentifier<T, I, R> & Readonly<{
|
|
994
|
-
key: K;
|
|
995
|
-
}> : never;
|
|
996
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
997
|
-
type NestedValue<Path extends string, Value> = Path extends `${infer Head}.${infer Tail}` ? { [K in Head]: NestedValue<Tail, Value> } : { [K in Path]: Value };
|
|
998
|
-
/**
|
|
999
|
-
* Base type for client mutations.
|
|
617
|
+
* Base type for client mutations.
|
|
1000
618
|
*/
|
|
1001
619
|
type FateMutations = Record<string, MutationDefinition<any, any, any>>;
|
|
1002
|
-
type MutationTreeFromRecord<Mutations extends FateMutations, ValueMap extends Record<string, unknown>> = [keyof Mutations] extends [never] ? object : UnionToIntersection<{ [K in keyof Mutations & string]: NestedValue<K, ValueMap[K]
|
|
1003
|
-
type MutationFunctionsFor<Mutations extends FateMutations> = MutationTreeFromRecord<Mutations, { [K in keyof Mutations & string]: MutationFunction<MutationIdentifierFor<K, Mutations[K]
|
|
1004
|
-
type MutationActionsFor<Mutations extends FateMutations> = MutationTreeFromRecord<Mutations, { [K in keyof Mutations & string]: MutationAction<MutationIdentifierFor<K, Mutations[K]
|
|
620
|
+
type MutationTreeFromRecord<Mutations extends FateMutations, ValueMap extends Record<string, unknown>> = [keyof Mutations] extends [never] ? object : UnionToIntersection<{ [K in keyof Mutations & string]: NestedValue<K, ValueMap[K]>; }[keyof Mutations & string]>;
|
|
621
|
+
type MutationFunctionsFor<Mutations extends FateMutations> = MutationTreeFromRecord<Mutations, { [K in keyof Mutations & string]: MutationFunction<MutationIdentifierFor<K, Mutations[K]>>; }>;
|
|
622
|
+
type MutationActionsFor<Mutations extends FateMutations> = MutationTreeFromRecord<Mutations, { [K in keyof Mutations & string]: MutationAction<MutationIdentifierFor<K, Mutations[K]>>; }>;
|
|
623
|
+
/** @internal Serializable input to a live or restored mutation. */
|
|
624
|
+
type MutationCommand = {
|
|
625
|
+
args?: AnyRecord;
|
|
626
|
+
delete?: boolean;
|
|
627
|
+
entity: string;
|
|
628
|
+
input: AnyRecord;
|
|
629
|
+
insert: InsertPosition;
|
|
630
|
+
key: string;
|
|
631
|
+
optimistic?: AnyRecord;
|
|
632
|
+
plan?: SelectionPlan;
|
|
633
|
+
};
|
|
1005
634
|
//#endregion
|
|
1006
635
|
//#region src/types.d.ts
|
|
1007
636
|
/** Canonical runtime name for an entity type as returned by the server. */
|
|
@@ -1086,9 +715,15 @@ type ViewRef<TName extends string> = Readonly<{
|
|
|
1086
715
|
[ViewsTag]: Set<string>;
|
|
1087
716
|
}>;
|
|
1088
717
|
/** Describes how a field relates to another entity for normalization. */
|
|
1089
|
-
type RelationDescriptor =
|
|
718
|
+
type RelationDescriptor =
|
|
719
|
+
/** Field stores a scalar value that does not link to another type. */
|
|
720
|
+
'scalar' |
|
|
721
|
+
/** Field points to a single entity of the given type. */
|
|
722
|
+
{
|
|
1090
723
|
type: string;
|
|
1091
|
-
}
|
|
724
|
+
} |
|
|
725
|
+
/** Field holds a list of entities of the given type. */
|
|
726
|
+
{
|
|
1092
727
|
listOf: string;
|
|
1093
728
|
};
|
|
1094
729
|
/** Configuration for a server entity type used by the client cache. */
|
|
@@ -1135,7 +770,7 @@ type Entity = {
|
|
|
1135
770
|
__typename: string;
|
|
1136
771
|
};
|
|
1137
772
|
type PlainObjectSelectionField<V> = V extends Array<infer U> ? PlainObjectSelectionField<U> | true : V extends AnyRecord ? PlainObjectSelection<V> | true : true;
|
|
1138
|
-
type PlainObjectSelection<T> = { [K in keyof T]?: PlainObjectSelectionField<T[K]
|
|
773
|
+
type PlainObjectSelection<T> = { [K in keyof T]?: PlainObjectSelectionField<T[K]>; };
|
|
1139
774
|
type ConnectionSelectionBase<T extends Entity> = Readonly<{
|
|
1140
775
|
items: Readonly<{
|
|
1141
776
|
cursor?: true;
|
|
@@ -1154,13 +789,13 @@ type ConnectionSelection<T extends Entity> = ConnectionSelectionBase<T> | (Selec
|
|
|
1154
789
|
type BaseSelectionFieldValue<T extends Entity, K extends keyof T> = NonNullable<T[K]> extends Array<infer U extends Entity> ? true | Selection<U> | ConnectionSelection<U> | View<U, Selection<U>> : NonNullable<T[K]> extends Entity ? true | Selection<NonNullable<T[K]>> | View<NonNullable<T[K]>, Selection<NonNullable<T[K]>>> : NonNullable<T[K]> extends AnyRecord ? PlainObjectSelection<NonNullable<T[K]>> : true;
|
|
1155
790
|
type SelectionFieldValue<T extends Entity, K extends keyof T> = BaseSelectionFieldValue<T, K> | SelectionArgs | (SelectionArgs & Extract<BaseSelectionFieldValue<T, K>, object>);
|
|
1156
791
|
type DeferrableSelectionFieldValue<T extends Entity, K extends keyof T> = SelectionFieldValue<T, K> | DeferredSelection<SelectionFieldValue<T, K>>;
|
|
1157
|
-
type SelectionShape<T extends Entity> = { [K in keyof T as K extends '__typename' ? never : K]?: DeferrableSelectionFieldValue<T, K
|
|
792
|
+
type SelectionShape<T extends Entity> = { [K in keyof T as K extends '__typename' ? never : K]?: DeferrableSelectionFieldValue<T, K>; } & {
|
|
1158
793
|
__typename?: true;
|
|
1159
794
|
};
|
|
1160
795
|
type SelectionViewSpread<T extends Entity> = { readonly [K in ViewTag]?: Readonly<{
|
|
1161
796
|
select: Selection<T>;
|
|
1162
797
|
[ViewKind]: true;
|
|
1163
|
-
}
|
|
798
|
+
}>; };
|
|
1164
799
|
/** Declarative selection of the fields a view needs from an entity. */
|
|
1165
800
|
type Selection<T extends Entity> = SelectionShape<T> & SelectionViewSpread<T>;
|
|
1166
801
|
/** View payload stored on a view tag containing the raw selection used to mask data. */
|
|
@@ -1172,7 +807,7 @@ type ViewPayload<T extends Entity, S extends Selection<T> = Selection<T>> = Read
|
|
|
1172
807
|
type View<T extends Entity, S extends Selection<T> = Selection<T>> = Readonly<{
|
|
1173
808
|
[viewTag: ViewTag]: ViewPayload<T, S>;
|
|
1174
809
|
}> & __ViewEntityAnchor<T> & __ViewSelectionAnchor<S>;
|
|
1175
|
-
type HasViewTag<S> = S extends { [K in ViewTag]?: infer P } ? P extends {
|
|
810
|
+
type HasViewTag<S> = S extends { [K in ViewTag]?: infer P; } ? P extends {
|
|
1176
811
|
[ViewKind]: true;
|
|
1177
812
|
} ? true : false : false;
|
|
1178
813
|
/**
|
|
@@ -1210,13 +845,13 @@ type ConnectionMask<T extends Entity, S> = S extends {
|
|
|
1210
845
|
node: ViewRef<T['__typename']>;
|
|
1211
846
|
}>;
|
|
1212
847
|
} & (PaginationSelection extends object ? {
|
|
1213
|
-
pagination: { [K in keyof PaginationSelection]: Pagination[K & keyof Pagination] };
|
|
848
|
+
pagination: { [K in keyof PaginationSelection]: Pagination[K & keyof Pagination]; };
|
|
1214
849
|
} : Record<string, never>) : Array<T>;
|
|
1215
850
|
type EntityName<T> = T extends {
|
|
1216
851
|
__typename: infer N extends string;
|
|
1217
852
|
} ? N : never;
|
|
1218
853
|
/** Recursively applies a view selection to an entity to mask fields that aren't selected. */
|
|
1219
|
-
type MaskNonNullish<T, S> = T extends Array<infer U extends Entity> ? S extends true ? Array<U> : S extends ConnectionLikeSelection ? ConnectionMask<U, S> : HasViewTag<S> extends true ? Array<ViewRef<U['__typename']>> : Array<Mask<U, S>> : S extends true ? T : S extends object ? HasViewTag<S> extends true ? NonNullish<T> extends Entity ? ViewRef<EntityName<NonNullish<T>>> : ViewRef<EntityName<NonNullable<T>>> : { [K in keyof S as K extends 'args' ? never : K]: S[K] extends true ? NonNullish<T>[Extract<K, keyof T>] : S[K] extends DeferredSelection<infer DeferredSelectionValue> ? Deferred<Mask<NonNullish<T>[Extract<K, keyof T>], DeferredSelectionValue>> : Mask<NonNullish<T>[Extract<K, keyof T>], Extract<S[K], object
|
|
854
|
+
type MaskNonNullish<T, S> = T extends Array<infer U extends Entity> ? S extends true ? Array<U> : S extends ConnectionLikeSelection ? ConnectionMask<U, S> : HasViewTag<S> extends true ? Array<ViewRef<U['__typename']>> : Array<Mask<U, S>> : S extends true ? T : S extends object ? HasViewTag<S> extends true ? NonNullish<T> extends Entity ? ViewRef<EntityName<NonNullish<T>>> : ViewRef<EntityName<NonNullable<T>>> : { [K in keyof S as K extends 'args' ? never : K]: S[K] extends true ? NonNullish<T>[Extract<K, keyof T>] : S[K] extends DeferredSelection<infer DeferredSelectionValue> ? Deferred<Mask<NonNullish<T>[Extract<K, keyof T>], DeferredSelectionValue>> : Mask<NonNullish<T>[Extract<K, keyof T>], Extract<S[K], object>>; } & (T extends Entity ? Pick<NonNullish<T>, '__typename'> : Record<never, never>) : T;
|
|
1220
855
|
type Mask<T, S> = WithNullish<T, MaskNonNullish<NonNullish<T>, S>>;
|
|
1221
856
|
/** Entity type captured from a view definition. */
|
|
1222
857
|
type ViewEntity<V> = V extends View<infer T, any> ? T : never;
|
|
@@ -1280,7 +915,7 @@ type ListResult<Item extends AnyRequestItem, Type extends TypeName, Result> = It
|
|
|
1280
915
|
* The result of a `FateClient.request` and `useRequest` call, mapping each
|
|
1281
916
|
* request key to its corresponding result.
|
|
1282
917
|
*/
|
|
1283
|
-
type RequestResult<R extends FateRoots, Q extends AnyRequest> = { [K in keyof Q]: K extends keyof R ? ListResult<Q[K], RootType<R[K]>, RootResult<R[K]>> : never };
|
|
918
|
+
type RequestResult<R extends FateRoots, Q extends AnyRequest> = { [K in keyof Q]: K extends keyof R ? ListResult<Q[K], RootType<R[K]>, RootResult<R[K]>> : never; };
|
|
1284
919
|
/** Brand used on root definitions to mark their identity in the d.ts output. */
|
|
1285
920
|
declare const RootKind = "__fate__root";
|
|
1286
921
|
/** Brand used on mutation definitions to mark their identity in the d.ts output. */
|
|
@@ -1322,78 +957,603 @@ type MutationShape = {
|
|
|
1322
957
|
type MutationMapFromDefinitions<D extends FateMutations> = { [K in keyof D]: {
|
|
1323
958
|
input: MutationInput<D[K]>;
|
|
1324
959
|
output: MutationResult<D[K]>;
|
|
1325
|
-
} };
|
|
960
|
+
}; };
|
|
1326
961
|
type OptimisticUpdateValue<T> = T extends ReadonlyArray<infer U> ? Array<OptimisticUpdateValue<U>> : NonNullish<T> extends AnyRecord ? OptimisticUpdate<NonNullish<T>> | Nullish<T> : NonNullish<T> | Nullish<T>;
|
|
1327
962
|
/** Shape used to describe optimistic updates for mutations. */
|
|
1328
|
-
type OptimisticUpdate<T> = { [K in keyof T]?: OptimisticUpdateValue<T[K]
|
|
1329
|
-
/** Snapshot captured before mutating the cache, used to roll back on errors. */
|
|
1330
|
-
type Snapshot = Readonly<{
|
|
1331
|
-
mask?: FieldMask;
|
|
1332
|
-
record?: AnyRecord;
|
|
1333
|
-
}>;
|
|
963
|
+
type OptimisticUpdate<T> = { [K in keyof T]?: OptimisticUpdateValue<T[K]>; };
|
|
1334
964
|
/** Promise-like value returned by cache reads that already have a resolved payload for React `use`. */
|
|
1335
965
|
interface FateThenable<T> extends PromiseLike<T> {
|
|
1336
966
|
status: 'fulfilled';
|
|
1337
967
|
value: T;
|
|
1338
968
|
}
|
|
1339
969
|
//#endregion
|
|
1340
|
-
//#region src/
|
|
970
|
+
//#region src/selection.d.ts
|
|
1341
971
|
/**
|
|
1342
|
-
*
|
|
972
|
+
* Representation of a composed selection including hashed args and the
|
|
973
|
+
* flat set of field paths to read or fetch.
|
|
1343
974
|
*/
|
|
1344
|
-
type
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
cursor?: string;
|
|
1353
|
-
node?: unknown;
|
|
1354
|
-
}>;
|
|
1355
|
-
pagination: Pagination;
|
|
975
|
+
type SelectionPlan = {
|
|
976
|
+
readonly args: Map<string, Readonly<{
|
|
977
|
+
hash: string;
|
|
978
|
+
ignoreKeys?: ReadonlySet<string>;
|
|
979
|
+
value: AnyRecord;
|
|
980
|
+
}>>;
|
|
981
|
+
readonly live: Map<string, ConnectionLivePolicy>;
|
|
982
|
+
readonly paths: Set<string>;
|
|
1356
983
|
};
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
984
|
+
/**
|
|
985
|
+
* Flattens a view into a `SelectionPlan`, expanding composed views and
|
|
986
|
+
* partitioning nested args so the client can fetch exactly what is declared.
|
|
987
|
+
*/
|
|
988
|
+
declare const getSelectionPlan: <T extends Entity, S extends Selection<T>, V extends View<T, S>>(viewComposition: V, ref: ViewRef<T['__typename']> | null) => SelectionPlan;
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/request-descriptor.d.ts
|
|
991
|
+
type NodeRequestDescriptor = Readonly<{
|
|
992
|
+
ids: ReadonlyArray<string | number>;
|
|
993
|
+
kind: 'node' | 'nodes';
|
|
994
|
+
name: string;
|
|
995
|
+
plan: SelectionPlan;
|
|
996
|
+
refViewNames: ReadonlySet<string>;
|
|
997
|
+
type: string;
|
|
998
|
+
viewSignature: string;
|
|
1361
999
|
}>;
|
|
1362
|
-
type
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
type:
|
|
1370
|
-
|
|
1371
|
-
id: string | number;
|
|
1372
|
-
nodeType: string;
|
|
1373
|
-
type: 'deleteEdge';
|
|
1374
|
-
}> | Readonly<{
|
|
1375
|
-
type: 'invalidate';
|
|
1000
|
+
type QueryRequestDescriptor = Readonly<{
|
|
1001
|
+
argsPayload: ResolvedArgsPayload | undefined;
|
|
1002
|
+
kind: 'query';
|
|
1003
|
+
name: string;
|
|
1004
|
+
plan: SelectionPlan;
|
|
1005
|
+
queryKey: string;
|
|
1006
|
+
refViewNames: ReadonlySet<string>;
|
|
1007
|
+
type: string;
|
|
1008
|
+
viewSignature: string;
|
|
1376
1009
|
}>;
|
|
1377
|
-
type
|
|
1378
|
-
|
|
1379
|
-
|
|
1010
|
+
type ListRequestDescriptor = Readonly<{
|
|
1011
|
+
argsPayload: ResolvedArgsPayload | undefined;
|
|
1012
|
+
hasItems: boolean;
|
|
1013
|
+
kind: 'list';
|
|
1014
|
+
listKey: string;
|
|
1015
|
+
name: string;
|
|
1016
|
+
nodeRefViewNames: ReadonlySet<string>;
|
|
1017
|
+
plan: SelectionPlan;
|
|
1018
|
+
type: string;
|
|
1019
|
+
viewSignature: string;
|
|
1380
1020
|
}>;
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1021
|
+
type RequestItemDescriptor = NodeRequestDescriptor | QueryRequestDescriptor | ListRequestDescriptor;
|
|
1022
|
+
type RequestDescriptor = Readonly<{
|
|
1023
|
+
items: ReadonlyArray<RequestItemDescriptor>;
|
|
1024
|
+
key: string;
|
|
1025
|
+
}>;
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region src/cache.d.ts
|
|
1028
|
+
declare class ViewDataCache {
|
|
1029
|
+
private readonly isEnabled;
|
|
1030
|
+
constructor(isEnabled?: () => boolean);
|
|
1031
|
+
private cache;
|
|
1032
|
+
private rootDependencies;
|
|
1033
|
+
private dependencyIndex;
|
|
1034
|
+
clear(): void;
|
|
1035
|
+
get<T extends Entity, S extends Selection<T>, V extends View<T, S>>(entityId: EntityId, view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>> | null;
|
|
1036
|
+
set<T extends Entity, S extends Selection<T>, V extends View<T, S>>(entityId: EntityId, view: V, ref: ViewRef<T['__typename']>, thenable: FateThenable<ViewSnapshot<T, S>>, dependencies: ReadonlySet<EntityId>): void;
|
|
1037
|
+
invalidate(entityId: EntityId): void;
|
|
1038
|
+
private invalidateDependents;
|
|
1039
|
+
private delete;
|
|
1040
|
+
}
|
|
1041
|
+
//#endregion
|
|
1042
|
+
//#region src/store.d.ts
|
|
1043
|
+
type List = Readonly<{
|
|
1044
|
+
backwardPageLimit?: number;
|
|
1045
|
+
cursors?: ReadonlyArray<string | undefined>;
|
|
1046
|
+
forwardPageLimit?: number;
|
|
1047
|
+
ids: ReadonlyArray<EntityId>;
|
|
1048
|
+
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
1049
|
+
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
1050
|
+
pagination?: Pagination;
|
|
1051
|
+
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
1052
|
+
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
1053
|
+
}>;
|
|
1054
|
+
type StoreHydrationState = Readonly<{
|
|
1055
|
+
coverage: ReadonlyArray<readonly [EntityId, ReadonlyArray<string>]>;
|
|
1056
|
+
lists: ReadonlyArray<readonly [string, List]>;
|
|
1057
|
+
records: ReadonlyArray<readonly [EntityId, AnyRecord]>;
|
|
1058
|
+
}>;
|
|
1059
|
+
declare class Store {
|
|
1060
|
+
private readonly onRebase?;
|
|
1061
|
+
private readonly onChange?;
|
|
1062
|
+
private coverage;
|
|
1063
|
+
private listKeysByOwnerField;
|
|
1064
|
+
private listKeysByReferencedEntity;
|
|
1065
|
+
private lists;
|
|
1066
|
+
private recordReferenceFields;
|
|
1067
|
+
private recordReferencesByTarget;
|
|
1068
|
+
private records;
|
|
1069
|
+
private subscriptions;
|
|
1070
|
+
private listSubscriptions;
|
|
1071
|
+
private readonly optimisticLayers;
|
|
1072
|
+
private readonly optimisticBase;
|
|
1073
|
+
private recordingLayer;
|
|
1074
|
+
private rebase;
|
|
1075
|
+
constructor(onRebase?: ((ids: ReadonlySet<EntityId>) => void) | undefined, onChange?: ((kind: 'record' | 'list', key: string, paths?: Iterable<string>, previousList?: List) => void) | undefined);
|
|
1076
|
+
get hasOptimisticUpdates(): boolean;
|
|
1077
|
+
get isRebasing(): boolean;
|
|
1078
|
+
/** Apply a synchronous cache update beneath the pending optimistic layers. */
|
|
1079
|
+
update<T>(apply: () => T): T;
|
|
1080
|
+
private getRebaseChanges;
|
|
1081
|
+
/** Returns an idempotent settlement function; omit its update to roll back. */
|
|
1082
|
+
optimisticUpdate(apply: () => void, durable?: boolean): (commit?: () => void) => void;
|
|
1083
|
+
private getPendingOverlap;
|
|
1084
|
+
private captureRecord;
|
|
1085
|
+
private captureList;
|
|
1086
|
+
get hasTransientOptimisticUpdates(): boolean;
|
|
1087
|
+
getOptimisticRoots(): {
|
|
1088
|
+
baseRecords: AnyRecord[];
|
|
1089
|
+
lists: string[];
|
|
1090
|
+
records: string[];
|
|
1091
|
+
};
|
|
1092
|
+
/** @internal Indexed owners needed for mutation rollback. */
|
|
1093
|
+
getPersistenceOwners(id: EntityId): {
|
|
1094
|
+
lists: string[];
|
|
1095
|
+
records: string[];
|
|
1096
|
+
};
|
|
1097
|
+
/** @internal Read one confirmed record without copying the cache. */
|
|
1098
|
+
readConfirmed(id: EntityId): {
|
|
1099
|
+
paths: string[];
|
|
1100
|
+
record: AnyRecord;
|
|
1101
|
+
} | undefined;
|
|
1102
|
+
/** @internal */
|
|
1103
|
+
readConfirmedList(key: string): Readonly<{
|
|
1104
|
+
backwardPageLimit?: number;
|
|
1105
|
+
cursors?: ReadonlyArray<string | undefined>;
|
|
1106
|
+
forwardPageLimit?: number;
|
|
1107
|
+
ids: ReadonlyArray<EntityId>;
|
|
1108
|
+
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
1109
|
+
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
1110
|
+
pagination?: Pagination;
|
|
1111
|
+
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
1112
|
+
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
1113
|
+
}> | undefined;
|
|
1114
|
+
dehydrateConfirmed(): StoreHydrationState;
|
|
1115
|
+
dehydrate(): StoreHydrationState;
|
|
1116
|
+
hydrate(state: StoreHydrationState, mode: 'preserve-existing' | 'replace', options?: {
|
|
1117
|
+
deferNotifications?: boolean;
|
|
1118
|
+
}): () => void;
|
|
1119
|
+
private rebuildIndexes;
|
|
1120
|
+
read(id: EntityId): AnyRecord | undefined;
|
|
1121
|
+
merge(id: EntityId, partial: AnyRecord, paths: Iterable<string>): void;
|
|
1122
|
+
private mergeInternal;
|
|
1123
|
+
deleteRecord(id: EntityId): void;
|
|
1124
|
+
missingForSelection(id: EntityId, paths: Iterable<string>): Set<string>;
|
|
1125
|
+
subscribe(id: EntityId, selection: ReadonlySet<string> | null, fn: () => void): () => void;
|
|
1126
|
+
subscribe(id: EntityId, fn: () => void): () => void;
|
|
1127
|
+
private notify;
|
|
1128
|
+
private notifyListSubscribers;
|
|
1129
|
+
getList(key: string): ReadonlyArray<EntityId> | undefined;
|
|
1130
|
+
getListState(key: string): List | undefined;
|
|
1131
|
+
getListsForField(ownerId: EntityId, field: string): Array<readonly [string, List]>;
|
|
1132
|
+
setList(key: string, state: List): void;
|
|
1133
|
+
replaceListEntityId(previousId: EntityId, nextId: EntityId): void;
|
|
1134
|
+
restoreList(key: string, list?: List): void;
|
|
1135
|
+
collectGarbage(markedRecords: ReadonlySet<EntityId>, markedLists: ReadonlySet<string>, options?: {
|
|
1136
|
+
onRecordDeleted?: (id: EntityId) => void;
|
|
1137
|
+
}): {
|
|
1138
|
+
lists: Set<string>;
|
|
1139
|
+
records: Set<EntityId>;
|
|
1140
|
+
};
|
|
1141
|
+
private deleteList;
|
|
1142
|
+
subscribeList(key: string, fn: () => void): () => void;
|
|
1143
|
+
removeReferencesTo(targetId: EntityId, viewDataCache: ViewDataCache): void;
|
|
1144
|
+
private restore;
|
|
1145
|
+
private addListIndexes;
|
|
1146
|
+
private removeListIndexes;
|
|
1147
|
+
private getListReferencedEntityIds;
|
|
1148
|
+
private getRecordFieldReferences;
|
|
1149
|
+
private addRecordFieldReferenceIndex;
|
|
1150
|
+
private removeRecordFieldReferenceIndex;
|
|
1151
|
+
private addRecordReferenceIndexes;
|
|
1152
|
+
private removeRecordReferenceIndexes;
|
|
1153
|
+
private updateRecordReferenceIndexes;
|
|
1154
|
+
}
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region src/hydration.d.ts
|
|
1157
|
+
/** JSON-safe opaque value contained in a dehydrated fate snapshot. */
|
|
1158
|
+
type FateSerializedValue = null | boolean | number | string | ReadonlyArray<FateSerializedValue> | Readonly<{
|
|
1159
|
+
[key: string]: FateSerializedValue;
|
|
1160
|
+
}>;
|
|
1161
|
+
/** Versioned, JSON-safe durable cache snapshot produced by `FateClient.dehydrate()`. */
|
|
1162
|
+
declare const hydrationScopeBrand: unique symbol;
|
|
1163
|
+
type FateDehydratedState<Scope extends string = string> = Readonly<{
|
|
1164
|
+
data: FateSerializedValue;
|
|
1165
|
+
readonly [hydrationScopeBrand]?: Scope;
|
|
1166
|
+
scope: Scope;
|
|
1167
|
+
version: 1;
|
|
1168
|
+
}>;
|
|
1169
|
+
/** Controls how `FateClient.hydrate()` reconciles a snapshot with browser cache state. */
|
|
1170
|
+
type HydrateOptions = Readonly<{
|
|
1171
|
+
/**
|
|
1172
|
+
* `preserve-existing` keeps browser values and list windows when conflicts
|
|
1173
|
+
* occur. `replace` treats the snapshot as authoritative.
|
|
1174
|
+
*
|
|
1175
|
+
* @defaultValue 'preserve-existing'
|
|
1176
|
+
*/
|
|
1177
|
+
merge?: 'preserve-existing' | 'replace';
|
|
1178
|
+
}>;
|
|
1179
|
+
/** Resource limits applied while encoding and decoding hydration snapshots. */
|
|
1180
|
+
type HydrationLimits = Readonly<{
|
|
1181
|
+
/** Maximum number of entries in any encoded array or object. */
|
|
1182
|
+
maxCollectionLength: number;
|
|
1183
|
+
/** Maximum number of encoded values in a hydration snapshot. */
|
|
1184
|
+
maxNodes: number;
|
|
1185
|
+
/** Maximum length of an encoded string, object key, or bigint payload. */
|
|
1186
|
+
maxStringLength: number;
|
|
1187
|
+
}>;
|
|
1188
|
+
type ClientHydrationState = Readonly<{
|
|
1189
|
+
rootLists: ReadonlyArray<readonly [string, ReadonlyArray<string>]>;
|
|
1190
|
+
rootRequests: ReadonlyArray<readonly [string, string | null]>;
|
|
1191
|
+
store: StoreHydrationState;
|
|
1192
|
+
}>;
|
|
1193
|
+
declare const encodeHydrationValue: (value: unknown, limits?: Partial<HydrationLimits>) => FateSerializedValue;
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/operation-lifetime.d.ts
|
|
1196
|
+
type RetainHandle = Readonly<{
|
|
1197
|
+
dispose(): void;
|
|
1198
|
+
}>;
|
|
1199
|
+
//#endregion
|
|
1200
|
+
//#region src/client.d.ts
|
|
1201
|
+
/**
|
|
1202
|
+
* Strategy used when resolving a request.
|
|
1203
|
+
*/
|
|
1204
|
+
type RequestMode =
|
|
1205
|
+
/** (default) Use cached data if present, otherwise fetch. */
|
|
1206
|
+
'cache-first' |
|
|
1207
|
+
/** Show cached data immediately and refresh in the background. */
|
|
1208
|
+
'stale-while-revalidate' |
|
|
1209
|
+
/** Always fetch from the network and ignore cached entries. */
|
|
1210
|
+
'network-only';
|
|
1211
|
+
/**
|
|
1212
|
+
* Request options that affect how requests are fetched and retained.
|
|
1213
|
+
*/
|
|
1214
|
+
type RequestOptions = Readonly<{
|
|
1215
|
+
mode?: RequestMode;
|
|
1216
|
+
/** Override disk retention in milliseconds; only used with persistence. */
|
|
1217
|
+
persist?: {
|
|
1218
|
+
maxAge: number;
|
|
1219
|
+
};
|
|
1220
|
+
}>;
|
|
1221
|
+
type DeferredSnapshot<T> = Readonly<{
|
|
1222
|
+
coverage: ReadonlyArray<readonly [id: EntityId, paths: ReadonlySet<string>]>;
|
|
1223
|
+
data: T;
|
|
1224
|
+
}>;
|
|
1225
|
+
type FateClientOptions<Roots extends FateRoots, Mutations extends FateMutations, HydrationScope extends string> = {
|
|
1226
|
+
/**
|
|
1227
|
+
* Number of recently released requests to keep retained before their records
|
|
1228
|
+
* and lists are eligible for garbage collection.
|
|
1229
|
+
*
|
|
1230
|
+
* @defaultValue 10
|
|
1231
|
+
*/
|
|
1232
|
+
gcReleaseBufferSize?: number;
|
|
1233
|
+
/**
|
|
1234
|
+
* Bounds hydration snapshot encoding and decoding work.
|
|
1235
|
+
*/
|
|
1236
|
+
hydrationLimits?: Partial<HydrationLimits>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Identifies snapshots compatible with this client. Change this value when
|
|
1239
|
+
* deploying an incompatible cache schema or separating cache namespaces.
|
|
1240
|
+
*/
|
|
1241
|
+
hydrationScope?: HydrationScope;
|
|
1242
|
+
mutations?: Mutations;
|
|
1243
|
+
onLiveError?: (error: unknown) => void;
|
|
1244
|
+
persistence?: Persistence;
|
|
1245
|
+
roots: Roots;
|
|
1246
|
+
transport: Transport<MutationMapFromDefinitions<Mutations>>;
|
|
1247
|
+
types: ReadonlyArray<Omit<TypeConfig, 'getId'> & Partial<{
|
|
1248
|
+
getId: TypeConfig['getId'];
|
|
1249
|
+
}>>;
|
|
1250
|
+
};
|
|
1251
|
+
/**
|
|
1252
|
+
* Core client that normalizes records, manages the view cache, and coordinates
|
|
1253
|
+
* data fetching.
|
|
1254
|
+
*/
|
|
1255
|
+
declare class FateClient<Roots extends FateRoots, Mutations extends FateMutations, HydrationScope extends string = string> {
|
|
1256
|
+
private readonly mutationEntities?;
|
|
1257
|
+
private readonly mutationMap;
|
|
1258
|
+
private readonly parentLists;
|
|
1259
|
+
private readonly rootLists;
|
|
1260
|
+
private readonly pending;
|
|
1261
|
+
private readonly pendingDeferred;
|
|
1262
|
+
private readonly pendingOptimisticMutations;
|
|
1263
|
+
private readonly optimisticEntityResolutions;
|
|
1264
|
+
private readonly onLiveError;
|
|
1265
|
+
private readonly liveSubscriptions;
|
|
1266
|
+
private readonly liveConnectionInvalidations;
|
|
1267
|
+
private readonly stableRefs;
|
|
1268
|
+
private readonly requests;
|
|
1269
|
+
private readonly requestExecutionOptions;
|
|
1270
|
+
private readonly rootRequests;
|
|
1271
|
+
private readonly stalledRequests;
|
|
1272
|
+
private gcPending;
|
|
1273
|
+
private gcScheduled;
|
|
1274
|
+
private pendingNetworkRequests;
|
|
1275
|
+
private readonly persistenceDisposal?;
|
|
1276
|
+
readonly store: Store;
|
|
1277
|
+
private readonly operationLifetime;
|
|
1278
|
+
private readonly hydrationLimits;
|
|
1279
|
+
private readonly hydrationScope;
|
|
1280
|
+
private readonly types;
|
|
1281
|
+
private readonly transport;
|
|
1282
|
+
private readonly viewDataCache;
|
|
1283
|
+
private liveConnectionInvalidationToken;
|
|
1284
|
+
readonly persistence?: PersistenceSession;
|
|
1285
|
+
readonly actions: MutationActionsFor<Mutations>;
|
|
1286
|
+
readonly mutations: MutationFunctionsFor<Mutations>;
|
|
1287
|
+
readonly roots: Roots;
|
|
1288
|
+
constructor(options: FateClientOptions<Roots, Mutations, HydrationScope>);
|
|
1289
|
+
private initializeParentLists;
|
|
1290
|
+
/**
|
|
1291
|
+
* Exports the durable normalized cache as an opaque JSON-safe value for SSR
|
|
1292
|
+
* transfer or persistence. Runtime requests, subscriptions, retainers, and
|
|
1293
|
+
* optimistic state are intentionally excluded.
|
|
1294
|
+
*/
|
|
1295
|
+
dehydrate(): FateDehydratedState<HydrationScope>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Restores a durable normalized cache snapshot without restoring runtime
|
|
1298
|
+
* request handles, retainers, subscriptions, or optimistic update state.
|
|
1299
|
+
* Hydrate before rendering SSR content. Replaying the same snapshot is safe.
|
|
1300
|
+
*/
|
|
1301
|
+
hydrate(state: FateDehydratedState<HydrationScope>, options?: HydrateOptions): void;
|
|
1302
|
+
/** @internal */
|
|
1303
|
+
exportPersistenceState(): FateDehydratedState<HydrationScope>;
|
|
1304
|
+
/** @internal */
|
|
1305
|
+
retainPersistenceRequest(request: RequestDescriptor): Readonly<{
|
|
1306
|
+
dispose(): void;
|
|
1307
|
+
}>;
|
|
1308
|
+
/** @internal */
|
|
1309
|
+
getPersistenceScope(): HydrationScope;
|
|
1310
|
+
/** @internal */
|
|
1311
|
+
getPersistenceRootLists(type: string): Set<string>;
|
|
1312
|
+
/** @internal */
|
|
1313
|
+
getPersistenceQuery(key: string): string | null | undefined;
|
|
1314
|
+
/** @internal Merge a small disk read beneath optimistic layers. */
|
|
1315
|
+
restorePersistenceData(state: ClientHydrationState): void;
|
|
1316
|
+
/** @internal */
|
|
1317
|
+
getRetainedRequests(): readonly Readonly<{
|
|
1318
|
+
items: ReadonlyArray<RequestItemDescriptor>;
|
|
1319
|
+
key: string;
|
|
1320
|
+
}>[];
|
|
1321
|
+
/** @internal */
|
|
1322
|
+
restoreRetainedRequests(requests: ReadonlyArray<RequestDescriptor>): void;
|
|
1323
|
+
/** @internal */
|
|
1324
|
+
hasMutation(key: string, entity: string): boolean;
|
|
1325
|
+
private registerRootList;
|
|
1326
|
+
private applyListInsert;
|
|
1327
|
+
private insertIntoRootLists;
|
|
1328
|
+
getTypeConfig(type: string): TypeConfig;
|
|
1329
|
+
private getListNodeType;
|
|
1330
|
+
/** @internal Validates local wiring without requiring network connectivity. */
|
|
1331
|
+
validatePersistence(): void;
|
|
1332
|
+
/** @internal */
|
|
1333
|
+
assertPersistenceActive(): void;
|
|
1334
|
+
/** @internal */
|
|
1335
|
+
disposePersistence(): void;
|
|
1336
|
+
private requireDurableMutationTransport;
|
|
1337
|
+
executeMutation(key: string, input: unknown, select: Set<string>, options?: {
|
|
1338
|
+
args?: AnyRecord;
|
|
1339
|
+
identity?: MutationIdentity;
|
|
1340
|
+
plan?: SelectionPlan;
|
|
1341
|
+
}): Promise<unknown>;
|
|
1342
|
+
write(type: string, data: AnyRecord, select: ReadonlySet<string>, plan?: SelectionPlan, insert?: InsertPosition): string;
|
|
1343
|
+
deleteRecord(type: string, id: string | number): void;
|
|
1344
|
+
private stableRefWithViewNames;
|
|
1345
|
+
ref<T extends Entity>(type: T['__typename'], id: string | number, view: View<T, Selection<T>>): ViewRef<T['__typename']>;
|
|
1346
|
+
rootListRef(entityId: EntityId, rootView: View<any, any>): Readonly<{
|
|
1347
|
+
__typename: string;
|
|
1348
|
+
id: string | number;
|
|
1349
|
+
[ViewsTag]: Set<string>;
|
|
1350
|
+
}>;
|
|
1351
|
+
readView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>>;
|
|
1352
|
+
readDeferred<T>(deferred: Deferred<T>): PromiseLike<DeferredSnapshot<T>>;
|
|
1353
|
+
assertLiveViewSupport(): void;
|
|
1354
|
+
assertLiveConnectionSupport(): void;
|
|
1355
|
+
subscribeLiveView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): () => void;
|
|
1356
|
+
subscribeLiveListView<V extends View<any, any>>(view: V, connection: ConnectionMetadata): () => void;
|
|
1357
|
+
private applyLiveConnectionEvent;
|
|
1358
|
+
private invalidateLiveConnection;
|
|
1359
|
+
private deleteConnectionEdge;
|
|
1360
|
+
private insertConnectionEdge;
|
|
1361
|
+
private syncNestedConnectionOwnerField;
|
|
1362
|
+
private getConnectionInsertIndex;
|
|
1363
|
+
private removeEntityFromListState;
|
|
1364
|
+
private mergeListState;
|
|
1365
|
+
registerPendingOptimisticMutation(entityId: EntityId, promise: Promise<unknown>): void;
|
|
1366
|
+
resolveOptimisticEntity(optimisticEntityId: EntityId, resolvedEntityId: EntityId): void;
|
|
1367
|
+
private getPendingOptimisticMutations;
|
|
1368
|
+
loadConnection<V extends View<any, any>>(view: V, connection: ConnectionMetadata, args: Record<string, unknown>, options?: {
|
|
1369
|
+
direction?: 'forward' | 'backward';
|
|
1370
|
+
}): Promise<Readonly<{
|
|
1371
|
+
backwardPageLimit?: number;
|
|
1372
|
+
cursors?: ReadonlyArray<string | undefined>;
|
|
1373
|
+
forwardPageLimit?: number;
|
|
1374
|
+
ids: ReadonlyArray<EntityId>;
|
|
1375
|
+
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
1376
|
+
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
1377
|
+
pagination?: Pagination;
|
|
1378
|
+
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
1379
|
+
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
1380
|
+
}> | undefined>;
|
|
1381
|
+
private loadConnectionInternal;
|
|
1382
|
+
request<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
1383
|
+
requestForRender<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
1384
|
+
prepareRequestForRender<R extends Request$1>(request: R, options: RequestOptions | undefined): Readonly<{
|
|
1385
|
+
promise: Promise<RequestResult<Roots, R>>;
|
|
1386
|
+
requestKey: string;
|
|
1387
|
+
}>;
|
|
1388
|
+
private requestWithDescriptor;
|
|
1389
|
+
releaseRequest(request: Request$1, mode: RequestMode): void;
|
|
1390
|
+
releaseRequestKey(requestKey: string, mode: RequestMode): void;
|
|
1391
|
+
retainRequestKey(requestKey: string, mode?: RequestMode): RetainHandle;
|
|
1392
|
+
/**
|
|
1393
|
+
* Keeps the records and lists reachable from a request alive until the
|
|
1394
|
+
* returned handle is disposed.
|
|
1395
|
+
*
|
|
1396
|
+
* `useRequest` calls this automatically while the component is mounted.
|
|
1397
|
+
* Use it directly for non-React request lifetimes, tests, or preloaded data
|
|
1398
|
+
* that must survive manual garbage collection.
|
|
1399
|
+
*/
|
|
1400
|
+
retain(request: Request$1): RetainHandle;
|
|
1401
|
+
private scheduleGarbageCollection;
|
|
1402
|
+
/**
|
|
1403
|
+
* Removes records and lists that are not reachable from retained requests or
|
|
1404
|
+
* the release buffer.
|
|
1405
|
+
*
|
|
1406
|
+
* Garbage collection is scheduled automatically when retained requests are
|
|
1407
|
+
* released. Calling this method manually is mainly useful in tests and custom
|
|
1408
|
+
* memory-management flows.
|
|
1409
|
+
*/
|
|
1410
|
+
gc(): void;
|
|
1411
|
+
private executeRequestHandle;
|
|
1412
|
+
private markRecordReferences;
|
|
1413
|
+
private hasActiveOptimisticUpdates;
|
|
1414
|
+
private hasPendingRequests;
|
|
1415
|
+
/** @internal */
|
|
1416
|
+
withPersistenceLifecycle<T>(request: () => Promise<T>): Promise<T>;
|
|
1417
|
+
trackPendingRequest<T>(request: () => Promise<T>): Promise<T>;
|
|
1418
|
+
private runPendingGarbageCollection;
|
|
1419
|
+
private handleStoreAndNetworkRequest;
|
|
1420
|
+
private getRootType;
|
|
1421
|
+
private createRequestDescriptor;
|
|
1422
|
+
getRequestKey(request: Request$1): string;
|
|
1423
|
+
private hasRootListData;
|
|
1424
|
+
private executeRequest;
|
|
1425
|
+
private hasRequestData;
|
|
1426
|
+
getRequestResult<R extends Request$1>(request: R): RequestResult<Roots, R>;
|
|
1427
|
+
private getRequestResultFromDescriptor;
|
|
1428
|
+
private fetchByIdAndNormalize;
|
|
1429
|
+
private fetchQueryAndNormalize;
|
|
1430
|
+
private fetchListAndNormalize;
|
|
1431
|
+
private writeEntity;
|
|
1432
|
+
private linkParentLists;
|
|
1433
|
+
private readViewSelection;
|
|
1434
|
+
private clearStalledRequestsForEntity;
|
|
1435
|
+
private pendingPrefix;
|
|
1436
|
+
private pendingKey;
|
|
1437
|
+
private deferredPendingKey;
|
|
1438
|
+
private deferredSelectionSignature;
|
|
1439
|
+
private hasMissingDeferredList;
|
|
1440
|
+
private liveSubscriptionKey;
|
|
1441
|
+
private liveConnectionSubscriptionKey;
|
|
1442
|
+
private releaseLiveSubscription;
|
|
1443
|
+
private reportLiveError;
|
|
1444
|
+
}
|
|
1445
|
+
declare function createClient<T extends [FateRoots, FateMutations] = [Record<never, RootDefinition<any, any>>, Record<never, MutationDefinition<any, any, any>>], HydrationScope extends string = string>(options: FateClientOptions<T[0], T[1], HydrationScope>): FateClient<T[0], T[1], HydrationScope>;
|
|
1446
|
+
//#endregion
|
|
1447
|
+
//#region src/persistence-types.d.ts
|
|
1448
|
+
/** Identity of one logical mutation, reused across every delivery attempt. */
|
|
1449
|
+
type MutationIdentity = Readonly<{
|
|
1450
|
+
id: string;
|
|
1451
|
+
replayOnly?: true;
|
|
1452
|
+
/** Return an existing receipt; never execute a new mutation. */ scope: string;
|
|
1453
|
+
}>;
|
|
1454
|
+
/** A persistence integration. Implementations are imported separately from Fate core. */
|
|
1455
|
+
interface Persistence {
|
|
1456
|
+
attach(client: FateClient<any, any, any>): PersistenceSession;
|
|
1457
|
+
}
|
|
1458
|
+
type PersistedMutationStatus = Readonly<{
|
|
1459
|
+
error?: string;
|
|
1460
|
+
id: string;
|
|
1461
|
+
input: unknown;
|
|
1462
|
+
name: string;
|
|
1463
|
+
status: 'queued' | 'sending' | 'failed';
|
|
1464
|
+
}>;
|
|
1465
|
+
type PersistenceSnapshot = Readonly<{
|
|
1466
|
+
error?: Error;
|
|
1467
|
+
mutations: ReadonlyArray<PersistedMutationStatus>;
|
|
1468
|
+
status: 'restoring' | 'ready' | 'error' | 'disposed';
|
|
1469
|
+
}>;
|
|
1470
|
+
type RequestPersistenceOptions = Readonly<{
|
|
1471
|
+
maxAge: number;
|
|
1472
|
+
}>;
|
|
1473
|
+
/** Observability and lifecycle of an attached persistence integration. */
|
|
1474
|
+
interface PersistenceSession {
|
|
1475
|
+
/** @internal */
|
|
1476
|
+
changed(kind?: 'record' | 'list', key?: string, paths?: Iterable<string>, previousList?: List): void;
|
|
1477
|
+
clearCache(): Promise<void>;
|
|
1478
|
+
discard(id: string): Promise<void>;
|
|
1479
|
+
dispose(): void;
|
|
1480
|
+
/** @internal */
|
|
1481
|
+
fetched(request: RequestDescriptor, options?: RequestPersistenceOptions): void;
|
|
1482
|
+
flush(): Promise<void>;
|
|
1483
|
+
getSnapshot(): PersistenceSnapshot;
|
|
1484
|
+
/** @internal */
|
|
1485
|
+
mutate(command: MutationCommand): Promise<unknown>;
|
|
1486
|
+
readonly ready: Promise<void>;
|
|
1487
|
+
/** @internal */
|
|
1488
|
+
restoreRequest(request: RequestDescriptor): Promise<void>;
|
|
1489
|
+
retry(): void;
|
|
1490
|
+
subscribe(listener: () => void): () => void;
|
|
1491
|
+
/** @internal */
|
|
1492
|
+
used(request: RequestDescriptor, options?: RequestPersistenceOptions): void;
|
|
1493
|
+
}
|
|
1494
|
+
//#endregion
|
|
1495
|
+
//#region src/transport.d.ts
|
|
1496
|
+
/**
|
|
1497
|
+
* Normalized representation of args passed to a transport.
|
|
1498
|
+
*/
|
|
1499
|
+
type ResolvedArgsPayload = AnyRecord;
|
|
1500
|
+
type TransportMutations = Record<string, MutationShape>;
|
|
1501
|
+
type EmptyTransportMutations = Record<never, MutationShape>;
|
|
1502
|
+
type Bivariant<Fn extends (...args: Array<any>) => any> = {
|
|
1503
|
+
bivarianceHack: Fn;
|
|
1504
|
+
}['bivarianceHack'];
|
|
1505
|
+
type TRPCListResult = {
|
|
1506
|
+
items: Array<{
|
|
1507
|
+
cursor?: string;
|
|
1508
|
+
node?: unknown;
|
|
1509
|
+
}>;
|
|
1510
|
+
pagination: Pagination;
|
|
1511
|
+
};
|
|
1512
|
+
type LiveEventHandlers = Readonly<{
|
|
1513
|
+
onData: (record: unknown, select?: ReadonlyArray<string>) => void;
|
|
1514
|
+
onDelete?: (id?: string | number) => void;
|
|
1515
|
+
onError?: (error: unknown) => void;
|
|
1516
|
+
}>;
|
|
1517
|
+
type LiveConnectionEvent = Readonly<{
|
|
1518
|
+
edge: {
|
|
1519
|
+
cursor?: string;
|
|
1520
|
+
node: unknown;
|
|
1521
|
+
};
|
|
1522
|
+
nodeType: string;
|
|
1523
|
+
targetCursor?: string;
|
|
1524
|
+
type: 'appendEdge' | 'appendNode' | 'insertEdgeAfter' | 'insertEdgeBefore' | 'prependEdge' | 'prependNode';
|
|
1525
|
+
}> | Readonly<{
|
|
1526
|
+
id: string | number;
|
|
1527
|
+
nodeType: string;
|
|
1528
|
+
type: 'deleteEdge';
|
|
1529
|
+
}> | Readonly<{
|
|
1530
|
+
type: 'invalidate';
|
|
1531
|
+
}>;
|
|
1532
|
+
type LiveConnectionEventHandlers = Readonly<{
|
|
1533
|
+
onError?: (error: unknown) => void;
|
|
1534
|
+
onEvent: (event: LiveConnectionEvent) => void;
|
|
1535
|
+
}>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Contract the fate client expects from a network transport. The transport is
|
|
1538
|
+
* responsible for fetching records by ID, fetching lists, and executing
|
|
1539
|
+
* mutations with the provided selections.
|
|
1540
|
+
*/
|
|
1541
|
+
interface Transport<Mutations extends TransportMutations = EmptyTransportMutations> {
|
|
1542
|
+
fetchById(type: string, ids: Array<string | number>, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<Array<unknown>>;
|
|
1543
|
+
fetchList?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<{
|
|
1544
|
+
items: Array<{
|
|
1545
|
+
cursor: string | undefined;
|
|
1546
|
+
node: unknown;
|
|
1547
|
+
}>;
|
|
1548
|
+
pagination: Pagination;
|
|
1549
|
+
}>;
|
|
1550
|
+
fetchQuery?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<unknown>;
|
|
1551
|
+
mutate?<K extends Extract<keyof Mutations, string>>(proc: K, input: Mutations[K]['input'], select: Set<string>): Promise<Mutations[K]['output']>;
|
|
1552
|
+
/**
|
|
1553
|
+
* Deliver through an endpoint that durably deduplicates this identity. Required
|
|
1554
|
+
* for persisted mutations; never falls back to ordinary mutate.
|
|
1555
|
+
*/
|
|
1556
|
+
mutateDurably?<K extends Extract<keyof Mutations, string>>(proc: K, input: Mutations[K]['input'], select: Set<string>, identity: MutationIdentity): Promise<Mutations[K]['output']>;
|
|
1397
1557
|
subscribeById?(type: string, id: string | number, select: Iterable<string>, args: ResolvedArgsPayload | undefined, handlers: LiveEventHandlers): () => void;
|
|
1398
1558
|
subscribeConnection?(procedure: string, type: string, args: ResolvedArgsPayload | undefined, select: Iterable<string>, selectionArgs: ResolvedArgsPayload | undefined, handlers: LiveConnectionEventHandlers): () => void;
|
|
1399
1559
|
}
|
|
@@ -1424,24 +1584,19 @@ type TRPCMutationResolvers<AppRouter extends AnyRouter> = Record<string, Mutatio
|
|
|
1424
1584
|
type MutationMapFromResolvers<R extends Record<string, MutationResolver<any>>> = { [K in keyof R]: R[K] extends ((client: any) => (input: infer Input) => Promise<infer Output>) ? {
|
|
1425
1585
|
input: Input;
|
|
1426
1586
|
output: Output;
|
|
1427
|
-
} : never };
|
|
1587
|
+
} : never; };
|
|
1428
1588
|
type EmptyMutationResolvers<AppRouter extends AnyRouter> = Record<never, MutationResolver<AppRouter>>;
|
|
1429
1589
|
/**
|
|
1430
1590
|
* Builds a `Transport` backed by a tRPC client using the configured resolvers
|
|
1431
1591
|
* for by-id queries, lists, and mutations.
|
|
1432
1592
|
*/
|
|
1433
|
-
declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations extends TRPCMutationResolvers<AppRouter> = EmptyMutationResolvers<AppRouter>>({
|
|
1434
|
-
byId,
|
|
1435
|
-
client,
|
|
1436
|
-
lists,
|
|
1437
|
-
mutations,
|
|
1438
|
-
queries
|
|
1439
|
-
}: {
|
|
1593
|
+
declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations extends TRPCMutationResolvers<AppRouter> = EmptyMutationResolvers<AppRouter>>({ byId, client, lists, mutateDurably, mutations, queries }: {
|
|
1440
1594
|
byId: TRPCByIdResolvers<AppRouter>;
|
|
1441
1595
|
client: TRPCClient<AppRouter>;
|
|
1442
1596
|
lists?: TRPCListResolvers<AppRouter>;
|
|
1597
|
+
mutateDurably?: Transport<MutationMapFromResolvers<Mutations>>['mutateDurably'];
|
|
1443
1598
|
mutations?: Mutations;
|
|
1444
1599
|
queries?: TRPCQueryResolvers<AppRouter>;
|
|
1445
1600
|
}): Transport<MutationMapFromResolvers<Mutations>>;
|
|
1446
1601
|
//#endregion
|
|
1447
|
-
export {
|
|
1602
|
+
export { ViewSnapshot as $, FateThenable as A, Pagination as B, Deferred as C, Entity as D, DeferredTag as E, MutationIdentifier as F, TypeConfig as G, RequestResult as H, MutationInput as I, ViewData as J, TypeName as K, MutationResult as L, Mask as M, MutationDefinition as N, EntityId as O, MutationEntity as P, ViewSelection as Q, MutationShape as R, DeferTag as S, DeferredSelection as T, RootDefinition as U, Request$1 as V, Selection as W, ViewEntityName as X, ViewEntity as Y, ViewRef as Z, getSelectionPlan as _, PersistenceSession as a, mutation as at, ConnectionRef as b, FateClient as c, createClient as d, ViewTag as et, FateDehydratedState as f, List as g, encodeHydrationValue as h, Persistence as i, FateMutations as it, ListItem as j, FateRoots as k, RequestMode as l, HydrationLimits as m, createTRPCTransport as n, __FateSelectionBrand as nt, PersistenceSnapshot as o, AnyProcedure as ot, HydrateOptions as p, View as q, MutationIdentity as r, isViewTag as rt, DeferredSnapshot as s, QueryProcedure as st, Transport as t, __FateEntityBrand as tt, RequestOptions as u, AnyRecord as v, DeferredMetadata as w, ConnectionTag as x, ConnectionMetadata as y, NodesItem as z };
|