@nkzw/fate 1.0.3 → 1.2.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 +1220 -147
- package/docs/api/classes/FateClient.md +134 -40
- package/docs/api/functions/clientRoot.md +1 -1
- package/docs/api/functions/createClient.md +8 -4
- package/docs/api/functions/createGraphQLTransport.md +21 -0
- package/docs/api/functions/createHTTPTransport.md +1 -1
- package/docs/api/functions/createTRPCTransport.md +1 -1
- package/docs/api/functions/defer.md +21 -0
- package/docs/api/functions/getDeferredMetadata.md +21 -0
- package/docs/api/functions/getListEntries.md +1 -1
- package/docs/api/functions/getSelectionPlan.md +1 -1
- package/docs/api/functions/graphqlMutation.md +39 -0
- package/docs/api/functions/isDeferred.md +15 -0
- 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 +19 -0
- package/docs/api/interfaces/FateThenable.md +3 -3
- package/docs/api/interfaces/Transport.md +7 -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 +19 -0
- package/docs/api/type-aliases/DeferredMetadata.md +7 -0
- package/docs/api/type-aliases/DeferredSelection.md +13 -0
- package/docs/api/type-aliases/DeferredSnapshot.md +11 -0
- 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 +11 -0
- 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 +1 -1
- 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 +19 -0
- package/docs/api/type-aliases/GraphQLMutationInput.md +11 -0
- package/docs/api/type-aliases/GraphQLMutationMap.md +11 -0
- package/docs/api/type-aliases/GraphQLMutationOutput.md +11 -0
- package/docs/api/type-aliases/GraphQLTransportOptions.md +119 -0
- package/docs/api/type-aliases/HydrateOptions.md +7 -0
- package/docs/api/type-aliases/HydrationLimits.md +7 -0
- 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/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/Request.md +1 -1
- package/docs/api/type-aliases/RequestMode.md +1 -1
- package/docs/api/type-aliases/RequestOptions.md +1 -1
- package/docs/api/type-aliases/RequestResult.md +1 -1
- package/docs/api/type-aliases/Selection.md +1 -1
- package/docs/api/type-aliases/Snapshot.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 +7 -0
- package/docs/api/variables/DeferredTag.md +7 -0
- package/docs/guide/actions.md +7 -7
- package/docs/guide/deferred-views.md +62 -0
- package/docs/guide/getting-started.md +21 -3
- package/docs/guide/requests.md +52 -0
- package/docs/guide/vue.md +256 -0
- package/docs/index.md +1 -0
- package/docs/integrations/graphql.md +345 -0
- package/docs/{guide/server-integration.md → integrations/server.md} +94 -7
- package/docs/{guide/void-integration.md → integrations/void.md} +94 -12
- package/lib/{executor-BqwHdN3n.d.mts → executor-Dh-MLUXc.d.mts} +1 -1
- package/lib/graphqlTransport-B3cbhvJX.d.mts +74 -0
- package/lib/graphqlTransport-IFgmY-Qq.mjs +499 -0
- package/lib/graphqlTransport.d.mts +2 -0
- package/lib/graphqlTransport.mjs +2 -0
- package/lib/index.d.mts +10 -4
- package/lib/index.mjs +619 -91
- package/lib/{list-4wRNSVgI.d.mts → list-BrL6PD_6.d.mts} +1 -1
- package/lib/list.d.mts +1 -1
- package/lib/list.mjs +1 -1
- package/lib/{liveTopics-DzNtJaBD.mjs → liveTopics-JIDh3t3P.mjs} +1 -1
- package/lib/{record-CirbfZWX.d.mts → record-BkvZwvFk.d.mts} +2 -2
- package/lib/server/drizzle.d.mts +6 -8
- package/lib/server/drizzle.mjs +2 -2
- package/lib/server/prisma.d.mts +6 -8
- package/lib/server/prisma.mjs +2 -2
- package/lib/server.d.mts +3 -3
- package/lib/server.mjs +3 -3
- package/lib/{sourceRouter-C22uFcZg.mjs → sourceRouter-N9Vp0Cj6.mjs} +1 -1
- package/lib/{types-Dz46PXr3.d.mts → transport-BjGm__3t.d.mts} +246 -145
- package/lib/vite.d.mts +2 -2
- package/lib/vite.mjs +150 -3
- package/package.json +11 -3
- /package/lib/{list-C_mi6GnE.mjs → list-_6fXYLtJ.mjs} +0 -0
- /package/lib/{record-AeZJC9fd.mjs → record-B07VwXd-.mjs} +0 -0
|
@@ -1,32 +1,6 @@
|
|
|
1
1
|
import { TRPCClient } from "@trpc/client";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
4
|
-
type FieldMask = {
|
|
5
|
-
all: boolean;
|
|
6
|
-
children: Map<string, FieldMask>;
|
|
7
|
-
};
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/selection.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Representation of a composed selection including hashed args and the
|
|
12
|
-
* flat set of field paths to read or fetch.
|
|
13
|
-
*/
|
|
14
|
-
type SelectionPlan = {
|
|
15
|
-
readonly args: Map<string, Readonly<{
|
|
16
|
-
hash: string;
|
|
17
|
-
ignoreKeys?: ReadonlySet<string>;
|
|
18
|
-
value: AnyRecord;
|
|
19
|
-
}>>;
|
|
20
|
-
readonly live: Map<string, ConnectionLivePolicy>;
|
|
21
|
-
readonly paths: Set<string>;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Flattens a view into a `SelectionPlan`, expanding composed views and
|
|
25
|
-
* partitioning nested args so the client can fetch exactly what is declared.
|
|
26
|
-
*/
|
|
27
|
-
declare const getSelectionPlan: <T extends Entity, S extends Selection<T>, V extends View<T, S>>(viewComposition: V, ref: ViewRef<T["__typename"]> | null) => SelectionPlan;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
|
|
3
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@6.0.3/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
|
|
30
4
|
//#region src/observable/types.d.ts
|
|
31
5
|
interface Unsubscribable {
|
|
32
6
|
unsubscribe(): void;
|
|
@@ -50,7 +24,7 @@ interface Observer<TValue, TError> {
|
|
|
50
24
|
type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
51
25
|
type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
|
|
52
26
|
//#endregion
|
|
53
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@
|
|
27
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@6.0.3/node_modules/@trpc/server/dist/unstable-core-do-not-import.d-BdVSvUCr.d.mts
|
|
54
28
|
/**
|
|
55
29
|
* @public
|
|
56
30
|
*/
|
|
@@ -613,123 +587,18 @@ interface Router<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
|
|
|
613
587
|
}
|
|
614
588
|
type AnyRouter = Router<any, any>;
|
|
615
589
|
//#endregion
|
|
616
|
-
//#region src/
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
type ResolvedArgsPayload = AnyRecord;
|
|
621
|
-
type TransportMutations = Record<string, MutationShape>;
|
|
622
|
-
type EmptyTransportMutations = Record<never, MutationShape>;
|
|
623
|
-
type Bivariant<Fn extends (...args: Array<any>) => any> = {
|
|
624
|
-
bivarianceHack: Fn;
|
|
625
|
-
}['bivarianceHack'];
|
|
626
|
-
type TRPCListResult = {
|
|
627
|
-
items: Array<{
|
|
628
|
-
cursor?: string;
|
|
629
|
-
node?: unknown;
|
|
630
|
-
}>;
|
|
631
|
-
pagination: Pagination;
|
|
590
|
+
//#region src/mask.d.ts
|
|
591
|
+
type FieldMask = {
|
|
592
|
+
all: boolean;
|
|
593
|
+
children: Map<string, FieldMask>;
|
|
632
594
|
};
|
|
633
|
-
type LiveEventHandlers = Readonly<{
|
|
634
|
-
onData: (record: unknown, select?: ReadonlyArray<string>) => void;
|
|
635
|
-
onDelete?: (id?: string | number) => void;
|
|
636
|
-
onError?: (error: unknown) => void;
|
|
637
|
-
}>;
|
|
638
|
-
type LiveConnectionEvent = Readonly<{
|
|
639
|
-
edge: {
|
|
640
|
-
cursor?: string;
|
|
641
|
-
node: unknown;
|
|
642
|
-
};
|
|
643
|
-
nodeType: string;
|
|
644
|
-
targetCursor?: string;
|
|
645
|
-
type: 'appendEdge' | 'appendNode' | 'insertEdgeAfter' | 'insertEdgeBefore' | 'prependEdge' | 'prependNode';
|
|
646
|
-
}> | Readonly<{
|
|
647
|
-
id: string | number;
|
|
648
|
-
nodeType: string;
|
|
649
|
-
type: 'deleteEdge';
|
|
650
|
-
}> | Readonly<{
|
|
651
|
-
type: 'invalidate';
|
|
652
|
-
}>;
|
|
653
|
-
type LiveConnectionEventHandlers = Readonly<{
|
|
654
|
-
onError?: (error: unknown) => void;
|
|
655
|
-
onEvent: (event: LiveConnectionEvent) => void;
|
|
656
|
-
}>;
|
|
657
|
-
/**
|
|
658
|
-
* Contract the fate client expects from a network transport. The transport is
|
|
659
|
-
* responsible for fetching records by ID, fetching lists, and executing
|
|
660
|
-
* mutations with the provided selections.
|
|
661
|
-
*/
|
|
662
|
-
interface Transport<Mutations extends TransportMutations = EmptyTransportMutations> {
|
|
663
|
-
fetchById(type: string, ids: Array<string | number>, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<Array<unknown>>;
|
|
664
|
-
fetchList?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<{
|
|
665
|
-
items: Array<{
|
|
666
|
-
cursor: string | undefined;
|
|
667
|
-
node: unknown;
|
|
668
|
-
}>;
|
|
669
|
-
pagination: Pagination;
|
|
670
|
-
}>;
|
|
671
|
-
fetchQuery?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<unknown>;
|
|
672
|
-
mutate?<K extends Extract<keyof Mutations, string>>(proc: K, input: Mutations[K]['input'], select: Set<string>): Promise<Mutations[K]['output']>;
|
|
673
|
-
subscribeById?(type: string, id: string | number, select: Iterable<string>, args: ResolvedArgsPayload | undefined, handlers: LiveEventHandlers): () => void;
|
|
674
|
-
subscribeConnection?(procedure: string, type: string, args: ResolvedArgsPayload | undefined, select: Iterable<string>, selectionArgs: ResolvedArgsPayload | undefined, handlers: LiveConnectionEventHandlers): () => void;
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Mapping of entity type to tRPC procedures used for fetching entities by ID.
|
|
678
|
-
*/
|
|
679
|
-
type TRPCByIdResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => (input: {
|
|
680
|
-
args?: ResolvedArgsPayload;
|
|
681
|
-
ids: Array<string | number>;
|
|
682
|
-
select: Array<string>;
|
|
683
|
-
}) => Promise<unknown>>;
|
|
684
|
-
/**
|
|
685
|
-
* Mapping of list procedure name to a tRPC resolver factory.
|
|
686
|
-
*/
|
|
687
|
-
type TRPCListResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => Bivariant<(input: any) => Promise<TRPCListResult>>>;
|
|
688
|
-
/**
|
|
689
|
-
* Mapping of query procedure name to a tRPC resolver factory.
|
|
690
|
-
*/
|
|
691
|
-
type TRPCQueryResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => (input: {
|
|
692
|
-
args?: ResolvedArgsPayload;
|
|
693
|
-
select: Array<string>;
|
|
694
|
-
}) => Promise<unknown>>;
|
|
695
|
-
/**
|
|
696
|
-
* Mapping of a mutation procedure name to a tRPC resolver factory.
|
|
697
|
-
*/
|
|
698
|
-
type MutationResolver<AppRouter extends AnyRouter> = (client: TRPCClient<AppRouter>) => (input: any) => Promise<any>;
|
|
699
|
-
type TRPCMutationResolvers<AppRouter extends AnyRouter> = Record<string, MutationResolver<AppRouter>>;
|
|
700
|
-
type MutationMapFromResolvers<R extends Record<string, MutationResolver<any>>> = { [K in keyof R]: R[K] extends ((client: any) => (input: infer Input) => Promise<infer Output>) ? {
|
|
701
|
-
input: Input;
|
|
702
|
-
output: Output;
|
|
703
|
-
} : never };
|
|
704
|
-
type EmptyMutationResolvers<AppRouter extends AnyRouter> = Record<never, MutationResolver<AppRouter>>;
|
|
705
|
-
/**
|
|
706
|
-
* Builds a `Transport` backed by a tRPC client using the configured resolvers
|
|
707
|
-
* for by-id queries, lists, and mutations.
|
|
708
|
-
*/
|
|
709
|
-
declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations extends TRPCMutationResolvers<AppRouter> = EmptyMutationResolvers<AppRouter>>({
|
|
710
|
-
byId,
|
|
711
|
-
client,
|
|
712
|
-
lists,
|
|
713
|
-
mutations,
|
|
714
|
-
queries
|
|
715
|
-
}: {
|
|
716
|
-
byId: TRPCByIdResolvers<AppRouter>;
|
|
717
|
-
client: TRPCClient<AppRouter>;
|
|
718
|
-
lists?: TRPCListResolvers<AppRouter>;
|
|
719
|
-
mutations?: Mutations;
|
|
720
|
-
queries?: TRPCQueryResolvers<AppRouter>;
|
|
721
|
-
}): Transport<MutationMapFromResolvers<Mutations>>;
|
|
722
|
-
//#endregion
|
|
723
|
-
//#region src/operation-lifetime.d.ts
|
|
724
|
-
type RetainHandle = Readonly<{
|
|
725
|
-
dispose(): void;
|
|
726
|
-
}>;
|
|
727
595
|
//#endregion
|
|
728
596
|
//#region src/cache.d.ts
|
|
729
597
|
declare class ViewDataCache {
|
|
730
598
|
private cache;
|
|
731
599
|
private rootDependencies;
|
|
732
600
|
private dependencyIndex;
|
|
601
|
+
clear(): void;
|
|
733
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;
|
|
734
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;
|
|
735
604
|
invalidate(entityId: EntityId): void;
|
|
@@ -749,6 +618,11 @@ type List = Readonly<{
|
|
|
749
618
|
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
750
619
|
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
751
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
|
+
}>;
|
|
752
626
|
declare class Store {
|
|
753
627
|
private coverage;
|
|
754
628
|
private listKeysByOwnerField;
|
|
@@ -759,6 +633,11 @@ declare class Store {
|
|
|
759
633
|
private records;
|
|
760
634
|
private subscriptions;
|
|
761
635
|
private listSubscriptions;
|
|
636
|
+
dehydrate(): StoreHydrationState;
|
|
637
|
+
hydrate(state: StoreHydrationState, mode: 'preserve-existing' | 'replace', options?: {
|
|
638
|
+
deferNotifications?: boolean;
|
|
639
|
+
}): () => void;
|
|
640
|
+
private rebuildIndexes;
|
|
762
641
|
read(id: EntityId): AnyRecord | undefined;
|
|
763
642
|
merge(id: EntityId, partial: AnyRecord, paths: Iterable<string>): void;
|
|
764
643
|
private mergeInternal;
|
|
@@ -796,6 +675,61 @@ declare class Store {
|
|
|
796
675
|
private updateRecordReferenceIndexes;
|
|
797
676
|
}
|
|
798
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
|
|
709
|
+
/**
|
|
710
|
+
* Representation of a composed selection including hashed args and the
|
|
711
|
+
* flat set of field paths to read or fetch.
|
|
712
|
+
*/
|
|
713
|
+
type SelectionPlan = {
|
|
714
|
+
readonly args: Map<string, Readonly<{
|
|
715
|
+
hash: string;
|
|
716
|
+
ignoreKeys?: ReadonlySet<string>;
|
|
717
|
+
value: AnyRecord;
|
|
718
|
+
}>>;
|
|
719
|
+
readonly live: Map<string, ConnectionLivePolicy>;
|
|
720
|
+
readonly paths: Set<string>;
|
|
721
|
+
};
|
|
722
|
+
/**
|
|
723
|
+
* Flattens a view into a `SelectionPlan`, expanding composed views and
|
|
724
|
+
* partitioning nested args so the client can fetch exactly what is declared.
|
|
725
|
+
*/
|
|
726
|
+
declare const getSelectionPlan: <T extends Entity, S extends Selection<T>, V extends View<T, S>>(viewComposition: V, ref: ViewRef<T["__typename"]> | null) => SelectionPlan;
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/operation-lifetime.d.ts
|
|
729
|
+
type RetainHandle = Readonly<{
|
|
730
|
+
dispose(): void;
|
|
731
|
+
}>;
|
|
732
|
+
//#endregion
|
|
799
733
|
//#region src/client.d.ts
|
|
800
734
|
/**
|
|
801
735
|
* Strategy used when resolving a request.
|
|
@@ -807,7 +741,11 @@ type RequestMode = /** (default) Use cached data if present, otherwise fetch. */
|
|
|
807
741
|
type RequestOptions = Readonly<{
|
|
808
742
|
mode?: RequestMode;
|
|
809
743
|
}>;
|
|
810
|
-
type
|
|
744
|
+
type DeferredSnapshot<T> = Readonly<{
|
|
745
|
+
coverage: ReadonlyArray<readonly [id: EntityId, paths: ReadonlySet<string>]>;
|
|
746
|
+
data: T;
|
|
747
|
+
}>;
|
|
748
|
+
type FateClientOptions<Roots extends FateRoots, Mutations extends FateMutations, HydrationScope extends string> = {
|
|
811
749
|
/**
|
|
812
750
|
* Number of recently released requests to keep retained before their records
|
|
813
751
|
* and lists are eligible for garbage collection.
|
|
@@ -815,6 +753,15 @@ type FateClientOptions<Roots extends FateRoots, Mutations extends FateMutations>
|
|
|
815
753
|
* @defaultValue 10
|
|
816
754
|
*/
|
|
817
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;
|
|
818
765
|
mutations?: Mutations;
|
|
819
766
|
onLiveError?: (error: unknown) => void;
|
|
820
767
|
roots: Roots;
|
|
@@ -827,11 +774,12 @@ type FateClientOptions<Roots extends FateRoots, Mutations extends FateMutations>
|
|
|
827
774
|
* Core client that normalizes records, manages the view cache, and coordinates
|
|
828
775
|
* data fetching.
|
|
829
776
|
*/
|
|
830
|
-
declare class FateClient<Roots extends FateRoots, Mutations extends FateMutations> {
|
|
777
|
+
declare class FateClient<Roots extends FateRoots, Mutations extends FateMutations, HydrationScope extends string = string> {
|
|
831
778
|
private readonly mutationMap;
|
|
832
779
|
private readonly parentLists;
|
|
833
780
|
private readonly rootLists;
|
|
834
781
|
private readonly pending;
|
|
782
|
+
private readonly pendingDeferred;
|
|
835
783
|
private readonly pendingOptimisticMutations;
|
|
836
784
|
private readonly optimisticMasks;
|
|
837
785
|
private readonly optimisticByEntity;
|
|
@@ -846,8 +794,11 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
846
794
|
private readonly stalledRequests;
|
|
847
795
|
private gcPending;
|
|
848
796
|
private gcScheduled;
|
|
797
|
+
private pendingNetworkRequests;
|
|
849
798
|
readonly store: Store;
|
|
850
799
|
private readonly operationLifetime;
|
|
800
|
+
private readonly hydrationLimits;
|
|
801
|
+
private readonly hydrationScope;
|
|
851
802
|
private readonly types;
|
|
852
803
|
private readonly transport;
|
|
853
804
|
private readonly viewDataCache;
|
|
@@ -855,8 +806,20 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
855
806
|
readonly actions: MutationActionsFor<Mutations>;
|
|
856
807
|
readonly mutations: MutationFunctionsFor<Mutations>;
|
|
857
808
|
readonly roots: Roots;
|
|
858
|
-
constructor(options: FateClientOptions<Roots, Mutations>);
|
|
809
|
+
constructor(options: FateClientOptions<Roots, Mutations, HydrationScope>);
|
|
859
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;
|
|
860
823
|
private registerRootList;
|
|
861
824
|
private snapshotList;
|
|
862
825
|
private applyListInsert;
|
|
@@ -878,6 +841,7 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
878
841
|
[ViewsTag]: Set<string>;
|
|
879
842
|
}>;
|
|
880
843
|
readView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>>;
|
|
844
|
+
readDeferred<T>(deferred: Deferred<T>): PromiseLike<DeferredSnapshot<T>>;
|
|
881
845
|
assertLiveViewSupport(): void;
|
|
882
846
|
assertLiveConnectionSupport(): void;
|
|
883
847
|
subscribeLiveView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): () => void;
|
|
@@ -914,6 +878,7 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
914
878
|
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
915
879
|
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
916
880
|
}> | undefined>;
|
|
881
|
+
private loadConnectionInternal;
|
|
917
882
|
request<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
918
883
|
requestForRender<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
919
884
|
prepareRequestForRender<R extends Request$1>(request: R, options: RequestOptions | undefined): Readonly<{
|
|
@@ -946,6 +911,8 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
946
911
|
private executeRequestHandle;
|
|
947
912
|
private markRecordReferences;
|
|
948
913
|
private hasActiveOptimisticUpdates;
|
|
914
|
+
private hasPendingRequests;
|
|
915
|
+
trackPendingRequest<T>(request: () => Promise<T>): Promise<T>;
|
|
949
916
|
private runPendingGarbageCollection;
|
|
950
917
|
private handleStoreAndNetworkRequest;
|
|
951
918
|
private getRootType;
|
|
@@ -965,12 +932,15 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
965
932
|
private clearStalledRequestsForEntity;
|
|
966
933
|
private pendingPrefix;
|
|
967
934
|
private pendingKey;
|
|
935
|
+
private deferredPendingKey;
|
|
936
|
+
private deferredSelectionSignature;
|
|
937
|
+
private hasMissingDeferredList;
|
|
968
938
|
private liveSubscriptionKey;
|
|
969
939
|
private liveConnectionSubscriptionKey;
|
|
970
940
|
private releaseLiveSubscription;
|
|
971
941
|
private reportLiveError;
|
|
972
942
|
}
|
|
973
|
-
declare function createClient<T extends [FateRoots, FateMutations] = [Record<never, RootDefinition<any, any>>, Record<never, MutationDefinition<any, any, any>>]>(options: FateClientOptions<T[0], T[1]>): FateClient<T[0], T[1]>;
|
|
943
|
+
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>;
|
|
974
944
|
//#endregion
|
|
975
945
|
//#region src/mutation.d.ts
|
|
976
946
|
/**
|
|
@@ -1043,6 +1013,10 @@ declare const ViewKind: unique symbol;
|
|
|
1043
1013
|
declare const ViewsTag: unique symbol;
|
|
1044
1014
|
/** Symbol attached to connection results so pagination helpers can find their metadata. */
|
|
1045
1015
|
declare const ConnectionTag: unique symbol;
|
|
1016
|
+
/** Symbol used to mark a selection as deferred. */
|
|
1017
|
+
declare const DeferTag: unique symbol;
|
|
1018
|
+
/** Symbol attached to deferred values returned from masked views. */
|
|
1019
|
+
declare const DeferredTag: unique symbol;
|
|
1046
1020
|
declare const __FateEntityBrand: unique symbol;
|
|
1047
1021
|
declare const __FateSelectionBrand: unique symbol;
|
|
1048
1022
|
declare const __FateMutationEntityBrand: unique symbol;
|
|
@@ -1050,6 +1024,7 @@ declare const __FateMutationInputBrand: unique symbol;
|
|
|
1050
1024
|
declare const __FateMutationResultBrand: unique symbol;
|
|
1051
1025
|
declare const __FateRootResultBrand: unique symbol;
|
|
1052
1026
|
declare const __FateRootTypeBrand: unique symbol;
|
|
1027
|
+
declare const __FateDeferredBrand: unique symbol;
|
|
1053
1028
|
type __ViewEntityAnchor<T extends Entity> = {
|
|
1054
1029
|
readonly [__FateEntityBrand]?: T;
|
|
1055
1030
|
};
|
|
@@ -1136,6 +1111,24 @@ type ConnectionRef<TName extends string> = Readonly<{
|
|
|
1136
1111
|
}>;
|
|
1137
1112
|
pagination?: Pagination;
|
|
1138
1113
|
}>;
|
|
1114
|
+
/** Selection wrapper created by `defer(...)`. */
|
|
1115
|
+
type DeferredSelection<S> = Readonly<{
|
|
1116
|
+
[DeferTag]: S;
|
|
1117
|
+
}>;
|
|
1118
|
+
/** Runtime metadata used by the client to resolve a deferred field. */
|
|
1119
|
+
type DeferredMetadata = Readonly<{
|
|
1120
|
+
field: string;
|
|
1121
|
+
id: string | number;
|
|
1122
|
+
owner: EntityId;
|
|
1123
|
+
selection: unknown;
|
|
1124
|
+
type: string;
|
|
1125
|
+
}>;
|
|
1126
|
+
/** A deferred value returned from a masked view. Existing view hooks resolve it when read. */
|
|
1127
|
+
type Deferred<T> = Readonly<{
|
|
1128
|
+
[DeferredTag]: DeferredMetadata;
|
|
1129
|
+
}> & {
|
|
1130
|
+
readonly [__FateDeferredBrand]: T;
|
|
1131
|
+
};
|
|
1139
1132
|
/** Base shape shared by all entities fetched by fate. */
|
|
1140
1133
|
type Entity = {
|
|
1141
1134
|
__typename: string;
|
|
@@ -1159,7 +1152,8 @@ type ConnectionSelectionBase<T extends Entity> = Readonly<{
|
|
|
1159
1152
|
type ConnectionSelection<T extends Entity> = ConnectionSelectionBase<T> | (SelectionArgs & ConnectionSelectionBase<T>);
|
|
1160
1153
|
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;
|
|
1161
1154
|
type SelectionFieldValue<T extends Entity, K extends keyof T> = BaseSelectionFieldValue<T, K> | SelectionArgs | (SelectionArgs & Extract<BaseSelectionFieldValue<T, K>, object>);
|
|
1162
|
-
type
|
|
1155
|
+
type DeferrableSelectionFieldValue<T extends Entity, K extends keyof T> = SelectionFieldValue<T, K> | DeferredSelection<SelectionFieldValue<T, K>>;
|
|
1156
|
+
type SelectionShape<T extends Entity> = { [K in keyof T as K extends '__typename' ? never : K]?: DeferrableSelectionFieldValue<T, K> } & {
|
|
1163
1157
|
__typename?: true;
|
|
1164
1158
|
};
|
|
1165
1159
|
type SelectionViewSpread<T extends Entity> = { readonly [K in ViewTag]?: Readonly<{
|
|
@@ -1221,7 +1215,7 @@ type EntityName<T> = T extends {
|
|
|
1221
1215
|
__typename: infer N extends string;
|
|
1222
1216
|
} ? N : never;
|
|
1223
1217
|
/** Recursively applies a view selection to an entity to mask fields that aren't selected. */
|
|
1224
|
-
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>] : Mask<NonNullish<T>[Extract<K, keyof T>], Extract<S[K], object>> } & (T extends Entity ? Pick<NonNullish<T>, '__typename'> : Record<never, never>) : T;
|
|
1218
|
+
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;
|
|
1225
1219
|
type Mask<T, S> = WithNullish<T, MaskNonNullish<NonNullish<T>, S>>;
|
|
1226
1220
|
/** Entity type captured from a view definition. */
|
|
1227
1221
|
type ViewEntity<V> = V extends View<infer T, any> ? T : never;
|
|
@@ -1342,4 +1336,111 @@ interface FateThenable<T> extends PromiseLike<T> {
|
|
|
1342
1336
|
value: T;
|
|
1343
1337
|
}
|
|
1344
1338
|
//#endregion
|
|
1345
|
-
|
|
1339
|
+
//#region src/transport.d.ts
|
|
1340
|
+
/**
|
|
1341
|
+
* Normalized representation of args passed to a transport.
|
|
1342
|
+
*/
|
|
1343
|
+
type ResolvedArgsPayload = AnyRecord;
|
|
1344
|
+
type TransportMutations = Record<string, MutationShape>;
|
|
1345
|
+
type EmptyTransportMutations = Record<never, MutationShape>;
|
|
1346
|
+
type Bivariant<Fn extends (...args: Array<any>) => any> = {
|
|
1347
|
+
bivarianceHack: Fn;
|
|
1348
|
+
}['bivarianceHack'];
|
|
1349
|
+
type TRPCListResult = {
|
|
1350
|
+
items: Array<{
|
|
1351
|
+
cursor?: string;
|
|
1352
|
+
node?: unknown;
|
|
1353
|
+
}>;
|
|
1354
|
+
pagination: Pagination;
|
|
1355
|
+
};
|
|
1356
|
+
type LiveEventHandlers = Readonly<{
|
|
1357
|
+
onData: (record: unknown, select?: ReadonlyArray<string>) => void;
|
|
1358
|
+
onDelete?: (id?: string | number) => void;
|
|
1359
|
+
onError?: (error: unknown) => void;
|
|
1360
|
+
}>;
|
|
1361
|
+
type LiveConnectionEvent = Readonly<{
|
|
1362
|
+
edge: {
|
|
1363
|
+
cursor?: string;
|
|
1364
|
+
node: unknown;
|
|
1365
|
+
};
|
|
1366
|
+
nodeType: string;
|
|
1367
|
+
targetCursor?: string;
|
|
1368
|
+
type: 'appendEdge' | 'appendNode' | 'insertEdgeAfter' | 'insertEdgeBefore' | 'prependEdge' | 'prependNode';
|
|
1369
|
+
}> | Readonly<{
|
|
1370
|
+
id: string | number;
|
|
1371
|
+
nodeType: string;
|
|
1372
|
+
type: 'deleteEdge';
|
|
1373
|
+
}> | Readonly<{
|
|
1374
|
+
type: 'invalidate';
|
|
1375
|
+
}>;
|
|
1376
|
+
type LiveConnectionEventHandlers = Readonly<{
|
|
1377
|
+
onError?: (error: unknown) => void;
|
|
1378
|
+
onEvent: (event: LiveConnectionEvent) => void;
|
|
1379
|
+
}>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Contract the fate client expects from a network transport. The transport is
|
|
1382
|
+
* responsible for fetching records by ID, fetching lists, and executing
|
|
1383
|
+
* mutations with the provided selections.
|
|
1384
|
+
*/
|
|
1385
|
+
interface Transport<Mutations extends TransportMutations = EmptyTransportMutations> {
|
|
1386
|
+
fetchById(type: string, ids: Array<string | number>, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<Array<unknown>>;
|
|
1387
|
+
fetchList?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<{
|
|
1388
|
+
items: Array<{
|
|
1389
|
+
cursor: string | undefined;
|
|
1390
|
+
node: unknown;
|
|
1391
|
+
}>;
|
|
1392
|
+
pagination: Pagination;
|
|
1393
|
+
}>;
|
|
1394
|
+
fetchQuery?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<unknown>;
|
|
1395
|
+
mutate?<K extends Extract<keyof Mutations, string>>(proc: K, input: Mutations[K]['input'], select: Set<string>): Promise<Mutations[K]['output']>;
|
|
1396
|
+
subscribeById?(type: string, id: string | number, select: Iterable<string>, args: ResolvedArgsPayload | undefined, handlers: LiveEventHandlers): () => void;
|
|
1397
|
+
subscribeConnection?(procedure: string, type: string, args: ResolvedArgsPayload | undefined, select: Iterable<string>, selectionArgs: ResolvedArgsPayload | undefined, handlers: LiveConnectionEventHandlers): () => void;
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Mapping of entity type to tRPC procedures used for fetching entities by ID.
|
|
1401
|
+
*/
|
|
1402
|
+
type TRPCByIdResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => (input: {
|
|
1403
|
+
args?: ResolvedArgsPayload;
|
|
1404
|
+
ids: Array<string | number>;
|
|
1405
|
+
select: Array<string>;
|
|
1406
|
+
}) => Promise<unknown>>;
|
|
1407
|
+
/**
|
|
1408
|
+
* Mapping of list procedure name to a tRPC resolver factory.
|
|
1409
|
+
*/
|
|
1410
|
+
type TRPCListResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => Bivariant<(input: any) => Promise<TRPCListResult>>>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Mapping of query procedure name to a tRPC resolver factory.
|
|
1413
|
+
*/
|
|
1414
|
+
type TRPCQueryResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => (input: {
|
|
1415
|
+
args?: ResolvedArgsPayload;
|
|
1416
|
+
select: Array<string>;
|
|
1417
|
+
}) => Promise<unknown>>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Mapping of a mutation procedure name to a tRPC resolver factory.
|
|
1420
|
+
*/
|
|
1421
|
+
type MutationResolver<AppRouter extends AnyRouter> = (client: TRPCClient<AppRouter>) => (input: any) => Promise<any>;
|
|
1422
|
+
type TRPCMutationResolvers<AppRouter extends AnyRouter> = Record<string, MutationResolver<AppRouter>>;
|
|
1423
|
+
type MutationMapFromResolvers<R extends Record<string, MutationResolver<any>>> = { [K in keyof R]: R[K] extends ((client: any) => (input: infer Input) => Promise<infer Output>) ? {
|
|
1424
|
+
input: Input;
|
|
1425
|
+
output: Output;
|
|
1426
|
+
} : never };
|
|
1427
|
+
type EmptyMutationResolvers<AppRouter extends AnyRouter> = Record<never, MutationResolver<AppRouter>>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Builds a `Transport` backed by a tRPC client using the configured resolvers
|
|
1430
|
+
* for by-id queries, lists, and mutations.
|
|
1431
|
+
*/
|
|
1432
|
+
declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations extends TRPCMutationResolvers<AppRouter> = EmptyMutationResolvers<AppRouter>>({
|
|
1433
|
+
byId,
|
|
1434
|
+
client,
|
|
1435
|
+
lists,
|
|
1436
|
+
mutations,
|
|
1437
|
+
queries
|
|
1438
|
+
}: {
|
|
1439
|
+
byId: TRPCByIdResolvers<AppRouter>;
|
|
1440
|
+
client: TRPCClient<AppRouter>;
|
|
1441
|
+
lists?: TRPCListResolvers<AppRouter>;
|
|
1442
|
+
mutations?: Mutations;
|
|
1443
|
+
queries?: TRPCQueryResolvers<AppRouter>;
|
|
1444
|
+
}): Transport<MutationMapFromResolvers<Mutations>>;
|
|
1445
|
+
//#endregion
|
|
1446
|
+
export { HydrateOptions as $, Snapshot as A, ViewTag as B, MutationShape as C, RequestResult as D, Request$1 as E, ViewEntity as F, mutation as G, __FateSelectionBrand as H, ViewEntityName as I, RequestMode as J, DeferredSnapshot as K, ViewRef as L, TypeName as M, View as N, RootDefinition as O, ViewData as P, FateDehydratedState as Q, ViewSelection as R, MutationResult as S, Pagination as T, isViewTag as U, __FateEntityBrand as V, FateMutations as W, createClient as X, RequestOptions as Y, getSelectionPlan as Z, Mask as _, ConnectionRef as a, MutationIdentifier as b, Deferred as c, DeferredTag as d, HydrationLimits as et, Entity as f, ListItem as g, FateThenable as h, ConnectionMetadata as i, TypeConfig as j, Selection as k, DeferredMetadata as l, FateRoots as m, createTRPCTransport as n, AnyProcedure as nt, ConnectionTag as o, EntityId as p, FateClient as q, AnyRecord as r, QueryProcedure as rt, DeferTag as s, Transport as t, List as tt, DeferredSelection as u, MutationDefinition as v, NodesItem as w, MutationInput as x, MutationEntity as y, ViewSnapshot as z };
|
package/lib/vite.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
|
|
3
3
|
//#region src/viteTypes.d.ts
|
|
4
|
-
type FateViteTransport = 'native' | 'trpc' | 'void';
|
|
4
|
+
type FateViteTransport = 'graphql' | 'native' | 'trpc' | 'void';
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/vite.d.ts
|
|
7
|
-
type ClientRuntime = '@nkzw/fate' | 'react-fate';
|
|
7
|
+
type ClientRuntime = '@nkzw/fate' | 'react-fate' | 'vue-fate';
|
|
8
8
|
type FateVitePluginOptions = {
|
|
9
9
|
clientModule?: ClientRuntime;
|
|
10
10
|
generatedFile?: false | string;
|