@nkzw/fate 0.1.1 → 0.1.3

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.
@@ -0,0 +1,1193 @@
1
+ import { TRPCClient } from "@trpc/client";
2
+
3
+ //#region src/mask.d.ts
4
+ type FieldMask = {
5
+ all: boolean;
6
+ children: Map<string, FieldMask>;
7
+ };
8
+ //#endregion
9
+ //#region src/selection.d.ts
10
+ /**
11
+ * Representation of a composed selection including hashed args and the
12
+ * flat set of field paths to read or fetch.
13
+ */
14
+ type SelectionPlan = {
15
+ readonly args: Map<string, Readonly<{
16
+ hash: string;
17
+ ignoreKeys?: ReadonlySet<string>;
18
+ value: AnyRecord;
19
+ }>>;
20
+ readonly paths: Set<string>;
21
+ };
22
+ /**
23
+ * Flattens a view into a `SelectionPlan`, expanding composed views and
24
+ * partitioning nested args so the client can fetch exactly what is declared.
25
+ */
26
+ declare const getSelectionPlan: <T extends Entity, S extends Selection<T>, V extends View<T, S>>(viewComposition: V, ref: ViewRef<T["__typename"]> | null) => SelectionPlan;
27
+ //#endregion
28
+ //#region src/cache.d.ts
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
73
+ //#region src/observable/types.d.ts
74
+ interface Unsubscribable {
75
+ unsubscribe(): void;
76
+ }
77
+ interface Subscribable<TValue, TError> {
78
+ subscribe(observer: Partial<Observer<TValue, TError>>): Unsubscribable;
79
+ }
80
+ interface Observable<TValue, TError> extends Subscribable<TValue, TError> {
81
+ pipe(): Observable<TValue, TError>;
82
+ pipe<TValue1, TError1>(op1: OperatorFunction<TValue, TError, TValue1, TError1>): Observable<TValue1, TError1>;
83
+ pipe<TValue1, TError1, TValue2, TError2>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>): Observable<TValue2, TError2>;
84
+ 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>;
85
+ 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>;
86
+ 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
+ }
88
+ interface Observer<TValue, TError> {
89
+ next: (value: TValue) => void;
90
+ error: (err: TError) => void;
91
+ complete: () => void;
92
+ }
93
+ type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
94
+ type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
95
+ //#endregion
96
+ //#region ../../node_modules/.pnpm/@trpc+server@11.8.1_typescript@5.9.3/node_modules/@trpc/server/dist/unstable-core-do-not-import.d-CjQPvBRI.d.mts
97
+ /**
98
+ * @public
99
+ */
100
+ type MaybePromise<TType> = Promise<TType> | TType;
101
+ /**
102
+ * @internal
103
+ * Returns the raw input type of a procedure
104
+ */
105
+ type GetRawInputFn = () => Promise<unknown>;
106
+ type ValueOf<TObj> = TObj[keyof TObj];
107
+ //#endregion
108
+ //#region src/unstable-core-do-not-import/rpc/codes.d.ts
109
+ /**
110
+ * JSON-RPC 2.0 Error codes
111
+ *
112
+ * `-32000` to `-32099` are reserved for implementation-defined server-errors.
113
+ * For tRPC we're copying the last digits of HTTP 4XX errors.
114
+ */
115
+ declare const TRPC_ERROR_CODES_BY_KEY: {
116
+ /**
117
+ * Invalid JSON was received by the server.
118
+ * An error occurred on the server while parsing the JSON text.
119
+ */
120
+ readonly PARSE_ERROR: -32700;
121
+ /**
122
+ * The JSON sent is not a valid Request object.
123
+ */
124
+ readonly BAD_REQUEST: -32600;
125
+ readonly INTERNAL_SERVER_ERROR: -32603;
126
+ readonly NOT_IMPLEMENTED: -32603;
127
+ readonly BAD_GATEWAY: -32603;
128
+ readonly SERVICE_UNAVAILABLE: -32603;
129
+ readonly GATEWAY_TIMEOUT: -32603;
130
+ readonly UNAUTHORIZED: -32001;
131
+ readonly PAYMENT_REQUIRED: -32002;
132
+ readonly FORBIDDEN: -32003;
133
+ readonly NOT_FOUND: -32004;
134
+ readonly METHOD_NOT_SUPPORTED: -32005;
135
+ readonly TIMEOUT: -32008;
136
+ readonly CONFLICT: -32009;
137
+ readonly PRECONDITION_FAILED: -32012;
138
+ readonly PAYLOAD_TOO_LARGE: -32013;
139
+ readonly UNSUPPORTED_MEDIA_TYPE: -32015;
140
+ readonly UNPROCESSABLE_CONTENT: -32022;
141
+ readonly PRECONDITION_REQUIRED: -32028;
142
+ readonly TOO_MANY_REQUESTS: -32029;
143
+ readonly CLIENT_CLOSED_REQUEST: -32099;
144
+ };
145
+ type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
146
+ type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
147
+ /**
148
+ * tRPC error codes that are considered retryable
149
+ * With out of the box SSE, the client will reconnect when these errors are encountered
150
+ */
151
+ declare class TRPCError extends Error {
152
+ readonly cause?: Error;
153
+ 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";
154
+ constructor(opts: {
155
+ message?: string;
156
+ code: TRPC_ERROR_CODE_KEY;
157
+ cause?: unknown;
158
+ });
159
+ } //# sourceMappingURL=TRPCError.d.ts.map
160
+ //#endregion
161
+ //#region src/vendor/standard-schema-v1/spec.d.ts
162
+ /**
163
+ *
164
+ * @see https://github.com/standard-schema/standard-schema/blob/main/packages/spec/src/index.ts
165
+ */
166
+ /** The Standard Schema interface. */
167
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
168
+ /** The Standard Schema properties. */
169
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>;
170
+ }
171
+ declare namespace StandardSchemaV1 {
172
+ /** The Standard Schema properties interface. */
173
+ interface Props<Input = unknown, Output = Input> {
174
+ /** The version number of the standard. */
175
+ readonly version: 1;
176
+ /** The vendor name of the schema library. */
177
+ readonly vendor: string;
178
+ /** Validates unknown input values. */
179
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
180
+ /** Inferred types associated with the schema. */
181
+ readonly types?: Types<Input, Output> | undefined;
182
+ }
183
+ /** The result interface of the validate function. */
184
+ type Result<Output> = SuccessResult<Output> | FailureResult;
185
+ /** The result interface if validation succeeds. */
186
+ interface SuccessResult<Output> {
187
+ /** The typed output value. */
188
+ readonly value: Output;
189
+ /** The non-existent issues. */
190
+ readonly issues?: undefined;
191
+ }
192
+ /** The result interface if validation fails. */
193
+ interface FailureResult {
194
+ /** The issues of failed validation. */
195
+ readonly issues: ReadonlyArray<Issue>;
196
+ }
197
+ /** The issue interface of the failure output. */
198
+ interface Issue {
199
+ /** The error message of the issue. */
200
+ readonly message: string;
201
+ /** The path of the issue, if any. */
202
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
203
+ }
204
+ /** The path segment interface of the issue. */
205
+ interface PathSegment {
206
+ /** The key representing a path segment. */
207
+ readonly key: PropertyKey;
208
+ }
209
+ /** The Standard Schema types interface. */
210
+ interface Types<Input = unknown, Output = Input> {
211
+ /** The input type of the schema. */
212
+ readonly input: Input;
213
+ /** The output type of the schema. */
214
+ readonly output: Output;
215
+ }
216
+ /** Infers the input type of a Standard Schema. */
217
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
218
+ /** Infers the output type of a Standard Schema. */
219
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
220
+ } //# sourceMappingURL=spec.d.ts.map
221
+ //#endregion
222
+ //#region src/unstable-core-do-not-import/parser.d.ts
223
+ type ParserZodEsque<TInput, TParsedInput> = {
224
+ _input: TInput;
225
+ _output: TParsedInput;
226
+ };
227
+ type ParserValibotEsque<TInput, TParsedInput> = {
228
+ schema: {
229
+ _types?: {
230
+ input: TInput;
231
+ output: TParsedInput;
232
+ };
233
+ };
234
+ };
235
+ type ParserArkTypeEsque<TInput, TParsedInput> = {
236
+ inferIn: TInput;
237
+ infer: TParsedInput;
238
+ };
239
+ type ParserStandardSchemaEsque<TInput, TParsedInput> = StandardSchemaV1<TInput, TParsedInput>;
240
+ type ParserMyZodEsque<TInput> = {
241
+ parse: (input: any) => TInput;
242
+ };
243
+ type ParserSuperstructEsque<TInput> = {
244
+ create: (input: unknown) => TInput;
245
+ };
246
+ type ParserCustomValidatorEsque<TInput> = (input: unknown) => Promise<TInput> | TInput;
247
+ type ParserYupEsque<TInput> = {
248
+ validateSync: (input: unknown) => TInput;
249
+ };
250
+ type ParserScaleEsque<TInput> = {
251
+ assert(value: unknown): asserts value is TInput;
252
+ };
253
+ type ParserWithoutInput<TInput> = ParserCustomValidatorEsque<TInput> | ParserMyZodEsque<TInput> | ParserScaleEsque<TInput> | ParserSuperstructEsque<TInput> | ParserYupEsque<TInput>;
254
+ type ParserWithInputOutput<TInput, TParsedInput> = ParserZodEsque<TInput, TParsedInput> | ParserValibotEsque<TInput, TParsedInput> | ParserArkTypeEsque<TInput, TParsedInput> | ParserStandardSchemaEsque<TInput, TParsedInput>;
255
+ type Parser = ParserWithInputOutput<any, any> | ParserWithoutInput<any>;
256
+ /**
257
+ * @internal
258
+ */
259
+ interface ProcedureCallOptions<TContext> {
260
+ ctx: TContext;
261
+ getRawInput: GetRawInputFn;
262
+ input?: unknown;
263
+ path: string;
264
+ type: ProcedureType;
265
+ signal: AbortSignal | undefined;
266
+ } //#endregion
267
+ //#region src/unstable-core-do-not-import/procedure.d.ts
268
+ declare const procedureTypes: readonly ["query", "mutation", "subscription"];
269
+ /**
270
+ * @public
271
+ */
272
+ type ProcedureType = (typeof procedureTypes)[number];
273
+ interface BuiltProcedureDef {
274
+ meta: unknown;
275
+ input: unknown;
276
+ output: unknown;
277
+ }
278
+ /**
279
+ *
280
+ * @internal
281
+ */
282
+ interface Procedure<TType extends ProcedureType, TDef extends BuiltProcedureDef> {
283
+ _def: {
284
+ /**
285
+ * These are just types, they can't be used at runtime
286
+ * @internal
287
+ */
288
+ $types: {
289
+ input: TDef['input'];
290
+ output: TDef['output'];
291
+ };
292
+ procedure: true;
293
+ type: TType;
294
+ /**
295
+ * @internal
296
+ * Meta is not inferrable on individual procedures, only on the router
297
+ */
298
+ meta: unknown;
299
+ experimental_caller: boolean;
300
+ /**
301
+ * The input parsers for the procedure
302
+ */
303
+ inputs: Parser[];
304
+ };
305
+ meta: TDef['meta'];
306
+ /**
307
+ * @internal
308
+ */
309
+ (opts: ProcedureCallOptions<unknown>): Promise<TDef['output']>;
310
+ }
311
+ interface QueryProcedure<TDef extends BuiltProcedureDef> extends Procedure<'query', TDef> {}
312
+ interface MutationProcedure<TDef extends BuiltProcedureDef> extends Procedure<'mutation', TDef> {}
313
+ interface SubscriptionProcedure<TDef extends BuiltProcedureDef> extends Procedure<'subscription', TDef> {}
314
+ /**
315
+ * @deprecated
316
+ */
317
+ interface LegacyObservableSubscriptionProcedure<TDef extends BuiltProcedureDef> extends SubscriptionProcedure<TDef> {
318
+ _observable: true;
319
+ }
320
+ type AnyQueryProcedure = QueryProcedure<any>;
321
+ type AnyMutationProcedure = MutationProcedure<any>;
322
+ type AnySubscriptionProcedure = SubscriptionProcedure<any> | LegacyObservableSubscriptionProcedure<any>;
323
+ type AnyProcedure = AnyQueryProcedure | AnyMutationProcedure | AnySubscriptionProcedure;
324
+ type inferProcedureInput<TProcedure extends AnyProcedure> = undefined extends inferProcedureParams<TProcedure>['$types']['input'] ? void | inferProcedureParams<TProcedure>['$types']['input'] : inferProcedureParams<TProcedure>['$types']['input'];
325
+ type inferProcedureParams<TProcedure> = TProcedure extends AnyProcedure ? TProcedure['_def'] : never;
326
+ type inferProcedureOutput<TProcedure> = inferProcedureParams<TProcedure>['$types']['output'];
327
+ /**
328
+ * @internal
329
+ */
330
+ interface ErrorHandlerOptions<TContext> {
331
+ error: TRPCError;
332
+ type: ProcedureType | 'unknown';
333
+ path: string | undefined;
334
+ input: unknown;
335
+ ctx: TContext | undefined;
336
+ } //#endregion
337
+ //#region src/unstable-core-do-not-import/http/types.d.ts
338
+ /**
339
+ * @deprecated use `Headers` instead, this will be removed in v12
340
+ */
341
+ //#endregion
342
+ //#region src/unstable-core-do-not-import/rpc/envelopes.d.ts
343
+ /**
344
+ * Error response
345
+ */
346
+ interface TRPCErrorShape<TData extends object = object> {
347
+ code: TRPC_ERROR_CODE_NUMBER;
348
+ message: string;
349
+ data: TData;
350
+ }
351
+ /**
352
+ * JSON-RPC 2.0 Specification
353
+ */
354
+ //# sourceMappingURL=envelopes.d.ts.map
355
+ //#endregion
356
+ //#region src/unstable-core-do-not-import/transformer.d.ts
357
+ /**
358
+ * @public
359
+ */
360
+ interface DataTransformer {
361
+ serialize(object: any): any;
362
+ deserialize(object: any): any;
363
+ }
364
+ interface InputDataTransformer extends DataTransformer {
365
+ /**
366
+ * This function runs **on the client** before sending the data to the server.
367
+ */
368
+ serialize(object: any): any;
369
+ /**
370
+ * This function runs **on the server** to transform the data before it is passed to the resolver
371
+ */
372
+ deserialize(object: any): any;
373
+ }
374
+ interface OutputDataTransformer extends DataTransformer {
375
+ /**
376
+ * This function runs **on the server** before sending the data to the client.
377
+ */
378
+ serialize(object: any): any;
379
+ /**
380
+ * This function runs **only on the client** to transform the data sent from the server.
381
+ */
382
+ deserialize(object: any): any;
383
+ }
384
+ /**
385
+ * @public
386
+ */
387
+ interface CombinedDataTransformer {
388
+ /**
389
+ * Specify how the data sent from the client to the server should be transformed.
390
+ */
391
+ input: InputDataTransformer;
392
+ /**
393
+ * Specify how the data sent from the server to the client should be transformed.
394
+ */
395
+ output: OutputDataTransformer;
396
+ }
397
+ /**
398
+ * @public
399
+ */
400
+ //# sourceMappingURL=parseTRPCMessage.d.ts.map
401
+ //#endregion
402
+ //#region src/unstable-core-do-not-import/error/formatter.d.ts
403
+ /**
404
+ * @internal
405
+ */
406
+ type ErrorFormatter<TContext, TShape extends TRPCErrorShape> = (opts: {
407
+ error: TRPCError;
408
+ type: ProcedureType | 'unknown';
409
+ path: string | undefined;
410
+ input: unknown;
411
+ ctx: TContext | undefined;
412
+ shape: DefaultErrorShape;
413
+ }) => TShape;
414
+ /**
415
+ * @internal
416
+ */
417
+ type DefaultErrorData = {
418
+ code: TRPC_ERROR_CODE_KEY;
419
+ httpStatus: number;
420
+ /**
421
+ * Path to the procedure that threw the error
422
+ */
423
+ path?: string;
424
+ /**
425
+ * Stack trace of the error (only in development)
426
+ */
427
+ stack?: string;
428
+ };
429
+ /**
430
+ * @internal
431
+ */
432
+ interface DefaultErrorShape extends TRPCErrorShape<DefaultErrorData> {
433
+ message: string;
434
+ code: TRPC_ERROR_CODE_NUMBER;
435
+ }
436
+ type Serialize$2 = (value: any) => any;
437
+ type PathArray = readonly (string | number)[];
438
+ type ProducerOnError = (opts: {
439
+ error: unknown;
440
+ path: PathArray;
441
+ }) => void;
442
+ interface JSONLProducerOptions {
443
+ serialize?: Serialize$2;
444
+ data: Record<string, unknown> | unknown[];
445
+ onError?: ProducerOnError;
446
+ formatError?: (opts: {
447
+ error: unknown;
448
+ path: PathArray;
449
+ }) => unknown;
450
+ maxDepth?: number;
451
+ /**
452
+ * Interval in milliseconds to send a ping to the client to keep the connection alive
453
+ * This will be sent as a whitespace character
454
+ * @default undefined
455
+ */
456
+ pingMs?: number;
457
+ }
458
+ /**
459
+ * JSON Lines stream producer
460
+ * @see https://jsonlines.org/
461
+ */
462
+ //# sourceMappingURL=sse.types.d.ts.map
463
+ //#endregion
464
+ //#region src/unstable-core-do-not-import/stream/sse.d.ts
465
+ type Serialize$1 = (value: any) => any;
466
+ /**
467
+ * @internal
468
+ */
469
+ interface SSEPingOptions {
470
+ /**
471
+ * Enable ping comments sent from the server
472
+ * @default false
473
+ */
474
+ enabled: boolean;
475
+ /**
476
+ * Interval in milliseconds
477
+ * @default 1000
478
+ */
479
+ intervalMs?: number;
480
+ }
481
+ interface SSEClientOptions {
482
+ /**
483
+ * Timeout and reconnect after inactivity in milliseconds
484
+ * @default undefined
485
+ */
486
+ reconnectAfterInactivityMs?: number;
487
+ }
488
+ interface SSEStreamProducerOptions<TValue = unknown> {
489
+ serialize?: Serialize$1;
490
+ data: AsyncIterable<TValue>;
491
+ maxDepth?: number;
492
+ ping?: SSEPingOptions;
493
+ /**
494
+ * Maximum duration in milliseconds for the request before ending the stream
495
+ * @default undefined
496
+ */
497
+ maxDurationMs?: number;
498
+ /**
499
+ * End the request immediately after data is sent
500
+ * Only useful for serverless runtimes that do not support streaming responses
501
+ * @default false
502
+ */
503
+ emitAndEndImmediately?: boolean;
504
+ formatError?: (opts: {
505
+ error: unknown;
506
+ }) => unknown;
507
+ /**
508
+ * Client-specific options - these will be sent to the client as part of the first message
509
+ * @default {}
510
+ */
511
+ client?: SSEClientOptions;
512
+ }
513
+ /**
514
+ *
515
+ * @see https://html.spec.whatwg.org/multipage/server-sent-events.html
516
+ */
517
+ //#endregion
518
+ //#region src/unstable-core-do-not-import/rootConfig.d.ts
519
+ /**
520
+ * The initial generics that are used in the init function
521
+ * @internal
522
+ */
523
+ interface RootTypes {
524
+ ctx: object;
525
+ meta: object;
526
+ errorShape: DefaultErrorShape;
527
+ transformer: boolean;
528
+ }
529
+ /**
530
+ * The default check to see if we're in a server
531
+ */
532
+ /**
533
+ * The tRPC root config
534
+ * @internal
535
+ */
536
+ interface RootConfig<TTypes extends RootTypes> {
537
+ /**
538
+ * The types that are used in the config
539
+ * @internal
540
+ */
541
+ $types: TTypes;
542
+ /**
543
+ * Use a data transformer
544
+ * @see https://trpc.io/docs/v11/data-transformers
545
+ */
546
+ transformer: CombinedDataTransformer;
547
+ /**
548
+ * Use custom error formatting
549
+ * @see https://trpc.io/docs/v11/error-formatting
550
+ */
551
+ errorFormatter: ErrorFormatter<TTypes['ctx'], TTypes['errorShape']>;
552
+ /**
553
+ * Allow `@trpc/server` to run in non-server environments
554
+ * @warning **Use with caution**, this should likely mainly be used within testing.
555
+ * @default false
556
+ */
557
+ allowOutsideOfServer: boolean;
558
+ /**
559
+ * Is this a server environment?
560
+ * @warning **Use with caution**, this should likely mainly be used within testing.
561
+ * @default typeof window === 'undefined' || 'Deno' in window || process.env.NODE_ENV === 'test'
562
+ */
563
+ isServer: boolean;
564
+ /**
565
+ * Is this development?
566
+ * Will be used to decide if the API should return stack traces
567
+ * @default process.env.NODE_ENV !== 'production'
568
+ */
569
+ isDev: boolean;
570
+ defaultMeta?: TTypes['meta'] extends object ? TTypes['meta'] : never;
571
+ /**
572
+ * Options for server-sent events (SSE) subscriptions
573
+ * @see https://trpc.io/docs/client/links/httpSubscriptionLink
574
+ */
575
+ sse?: {
576
+ /**
577
+ * Enable server-sent events (SSE) subscriptions
578
+ * @default true
579
+ */
580
+ enabled?: boolean;
581
+ } & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs' | 'client'>;
582
+ /**
583
+ * Options for batch stream
584
+ * @see https://trpc.io/docs/client/links/httpBatchStreamLink
585
+ */
586
+ jsonl?: Pick<JSONLProducerOptions, 'pingMs'>;
587
+ experimental?: {};
588
+ }
589
+ /**
590
+ * @internal
591
+ */
592
+ type CreateRootTypes<TGenerics extends RootTypes> = TGenerics;
593
+ type AnyRootTypes = CreateRootTypes<{
594
+ ctx: any;
595
+ meta: any;
596
+ errorShape: any;
597
+ transformer: any;
598
+ }>;
599
+ //#endregion
600
+ //#region src/unstable-core-do-not-import/router.d.ts
601
+ interface RouterRecord {
602
+ [key: string]: AnyProcedure | RouterRecord;
603
+ }
604
+ type DecorateProcedure<TProcedure extends AnyProcedure> = (input: inferProcedureInput<TProcedure>) => Promise<TProcedure['_def']['type'] extends 'subscription' ? TProcedure extends LegacyObservableSubscriptionProcedure<any> ? Observable<inferProcedureOutput<TProcedure>, TRPCError> : inferProcedureOutput<TProcedure> : inferProcedureOutput<TProcedure>>;
605
+ /**
606
+ * @internal
607
+ */
608
+ type DecorateRouterRecord<TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends AnyProcedure ? DecorateProcedure<$Value> : $Value extends RouterRecord ? DecorateRouterRecord<$Value> : never : never };
609
+ /**
610
+ * @internal
611
+ */
612
+ type RouterCallerErrorHandler<TContext> = (opts: ErrorHandlerOptions<TContext>) => void;
613
+ /**
614
+ * @internal
615
+ */
616
+ type RouterCaller<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = (
617
+ /**
618
+ * @note
619
+ * If passing a function, we recommend it's a cached function
620
+ * e.g. wrapped in `React.cache` to avoid unnecessary computations
621
+ */
622
+
623
+ ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>), options?: {
624
+ onError?: RouterCallerErrorHandler<TRoot['ctx']>;
625
+ signal?: AbortSignal;
626
+ }) => DecorateRouterRecord<TRecord>;
627
+ type Lazy<TAny> = (() => Promise<TAny>) & {};
628
+ type LazyLoader<TAny> = {
629
+ load: () => Promise<void>;
630
+ ref: Lazy<TAny>;
631
+ };
632
+ /**
633
+ * Lazy load a router
634
+ * @see https://trpc.io/docs/server/merging-routers#lazy-load
635
+ */
636
+ /**
637
+ * @internal
638
+ */
639
+ interface RouterDef<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
640
+ _config: RootConfig<TRoot>;
641
+ router: true;
642
+ procedure?: never;
643
+ procedures: TRecord;
644
+ record: TRecord;
645
+ lazy: Record<string, LazyLoader<AnyRouter>>;
646
+ }
647
+ interface Router<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
648
+ _def: RouterDef<TRoot, TRecord>;
649
+ /**
650
+ * @see https://trpc.io/docs/v11/server/server-side-calls
651
+ */
652
+ createCaller: RouterCaller<TRoot, TRecord>;
653
+ }
654
+ type AnyRouter = Router<any, any>;
655
+ //#endregion
656
+ //#region src/transport.d.ts
657
+ /**
658
+ * Normalized representation of args passed to a transport.
659
+ */
660
+ type ResolvedArgsPayload = AnyRecord;
661
+ type TransportMutations = Record<string, MutationShape>;
662
+ type EmptyTransportMutations = Record<never, MutationShape>;
663
+ type Bivariant<Fn extends (...args: Array<any>) => any> = {
664
+ bivarianceHack: Fn;
665
+ }['bivarianceHack'];
666
+ /**
667
+ * Contract the fate client expects from a network transport. The transport is
668
+ * responsible for fetching records by ID, fetching lists, and executing
669
+ * mutations with the provided selections.
670
+ */
671
+ interface Transport<Mutations extends TransportMutations = EmptyTransportMutations> {
672
+ fetchById(type: string, ids: Array<string | number>, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<Array<unknown>>;
673
+ fetchList?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<{
674
+ items: Array<{
675
+ cursor: string | undefined;
676
+ node: unknown;
677
+ }>;
678
+ pagination: Pagination;
679
+ }>;
680
+ fetchQuery?(proc: string, select: Iterable<string>, args?: ResolvedArgsPayload): Promise<unknown>;
681
+ mutate?<K extends Extract<keyof Mutations, string>>(proc: K, input: Mutations[K]['input'], select: Set<string>): Promise<Mutations[K]['output']>;
682
+ }
683
+ /**
684
+ * Mapping of entity type to tRPC procedures used for fetching entities by ID.
685
+ */
686
+ type TRPCByIdResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => (input: {
687
+ args?: ResolvedArgsPayload;
688
+ ids: Array<string | number>;
689
+ select: Array<string>;
690
+ }) => Promise<Array<unknown>>>;
691
+ /**
692
+ * Mapping of list procedure name to a tRPC resolver factory.
693
+ */
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
+ }>>>;
701
+ /**
702
+ * Mapping of query procedure name to a tRPC resolver factory.
703
+ */
704
+ type TRPCQueryResolvers<AppRouter extends AnyRouter> = Record<string, (client: TRPCClient<AppRouter>) => (input: {
705
+ args?: ResolvedArgsPayload;
706
+ select: Array<string>;
707
+ }) => Promise<unknown>>;
708
+ /**
709
+ * Mapping of a mutation procedure name to a tRPC resolver factory.
710
+ */
711
+ type MutationResolver<AppRouter extends AnyRouter> = (client: TRPCClient<AppRouter>) => (input: any) => Promise<any>;
712
+ type TRPCMutationResolvers<AppRouter extends AnyRouter> = Record<string, MutationResolver<AppRouter>>;
713
+ type MutationMapFromResolvers<R extends Record<string, MutationResolver<any>>> = { [K in keyof R]: R[K] extends ((client: any) => (input: infer Input) => Promise<infer Output>) ? {
714
+ input: Input;
715
+ output: Output;
716
+ } : never };
717
+ type EmptyMutationResolvers<AppRouter extends AnyRouter> = Record<never, MutationResolver<AppRouter>>;
718
+ /**
719
+ * Builds a `Transport` backed by a tRPC client using the configured resolvers
720
+ * for by-id queries, lists, and mutations.
721
+ */
722
+ declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations extends TRPCMutationResolvers<AppRouter> = EmptyMutationResolvers<AppRouter>>({
723
+ byId,
724
+ client,
725
+ lists,
726
+ mutations,
727
+ queries
728
+ }: {
729
+ byId: TRPCByIdResolvers<AppRouter>;
730
+ client: TRPCClient<AppRouter>;
731
+ lists?: TRPCListResolvers<AppRouter>;
732
+ mutations?: Mutations;
733
+ queries?: TRPCQueryResolvers<AppRouter>;
734
+ }): Transport<MutationMapFromResolvers<Mutations>>;
735
+ //#endregion
736
+ //#region src/client.d.ts
737
+ /**
738
+ * Strategy used when resolving a request.
739
+ */
740
+ 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';
741
+ /**
742
+ * Request options that affect how requests are fetched and retained.
743
+ */
744
+ type RequestOptions = Readonly<{
745
+ mode?: RequestMode;
746
+ }>;
747
+ type FateClientOptions<Roots extends FateRoots, Mutations extends FateMutations> = {
748
+ mutations?: Mutations;
749
+ roots: Roots;
750
+ transport: Transport<MutationMapFromDefinitions<Mutations>>;
751
+ types: ReadonlyArray<Omit<TypeConfig, 'getId'> & Partial<{
752
+ getId: TypeConfig['getId'];
753
+ }>>;
754
+ };
755
+ /**
756
+ * Core client that normalizes records, manages the view cache, and coordinates
757
+ * data fetching.
758
+ */
759
+ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutations> {
760
+ private readonly mutationMap;
761
+ private readonly parentLists;
762
+ private readonly rootLists;
763
+ private readonly pending;
764
+ private readonly pendingOptimisticMutations;
765
+ private readonly optimisticMasks;
766
+ private readonly optimisticByEntity;
767
+ private readonly optimisticEntityResolutions;
768
+ private optimisticTokenCounter;
769
+ private readonly requests;
770
+ private readonly rootRequests;
771
+ private readonly stalledRequests;
772
+ readonly store: Store;
773
+ private readonly types;
774
+ private readonly transport;
775
+ private readonly viewDataCache;
776
+ readonly actions: MutationActionsFor<Mutations>;
777
+ readonly mutations: MutationFunctionsFor<Mutations>;
778
+ readonly roots: Roots;
779
+ constructor(options: FateClientOptions<Roots, Mutations>);
780
+ private initializeParentLists;
781
+ private registerRootList;
782
+ private insertIntoRootLists;
783
+ getTypeConfig(type: string): TypeConfig;
784
+ executeMutation(key: string, input: unknown, select: Set<string>, options?: {
785
+ args?: AnyRecord;
786
+ plan?: SelectionPlan;
787
+ }): 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;
789
+ deleteRecord(type: string, id: string | number, snapshots?: Map<EntityId, Snapshot>, listSnapshots?: Map<string, List>): void;
790
+ restore(id: EntityId, snapshot: Snapshot): void;
791
+ restoreList(name: string, list?: List): void;
792
+ ref<T extends Entity>(type: T['__typename'], id: string | number, view: View<T, Selection<T>>): ViewRef<T['__typename']>;
793
+ rootListRef(entityId: EntityId, rootView: View<any, any>): Readonly<{
794
+ __typename: string;
795
+ id: string | number;
796
+ [ViewsTag]: Set<string>;
797
+ }>;
798
+ readView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>>;
799
+ private mergeListState;
800
+ registerPendingOptimisticMutation(entityId: EntityId, promise: Promise<unknown>): void;
801
+ resolveOptimisticEntity(optimisticEntityId: EntityId, resolvedEntityId: EntityId): void;
802
+ registerOptimisticUpdate(entityId: EntityId | null, select: ReadonlySet<string>): number | null;
803
+ clearOptimisticUpdate(token: number | null): void;
804
+ getPendingOptimisticMask(entityId: EntityId | null, options?: {
805
+ excludeToken?: number | null;
806
+ }): FieldMask | null;
807
+ private getPendingOptimisticMutations;
808
+ filterSelectionForPendingOptimistics(entityId: EntityId | null, select: Set<string>, options?: {
809
+ excludeToken?: number | null;
810
+ }): Set<string>;
811
+ loadConnection<V extends View<any, any>>(view: V, connection: ConnectionMetadata, args: Record<string, unknown>, options?: {
812
+ direction?: 'forward' | 'backward';
813
+ }): Promise<Readonly<{
814
+ cursors?: ReadonlyArray<string | undefined>;
815
+ ids: ReadonlyArray<EntityId>;
816
+ pagination?: Pagination;
817
+ }> | undefined>;
818
+ request<R extends Request$1>(request: R, options?: RequestOptions): Promise<RequestResult<Roots, R>>;
819
+ releaseRequest(request: Request$1, mode: RequestMode): void;
820
+ private handleStoreAndNetworkRequest;
821
+ private getRootType;
822
+ private executeRequest;
823
+ private hasRequestData;
824
+ getRequestResult<R extends Request$1>(request: R): RequestResult<Roots, R>;
825
+ private fetchByIdAndNormalize;
826
+ private fetchQueryAndNormalize;
827
+ private fetchListAndNormalize;
828
+ private resolveSelection;
829
+ private writeEntity;
830
+ private linkParentLists;
831
+ private readViewSelection;
832
+ private clearStalledRequestsForEntity;
833
+ private pendingPrefix;
834
+ private pendingKey;
835
+ }
836
+ 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
+ //#endregion
838
+ //#region src/mutation.d.ts
839
+ /**
840
+ * Defines a mutation for a given entity type, preserving the input and output
841
+ * types for transports.
842
+ */
843
+ declare function mutation<T extends Entity, I, R>(entity: T['__typename']): MutationDefinition<T, I, R>;
844
+ /** Where (or if) to insert the resulting record into relevant lists. */
845
+ type InsertPosition = 'after' | 'before' | 'none';
846
+ /**
847
+ * Options accepted by a mutation invocation, including optimistic updates and
848
+ * optional selection for the returned payload.
849
+ */
850
+ type MutationOptions<Identifier extends MutationIdentifier<any, any, any>> = {
851
+ /** Optional arguments to pass to the mutation resolver. */args?: Record<string, unknown>; /** If true, deletes the record with the ID specified in the input. */
852
+ delete?: boolean; /** Input data for the mutation. */
853
+ input: Omit<MutationInput<Identifier>, 'select'>;
854
+ insert?: InsertPosition; /** Optional optimistic update to apply immediately. */
855
+ optimistic?: OptimisticUpdate<MutationResult<Identifier>>; /** Optional view specifying which fields to select from the server. */
856
+ view?: View<MutationEntity<Identifier>, Selection<MutationEntity<Identifier>>>;
857
+ };
858
+ /**
859
+ * Callable mutation entry point returned on the client that resolves to either
860
+ * a successful result or an error.
861
+ */
862
+ type MutationFunction<I extends MutationIdentifier<any, any, any>> = (options: MutationOptions<I>) => Promise<{
863
+ error: undefined;
864
+ result: MutationResult<I>;
865
+ } | {
866
+ error: Error;
867
+ result: undefined;
868
+ }>;
869
+ /**
870
+ * React action-compatible wrapper that can be passed directly to form actions
871
+ * or transitions.
872
+ */
873
+ type MutationAction<I extends MutationIdentifier<any, any, any>> = (previousState: unknown,
874
+ /**
875
+ * Mutation options or 'reset' to reset the action state.
876
+ */
877
+
878
+ options: MutationOptions<I> | 'reset') => Promise<{
879
+ error: undefined;
880
+ result: MutationResult<I>;
881
+ } | {
882
+ error: Error;
883
+ result: undefined;
884
+ }>;
885
+ 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<{
886
+ key: K;
887
+ }> : never;
888
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
889
+ type NestedValue<Path extends string, Value> = Path extends `${infer Head}.${infer Tail}` ? { [K in Head]: NestedValue<Tail, Value> } : { [K in Path]: Value };
890
+ /**
891
+ * Base type for client mutations.
892
+ */
893
+ type FateMutations = Record<string, MutationDefinition<any, any, any>>;
894
+ type MutationTreeFromRecord<Mutations extends FateMutations, ValueMap extends Record<string, unknown>> = [keyof Mutations] extends [never] ? object : UnionToIntersection<{ [K in keyof Mutations & string]: NestedValue<K, ValueMap[K]> }[keyof Mutations & string]>;
895
+ type MutationFunctionsFor<Mutations extends FateMutations> = MutationTreeFromRecord<Mutations, { [K in keyof Mutations & string]: MutationFunction<MutationIdentifierFor<K, Mutations[K]>> }>;
896
+ type MutationActionsFor<Mutations extends FateMutations> = MutationTreeFromRecord<Mutations, { [K in keyof Mutations & string]: MutationAction<MutationIdentifierFor<K, Mutations[K]>> }>;
897
+ //#endregion
898
+ //#region src/types.d.ts
899
+ /** Canonical runtime name for an entity type as returned by the server. */
900
+ type TypeName = string;
901
+ /** Globally unique identifier for an entity in the normalized cache (`<TypeName>:<id>` format). */
902
+ type EntityId = string;
903
+ /** Internal marker added to objects that represent a view payload. */
904
+ declare const ViewKind: unique symbol;
905
+ /** Symbol used to attach the set of view tags that were spread into a ref or masked record. */
906
+ declare const ViewsTag: unique symbol;
907
+ /** Symbol attached to connection results so pagination helpers can find their metadata. */
908
+ declare const ConnectionTag: unique symbol;
909
+ declare const __FateEntityBrand: unique symbol;
910
+ declare const __FateSelectionBrand: unique symbol;
911
+ declare const __FateMutationEntityBrand: unique symbol;
912
+ declare const __FateMutationInputBrand: unique symbol;
913
+ declare const __FateMutationResultBrand: unique symbol;
914
+ declare const __FateRootResultBrand: unique symbol;
915
+ declare const __FateRootTypeBrand: unique symbol;
916
+ type __ViewEntityAnchor<T extends Entity> = {
917
+ readonly [__FateEntityBrand]?: T;
918
+ };
919
+ type __ViewSelectionAnchor<S> = {
920
+ [__FateSelectionBrand]?: S;
921
+ };
922
+ type __MutationEntityAnchor<T extends Entity> = {
923
+ readonly [__FateMutationEntityBrand]?: T;
924
+ };
925
+ type __MutationInputAnchor<I> = {
926
+ readonly [__FateMutationInputBrand]?: I;
927
+ };
928
+ type __MutationResultAnchor<R> = {
929
+ readonly [__FateMutationResultBrand]?: R;
930
+ };
931
+ type __RootResultAnchor<R> = {
932
+ readonly [__FateRootResultBrand]?: R;
933
+ };
934
+ type __RootTypeAnchor<T extends TypeName> = {
935
+ readonly [__FateRootTypeBrand]?: T;
936
+ };
937
+ /** Unique key that identifies a view composition entry inside a selection or reference. */
938
+ type ViewTag = `__fate-view__${string}`;
939
+ /** Determines whether a property key is a fate view tag. */
940
+ declare function isViewTag(key: string): key is ViewTag;
941
+ /** Alias for a loose record used throughout the fate's internals. */
942
+ type AnyRecord = Record<string, unknown>;
943
+ type Nullish<T> = Extract<T, null | undefined>;
944
+ type NonNullish<T> = Exclude<T, null | undefined>;
945
+ type WithNullish<T, R> = R | Nullish<T>;
946
+ type SelectionArgs = Readonly<{
947
+ args: AnyRecord;
948
+ }>;
949
+ /** Metadata stored alongside connection results to power pagination and cache updates. */
950
+ type ConnectionMetadata = Readonly<{
951
+ args?: AnyRecord;
952
+ field: string;
953
+ hash?: string;
954
+ key: string;
955
+ owner: EntityId;
956
+ procedure: string;
957
+ root?: boolean;
958
+ type: string;
959
+ }>;
960
+ /** Reference to a normalized entity instance that can be resolved against one or more view tags. */
961
+ type ViewRef<TName extends string> = Readonly<{
962
+ __typename: TName;
963
+ id: string | number;
964
+ [ViewsTag]: Set<string>;
965
+ }>;
966
+ /** Describes how a field relates to another entity for normalization. */
967
+ 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. */ | {
968
+ type: string;
969
+ } /** Field holds a list of entities of the given type. */ | {
970
+ listOf: string;
971
+ };
972
+ /** Configuration for a server entity type used by the client cache. */
973
+ type TypeConfig = {
974
+ fields?: Record<string, RelationDescriptor>;
975
+ getId: (record: unknown) => string | number;
976
+ type: string;
977
+ };
978
+ /** Pagination state returned alongside connection lists. */
979
+ type Pagination = {
980
+ hasNext: boolean;
981
+ hasPrevious: boolean;
982
+ nextCursor?: string;
983
+ previousCursor?: string;
984
+ };
985
+ /** Ref for a connection, including pagination metadata. */
986
+ type ConnectionRef<TName extends string> = Readonly<{
987
+ items: ReadonlyArray<{
988
+ cursor?: string;
989
+ node: ViewRef<TName>;
990
+ }>;
991
+ pagination?: Pagination;
992
+ }>;
993
+ /** Base shape shared by all entities fetched by fate. */
994
+ type Entity = {
995
+ __typename: string;
996
+ };
997
+ type PlainObjectSelectionField<V> = V extends Array<infer U> ? PlainObjectSelectionField<U> | true : V extends AnyRecord ? PlainObjectSelection<V> | true : true;
998
+ type PlainObjectSelection<T> = { [K in keyof T]?: PlainObjectSelectionField<T[K]> };
999
+ type ConnectionSelectionBase<T extends Entity> = Readonly<{
1000
+ items: Readonly<{
1001
+ cursor?: true;
1002
+ node: Selection<T> | View<T, Selection<T>>;
1003
+ }>;
1004
+ pagination?: Readonly<{
1005
+ hasNext?: true;
1006
+ hasPrevious?: true;
1007
+ nextCursor?: true;
1008
+ previousCursor?: true;
1009
+ }>;
1010
+ }>;
1011
+ /** Selection shape for a connection-style list, including pagination metadata and optional arguments. */
1012
+ type ConnectionSelection<T extends Entity> = ConnectionSelectionBase<T> | (SelectionArgs & ConnectionSelectionBase<T>);
1013
+ 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;
1014
+ type SelectionFieldValue<T extends Entity, K extends keyof T> = BaseSelectionFieldValue<T, K> | SelectionArgs | (SelectionArgs & Extract<BaseSelectionFieldValue<T, K>, object>);
1015
+ type SelectionShape<T extends Entity> = { [K in keyof T as K extends '__typename' ? never : K]?: SelectionFieldValue<T, K> } & {
1016
+ __typename?: true;
1017
+ };
1018
+ type SelectionViewSpread<T extends Entity> = { readonly [K in ViewTag]?: Readonly<{
1019
+ select: Selection<T>;
1020
+ [ViewKind]: true;
1021
+ }> };
1022
+ /** Declarative selection of the fields a view needs from an entity. */
1023
+ type Selection<T extends Entity> = SelectionShape<T> & SelectionViewSpread<T>;
1024
+ /** View payload stored on a view tag containing the raw selection used to mask data. */
1025
+ type ViewPayload<T extends Entity, S extends Selection<T> = Selection<T>> = Readonly<{
1026
+ select: S;
1027
+ [ViewKind]: true;
1028
+ }>;
1029
+ /** Definition of a view over an entity type, including the selection of fields. */
1030
+ type View<T extends Entity, S extends Selection<T> = Selection<T>> = Readonly<{
1031
+ [viewTag: ViewTag]: ViewPayload<T, S>;
1032
+ }> & __ViewEntityAnchor<T> & __ViewSelectionAnchor<S>;
1033
+ type HasViewTag<S> = S extends { [K in ViewTag]?: infer P } ? P extends {
1034
+ [ViewKind]: true;
1035
+ } ? true : false : false;
1036
+ /**
1037
+ * Data returned from a resolved view with masking applied and view tags
1038
+ * attached for downstream composition.
1039
+ */
1040
+ type ViewData<T extends Entity, S extends Selection<T>> = Readonly<(S extends Selection<T> ? Mask<T, S> : T) & {
1041
+ [ViewsTag]: Set<string>;
1042
+ }>;
1043
+ /**
1044
+ * Snapshot returned by the cache for a view, including the masked data and all
1045
+ * referenced entity IDs.
1046
+ */
1047
+ type ViewSnapshot<T extends Entity, S extends Selection<T>> = Readonly<{
1048
+ coverage: ReadonlyArray<readonly [id: EntityId, paths: ReadonlySet<string>]>;
1049
+ data: ViewData<T, S>;
1050
+ }>;
1051
+ type ConnectionMask<T extends Entity, S> = S extends {
1052
+ items: infer ItemSelection;
1053
+ pagination?: infer PaginationSelection;
1054
+ } ? {
1055
+ items: ItemSelection extends {
1056
+ cursor?: infer CursorSelection;
1057
+ node: unknown;
1058
+ } ? Array<(CursorSelection extends true ? {
1059
+ cursor: string;
1060
+ } : Record<string, never>) & {
1061
+ node: ViewRef<T['__typename']>;
1062
+ }> : Array<{
1063
+ node: ViewRef<T['__typename']>;
1064
+ }>;
1065
+ } & (PaginationSelection extends object ? {
1066
+ pagination: { [K in keyof PaginationSelection]: Pagination[K & keyof Pagination] };
1067
+ } : Record<string, never>) : Array<T>;
1068
+ type EntityName<T> = T extends {
1069
+ __typename: infer N extends string;
1070
+ } ? N : never;
1071
+ /** 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 ConnectionSelection<U> ? 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
+ type Mask<T, S> = WithNullish<T, MaskNonNullish<NonNullish<T>, S>>;
1074
+ /** Entity type captured from a view definition. */
1075
+ type ViewEntity<V> = V extends View<infer T, any> ? T : never;
1076
+ /** Name of the entity type captured from a view definition. */
1077
+ type ViewEntityName<V> = ViewEntity<V>['__typename'] & string;
1078
+ /** Selection captured from a view definition. */
1079
+ type ViewSelection<V> = V extends {
1080
+ readonly [__FateSelectionBrand]?: infer S;
1081
+ } ? S : never;
1082
+ /** Definition of a list request for fetching data from the backend. */
1083
+ type ListItem<V extends View<any, any>> = Readonly<{
1084
+ args?: Record<string, unknown>;
1085
+ list: V;
1086
+ }>;
1087
+ /** Definition of a root-level query request. */
1088
+ type QueryItem<V extends View<any, any>> = Readonly<{
1089
+ args?: Record<string, unknown>;
1090
+ view: V;
1091
+ }>;
1092
+ /** Definition of a node request with one explicit ID for fetching data from the backend. */
1093
+ type NodeItem<V extends View<any, any>> = Readonly<{
1094
+ id: string | number;
1095
+ view: V;
1096
+ }>;
1097
+ /** Definition of a node request with explicit IDs for fetching data from the backend. */
1098
+ type NodesItem<V extends View<any, any>> = Readonly<{
1099
+ ids: ReadonlyArray<string | number>;
1100
+ view: V;
1101
+ }>;
1102
+ type RequestItem = ListItem<View<any, any>> | NodeItem<View<any, any>> | NodesItem<View<any, any>> | QueryItem<View<any, any>>;
1103
+ /** Collection of node and list requests describing the data a screen needs. */
1104
+ type Request$1 = Record<string, RequestItem>;
1105
+ type AnyView = View<any, any>;
1106
+ type AnyListItem = ListItem<AnyView>;
1107
+ type AnyQueryItem = QueryItem<AnyView>;
1108
+ type AnyNodeItem = NodeItem<AnyView>;
1109
+ type AnyNodesItem = NodesItem<AnyView>;
1110
+ type AnyRequestItem = AnyListItem | AnyNodeItem | AnyNodesItem | AnyQueryItem;
1111
+ type AnyRequest = Record<string, AnyRequestItem>;
1112
+ /**
1113
+ * Typed result returned by `useRequest` and `FateClient.request`, mapping each
1114
+ * request key to an array of view refs for the requested type.
1115
+ */
1116
+ type ConnectionNodeType<Root> = Root extends {
1117
+ items?: {
1118
+ node?: infer Node;
1119
+ };
1120
+ } ? ViewEntityName<Node & View<any, any>> : never;
1121
+ 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 {
1122
+ items?: {
1123
+ node?: View<any, any>;
1124
+ };
1125
+ } ? Readonly<{
1126
+ items: ReadonlyArray<{
1127
+ cursor?: string | undefined;
1128
+ node: ViewRef<ConnectionNodeType<Item['list']>>;
1129
+ }>;
1130
+ pagination?: Pagination;
1131
+ }> : Array<ViewRef<Type>> : never;
1132
+ /**
1133
+ * The result of a `FateClient.request` and `useRequest` call, mapping each
1134
+ * request key to its corresponding result.
1135
+ */
1136
+ 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 };
1137
+ /** Brand used on root definitions to mark their identity in the d.ts output. */
1138
+ declare const RootKind = "__fate__root";
1139
+ /** Brand used on mutation definitions to mark their identity in the d.ts output. */
1140
+ declare const MutationKind = "__fate__mutation";
1141
+ /** Metadata describing a root query for a particular entity and result shape. */
1142
+ type RootDefinition<Type extends TypeName, Result> = Readonly<{
1143
+ [RootKind]: true;
1144
+ type: Type;
1145
+ }> & __RootResultAnchor<Result> & __RootTypeAnchor<Type>;
1146
+ /** Minimal root description used for typing root maps. */
1147
+ type FateRoots = Record<string, RootDefinition<TypeName, unknown>>;
1148
+ /** Extracts the entity type name from a root definition. */
1149
+ type RootType<R> = R extends __RootTypeAnchor<infer T> ? T : never;
1150
+ /** Extracts the result type from a root definition. */
1151
+ type RootResult<R> = R extends __RootResultAnchor<infer Data> ? Data : never;
1152
+ /** Metadata describing a mutation for a particular entity, input, and output. */
1153
+ type MutationDefinition<T extends Entity, I, R> = Readonly<{
1154
+ entity: T['__typename'];
1155
+ [MutationKind]: true;
1156
+ }> & __MutationEntityAnchor<T> & __MutationInputAnchor<I> & __MutationResultAnchor<R>;
1157
+ type MutationIdentifier<T extends Entity, I, R> = MutationDefinition<T, I, R> & Readonly<{
1158
+ key: string;
1159
+ }>;
1160
+ /** Extracts the input type from a mutation definition or identifier. */
1161
+ type MutationInput<M> = M extends __MutationInputAnchor<infer I> ? I : never;
1162
+ /** Extracts the result type from a mutation definition or identifier. */
1163
+ type MutationResult<M> = M extends __MutationResultAnchor<infer R> ? R : never;
1164
+ /** Extracts the entity type from a mutation definition or identifier. */
1165
+ type MutationEntity<M> = M extends __MutationEntityAnchor<infer E> ? E : never;
1166
+ /** Minimal mutation description used for transport typing. */
1167
+ type MutationShape = {
1168
+ input: unknown;
1169
+ output: unknown;
1170
+ };
1171
+ /**
1172
+ * Convenience helper that maps mutation definitions to their input/output
1173
+ * shapes for use by transports.
1174
+ */
1175
+ type MutationMapFromDefinitions<D extends FateMutations> = { [K in keyof D]: {
1176
+ input: MutationInput<D[K]>;
1177
+ output: MutationResult<D[K]>;
1178
+ } };
1179
+ type OptimisticUpdateValue<T> = T extends ReadonlyArray<infer U> ? Array<OptimisticUpdateValue<U>> : NonNullish<T> extends AnyRecord ? OptimisticUpdate<NonNullish<T>> | Nullish<T> : NonNullish<T> | Nullish<T>;
1180
+ /** Shape used to describe optimistic updates for mutations. */
1181
+ type OptimisticUpdate<T> = { [K in keyof T]?: OptimisticUpdateValue<T[K]> };
1182
+ /** Snapshot captured before mutating the cache, used to roll back on errors. */
1183
+ type Snapshot = Readonly<{
1184
+ mask?: FieldMask;
1185
+ record?: AnyRecord;
1186
+ }>;
1187
+ /** Promise-like value returned by cache reads that already have a resolved payload for React `use`. */
1188
+ interface FateThenable<T> extends PromiseLike<T> {
1189
+ status: 'fulfilled';
1190
+ value: T;
1191
+ }
1192
+ //#endregion
1193
+ export { ViewSelection as A, RequestOptions as B, TypeConfig as C, ViewEntity as D, ViewData as E, isViewTag as F, getSelectionPlan as G, Transport as H, FateMutations as I, mutation as L, ViewTag as M, __FateEntityBrand as N, ViewEntityName as O, __FateSelectionBrand as P, FateClient as R, Snapshot as S, View as T, createTRPCTransport as U, createClient as V, QueryProcedure as W, Pagination as _, Entity as a, RootDefinition as b, FateThenable as c, MutationDefinition as d, MutationEntity as f, NodesItem as g, MutationResult as h, ConnectionTag as i, ViewSnapshot as j, ViewRef as k, ListItem as l, MutationInput as m, ConnectionMetadata as n, EntityId as o, MutationIdentifier as p, ConnectionRef as r, FateRoots as s, AnyRecord as t, Mask as u, Request$1 as v, TypeName as w, Selection as x, RequestResult as y, RequestMode as z };