@nkzw/fate 0.1.3 → 1.0.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 +810 -129
- package/docs/api/classes/FateClient.md +832 -0
- package/docs/api/functions/clientRoot.md +27 -0
- package/docs/api/functions/createClient.md +21 -0
- package/docs/api/functions/createHTTPTransport.md +51 -0
- package/docs/api/functions/createTRPCTransport.md +46 -0
- package/docs/api/functions/getListEntries.md +15 -0
- package/docs/api/functions/getSelectionPlan.md +36 -0
- package/docs/api/functions/isRecord.md +15 -0
- package/docs/api/functions/isViewTag.md +17 -0
- package/docs/api/functions/liveConnectionTopic.md +19 -0
- package/docs/api/functions/liveEntityTopic.md +19 -0
- package/docs/api/functions/liveGlobalConnectionTopic.md +15 -0
- package/docs/api/functions/mutation.md +32 -0
- package/docs/api/functions/toEntityId.md +21 -0
- package/docs/api/functions/view.md +26 -0
- package/docs/api/index.md +81 -0
- package/docs/api/interfaces/FateThenable.md +31 -0
- package/docs/api/interfaces/Transport.md +199 -0
- package/docs/api/server/classes/FateRequestError.md +67 -0
- package/docs/api/server/drizzle/functions/createDrizzleFate.md +431 -0
- package/docs/api/server/drizzle/functions/createDrizzleSourceAdapter.md +21 -0
- package/docs/api/server/drizzle/functions/createDrizzleSourceRegistry.md +21 -0
- package/docs/api/server/drizzle/index.md +23 -0
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyConfig.md +15 -0
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyInput.md +5 -0
- package/docs/api/server/drizzle/type-aliases/DrizzleQueryExtra.md +21 -0
- package/docs/api/server/drizzle/type-aliases/DrizzleSourceAdapter.md +337 -0
- package/docs/api/server/drizzle/type-aliases/DrizzleViewConfig.md +29 -0
- package/docs/api/server/functions/bindSourceProcedures.md +32 -0
- package/docs/api/server/functions/computed.md +43 -0
- package/docs/api/server/functions/count.md +21 -0
- package/docs/api/server/functions/createFateFetchHandler.md +21 -0
- package/docs/api/server/functions/createFateServer.md +41 -0
- package/docs/api/server/functions/createHonoFateHandler.md +21 -0
- package/docs/api/server/functions/createLiveEventBus.md +17 -0
- package/docs/api/server/functions/createNestedSourcePlan.md +103 -0
- package/docs/api/server/functions/createResolver.md +74 -0
- package/docs/api/server/functions/createSourcePlan.md +95 -0
- package/docs/api/server/functions/createSourceProcedures.md +46 -0
- package/docs/api/server/functions/dataView.md +32 -0
- package/docs/api/server/functions/field.md +15 -0
- package/docs/api/server/functions/getNestedSelection.md +19 -0
- package/docs/api/server/functions/getScopedArgs.md +21 -0
- package/docs/api/server/functions/hasNestedSelection.md +19 -0
- package/docs/api/server/functions/list.md +28 -0
- package/docs/api/server/functions/refetchSourceById.md +55 -0
- package/docs/api/server/functions/resolveSourceById.md +55 -0
- package/docs/api/server/functions/resolveSourceByIds.md +55 -0
- package/docs/api/server/functions/resolveSourceConnection.md +67 -0
- package/docs/api/server/functions/resolver.md +42 -0
- package/docs/api/server/functions/toPrismaSelect.md +25 -0
- package/docs/api/server/functions/withConnection.md +24 -0
- package/docs/api/server/index.md +109 -0
- package/docs/api/server/prisma/functions/createPrismaFate.md +435 -0
- package/docs/api/server/prisma/functions/createPrismaSourceAdapter.md +21 -0
- package/docs/api/server/prisma/functions/createPrismaSourceRegistry.md +21 -0
- package/docs/api/server/prisma/functions/prismaConnectionArgs.md +57 -0
- package/docs/api/server/prisma/index.md +23 -0
- package/docs/api/server/prisma/type-aliases/PrismaDelegate.md +59 -0
- package/docs/api/server/prisma/type-aliases/PrismaQueryExtra.md +5 -0
- package/docs/api/server/prisma/type-aliases/PrismaSourceAdapter.md +343 -0
- package/docs/api/server/prisma/type-aliases/PrismaViewConfig.md +31 -0
- package/docs/api/server/type-aliases/ComputedField.md +55 -0
- package/docs/api/server/type-aliases/ComputedSelection.md +5 -0
- package/docs/api/server/type-aliases/ConnectionItem.md +29 -0
- package/docs/api/server/type-aliases/ConnectionPagination.md +39 -0
- package/docs/api/server/type-aliases/ConnectionResult.md +29 -0
- package/docs/api/server/type-aliases/CountSelection.md +29 -0
- package/docs/api/server/type-aliases/CountWhere.md +5 -0
- package/docs/api/server/type-aliases/DataViewListOptions.md +13 -0
- package/docs/api/server/type-aliases/DataViewOrderBy.md +5 -0
- package/docs/api/server/type-aliases/DataViewOrderDirection.md +5 -0
- package/docs/api/server/type-aliases/DataViewResult.md +11 -0
- package/docs/api/server/type-aliases/Entity.md +21 -0
- package/docs/api/server/type-aliases/FateServer.md +75 -0
- package/docs/api/server/type-aliases/FateServerManifest.md +5 -0
- package/docs/api/server/type-aliases/FieldSelection.md +21 -0
- package/docs/api/server/type-aliases/LiveConnectionEventType.md +5 -0
- package/docs/api/server/type-aliases/LiveConnectionSourceEvent.md +5 -0
- package/docs/api/server/type-aliases/LiveEventBus.md +5 -0
- package/docs/api/server/type-aliases/LiveEventType.md +5 -0
- package/docs/api/server/type-aliases/LiveSourceEvent.md +5 -0
- package/docs/api/server/type-aliases/NativeFateAPI.md +47 -0
- package/docs/api/server/type-aliases/OrderDirection.md +5 -0
- package/docs/api/server/type-aliases/SourceConfig.md +55 -0
- package/docs/api/server/type-aliases/SourceDefinition.md +55 -0
- package/docs/api/server/type-aliases/SourceOrder.md +5 -0
- package/docs/api/server/type-aliases/SourceOrderField.md +21 -0
- package/docs/api/server/type-aliases/SourcePlan.md +29 -0
- package/docs/api/server/type-aliases/SourcePlanNode.md +29 -0
- package/docs/api/server/type-aliases/SourceRegistry.md +11 -0
- package/docs/api/server/type-aliases/SourceRelation.md +15 -0
- package/docs/api/server/type-aliases/SourceRelationConfig.md +23 -0
- package/docs/api/server/variables/byIdInput.md +5 -0
- package/docs/api/server/variables/connectionArgs.md +7 -0
- package/docs/api/type-aliases/ConnectionMetadata.md +7 -0
- package/docs/api/type-aliases/ConnectionRef.md +13 -0
- package/docs/api/type-aliases/Entity.md +15 -0
- package/docs/api/type-aliases/EntityId.md +7 -0
- package/docs/api/type-aliases/FateLiveConnectionEvent.md +5 -0
- package/docs/api/type-aliases/FateLiveEvent.md +5 -0
- package/docs/api/type-aliases/FateMutations.md +7 -0
- package/docs/api/type-aliases/FateOperation.md +5 -0
- package/docs/api/type-aliases/FateProtocolRequest.md +5 -0
- package/docs/api/type-aliases/FateProtocolResponse.md +5 -0
- package/docs/api/type-aliases/FateRecord.md +7 -0
- package/docs/api/type-aliases/FateRoots.md +7 -0
- package/docs/api/type-aliases/InferFateAPI.md +11 -0
- package/docs/api/type-aliases/List.md +5 -0
- package/docs/api/type-aliases/ListEntry.md +5 -0
- package/docs/api/type-aliases/ListItem.md +13 -0
- package/docs/api/type-aliases/Mask.md +15 -0
- package/docs/api/type-aliases/MutationDefinition.md +21 -0
- package/docs/api/type-aliases/MutationEntity.md +13 -0
- package/docs/api/type-aliases/MutationIdentifier.md +19 -0
- package/docs/api/type-aliases/MutationInput.md +13 -0
- package/docs/api/type-aliases/MutationResult.md +13 -0
- package/docs/api/type-aliases/NodesItem.md +13 -0
- package/docs/api/type-aliases/Pagination.md +39 -0
- package/docs/api/type-aliases/Request.md +7 -0
- package/docs/api/type-aliases/RequestMode.md +7 -0
- package/docs/api/type-aliases/RequestOptions.md +7 -0
- package/docs/api/type-aliases/RequestResult.md +18 -0
- package/docs/api/type-aliases/Selection.md +13 -0
- package/docs/api/type-aliases/Snapshot.md +7 -0
- package/docs/api/type-aliases/TypeConfig.md +41 -0
- package/docs/api/type-aliases/View.md +17 -0
- package/docs/api/type-aliases/ViewData.md +18 -0
- package/docs/api/type-aliases/ViewEntity.md +13 -0
- package/docs/api/type-aliases/ViewEntityName.md +13 -0
- package/docs/api/type-aliases/ViewRef.md +13 -0
- package/docs/api/type-aliases/ViewSelection.md +13 -0
- package/docs/api/type-aliases/ViewSnapshot.md +18 -0
- package/docs/api/type-aliases/ViewTag.md +7 -0
- package/docs/api/variables/ConnectionTag.md +7 -0
- package/docs/guide/actions.md +263 -0
- package/docs/guide/core-concepts.md +22 -0
- package/docs/guide/getting-started.md +57 -0
- package/docs/guide/list-views.md +86 -0
- package/docs/guide/live-views.md +245 -0
- package/docs/guide/requests.md +130 -0
- package/docs/guide/server-integration.md +630 -0
- package/docs/guide/views.md +278 -0
- package/docs/guide/void-integration.md +167 -0
- package/docs/index.md +4 -0
- package/lib/cli.mjs +17 -250
- package/lib/clientStub.d.mts +6 -0
- package/lib/clientStub.mjs +6 -0
- package/lib/executor-BqwHdN3n.d.mts +468 -0
- package/lib/index.d.mts +64 -2
- package/lib/index.mjs +1961 -555
- package/lib/list-4wRNSVgI.d.mts +10 -0
- package/lib/list-C_mi6GnE.mjs +16 -0
- package/lib/list.d.mts +2 -0
- package/lib/list.mjs +2 -0
- package/lib/liveTopics-DzNtJaBD.mjs +197 -0
- package/lib/{record-DnhZuvUe.mjs → record-AeZJC9fd.mjs} +1 -2
- package/lib/record-ENh92gyb.d.mts +315 -0
- package/lib/server/drizzle.d.mts +304 -0
- package/lib/server/drizzle.mjs +688 -0
- package/lib/server/prisma.d.mts +309 -0
- package/lib/server/prisma.mjs +345 -0
- package/lib/server.d.mts +82 -183
- package/lib/server.mjs +870 -416
- package/lib/sourceRouter-Bwpkr062.mjs +972 -0
- package/lib/{types-HECWvGpd.d.mts → types-Dz46PXr3.d.mts} +215 -63
- package/lib/vite.d.mts +17 -0
- package/lib/vite.mjs +593 -0
- package/package.json +44 -6
|
@@ -17,6 +17,7 @@ type SelectionPlan = {
|
|
|
17
17
|
ignoreKeys?: ReadonlySet<string>;
|
|
18
18
|
value: AnyRecord;
|
|
19
19
|
}>>;
|
|
20
|
+
readonly live: Map<string, ConnectionLivePolicy>;
|
|
20
21
|
readonly paths: Set<string>;
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
@@ -25,51 +26,7 @@ type SelectionPlan = {
|
|
|
25
26
|
*/
|
|
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;
|
|
27
28
|
//#endregion
|
|
28
|
-
//#region
|
|
29
|
-
declare class ViewDataCache {
|
|
30
|
-
private cache;
|
|
31
|
-
private rootDependencies;
|
|
32
|
-
private dependencyIndex;
|
|
33
|
-
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;
|
|
34
|
-
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;
|
|
35
|
-
invalidate(entityId: EntityId): void;
|
|
36
|
-
private invalidateDependents;
|
|
37
|
-
private delete;
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/store.d.ts
|
|
41
|
-
type List = Readonly<{
|
|
42
|
-
cursors?: ReadonlyArray<string | undefined>;
|
|
43
|
-
ids: ReadonlyArray<EntityId>;
|
|
44
|
-
pagination?: Pagination;
|
|
45
|
-
}>;
|
|
46
|
-
declare class Store {
|
|
47
|
-
private coverage;
|
|
48
|
-
private lists;
|
|
49
|
-
private records;
|
|
50
|
-
private subscriptions;
|
|
51
|
-
private listSubscriptions;
|
|
52
|
-
read(id: EntityId): AnyRecord | undefined;
|
|
53
|
-
merge(id: EntityId, partial: AnyRecord, paths: Iterable<string>): void;
|
|
54
|
-
private mergeInternal;
|
|
55
|
-
deleteRecord(id: EntityId): void;
|
|
56
|
-
missingForSelection(id: EntityId, paths: Iterable<string>): Set<string>;
|
|
57
|
-
subscribe(id: EntityId, selection: ReadonlySet<string> | null, fn: () => void): () => void;
|
|
58
|
-
subscribe(id: EntityId, fn: () => void): () => void;
|
|
59
|
-
private notify;
|
|
60
|
-
private notifyListSubscribers;
|
|
61
|
-
getList(key: string): ReadonlyArray<EntityId> | undefined;
|
|
62
|
-
getListState(key: string): List | undefined;
|
|
63
|
-
getListsForField(ownerId: EntityId, field: string): Array<readonly [string, List]>;
|
|
64
|
-
setList(key: string, state: List): void;
|
|
65
|
-
restoreList(key: string, list?: List): void;
|
|
66
|
-
subscribeList(key: string, fn: () => void): () => void;
|
|
67
|
-
removeReferencesTo(targetId: EntityId, viewDataCache: ViewDataCache, snapshots?: Map<EntityId, Snapshot>, listSnapshots?: Map<string, List>): void;
|
|
68
|
-
snapshot(id: EntityId): Snapshot;
|
|
69
|
-
restore(id: EntityId, snapshot: Snapshot): void;
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.8.1_typescript@5.9.3/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
|
|
29
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
|
|
73
30
|
//#region src/observable/types.d.ts
|
|
74
31
|
interface Unsubscribable {
|
|
75
32
|
unsubscribe(): void;
|
|
@@ -93,7 +50,7 @@ interface Observer<TValue, TError> {
|
|
|
93
50
|
type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
94
51
|
type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
|
|
95
52
|
//#endregion
|
|
96
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.
|
|
53
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/unstable-core-do-not-import.d-BdVSvUCr.d.mts
|
|
97
54
|
/**
|
|
98
55
|
* @public
|
|
99
56
|
*/
|
|
@@ -263,6 +220,10 @@ interface ProcedureCallOptions<TContext> {
|
|
|
263
220
|
path: string;
|
|
264
221
|
type: ProcedureType;
|
|
265
222
|
signal: AbortSignal | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* The index of this call in a batch request.
|
|
225
|
+
*/
|
|
226
|
+
batchIndex: number;
|
|
266
227
|
} //#endregion
|
|
267
228
|
//#region src/unstable-core-do-not-import/procedure.d.ts
|
|
268
229
|
declare const procedureTypes: readonly ["query", "mutation", "subscription"];
|
|
@@ -619,7 +580,6 @@ type RouterCaller<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = (
|
|
|
619
580
|
* If passing a function, we recommend it's a cached function
|
|
620
581
|
* e.g. wrapped in `React.cache` to avoid unnecessary computations
|
|
621
582
|
*/
|
|
622
|
-
|
|
623
583
|
ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>), options?: {
|
|
624
584
|
onError?: RouterCallerErrorHandler<TRoot['ctx']>;
|
|
625
585
|
signal?: AbortSignal;
|
|
@@ -663,6 +623,37 @@ type EmptyTransportMutations = Record<never, MutationShape>;
|
|
|
663
623
|
type Bivariant<Fn extends (...args: Array<any>) => any> = {
|
|
664
624
|
bivarianceHack: Fn;
|
|
665
625
|
}['bivarianceHack'];
|
|
626
|
+
type TRPCListResult = {
|
|
627
|
+
items: Array<{
|
|
628
|
+
cursor?: string;
|
|
629
|
+
node?: unknown;
|
|
630
|
+
}>;
|
|
631
|
+
pagination: Pagination;
|
|
632
|
+
};
|
|
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
|
+
}>;
|
|
666
657
|
/**
|
|
667
658
|
* Contract the fate client expects from a network transport. The transport is
|
|
668
659
|
* responsible for fetching records by ID, fetching lists, and executing
|
|
@@ -679,6 +670,8 @@ interface Transport<Mutations extends TransportMutations = EmptyTransportMutatio
|
|
|
679
670
|
}>;
|
|
680
671
|
fetchQuery?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<unknown>;
|
|
681
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;
|
|
682
675
|
}
|
|
683
676
|
/**
|
|
684
677
|
* Mapping of entity type to tRPC procedures used for fetching entities by ID.
|
|
@@ -687,17 +680,11 @@ type TRPCByIdResolvers<AppRouter extends AnyRouter> = Record<string, (client: TR
|
|
|
687
680
|
args?: ResolvedArgsPayload;
|
|
688
681
|
ids: Array<string | number>;
|
|
689
682
|
select: Array<string>;
|
|
690
|
-
}) => Promise<
|
|
683
|
+
}) => Promise<unknown>>;
|
|
691
684
|
/**
|
|
692
685
|
* Mapping of list procedure name to a tRPC resolver factory.
|
|
693
686
|
*/
|
|
694
|
-
type TRPCListResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => Bivariant<(input: any) => Promise<
|
|
695
|
-
items: Array<{
|
|
696
|
-
cursor: string | undefined;
|
|
697
|
-
node: unknown;
|
|
698
|
-
}>;
|
|
699
|
-
pagination: Pagination;
|
|
700
|
-
}>>>;
|
|
687
|
+
type TRPCListResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => Bivariant<(input: any) => Promise<TRPCListResult>>>;
|
|
701
688
|
/**
|
|
702
689
|
* Mapping of query procedure name to a tRPC resolver factory.
|
|
703
690
|
*/
|
|
@@ -733,6 +720,82 @@ declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations exte
|
|
|
733
720
|
queries?: TRPCQueryResolvers<AppRouter>;
|
|
734
721
|
}): Transport<MutationMapFromResolvers<Mutations>>;
|
|
735
722
|
//#endregion
|
|
723
|
+
//#region src/operation-lifetime.d.ts
|
|
724
|
+
type RetainHandle = Readonly<{
|
|
725
|
+
dispose(): void;
|
|
726
|
+
}>;
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/cache.d.ts
|
|
729
|
+
declare class ViewDataCache {
|
|
730
|
+
private cache;
|
|
731
|
+
private rootDependencies;
|
|
732
|
+
private dependencyIndex;
|
|
733
|
+
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
|
+
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
|
+
invalidate(entityId: EntityId): void;
|
|
736
|
+
private invalidateDependents;
|
|
737
|
+
private delete;
|
|
738
|
+
}
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/store.d.ts
|
|
741
|
+
type List = Readonly<{
|
|
742
|
+
backwardPageLimit?: number;
|
|
743
|
+
cursors?: ReadonlyArray<string | undefined>;
|
|
744
|
+
forwardPageLimit?: number;
|
|
745
|
+
ids: ReadonlyArray<EntityId>;
|
|
746
|
+
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
747
|
+
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
748
|
+
pagination?: Pagination;
|
|
749
|
+
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
750
|
+
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
751
|
+
}>;
|
|
752
|
+
declare class Store {
|
|
753
|
+
private coverage;
|
|
754
|
+
private listKeysByOwnerField;
|
|
755
|
+
private listKeysByReferencedEntity;
|
|
756
|
+
private lists;
|
|
757
|
+
private recordReferenceFields;
|
|
758
|
+
private recordReferencesByTarget;
|
|
759
|
+
private records;
|
|
760
|
+
private subscriptions;
|
|
761
|
+
private listSubscriptions;
|
|
762
|
+
read(id: EntityId): AnyRecord | undefined;
|
|
763
|
+
merge(id: EntityId, partial: AnyRecord, paths: Iterable<string>): void;
|
|
764
|
+
private mergeInternal;
|
|
765
|
+
deleteRecord(id: EntityId): void;
|
|
766
|
+
missingForSelection(id: EntityId, paths: Iterable<string>): Set<string>;
|
|
767
|
+
subscribe(id: EntityId, selection: ReadonlySet<string> | null, fn: () => void): () => void;
|
|
768
|
+
subscribe(id: EntityId, fn: () => void): () => void;
|
|
769
|
+
private notify;
|
|
770
|
+
private notifyListSubscribers;
|
|
771
|
+
getList(key: string): ReadonlyArray<EntityId> | undefined;
|
|
772
|
+
getListState(key: string): List | undefined;
|
|
773
|
+
getListsForField(ownerId: EntityId, field: string): Array<readonly [string, List]>;
|
|
774
|
+
setList(key: string, state: List): void;
|
|
775
|
+
replaceListEntityId(previousId: EntityId, nextId: EntityId): void;
|
|
776
|
+
restoreList(key: string, list?: List): void;
|
|
777
|
+
collectGarbage(markedRecords: ReadonlySet<EntityId>, markedLists: ReadonlySet<string>, options?: {
|
|
778
|
+
onRecordDeleted?: (id: EntityId) => void;
|
|
779
|
+
}): {
|
|
780
|
+
lists: Set<string>;
|
|
781
|
+
records: Set<EntityId>;
|
|
782
|
+
};
|
|
783
|
+
private deleteList;
|
|
784
|
+
subscribeList(key: string, fn: () => void): () => void;
|
|
785
|
+
removeReferencesTo(targetId: EntityId, viewDataCache: ViewDataCache, snapshots?: Map<EntityId, Snapshot>, listSnapshots?: Map<string, List>): void;
|
|
786
|
+
snapshot(id: EntityId): Snapshot;
|
|
787
|
+
restore(id: EntityId, snapshot: Snapshot): void;
|
|
788
|
+
private addListIndexes;
|
|
789
|
+
private removeListIndexes;
|
|
790
|
+
private getListReferencedEntityIds;
|
|
791
|
+
private getRecordFieldReferences;
|
|
792
|
+
private addRecordFieldReferenceIndex;
|
|
793
|
+
private removeRecordFieldReferenceIndex;
|
|
794
|
+
private addRecordReferenceIndexes;
|
|
795
|
+
private removeRecordReferenceIndexes;
|
|
796
|
+
private updateRecordReferenceIndexes;
|
|
797
|
+
}
|
|
798
|
+
//#endregion
|
|
736
799
|
//#region src/client.d.ts
|
|
737
800
|
/**
|
|
738
801
|
* Strategy used when resolving a request.
|
|
@@ -745,7 +808,15 @@ type RequestOptions = Readonly<{
|
|
|
745
808
|
mode?: RequestMode;
|
|
746
809
|
}>;
|
|
747
810
|
type FateClientOptions<Roots extends FateRoots, Mutations extends FateMutations> = {
|
|
811
|
+
/**
|
|
812
|
+
* Number of recently released requests to keep retained before their records
|
|
813
|
+
* and lists are eligible for garbage collection.
|
|
814
|
+
*
|
|
815
|
+
* @defaultValue 10
|
|
816
|
+
*/
|
|
817
|
+
gcReleaseBufferSize?: number;
|
|
748
818
|
mutations?: Mutations;
|
|
819
|
+
onLiveError?: (error: unknown) => void;
|
|
749
820
|
roots: Roots;
|
|
750
821
|
transport: Transport<MutationMapFromDefinitions<Mutations>>;
|
|
751
822
|
types: ReadonlyArray<Omit<TypeConfig, 'getId'> & Partial<{
|
|
@@ -766,29 +837,40 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
766
837
|
private readonly optimisticByEntity;
|
|
767
838
|
private readonly optimisticEntityResolutions;
|
|
768
839
|
private optimisticTokenCounter;
|
|
840
|
+
private readonly onLiveError;
|
|
841
|
+
private readonly liveSubscriptions;
|
|
842
|
+
private readonly liveConnectionInvalidations;
|
|
843
|
+
private readonly stableRefs;
|
|
769
844
|
private readonly requests;
|
|
770
845
|
private readonly rootRequests;
|
|
771
846
|
private readonly stalledRequests;
|
|
847
|
+
private gcPending;
|
|
848
|
+
private gcScheduled;
|
|
772
849
|
readonly store: Store;
|
|
850
|
+
private readonly operationLifetime;
|
|
773
851
|
private readonly types;
|
|
774
852
|
private readonly transport;
|
|
775
853
|
private readonly viewDataCache;
|
|
854
|
+
private liveConnectionInvalidationToken;
|
|
776
855
|
readonly actions: MutationActionsFor<Mutations>;
|
|
777
856
|
readonly mutations: MutationFunctionsFor<Mutations>;
|
|
778
857
|
readonly roots: Roots;
|
|
779
858
|
constructor(options: FateClientOptions<Roots, Mutations>);
|
|
780
859
|
private initializeParentLists;
|
|
781
860
|
private registerRootList;
|
|
861
|
+
private snapshotList;
|
|
862
|
+
private applyListInsert;
|
|
782
863
|
private insertIntoRootLists;
|
|
783
864
|
getTypeConfig(type: string): TypeConfig;
|
|
784
865
|
executeMutation(key: string, input: unknown, select: Set<string>, options?: {
|
|
785
866
|
args?: AnyRecord;
|
|
786
867
|
plan?: SelectionPlan;
|
|
787
868
|
}): Promise<unknown>;
|
|
788
|
-
write(type: string, data: AnyRecord, select: ReadonlySet<string>, snapshots?: Map<EntityId, Snapshot>, plan?: SelectionPlan, pathPrefix?: string | null, blockedMask?: FieldMask | null, insert?: InsertPosition): string;
|
|
869
|
+
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;
|
|
789
870
|
deleteRecord(type: string, id: string | number, snapshots?: Map<EntityId, Snapshot>, listSnapshots?: Map<string, List>): void;
|
|
790
871
|
restore(id: EntityId, snapshot: Snapshot): void;
|
|
791
872
|
restoreList(name: string, list?: List): void;
|
|
873
|
+
private stableRefWithViewNames;
|
|
792
874
|
ref<T extends Entity>(type: T['__typename'], id: string | number, view: View<T, Selection<T>>): ViewRef<T['__typename']>;
|
|
793
875
|
rootListRef(entityId: EntityId, rootView: View<any, any>): Readonly<{
|
|
794
876
|
__typename: string;
|
|
@@ -796,6 +878,17 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
796
878
|
[ViewsTag]: Set<string>;
|
|
797
879
|
}>;
|
|
798
880
|
readView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>>;
|
|
881
|
+
assertLiveViewSupport(): void;
|
|
882
|
+
assertLiveConnectionSupport(): void;
|
|
883
|
+
subscribeLiveView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): () => void;
|
|
884
|
+
subscribeLiveListView<V extends View<any, any>>(view: V, connection: ConnectionMetadata): () => void;
|
|
885
|
+
private applyLiveConnectionEvent;
|
|
886
|
+
private invalidateLiveConnection;
|
|
887
|
+
private deleteConnectionEdge;
|
|
888
|
+
private insertConnectionEdge;
|
|
889
|
+
private syncNestedConnectionOwnerField;
|
|
890
|
+
private getConnectionInsertIndex;
|
|
891
|
+
private removeEntityFromListState;
|
|
799
892
|
private mergeListState;
|
|
800
893
|
registerPendingOptimisticMutation(entityId: EntityId, promise: Promise<unknown>): void;
|
|
801
894
|
resolveOptimisticEntity(optimisticEntityId: EntityId, resolvedEntityId: EntityId): void;
|
|
@@ -811,27 +904,71 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
811
904
|
loadConnection<V extends View<any, any>>(view: V, connection: ConnectionMetadata, args: Record<string, unknown>, options?: {
|
|
812
905
|
direction?: 'forward' | 'backward';
|
|
813
906
|
}): Promise<Readonly<{
|
|
907
|
+
backwardPageLimit?: number;
|
|
814
908
|
cursors?: ReadonlyArray<string | undefined>;
|
|
909
|
+
forwardPageLimit?: number;
|
|
815
910
|
ids: ReadonlyArray<EntityId>;
|
|
911
|
+
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
912
|
+
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
816
913
|
pagination?: Pagination;
|
|
914
|
+
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
915
|
+
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
817
916
|
}> | undefined>;
|
|
818
917
|
request<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
918
|
+
requestForRender<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
|
|
919
|
+
prepareRequestForRender<R extends Request$1>(request: R, options: RequestOptions | undefined): Readonly<{
|
|
920
|
+
promise: Promise<RequestResult<Roots, R>>;
|
|
921
|
+
requestKey: string;
|
|
922
|
+
}>;
|
|
923
|
+
private requestWithDescriptor;
|
|
819
924
|
releaseRequest(request: Request$1, mode: RequestMode): void;
|
|
925
|
+
releaseRequestKey(requestKey: string, mode: RequestMode): void;
|
|
926
|
+
retainRequestKey(requestKey: string, mode?: RequestMode): RetainHandle;
|
|
927
|
+
/**
|
|
928
|
+
* Keeps the records and lists reachable from a request alive until the
|
|
929
|
+
* returned handle is disposed.
|
|
930
|
+
*
|
|
931
|
+
* `useRequest` calls this automatically while the component is mounted.
|
|
932
|
+
* Use it directly for non-React request lifetimes, tests, or preloaded data
|
|
933
|
+
* that must survive manual garbage collection.
|
|
934
|
+
*/
|
|
935
|
+
retain(request: Request$1): RetainHandle;
|
|
936
|
+
private scheduleGarbageCollection;
|
|
937
|
+
/**
|
|
938
|
+
* Removes records and lists that are not reachable from retained requests or
|
|
939
|
+
* the release buffer.
|
|
940
|
+
*
|
|
941
|
+
* Garbage collection is scheduled automatically when retained requests are
|
|
942
|
+
* released. Calling this method manually is mainly useful in tests and custom
|
|
943
|
+
* memory-management flows.
|
|
944
|
+
*/
|
|
945
|
+
gc(): void;
|
|
946
|
+
private executeRequestHandle;
|
|
947
|
+
private markRecordReferences;
|
|
948
|
+
private hasActiveOptimisticUpdates;
|
|
949
|
+
private runPendingGarbageCollection;
|
|
820
950
|
private handleStoreAndNetworkRequest;
|
|
821
951
|
private getRootType;
|
|
952
|
+
private createRequestDescriptor;
|
|
953
|
+
getRequestKey(request: Request$1): string;
|
|
954
|
+
private hasRootListData;
|
|
822
955
|
private executeRequest;
|
|
823
956
|
private hasRequestData;
|
|
824
957
|
getRequestResult<R extends Request$1>(request: R): RequestResult<Roots, R>;
|
|
958
|
+
private getRequestResultFromDescriptor;
|
|
825
959
|
private fetchByIdAndNormalize;
|
|
826
960
|
private fetchQueryAndNormalize;
|
|
827
961
|
private fetchListAndNormalize;
|
|
828
|
-
private resolveSelection;
|
|
829
962
|
private writeEntity;
|
|
830
963
|
private linkParentLists;
|
|
831
964
|
private readViewSelection;
|
|
832
965
|
private clearStalledRequestsForEntity;
|
|
833
966
|
private pendingPrefix;
|
|
834
967
|
private pendingKey;
|
|
968
|
+
private liveSubscriptionKey;
|
|
969
|
+
private liveConnectionSubscriptionKey;
|
|
970
|
+
private releaseLiveSubscription;
|
|
971
|
+
private reportLiveError;
|
|
835
972
|
}
|
|
836
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]>;
|
|
837
974
|
//#endregion
|
|
@@ -946,12 +1083,21 @@ type WithNullish<T, R> = R | Nullish<T>;
|
|
|
946
1083
|
type SelectionArgs = Readonly<{
|
|
947
1084
|
args: AnyRecord;
|
|
948
1085
|
}>;
|
|
1086
|
+
type ConnectionLivePolicy = Readonly<{
|
|
1087
|
+
append?: 'edge' | 'visible';
|
|
1088
|
+
prepend?: 'edge' | 'visible';
|
|
1089
|
+
}>;
|
|
1090
|
+
type ConnectionLiveSelectionPolicy = Readonly<{
|
|
1091
|
+
append?: ConnectionLivePolicy['append'] | string;
|
|
1092
|
+
prepend?: ConnectionLivePolicy['prepend'] | string;
|
|
1093
|
+
}>;
|
|
949
1094
|
/** Metadata stored alongside connection results to power pagination and cache updates. */
|
|
950
1095
|
type ConnectionMetadata = Readonly<{
|
|
951
1096
|
args?: AnyRecord;
|
|
952
1097
|
field: string;
|
|
953
1098
|
hash?: string;
|
|
954
1099
|
key: string;
|
|
1100
|
+
live?: ConnectionLivePolicy;
|
|
955
1101
|
owner: EntityId;
|
|
956
1102
|
procedure: string;
|
|
957
1103
|
root?: boolean;
|
|
@@ -1001,6 +1147,7 @@ type ConnectionSelectionBase<T extends Entity> = Readonly<{
|
|
|
1001
1147
|
cursor?: true;
|
|
1002
1148
|
node: Selection<T> | View<T, Selection<T>>;
|
|
1003
1149
|
}>;
|
|
1150
|
+
live?: ConnectionLiveSelectionPolicy;
|
|
1004
1151
|
pagination?: Readonly<{
|
|
1005
1152
|
hasNext?: true;
|
|
1006
1153
|
hasPrevious?: true;
|
|
@@ -1048,13 +1195,18 @@ type ViewSnapshot<T extends Entity, S extends Selection<T>> = Readonly<{
|
|
|
1048
1195
|
coverage: ReadonlyArray<readonly [id: EntityId, paths: ReadonlySet<string>]>;
|
|
1049
1196
|
data: ViewData<T, S>;
|
|
1050
1197
|
}>;
|
|
1198
|
+
type ConnectionLikeSelection = {
|
|
1199
|
+
readonly items: {
|
|
1200
|
+
readonly node: unknown;
|
|
1201
|
+
};
|
|
1202
|
+
};
|
|
1051
1203
|
type ConnectionMask<T extends Entity, S> = S extends {
|
|
1052
|
-
items: infer ItemSelection;
|
|
1053
|
-
pagination?: infer PaginationSelection;
|
|
1204
|
+
readonly items: infer ItemSelection;
|
|
1205
|
+
readonly pagination?: infer PaginationSelection;
|
|
1054
1206
|
} ? {
|
|
1055
1207
|
items: ItemSelection extends {
|
|
1056
|
-
cursor?: infer CursorSelection;
|
|
1057
|
-
node: unknown;
|
|
1208
|
+
readonly cursor?: infer CursorSelection;
|
|
1209
|
+
readonly node: unknown;
|
|
1058
1210
|
} ? Array<(CursorSelection extends true ? {
|
|
1059
1211
|
cursor: string;
|
|
1060
1212
|
} : Record<string, never>) & {
|
|
@@ -1069,7 +1221,7 @@ type EntityName<T> = T extends {
|
|
|
1069
1221
|
__typename: infer N extends string;
|
|
1070
1222
|
} ? N : never;
|
|
1071
1223
|
/** Recursively applies a view selection to an entity to mask fields that aren't selected. */
|
|
1072
|
-
type MaskNonNullish<T, S> = T extends Array<infer U extends Entity> ? S extends true ? Array<U> : S extends
|
|
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;
|
|
1073
1225
|
type Mask<T, S> = WithNullish<T, MaskNonNullish<NonNullish<T>, S>>;
|
|
1074
1226
|
/** Entity type captured from a view definition. */
|
|
1075
1227
|
type ViewEntity<V> = V extends View<infer T, any> ? T : never;
|
|
@@ -1190,4 +1342,4 @@ interface FateThenable<T> extends PromiseLike<T> {
|
|
|
1190
1342
|
value: T;
|
|
1191
1343
|
}
|
|
1192
1344
|
//#endregion
|
|
1193
|
-
export {
|
|
1345
|
+
export { ViewRef as A, RequestMode as B, Snapshot as C, ViewData as D, View as E, __FateSelectionBrand as F, createTRPCTransport as G, createClient as H, isViewTag as I, getSelectionPlan as J, AnyProcedure as K, FateMutations as L, ViewSnapshot as M, ViewTag as N, ViewEntity as O, __FateEntityBrand as P, mutation as R, Selection as S, TypeName as T, List as U, RequestOptions as V, Transport as W, NodesItem as _, Entity as a, RequestResult as b, FateThenable as c, MutationDefinition as d, MutationEntity as f, MutationShape as g, MutationResult as h, ConnectionTag as i, ViewSelection as j, ViewEntityName as k, ListItem as l, MutationInput as m, ConnectionMetadata as n, EntityId as o, MutationIdentifier as p, QueryProcedure as q, ConnectionRef as r, FateRoots as s, AnyRecord as t, Mask as u, Pagination as v, TypeConfig as w, RootDefinition as x, Request$1 as y, FateClient as z };
|
package/lib/vite.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/viteTypes.d.ts
|
|
4
|
+
type FateViteTransport = 'native' | 'trpc' | 'void';
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/vite.d.ts
|
|
7
|
+
type ClientRuntime = '@nkzw/fate' | 'react-fate';
|
|
8
|
+
type FateVitePluginOptions = {
|
|
9
|
+
clientModule?: ClientRuntime;
|
|
10
|
+
generatedFile?: false | string;
|
|
11
|
+
module: string;
|
|
12
|
+
transport?: FateViteTransport;
|
|
13
|
+
tsconfigFile?: false | string;
|
|
14
|
+
};
|
|
15
|
+
declare const fate: (options: FateVitePluginOptions) => Plugin;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { FateVitePluginOptions, type FateViteTransport, fate };
|