@nkzw/fate 0.1.2 → 1.0.0-rc.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 -3
- package/lib/index.mjs +1965 -559
- 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 -184
- package/lib/server.mjs +870 -416
- package/lib/sourceRouter-Bwpkr062.mjs +972 -0
- package/lib/{types-Djlh7mMH.d.mts → types-Dz46PXr3.d.mts} +327 -197
- package/lib/vite.d.mts +17 -0
- package/lib/vite.mjs +592 -0
- package/package.json +44 -6
|
@@ -17,83 +17,40 @@ 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
|
/**
|
|
23
24
|
* Flattens a view into a `SelectionPlan`, expanding composed views and
|
|
24
25
|
* partitioning nested args so the client can fetch exactly what is declared.
|
|
25
26
|
*/
|
|
26
|
-
declare const getSelectionPlan: <T
|
|
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$1 extends Entity, S extends Selection<T$1>, V extends View<T$1, S>>(entityId: EntityId, view: V, ref: ViewRef<T$1['__typename']>): FateThenable<ViewSnapshot<T$1, S>> | null;
|
|
34
|
-
set<T$1 extends Entity, S extends Selection<T$1>, V extends View<T$1, S>>(entityId: EntityId, view: V, ref: ViewRef<T$1['__typename']>, thenable: FateThenable<ViewSnapshot<T$1, 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;
|
|
76
33
|
}
|
|
77
|
-
interface Subscribable<TValue
|
|
78
|
-
subscribe(observer: Partial<Observer<TValue
|
|
34
|
+
interface Subscribable<TValue, TError> {
|
|
35
|
+
subscribe(observer: Partial<Observer<TValue, TError>>): Unsubscribable;
|
|
79
36
|
}
|
|
80
|
-
interface Observable<TValue
|
|
81
|
-
pipe(): Observable<TValue
|
|
82
|
-
pipe<TValue1, TError1>(op1: OperatorFunction<TValue
|
|
83
|
-
pipe<TValue1, TError1, TValue2, TError2>(op1: OperatorFunction<TValue
|
|
84
|
-
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(op1: OperatorFunction<TValue
|
|
85
|
-
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(op1: OperatorFunction<TValue
|
|
86
|
-
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4, TValue5, TError5>(op1: OperatorFunction<TValue
|
|
37
|
+
interface Observable<TValue, TError> extends Subscribable<TValue, TError> {
|
|
38
|
+
pipe(): Observable<TValue, TError>;
|
|
39
|
+
pipe<TValue1, TError1>(op1: OperatorFunction<TValue, TError, TValue1, TError1>): Observable<TValue1, TError1>;
|
|
40
|
+
pipe<TValue1, TError1, TValue2, TError2>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>): Observable<TValue2, TError2>;
|
|
41
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>): Observable<TValue2, TError2>;
|
|
42
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>): Observable<TValue2, TError2>;
|
|
43
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4, TValue5, TError5>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>, op5: OperatorFunction<TValue4, TError4, TValue5, TError5>): Observable<TValue2, TError2>;
|
|
87
44
|
}
|
|
88
|
-
interface Observer<TValue
|
|
89
|
-
next: (value: TValue
|
|
45
|
+
interface Observer<TValue, TError> {
|
|
46
|
+
next: (value: TValue) => void;
|
|
90
47
|
error: (err: TError) => void;
|
|
91
48
|
complete: () => void;
|
|
92
49
|
}
|
|
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
|
*/
|
|
@@ -148,7 +105,6 @@ type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
|
|
|
148
105
|
* tRPC error codes that are considered retryable
|
|
149
106
|
* With out of the box SSE, the client will reconnect when these errors are encountered
|
|
150
107
|
*/
|
|
151
|
-
|
|
152
108
|
declare class TRPCError extends Error {
|
|
153
109
|
readonly cause?: Error;
|
|
154
110
|
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";
|
|
@@ -157,8 +113,7 @@ declare class TRPCError extends Error {
|
|
|
157
113
|
code: TRPC_ERROR_CODE_KEY;
|
|
158
114
|
cause?: unknown;
|
|
159
115
|
});
|
|
160
|
-
}
|
|
161
|
-
//# sourceMappingURL=TRPCError.d.ts.map
|
|
116
|
+
} //# sourceMappingURL=TRPCError.d.ts.map
|
|
162
117
|
//#endregion
|
|
163
118
|
//#region src/vendor/standard-schema-v1/spec.d.ts
|
|
164
119
|
/**
|
|
@@ -166,28 +121,28 @@ declare class TRPCError extends Error {
|
|
|
166
121
|
* @see https://github.com/standard-schema/standard-schema/blob/main/packages/spec/src/index.ts
|
|
167
122
|
*/
|
|
168
123
|
/** The Standard Schema interface. */
|
|
169
|
-
interface StandardSchemaV1<Input
|
|
124
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
170
125
|
/** The Standard Schema properties. */
|
|
171
|
-
readonly '~standard': StandardSchemaV1.Props<Input
|
|
126
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
172
127
|
}
|
|
173
128
|
declare namespace StandardSchemaV1 {
|
|
174
129
|
/** The Standard Schema properties interface. */
|
|
175
|
-
interface Props<Input
|
|
130
|
+
interface Props<Input = unknown, Output = Input> {
|
|
176
131
|
/** The version number of the standard. */
|
|
177
132
|
readonly version: 1;
|
|
178
133
|
/** The vendor name of the schema library. */
|
|
179
134
|
readonly vendor: string;
|
|
180
135
|
/** Validates unknown input values. */
|
|
181
|
-
readonly validate: (value: unknown) => Result<Output
|
|
136
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
182
137
|
/** Inferred types associated with the schema. */
|
|
183
|
-
readonly types?: Types<Input
|
|
138
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
184
139
|
}
|
|
185
140
|
/** The result interface of the validate function. */
|
|
186
|
-
type Result<Output
|
|
141
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
187
142
|
/** The result interface if validation succeeds. */
|
|
188
|
-
interface SuccessResult<Output
|
|
143
|
+
interface SuccessResult<Output> {
|
|
189
144
|
/** The typed output value. */
|
|
190
|
-
readonly value: Output
|
|
145
|
+
readonly value: Output;
|
|
191
146
|
/** The non-existent issues. */
|
|
192
147
|
readonly issues?: undefined;
|
|
193
148
|
}
|
|
@@ -209,18 +164,17 @@ declare namespace StandardSchemaV1 {
|
|
|
209
164
|
readonly key: PropertyKey;
|
|
210
165
|
}
|
|
211
166
|
/** The Standard Schema types interface. */
|
|
212
|
-
interface Types<Input
|
|
167
|
+
interface Types<Input = unknown, Output = Input> {
|
|
213
168
|
/** The input type of the schema. */
|
|
214
|
-
readonly input: Input
|
|
169
|
+
readonly input: Input;
|
|
215
170
|
/** The output type of the schema. */
|
|
216
|
-
readonly output: Output
|
|
171
|
+
readonly output: Output;
|
|
217
172
|
}
|
|
218
173
|
/** Infers the input type of a Standard Schema. */
|
|
219
174
|
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
220
175
|
/** Infers the output type of a Standard Schema. */
|
|
221
176
|
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
222
|
-
}
|
|
223
|
-
//# sourceMappingURL=spec.d.ts.map
|
|
177
|
+
} //# sourceMappingURL=spec.d.ts.map
|
|
224
178
|
//#endregion
|
|
225
179
|
//#region src/unstable-core-do-not-import/parser.d.ts
|
|
226
180
|
type ParserZodEsque<TInput, TParsedInput> = {
|
|
@@ -259,15 +213,18 @@ type Parser = ParserWithInputOutput<any, any> | ParserWithoutInput<any>;
|
|
|
259
213
|
/**
|
|
260
214
|
* @internal
|
|
261
215
|
*/
|
|
262
|
-
interface ProcedureCallOptions<TContext
|
|
263
|
-
ctx: TContext
|
|
216
|
+
interface ProcedureCallOptions<TContext> {
|
|
217
|
+
ctx: TContext;
|
|
264
218
|
getRawInput: GetRawInputFn;
|
|
265
219
|
input?: unknown;
|
|
266
220
|
path: string;
|
|
267
221
|
type: ProcedureType;
|
|
268
222
|
signal: AbortSignal | undefined;
|
|
269
|
-
|
|
270
|
-
|
|
223
|
+
/**
|
|
224
|
+
* The index of this call in a batch request.
|
|
225
|
+
*/
|
|
226
|
+
batchIndex: number;
|
|
227
|
+
} //#endregion
|
|
271
228
|
//#region src/unstable-core-do-not-import/procedure.d.ts
|
|
272
229
|
declare const procedureTypes: readonly ["query", "mutation", "subscription"];
|
|
273
230
|
/**
|
|
@@ -331,19 +288,17 @@ type inferProcedureOutput<TProcedure> = inferProcedureParams<TProcedure>['$types
|
|
|
331
288
|
/**
|
|
332
289
|
* @internal
|
|
333
290
|
*/
|
|
334
|
-
interface ErrorHandlerOptions<TContext
|
|
291
|
+
interface ErrorHandlerOptions<TContext> {
|
|
335
292
|
error: TRPCError;
|
|
336
293
|
type: ProcedureType | 'unknown';
|
|
337
294
|
path: string | undefined;
|
|
338
295
|
input: unknown;
|
|
339
|
-
ctx: TContext
|
|
340
|
-
}
|
|
341
|
-
//#endregion
|
|
296
|
+
ctx: TContext | undefined;
|
|
297
|
+
} //#endregion
|
|
342
298
|
//#region src/unstable-core-do-not-import/http/types.d.ts
|
|
343
299
|
/**
|
|
344
300
|
* @deprecated use `Headers` instead, this will be removed in v12
|
|
345
301
|
*/
|
|
346
|
-
|
|
347
302
|
//#endregion
|
|
348
303
|
//#region src/unstable-core-do-not-import/rpc/envelopes.d.ts
|
|
349
304
|
/**
|
|
@@ -357,7 +312,6 @@ interface TRPCErrorShape<TData extends object = object> {
|
|
|
357
312
|
/**
|
|
358
313
|
* JSON-RPC 2.0 Specification
|
|
359
314
|
*/
|
|
360
|
-
|
|
361
315
|
//# sourceMappingURL=envelopes.d.ts.map
|
|
362
316
|
//#endregion
|
|
363
317
|
//#region src/unstable-core-do-not-import/transformer.d.ts
|
|
@@ -404,20 +358,18 @@ interface CombinedDataTransformer {
|
|
|
404
358
|
/**
|
|
405
359
|
* @public
|
|
406
360
|
*/
|
|
407
|
-
|
|
408
361
|
//# sourceMappingURL=parseTRPCMessage.d.ts.map
|
|
409
|
-
|
|
410
362
|
//#endregion
|
|
411
363
|
//#region src/unstable-core-do-not-import/error/formatter.d.ts
|
|
412
364
|
/**
|
|
413
365
|
* @internal
|
|
414
366
|
*/
|
|
415
|
-
type ErrorFormatter<TContext
|
|
367
|
+
type ErrorFormatter<TContext, TShape extends TRPCErrorShape> = (opts: {
|
|
416
368
|
error: TRPCError;
|
|
417
369
|
type: ProcedureType | 'unknown';
|
|
418
370
|
path: string | undefined;
|
|
419
371
|
input: unknown;
|
|
420
|
-
ctx: TContext
|
|
372
|
+
ctx: TContext | undefined;
|
|
421
373
|
shape: DefaultErrorShape;
|
|
422
374
|
}) => TShape;
|
|
423
375
|
/**
|
|
@@ -468,7 +420,6 @@ interface JSONLProducerOptions {
|
|
|
468
420
|
* JSON Lines stream producer
|
|
469
421
|
* @see https://jsonlines.org/
|
|
470
422
|
*/
|
|
471
|
-
|
|
472
423
|
//# sourceMappingURL=sse.types.d.ts.map
|
|
473
424
|
//#endregion
|
|
474
425
|
//#region src/unstable-core-do-not-import/stream/sse.d.ts
|
|
@@ -495,9 +446,9 @@ interface SSEClientOptions {
|
|
|
495
446
|
*/
|
|
496
447
|
reconnectAfterInactivityMs?: number;
|
|
497
448
|
}
|
|
498
|
-
interface SSEStreamProducerOptions<TValue
|
|
449
|
+
interface SSEStreamProducerOptions<TValue = unknown> {
|
|
499
450
|
serialize?: Serialize$1;
|
|
500
|
-
data: AsyncIterable<TValue
|
|
451
|
+
data: AsyncIterable<TValue>;
|
|
501
452
|
maxDepth?: number;
|
|
502
453
|
ping?: SSEPingOptions;
|
|
503
454
|
/**
|
|
@@ -524,7 +475,6 @@ interface SSEStreamProducerOptions<TValue$1 = unknown> {
|
|
|
524
475
|
*
|
|
525
476
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
526
477
|
*/
|
|
527
|
-
|
|
528
478
|
//#endregion
|
|
529
479
|
//#region src/unstable-core-do-not-import/rootConfig.d.ts
|
|
530
480
|
/**
|
|
@@ -540,7 +490,6 @@ interface RootTypes {
|
|
|
540
490
|
/**
|
|
541
491
|
* The default check to see if we're in a server
|
|
542
492
|
*/
|
|
543
|
-
|
|
544
493
|
/**
|
|
545
494
|
* The tRPC root config
|
|
546
495
|
* @internal
|
|
@@ -621,7 +570,7 @@ type DecorateRouterRecord<TRecord extends RouterRecord> = { [TKey in keyof TReco
|
|
|
621
570
|
/**
|
|
622
571
|
* @internal
|
|
623
572
|
*/
|
|
624
|
-
type RouterCallerErrorHandler<TContext
|
|
573
|
+
type RouterCallerErrorHandler<TContext> = (opts: ErrorHandlerOptions<TContext>) => void;
|
|
625
574
|
/**
|
|
626
575
|
* @internal
|
|
627
576
|
*/
|
|
@@ -644,7 +593,6 @@ type LazyLoader<TAny> = {
|
|
|
644
593
|
* Lazy load a router
|
|
645
594
|
* @see https://trpc.io/docs/server/merging-routers#lazy-load
|
|
646
595
|
*/
|
|
647
|
-
|
|
648
596
|
/**
|
|
649
597
|
* @internal
|
|
650
598
|
*/
|
|
@@ -675,6 +623,37 @@ type EmptyTransportMutations = Record<never, MutationShape>;
|
|
|
675
623
|
type Bivariant<Fn extends (...args: Array<any>) => any> = {
|
|
676
624
|
bivarianceHack: Fn;
|
|
677
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
|
+
}>;
|
|
678
657
|
/**
|
|
679
658
|
* Contract the fate client expects from a network transport. The transport is
|
|
680
659
|
* responsible for fetching records by ID, fetching lists, and executing
|
|
@@ -690,7 +669,9 @@ interface Transport<Mutations extends TransportMutations = EmptyTransportMutatio
|
|
|
690
669
|
pagination: Pagination;
|
|
691
670
|
}>;
|
|
692
671
|
fetchQuery?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<unknown>;
|
|
693
|
-
mutate?<K
|
|
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;
|
|
694
675
|
}
|
|
695
676
|
/**
|
|
696
677
|
* Mapping of entity type to tRPC procedures used for fetching entities by ID.
|
|
@@ -699,17 +680,11 @@ type TRPCByIdResolvers<AppRouter extends AnyRouter> = Record<string, (client: TR
|
|
|
699
680
|
args?: ResolvedArgsPayload;
|
|
700
681
|
ids: Array<string | number>;
|
|
701
682
|
select: Array<string>;
|
|
702
|
-
}) => Promise<
|
|
683
|
+
}) => Promise<unknown>>;
|
|
703
684
|
/**
|
|
704
685
|
* Mapping of list procedure name to a tRPC resolver factory.
|
|
705
686
|
*/
|
|
706
|
-
type TRPCListResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => Bivariant<(input: any) => Promise<
|
|
707
|
-
items: Array<{
|
|
708
|
-
cursor: string | undefined;
|
|
709
|
-
node: unknown;
|
|
710
|
-
}>;
|
|
711
|
-
pagination: Pagination;
|
|
712
|
-
}>>>;
|
|
687
|
+
type TRPCListResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => Bivariant<(input: any) => Promise<TRPCListResult>>>;
|
|
713
688
|
/**
|
|
714
689
|
* Mapping of query procedure name to a tRPC resolver factory.
|
|
715
690
|
*/
|
|
@@ -722,7 +697,7 @@ type TRPCQueryResolvers<AppRouter extends AnyRouter> = Record<string, (client: T
|
|
|
722
697
|
*/
|
|
723
698
|
type MutationResolver<AppRouter extends AnyRouter> = (client: TRPCClient<AppRouter>) => (input: any) => Promise<any>;
|
|
724
699
|
type TRPCMutationResolvers<AppRouter extends AnyRouter> = Record<string, MutationResolver<AppRouter>>;
|
|
725
|
-
type MutationMapFromResolvers<R
|
|
700
|
+
type MutationMapFromResolvers<R extends Record<string, MutationResolver<any>>> = { [K in keyof R]: R[K] extends ((client: any) => (input: infer Input) => Promise<infer Output>) ? {
|
|
726
701
|
input: Input;
|
|
727
702
|
output: Output;
|
|
728
703
|
} : never };
|
|
@@ -745,14 +720,87 @@ declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations exte
|
|
|
745
720
|
queries?: TRPCQueryResolvers<AppRouter>;
|
|
746
721
|
}): Transport<MutationMapFromResolvers<Mutations>>;
|
|
747
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
|
|
748
799
|
//#region src/client.d.ts
|
|
749
800
|
/**
|
|
750
801
|
* Strategy used when resolving a request.
|
|
751
802
|
*/
|
|
752
|
-
type RequestMode = /** (default) Use cached data if present, otherwise fetch. */
|
|
753
|
-
'cache-first'
|
|
754
|
-
/** Show cached data immediately and refresh in the background. */ | 'stale-while-revalidate'
|
|
755
|
-
/** Always fetch from the network and ignore cached entries. */ | 'network-only';
|
|
803
|
+
type RequestMode = /** (default) Use cached data if present, otherwise fetch. */'cache-first' /** Show cached data immediately and refresh in the background. */ | 'stale-while-revalidate' /** Always fetch from the network and ignore cached entries. */ | 'network-only';
|
|
756
804
|
/**
|
|
757
805
|
* Request options that affect how requests are fetched and retained.
|
|
758
806
|
*/
|
|
@@ -760,7 +808,15 @@ type RequestOptions = Readonly<{
|
|
|
760
808
|
mode?: RequestMode;
|
|
761
809
|
}>;
|
|
762
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;
|
|
763
818
|
mutations?: Mutations;
|
|
819
|
+
onLiveError?: (error: unknown) => void;
|
|
764
820
|
roots: Roots;
|
|
765
821
|
transport: Transport<MutationMapFromDefinitions<Mutations>>;
|
|
766
822
|
types: ReadonlyArray<Omit<TypeConfig, 'getId'> & Partial<{
|
|
@@ -781,36 +837,58 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
781
837
|
private readonly optimisticByEntity;
|
|
782
838
|
private readonly optimisticEntityResolutions;
|
|
783
839
|
private optimisticTokenCounter;
|
|
840
|
+
private readonly onLiveError;
|
|
841
|
+
private readonly liveSubscriptions;
|
|
842
|
+
private readonly liveConnectionInvalidations;
|
|
843
|
+
private readonly stableRefs;
|
|
784
844
|
private readonly requests;
|
|
785
845
|
private readonly rootRequests;
|
|
786
846
|
private readonly stalledRequests;
|
|
847
|
+
private gcPending;
|
|
848
|
+
private gcScheduled;
|
|
787
849
|
readonly store: Store;
|
|
850
|
+
private readonly operationLifetime;
|
|
788
851
|
private readonly types;
|
|
789
852
|
private readonly transport;
|
|
790
853
|
private readonly viewDataCache;
|
|
854
|
+
private liveConnectionInvalidationToken;
|
|
791
855
|
readonly actions: MutationActionsFor<Mutations>;
|
|
792
856
|
readonly mutations: MutationFunctionsFor<Mutations>;
|
|
793
857
|
readonly roots: Roots;
|
|
794
858
|
constructor(options: FateClientOptions<Roots, Mutations>);
|
|
795
859
|
private initializeParentLists;
|
|
796
860
|
private registerRootList;
|
|
861
|
+
private snapshotList;
|
|
862
|
+
private applyListInsert;
|
|
797
863
|
private insertIntoRootLists;
|
|
798
864
|
getTypeConfig(type: string): TypeConfig;
|
|
799
865
|
executeMutation(key: string, input: unknown, select: Set<string>, options?: {
|
|
800
866
|
args?: AnyRecord;
|
|
801
867
|
plan?: SelectionPlan;
|
|
802
868
|
}): Promise<unknown>;
|
|
803
|
-
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;
|
|
804
870
|
deleteRecord(type: string, id: string | number, snapshots?: Map<EntityId, Snapshot>, listSnapshots?: Map<string, List>): void;
|
|
805
871
|
restore(id: EntityId, snapshot: Snapshot): void;
|
|
806
872
|
restoreList(name: string, list?: List): void;
|
|
807
|
-
|
|
873
|
+
private stableRefWithViewNames;
|
|
874
|
+
ref<T extends Entity>(type: T['__typename'], id: string | number, view: View<T, Selection<T>>): ViewRef<T['__typename']>;
|
|
808
875
|
rootListRef(entityId: EntityId, rootView: View<any, any>): Readonly<{
|
|
809
876
|
__typename: string;
|
|
810
877
|
id: string | number;
|
|
811
878
|
[ViewsTag]: Set<string>;
|
|
812
879
|
}>;
|
|
813
|
-
readView<T
|
|
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;
|
|
814
892
|
private mergeListState;
|
|
815
893
|
registerPendingOptimisticMutation(entityId: EntityId, promise: Promise<unknown>): void;
|
|
816
894
|
resolveOptimisticEntity(optimisticEntityId: EntityId, resolvedEntityId: EntityId): void;
|
|
@@ -826,36 +904,80 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
826
904
|
loadConnection<V extends View<any, any>>(view: V, connection: ConnectionMetadata, args: Record<string, unknown>, options?: {
|
|
827
905
|
direction?: 'forward' | 'backward';
|
|
828
906
|
}): Promise<Readonly<{
|
|
907
|
+
backwardPageLimit?: number;
|
|
829
908
|
cursors?: ReadonlyArray<string | undefined>;
|
|
909
|
+
forwardPageLimit?: number;
|
|
830
910
|
ids: ReadonlyArray<EntityId>;
|
|
911
|
+
liveAfterIds?: ReadonlyArray<EntityId>;
|
|
912
|
+
liveBeforeIds?: ReadonlyArray<EntityId>;
|
|
831
913
|
pagination?: Pagination;
|
|
914
|
+
pendingAfterIds?: ReadonlyArray<EntityId>;
|
|
915
|
+
pendingBeforeIds?: ReadonlyArray<EntityId>;
|
|
832
916
|
}> | undefined>;
|
|
833
|
-
request<R
|
|
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;
|
|
834
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;
|
|
835
950
|
private handleStoreAndNetworkRequest;
|
|
836
951
|
private getRootType;
|
|
952
|
+
private createRequestDescriptor;
|
|
953
|
+
getRequestKey(request: Request$1): string;
|
|
954
|
+
private hasRootListData;
|
|
837
955
|
private executeRequest;
|
|
838
956
|
private hasRequestData;
|
|
839
|
-
getRequestResult<R
|
|
957
|
+
getRequestResult<R extends Request$1>(request: R): RequestResult<Roots, R>;
|
|
958
|
+
private getRequestResultFromDescriptor;
|
|
840
959
|
private fetchByIdAndNormalize;
|
|
841
960
|
private fetchQueryAndNormalize;
|
|
842
961
|
private fetchListAndNormalize;
|
|
843
|
-
private resolveSelection;
|
|
844
962
|
private writeEntity;
|
|
845
963
|
private linkParentLists;
|
|
846
964
|
private readViewSelection;
|
|
847
965
|
private clearStalledRequestsForEntity;
|
|
848
966
|
private pendingPrefix;
|
|
849
967
|
private pendingKey;
|
|
968
|
+
private liveSubscriptionKey;
|
|
969
|
+
private liveConnectionSubscriptionKey;
|
|
970
|
+
private releaseLiveSubscription;
|
|
971
|
+
private reportLiveError;
|
|
850
972
|
}
|
|
851
|
-
declare function createClient<T
|
|
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]>;
|
|
852
974
|
//#endregion
|
|
853
975
|
//#region src/mutation.d.ts
|
|
854
976
|
/**
|
|
855
977
|
* Defines a mutation for a given entity type, preserving the input and output
|
|
856
978
|
* types for transports.
|
|
857
979
|
*/
|
|
858
|
-
declare function mutation<T
|
|
980
|
+
declare function mutation<T extends Entity, I, R>(entity: T['__typename']): MutationDefinition<T, I, R>;
|
|
859
981
|
/** Where (or if) to insert the resulting record into relevant lists. */
|
|
860
982
|
type InsertPosition = 'after' | 'before' | 'none';
|
|
861
983
|
/**
|
|
@@ -863,25 +985,20 @@ type InsertPosition = 'after' | 'before' | 'none';
|
|
|
863
985
|
* optional selection for the returned payload.
|
|
864
986
|
*/
|
|
865
987
|
type MutationOptions<Identifier extends MutationIdentifier<any, any, any>> = {
|
|
866
|
-
/** Optional arguments to pass to the mutation resolver. */
|
|
867
|
-
|
|
868
|
-
/** If true, deletes the record with the ID specified in the input. */
|
|
869
|
-
delete?: boolean;
|
|
870
|
-
/** Input data for the mutation. */
|
|
988
|
+
/** Optional arguments to pass to the mutation resolver. */args?: Record<string, unknown>; /** If true, deletes the record with the ID specified in the input. */
|
|
989
|
+
delete?: boolean; /** Input data for the mutation. */
|
|
871
990
|
input: Omit<MutationInput<Identifier>, 'select'>;
|
|
872
|
-
insert?: InsertPosition;
|
|
873
|
-
/** Optional
|
|
874
|
-
optimistic?: OptimisticUpdate<MutationResult<Identifier>>;
|
|
875
|
-
/** Optional view specifying which fields to select from the server. */
|
|
991
|
+
insert?: InsertPosition; /** Optional optimistic update to apply immediately. */
|
|
992
|
+
optimistic?: OptimisticUpdate<MutationResult<Identifier>>; /** Optional view specifying which fields to select from the server. */
|
|
876
993
|
view?: View<MutationEntity<Identifier>, Selection<MutationEntity<Identifier>>>;
|
|
877
994
|
};
|
|
878
995
|
/**
|
|
879
996
|
* Callable mutation entry point returned on the client that resolves to either
|
|
880
997
|
* a successful result or an error.
|
|
881
998
|
*/
|
|
882
|
-
type MutationFunction<I
|
|
999
|
+
type MutationFunction<I extends MutationIdentifier<any, any, any>> = (options: MutationOptions<I>) => Promise<{
|
|
883
1000
|
error: undefined;
|
|
884
|
-
result: MutationResult<I
|
|
1001
|
+
result: MutationResult<I>;
|
|
885
1002
|
} | {
|
|
886
1003
|
error: Error;
|
|
887
1004
|
result: undefined;
|
|
@@ -890,21 +1007,22 @@ type MutationFunction<I$1 extends MutationIdentifier<any, any, any>> = (options:
|
|
|
890
1007
|
* React action-compatible wrapper that can be passed directly to form actions
|
|
891
1008
|
* or transitions.
|
|
892
1009
|
*/
|
|
893
|
-
type MutationAction<I
|
|
1010
|
+
type MutationAction<I extends MutationIdentifier<any, any, any>> = (previousState: unknown,
|
|
894
1011
|
/**
|
|
895
1012
|
* Mutation options or 'reset' to reset the action state.
|
|
896
1013
|
*/
|
|
897
|
-
|
|
1014
|
+
|
|
1015
|
+
options: MutationOptions<I> | 'reset') => Promise<{
|
|
898
1016
|
error: undefined;
|
|
899
|
-
result: MutationResult<I
|
|
1017
|
+
result: MutationResult<I>;
|
|
900
1018
|
} | {
|
|
901
1019
|
error: Error;
|
|
902
1020
|
result: undefined;
|
|
903
1021
|
}>;
|
|
904
|
-
type MutationIdentifierFor<K
|
|
905
|
-
key: K
|
|
1022
|
+
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<{
|
|
1023
|
+
key: K;
|
|
906
1024
|
}> : never;
|
|
907
|
-
type UnionToIntersection<U
|
|
1025
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
908
1026
|
type NestedValue<Path extends string, Value> = Path extends `${infer Head}.${infer Tail}` ? { [K in Head]: NestedValue<Tail, Value> } : { [K in Path]: Value };
|
|
909
1027
|
/**
|
|
910
1028
|
* Base type for client mutations.
|
|
@@ -932,26 +1050,26 @@ declare const __FateMutationInputBrand: unique symbol;
|
|
|
932
1050
|
declare const __FateMutationResultBrand: unique symbol;
|
|
933
1051
|
declare const __FateRootResultBrand: unique symbol;
|
|
934
1052
|
declare const __FateRootTypeBrand: unique symbol;
|
|
935
|
-
type __ViewEntityAnchor<T
|
|
936
|
-
readonly [__FateEntityBrand]?: T
|
|
1053
|
+
type __ViewEntityAnchor<T extends Entity> = {
|
|
1054
|
+
readonly [__FateEntityBrand]?: T;
|
|
937
1055
|
};
|
|
938
1056
|
type __ViewSelectionAnchor<S> = {
|
|
939
1057
|
[__FateSelectionBrand]?: S;
|
|
940
1058
|
};
|
|
941
|
-
type __MutationEntityAnchor<T
|
|
942
|
-
readonly [__FateMutationEntityBrand]?: T
|
|
1059
|
+
type __MutationEntityAnchor<T extends Entity> = {
|
|
1060
|
+
readonly [__FateMutationEntityBrand]?: T;
|
|
943
1061
|
};
|
|
944
|
-
type __MutationInputAnchor<I
|
|
945
|
-
readonly [__FateMutationInputBrand]?: I
|
|
1062
|
+
type __MutationInputAnchor<I> = {
|
|
1063
|
+
readonly [__FateMutationInputBrand]?: I;
|
|
946
1064
|
};
|
|
947
|
-
type __MutationResultAnchor<R
|
|
948
|
-
readonly [__FateMutationResultBrand]?: R
|
|
1065
|
+
type __MutationResultAnchor<R> = {
|
|
1066
|
+
readonly [__FateMutationResultBrand]?: R;
|
|
949
1067
|
};
|
|
950
|
-
type __RootResultAnchor<R
|
|
951
|
-
readonly [__FateRootResultBrand]?: R
|
|
1068
|
+
type __RootResultAnchor<R> = {
|
|
1069
|
+
readonly [__FateRootResultBrand]?: R;
|
|
952
1070
|
};
|
|
953
|
-
type __RootTypeAnchor<T
|
|
954
|
-
readonly [__FateRootTypeBrand]?: T
|
|
1071
|
+
type __RootTypeAnchor<T extends TypeName> = {
|
|
1072
|
+
readonly [__FateRootTypeBrand]?: T;
|
|
955
1073
|
};
|
|
956
1074
|
/** Unique key that identifies a view composition entry inside a selection or reference. */
|
|
957
1075
|
type ViewTag = `__fate-view__${string}`;
|
|
@@ -959,18 +1077,27 @@ type ViewTag = `__fate-view__${string}`;
|
|
|
959
1077
|
declare function isViewTag(key: string): key is ViewTag;
|
|
960
1078
|
/** Alias for a loose record used throughout the fate's internals. */
|
|
961
1079
|
type AnyRecord = Record<string, unknown>;
|
|
962
|
-
type Nullish<T
|
|
963
|
-
type NonNullish<T
|
|
964
|
-
type WithNullish<T
|
|
1080
|
+
type Nullish<T> = Extract<T, null | undefined>;
|
|
1081
|
+
type NonNullish<T> = Exclude<T, null | undefined>;
|
|
1082
|
+
type WithNullish<T, R> = R | Nullish<T>;
|
|
965
1083
|
type SelectionArgs = Readonly<{
|
|
966
1084
|
args: AnyRecord;
|
|
967
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
|
+
}>;
|
|
968
1094
|
/** Metadata stored alongside connection results to power pagination and cache updates. */
|
|
969
1095
|
type ConnectionMetadata = Readonly<{
|
|
970
1096
|
args?: AnyRecord;
|
|
971
1097
|
field: string;
|
|
972
1098
|
hash?: string;
|
|
973
1099
|
key: string;
|
|
1100
|
+
live?: ConnectionLivePolicy;
|
|
974
1101
|
owner: EntityId;
|
|
975
1102
|
procedure: string;
|
|
976
1103
|
root?: boolean;
|
|
@@ -983,12 +1110,9 @@ type ViewRef<TName extends string> = Readonly<{
|
|
|
983
1110
|
[ViewsTag]: Set<string>;
|
|
984
1111
|
}>;
|
|
985
1112
|
/** Describes how a field relates to another entity for normalization. */
|
|
986
|
-
type RelationDescriptor = /** Field stores a scalar value that does not link to another type. */
|
|
987
|
-
'scalar'
|
|
988
|
-
/** Field points to a single entity of the given type. */ | {
|
|
1113
|
+
type RelationDescriptor = /** Field stores a scalar value that does not link to another type. */'scalar' /** Field points to a single entity of the given type. */ | {
|
|
989
1114
|
type: string;
|
|
990
|
-
}
|
|
991
|
-
/** Field holds a list of entities of the given type. */ | {
|
|
1115
|
+
} /** Field holds a list of entities of the given type. */ | {
|
|
992
1116
|
listOf: string;
|
|
993
1117
|
};
|
|
994
1118
|
/** Configuration for a server entity type used by the client cache. */
|
|
@@ -1017,12 +1141,13 @@ type Entity = {
|
|
|
1017
1141
|
__typename: string;
|
|
1018
1142
|
};
|
|
1019
1143
|
type PlainObjectSelectionField<V> = V extends Array<infer U> ? PlainObjectSelectionField<U> | true : V extends AnyRecord ? PlainObjectSelection<V> | true : true;
|
|
1020
|
-
type PlainObjectSelection<T
|
|
1021
|
-
type ConnectionSelectionBase<T
|
|
1144
|
+
type PlainObjectSelection<T> = { [K in keyof T]?: PlainObjectSelectionField<T[K]> };
|
|
1145
|
+
type ConnectionSelectionBase<T extends Entity> = Readonly<{
|
|
1022
1146
|
items: Readonly<{
|
|
1023
1147
|
cursor?: true;
|
|
1024
|
-
node: Selection<T
|
|
1148
|
+
node: Selection<T> | View<T, Selection<T>>;
|
|
1025
1149
|
}>;
|
|
1150
|
+
live?: ConnectionLiveSelectionPolicy;
|
|
1026
1151
|
pagination?: Readonly<{
|
|
1027
1152
|
hasNext?: true;
|
|
1028
1153
|
hasPrevious?: true;
|
|
@@ -1031,27 +1156,27 @@ type ConnectionSelectionBase<T$1 extends Entity> = Readonly<{
|
|
|
1031
1156
|
}>;
|
|
1032
1157
|
}>;
|
|
1033
1158
|
/** Selection shape for a connection-style list, including pagination metadata and optional arguments. */
|
|
1034
|
-
type ConnectionSelection<T
|
|
1035
|
-
type BaseSelectionFieldValue<T
|
|
1036
|
-
type SelectionFieldValue<T
|
|
1037
|
-
type SelectionShape<T
|
|
1159
|
+
type ConnectionSelection<T extends Entity> = ConnectionSelectionBase<T> | (SelectionArgs & ConnectionSelectionBase<T>);
|
|
1160
|
+
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
|
+
type SelectionFieldValue<T extends Entity, K extends keyof T> = BaseSelectionFieldValue<T, K> | SelectionArgs | (SelectionArgs & Extract<BaseSelectionFieldValue<T, K>, object>);
|
|
1162
|
+
type SelectionShape<T extends Entity> = { [K in keyof T as K extends '__typename' ? never : K]?: SelectionFieldValue<T, K> } & {
|
|
1038
1163
|
__typename?: true;
|
|
1039
1164
|
};
|
|
1040
|
-
type SelectionViewSpread<T
|
|
1041
|
-
select: Selection<T
|
|
1165
|
+
type SelectionViewSpread<T extends Entity> = { readonly [K in ViewTag]?: Readonly<{
|
|
1166
|
+
select: Selection<T>;
|
|
1042
1167
|
[ViewKind]: true;
|
|
1043
1168
|
}> };
|
|
1044
1169
|
/** Declarative selection of the fields a view needs from an entity. */
|
|
1045
|
-
type Selection<T
|
|
1170
|
+
type Selection<T extends Entity> = SelectionShape<T> & SelectionViewSpread<T>;
|
|
1046
1171
|
/** View payload stored on a view tag containing the raw selection used to mask data. */
|
|
1047
|
-
type ViewPayload<T
|
|
1172
|
+
type ViewPayload<T extends Entity, S extends Selection<T> = Selection<T>> = Readonly<{
|
|
1048
1173
|
select: S;
|
|
1049
1174
|
[ViewKind]: true;
|
|
1050
1175
|
}>;
|
|
1051
1176
|
/** Definition of a view over an entity type, including the selection of fields. */
|
|
1052
|
-
type View<T
|
|
1053
|
-
[viewTag: ViewTag]: ViewPayload<T
|
|
1054
|
-
}> & __ViewEntityAnchor<T
|
|
1177
|
+
type View<T extends Entity, S extends Selection<T> = Selection<T>> = Readonly<{
|
|
1178
|
+
[viewTag: ViewTag]: ViewPayload<T, S>;
|
|
1179
|
+
}> & __ViewEntityAnchor<T> & __ViewSelectionAnchor<S>;
|
|
1055
1180
|
type HasViewTag<S> = S extends { [K in ViewTag]?: infer P } ? P extends {
|
|
1056
1181
|
[ViewKind]: true;
|
|
1057
1182
|
} ? true : false : false;
|
|
@@ -1059,40 +1184,45 @@ type HasViewTag<S> = S extends { [K in ViewTag]?: infer P } ? P extends {
|
|
|
1059
1184
|
* Data returned from a resolved view with masking applied and view tags
|
|
1060
1185
|
* attached for downstream composition.
|
|
1061
1186
|
*/
|
|
1062
|
-
type ViewData<T
|
|
1187
|
+
type ViewData<T extends Entity, S extends Selection<T>> = Readonly<(S extends Selection<T> ? Mask<T, S> : T) & {
|
|
1063
1188
|
[ViewsTag]: Set<string>;
|
|
1064
1189
|
}>;
|
|
1065
1190
|
/**
|
|
1066
1191
|
* Snapshot returned by the cache for a view, including the masked data and all
|
|
1067
1192
|
* referenced entity IDs.
|
|
1068
1193
|
*/
|
|
1069
|
-
type ViewSnapshot<T
|
|
1194
|
+
type ViewSnapshot<T extends Entity, S extends Selection<T>> = Readonly<{
|
|
1070
1195
|
coverage: ReadonlyArray<readonly [id: EntityId, paths: ReadonlySet<string>]>;
|
|
1071
|
-
data: ViewData<T
|
|
1196
|
+
data: ViewData<T, S>;
|
|
1072
1197
|
}>;
|
|
1073
|
-
type
|
|
1074
|
-
items:
|
|
1075
|
-
|
|
1198
|
+
type ConnectionLikeSelection = {
|
|
1199
|
+
readonly items: {
|
|
1200
|
+
readonly node: unknown;
|
|
1201
|
+
};
|
|
1202
|
+
};
|
|
1203
|
+
type ConnectionMask<T extends Entity, S> = S extends {
|
|
1204
|
+
readonly items: infer ItemSelection;
|
|
1205
|
+
readonly pagination?: infer PaginationSelection;
|
|
1076
1206
|
} ? {
|
|
1077
1207
|
items: ItemSelection extends {
|
|
1078
|
-
cursor?: infer CursorSelection;
|
|
1079
|
-
node: unknown;
|
|
1208
|
+
readonly cursor?: infer CursorSelection;
|
|
1209
|
+
readonly node: unknown;
|
|
1080
1210
|
} ? Array<(CursorSelection extends true ? {
|
|
1081
1211
|
cursor: string;
|
|
1082
1212
|
} : Record<string, never>) & {
|
|
1083
|
-
node: ViewRef<T
|
|
1213
|
+
node: ViewRef<T['__typename']>;
|
|
1084
1214
|
}> : Array<{
|
|
1085
|
-
node: ViewRef<T
|
|
1215
|
+
node: ViewRef<T['__typename']>;
|
|
1086
1216
|
}>;
|
|
1087
1217
|
} & (PaginationSelection extends object ? {
|
|
1088
1218
|
pagination: { [K in keyof PaginationSelection]: Pagination[K & keyof Pagination] };
|
|
1089
|
-
} : Record<string, never>) : Array<T
|
|
1090
|
-
type EntityName<T
|
|
1219
|
+
} : Record<string, never>) : Array<T>;
|
|
1220
|
+
type EntityName<T> = T extends {
|
|
1091
1221
|
__typename: infer N extends string;
|
|
1092
1222
|
} ? N : never;
|
|
1093
1223
|
/** Recursively applies a view selection to an entity to mask fields that aren't selected. */
|
|
1094
|
-
type MaskNonNullish<T
|
|
1095
|
-
type Mask<T
|
|
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;
|
|
1225
|
+
type Mask<T, S> = WithNullish<T, MaskNonNullish<NonNullish<T>, S>>;
|
|
1096
1226
|
/** Entity type captured from a view definition. */
|
|
1097
1227
|
type ViewEntity<V> = V extends View<infer T, any> ? T : never;
|
|
1098
1228
|
/** Name of the entity type captured from a view definition. */
|
|
@@ -1140,7 +1270,7 @@ type ConnectionNodeType<Root> = Root extends {
|
|
|
1140
1270
|
node?: infer Node;
|
|
1141
1271
|
};
|
|
1142
1272
|
} ? ViewEntityName<Node & View<any, any>> : never;
|
|
1143
|
-
type ListResult<Item extends AnyRequestItem, Type extends TypeName, Result
|
|
1273
|
+
type ListResult<Item extends AnyRequestItem, Type extends TypeName, Result> = Item extends AnyNodeItem ? ViewRef<Type> : Item extends AnyNodesItem ? Array<ViewRef<Type>> : Item extends AnyQueryItem ? Result extends null ? ViewRef<Type> | null : ViewRef<Type> : Item extends AnyListItem ? Item['list'] extends {
|
|
1144
1274
|
items?: {
|
|
1145
1275
|
node?: View<any, any>;
|
|
1146
1276
|
};
|
|
@@ -1155,28 +1285,28 @@ type ListResult<Item extends AnyRequestItem, Type extends TypeName, Result$1> =
|
|
|
1155
1285
|
* The result of a `FateClient.request` and `useRequest` call, mapping each
|
|
1156
1286
|
* request key to its corresponding result.
|
|
1157
1287
|
*/
|
|
1158
|
-
type RequestResult<R
|
|
1288
|
+
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 };
|
|
1159
1289
|
/** Brand used on root definitions to mark their identity in the d.ts output. */
|
|
1160
1290
|
declare const RootKind = "__fate__root";
|
|
1161
1291
|
/** Brand used on mutation definitions to mark their identity in the d.ts output. */
|
|
1162
1292
|
declare const MutationKind = "__fate__mutation";
|
|
1163
1293
|
/** Metadata describing a root query for a particular entity and result shape. */
|
|
1164
|
-
type RootDefinition<Type extends TypeName, Result
|
|
1294
|
+
type RootDefinition<Type extends TypeName, Result> = Readonly<{
|
|
1165
1295
|
[RootKind]: true;
|
|
1166
1296
|
type: Type;
|
|
1167
|
-
}> & __RootResultAnchor<Result
|
|
1297
|
+
}> & __RootResultAnchor<Result> & __RootTypeAnchor<Type>;
|
|
1168
1298
|
/** Minimal root description used for typing root maps. */
|
|
1169
1299
|
type FateRoots = Record<string, RootDefinition<TypeName, unknown>>;
|
|
1170
1300
|
/** Extracts the entity type name from a root definition. */
|
|
1171
|
-
type RootType<R
|
|
1301
|
+
type RootType<R> = R extends __RootTypeAnchor<infer T> ? T : never;
|
|
1172
1302
|
/** Extracts the result type from a root definition. */
|
|
1173
|
-
type RootResult<R
|
|
1303
|
+
type RootResult<R> = R extends __RootResultAnchor<infer Data> ? Data : never;
|
|
1174
1304
|
/** Metadata describing a mutation for a particular entity, input, and output. */
|
|
1175
|
-
type MutationDefinition<T
|
|
1176
|
-
entity: T
|
|
1305
|
+
type MutationDefinition<T extends Entity, I, R> = Readonly<{
|
|
1306
|
+
entity: T['__typename'];
|
|
1177
1307
|
[MutationKind]: true;
|
|
1178
|
-
}> & __MutationEntityAnchor<T
|
|
1179
|
-
type MutationIdentifier<T
|
|
1308
|
+
}> & __MutationEntityAnchor<T> & __MutationInputAnchor<I> & __MutationResultAnchor<R>;
|
|
1309
|
+
type MutationIdentifier<T extends Entity, I, R> = MutationDefinition<T, I, R> & Readonly<{
|
|
1180
1310
|
key: string;
|
|
1181
1311
|
}>;
|
|
1182
1312
|
/** Extracts the input type from a mutation definition or identifier. */
|
|
@@ -1198,18 +1328,18 @@ type MutationMapFromDefinitions<D extends FateMutations> = { [K in keyof D]: {
|
|
|
1198
1328
|
input: MutationInput<D[K]>;
|
|
1199
1329
|
output: MutationResult<D[K]>;
|
|
1200
1330
|
} };
|
|
1201
|
-
type OptimisticUpdateValue<T
|
|
1331
|
+
type OptimisticUpdateValue<T> = T extends ReadonlyArray<infer U> ? Array<OptimisticUpdateValue<U>> : NonNullish<T> extends AnyRecord ? OptimisticUpdate<NonNullish<T>> | Nullish<T> : NonNullish<T> | Nullish<T>;
|
|
1202
1332
|
/** Shape used to describe optimistic updates for mutations. */
|
|
1203
|
-
type OptimisticUpdate<T
|
|
1333
|
+
type OptimisticUpdate<T> = { [K in keyof T]?: OptimisticUpdateValue<T[K]> };
|
|
1204
1334
|
/** Snapshot captured before mutating the cache, used to roll back on errors. */
|
|
1205
1335
|
type Snapshot = Readonly<{
|
|
1206
1336
|
mask?: FieldMask;
|
|
1207
1337
|
record?: AnyRecord;
|
|
1208
1338
|
}>;
|
|
1209
1339
|
/** Promise-like value returned by cache reads that already have a resolved payload for React `use`. */
|
|
1210
|
-
interface FateThenable<T
|
|
1340
|
+
interface FateThenable<T> extends PromiseLike<T> {
|
|
1211
1341
|
status: 'fulfilled';
|
|
1212
|
-
value: T
|
|
1342
|
+
value: T;
|
|
1213
1343
|
}
|
|
1214
1344
|
//#endregion
|
|
1215
|
-
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 };
|