@trpc/server 11.19.0 → 11.21.1-canary.20.10e2ef98f
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/adapters/aws-lambda/index.d.ts +1 -0
- package/adapters/aws-lambda/index.js +1 -0
- package/adapters/express/index.d.ts +1 -0
- package/adapters/express/index.js +1 -0
- package/adapters/fastify/index.d.ts +1 -0
- package/adapters/fastify/index.js +1 -0
- package/adapters/fetch/index.d.ts +1 -0
- package/adapters/fetch/index.js +1 -0
- package/adapters/next/index.d.ts +1 -0
- package/adapters/next/index.js +1 -0
- package/adapters/next-app-dir/index.d.ts +1 -0
- package/adapters/next-app-dir/index.js +1 -0
- package/adapters/node-http/content-type/form-data/index.d.ts +1 -0
- package/adapters/node-http/content-type/form-data/index.js +1 -0
- package/adapters/node-http/content-type/json/index.d.ts +1 -0
- package/adapters/node-http/content-type/json/index.js +1 -0
- package/adapters/node-http/index.d.ts +1 -0
- package/adapters/node-http/index.js +1 -0
- package/adapters/standalone/index.d.ts +1 -0
- package/adapters/standalone/index.js +1 -0
- package/adapters/ws/index.d.ts +1 -0
- package/adapters/ws/index.js +1 -0
- package/dist/adapters/aws-lambda/index.cjs +2 -2
- package/dist/adapters/aws-lambda/index.d.cts +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +1 -1
- package/dist/adapters/aws-lambda/index.mjs +2 -2
- package/dist/adapters/express.cjs +3 -3
- package/dist/adapters/express.d.cts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.mjs +3 -3
- package/dist/adapters/fastify/index.cjs +4 -4
- package/dist/adapters/fastify/index.d.cts +2 -2
- package/dist/adapters/fastify/index.d.mts +2 -2
- package/dist/adapters/fastify/index.mjs +4 -4
- package/dist/adapters/fetch/index.cjs +2 -2
- package/dist/adapters/fetch/index.d.cts +1 -1
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/next-app-dir.cjs +7 -7
- package/dist/adapters/next-app-dir.d.cts +1 -1
- package/dist/adapters/next-app-dir.d.mts +1 -1
- package/dist/adapters/next-app-dir.mjs +2 -2
- package/dist/adapters/next.cjs +5 -5
- package/dist/adapters/next.d.cts +2 -2
- package/dist/adapters/next.d.mts +2 -2
- package/dist/adapters/next.mjs +4 -4
- package/dist/adapters/node-http/index.cjs +1 -1
- package/dist/adapters/node-http/index.d.cts +1 -1
- package/dist/adapters/node-http/index.d.mts +1 -1
- package/dist/adapters/node-http/index.mjs +1 -1
- package/dist/adapters/standalone.cjs +3 -3
- package/dist/adapters/standalone.d.cts +2 -2
- package/dist/adapters/standalone.d.mts +2 -2
- package/dist/adapters/standalone.mjs +3 -3
- package/dist/adapters/ws.cjs +1 -1
- package/dist/adapters/ws.d.cts +2 -2
- package/dist/adapters/ws.d.mts +2 -2
- package/dist/adapters/ws.mjs +1 -1
- package/dist/{tracked-BQJb0ANk.cjs → asyncGeneratorDelegate-D2tFgl_z.cjs} +167 -17
- package/dist/{tracked-D4jU_Hb3.mjs → asyncGeneratorDelegate-mPyp1u6d.mjs} +141 -9
- package/dist/asyncGeneratorDelegate-mPyp1u6d.mjs.map +1 -0
- package/dist/{codes-C6ZIq69A.cjs → codes-BwD4QurF.cjs} +9 -0
- package/dist/{codes-D5Ya6_Bi.mjs → codes-D6C_OiJy.mjs} +5 -2
- package/dist/codes-D6C_OiJy.mjs.map +1 -0
- package/dist/{getErrorShape-B0JBUs-i.mjs → getErrorShape-BziUKLM_.mjs} +52 -14
- package/dist/getErrorShape-BziUKLM_.mjs.map +1 -0
- package/dist/{getErrorShape-DeIapApr.cjs → getErrorShape-CVxLwJgN.cjs} +80 -12
- package/dist/http.cjs +2 -2
- package/dist/http.d.cts +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +2 -2
- package/dist/{index-_jAhoJQ7.d.mts → index-BDZDS1SD.d.mts} +2 -2
- package/dist/{index-BHatz_Pu.d.cts.map → index-BDZDS1SD.d.mts.map} +1 -1
- package/dist/{index-BHatz_Pu.d.cts → index-BzKrDvzg.d.cts} +2 -2
- package/dist/{index-_jAhoJQ7.d.mts.map → index-BzKrDvzg.d.cts.map} +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{initTRPC-B7UdX-c3.cjs → initTRPC-DLNeKv0z.cjs} +114 -26
- package/dist/{initTRPC-B259os3T.mjs → initTRPC-DpOypWK_.mjs} +95 -19
- package/dist/initTRPC-DpOypWK_.mjs.map +1 -0
- package/dist/{node-http-BUlb5EdB.mjs → node-http-B_z10Yky.mjs} +5 -5
- package/dist/{node-http-BUlb5EdB.mjs.map → node-http-B_z10Yky.mjs.map} +1 -1
- package/dist/{node-http-CikCqjt6.cjs → node-http-Bti3aBT6.cjs} +9 -9
- package/dist/{parseTRPCMessage-MJWDg1vX.mjs → parseTRPCMessage-CSh-CVPr.mjs} +2 -2
- package/dist/{parseTRPCMessage-MJWDg1vX.mjs.map → parseTRPCMessage-CSh-CVPr.mjs.map} +1 -1
- package/dist/{parseTRPCMessage-BxAIUx49.cjs → parseTRPCMessage-RJS87G_t.cjs} +1 -1
- package/dist/{resolveResponse-JtMyT9TQ.mjs → resolveResponse-CrB_9MSD.mjs} +43 -179
- package/dist/resolveResponse-CrB_9MSD.mjs.map +1 -0
- package/dist/{resolveResponse-DLpzHrPG.cjs → resolveResponse-D5JAuwvU.cjs} +90 -226
- package/dist/rpc.cjs +2 -2
- package/dist/rpc.d.cts +1 -1
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.mjs +2 -2
- package/dist/shared.cjs +1 -1
- package/dist/shared.d.cts +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/{unstable-core-do-not-import-BK_OKrtM.d.mts → unstable-core-do-not-import-JE3NCpqt.d.mts} +707 -636
- package/dist/unstable-core-do-not-import-JE3NCpqt.d.mts.map +1 -0
- package/dist/{unstable-core-do-not-import-B9ZnrQAU.d.cts → unstable-core-do-not-import-Jynlfuqc.d.cts} +707 -636
- package/dist/unstable-core-do-not-import-Jynlfuqc.d.cts.map +1 -0
- package/dist/unstable-core-do-not-import.cjs +30 -23
- package/dist/unstable-core-do-not-import.d.cts +2 -2
- package/dist/unstable-core-do-not-import.d.mts +2 -2
- package/dist/unstable-core-do-not-import.mjs +7 -7
- package/dist/{ws-BMSSVFiW.cjs → ws-BgBeYgGS.cjs} +22 -22
- package/dist/{ws-C7ZOJJeA.mjs → ws-CNjkWAs9.mjs} +7 -7
- package/dist/{ws-C7ZOJJeA.mjs.map → ws-CNjkWAs9.mjs.map} +1 -1
- package/http/index.d.ts +1 -0
- package/http/index.js +1 -0
- package/observable/index.d.ts +1 -0
- package/observable/index.js +1 -0
- package/package.json +14 -14
- package/rpc/index.d.ts +1 -0
- package/rpc/index.js +1 -0
- package/shared/index.d.ts +1 -0
- package/shared/index.js +1 -0
- package/src/@trpc/server/index.ts +1 -0
- package/src/unstable-core-do-not-import/clientish/inference.ts +12 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +90 -3
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +8 -17
- package/src/unstable-core-do-not-import/initTRPC.ts +10 -7
- package/src/unstable-core-do-not-import/middleware.ts +93 -2
- package/src/unstable-core-do-not-import/procedure.ts +2 -0
- package/src/unstable-core-do-not-import/procedureBuilder.ts +79 -13
- package/src/unstable-core-do-not-import/rootConfig.ts +8 -0
- package/src/unstable-core-do-not-import/stream/jsonl.ts +41 -33
- package/src/unstable-core-do-not-import/utils.ts +4 -0
- package/unstable-core-do-not-import/index.d.ts +1 -0
- package/unstable-core-do-not-import/index.js +1 -0
- package/dist/codes-D5Ya6_Bi.mjs.map +0 -1
- package/dist/getErrorShape-B0JBUs-i.mjs.map +0 -1
- package/dist/initTRPC-B259os3T.mjs.map +0 -1
- package/dist/resolveResponse-JtMyT9TQ.mjs.map +0 -1
- package/dist/tracked-D4jU_Hb3.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-B9ZnrQAU.d.cts.map +0 -1
- package/dist/unstable-core-do-not-import-BK_OKrtM.d.mts.map +0 -1
|
@@ -279,112 +279,96 @@ type inferParser<TParser extends Parser> = TParser extends ParserStandardSchemaE
|
|
|
279
279
|
type ParseFn<TType> = (value: unknown) => Promise<TType> | TType;
|
|
280
280
|
declare function getParseFn<TType>(procedureParser: Parser): ParseFn<TType>;
|
|
281
281
|
//#endregion
|
|
282
|
-
//#region src/unstable-core-do-not-import/
|
|
283
|
-
/**
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
//#region src/unstable-core-do-not-import/stream/jsonl.d.ts
|
|
283
|
+
/**
|
|
284
|
+
* A subset of the standard ReadableStream properties needed by tRPC internally.
|
|
285
|
+
* @see ReadableStream from lib.dom.d.ts
|
|
286
|
+
*/
|
|
287
|
+
type WebReadableStreamEsque = {
|
|
288
|
+
getReader: () => ReadableStreamDefaultReader<Uint8Array>;
|
|
286
289
|
};
|
|
287
|
-
type
|
|
288
|
-
|
|
290
|
+
type NodeJSReadableStreamEsque = {
|
|
291
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): NodeJSReadableStreamEsque;
|
|
292
|
+
};
|
|
293
|
+
declare function isPromise(value: unknown): value is Promise<unknown>;
|
|
294
|
+
type Serialize$2 = (value: any) => any;
|
|
295
|
+
type Deserialize$1 = (value: any) => any;
|
|
296
|
+
type PathArray = readonly (string | number)[];
|
|
297
|
+
type ProducerOnError = (opts: {
|
|
298
|
+
error: unknown;
|
|
299
|
+
path: PathArray;
|
|
300
|
+
}) => void;
|
|
301
|
+
interface JSONLProducerOptions {
|
|
302
|
+
serialize?: Serialize$2;
|
|
303
|
+
data: Record<string, unknown> | unknown[];
|
|
304
|
+
onError?: ProducerOnError;
|
|
305
|
+
formatError?: (opts: {
|
|
306
|
+
error: unknown;
|
|
307
|
+
path: PathArray;
|
|
308
|
+
}) => unknown;
|
|
309
|
+
maxDepth?: number;
|
|
289
310
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
311
|
+
* Interval in milliseconds to send a ping to the client to keep the connection alive
|
|
312
|
+
* This will be sent as a whitespace character
|
|
313
|
+
* @default undefined
|
|
292
314
|
*/
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
interface MiddlewareOKResult<_TContextOverride> extends MiddlewareResultBase {
|
|
296
|
-
ok: true;
|
|
297
|
-
data: unknown;
|
|
298
|
-
}
|
|
299
|
-
interface MiddlewareErrorResult<_TContextOverride> extends MiddlewareResultBase {
|
|
300
|
-
ok: false;
|
|
301
|
-
error: TRPCError;
|
|
315
|
+
pingMs?: number;
|
|
302
316
|
}
|
|
303
317
|
/**
|
|
304
|
-
*
|
|
318
|
+
* JSON Lines stream producer
|
|
319
|
+
* @see https://jsonlines.org/
|
|
305
320
|
*/
|
|
306
|
-
|
|
321
|
+
declare function jsonlStreamProducer(opts: JSONLProducerOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
322
|
+
type ConsumerOnError = (opts: {
|
|
323
|
+
error: unknown;
|
|
324
|
+
}) => void;
|
|
307
325
|
/**
|
|
308
|
-
*
|
|
326
|
+
* JSON Lines stream consumer
|
|
327
|
+
* @see https://jsonlines.org/
|
|
309
328
|
*/
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
329
|
+
declare function jsonlStreamConsumer<THead>(opts: {
|
|
330
|
+
from: NodeJSReadableStreamEsque | WebReadableStreamEsque;
|
|
331
|
+
deserialize?: Deserialize$1;
|
|
332
|
+
onError?: ConsumerOnError;
|
|
333
|
+
formatError?: (opts: {
|
|
334
|
+
error: unknown;
|
|
335
|
+
}) => Error;
|
|
315
336
|
/**
|
|
316
|
-
*
|
|
337
|
+
* This `AbortController` will be triggered when there are no more listeners to the stream.
|
|
317
338
|
*/
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
*/
|
|
323
|
-
type MiddlewareFunction<TContext, TMeta, TContextOverridesIn, $ContextOverridesOut, TInputOut> = {
|
|
324
|
-
(opts: {
|
|
325
|
-
ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;
|
|
326
|
-
type: ProcedureType;
|
|
327
|
-
path: string;
|
|
328
|
-
input: TInputOut;
|
|
329
|
-
getRawInput: GetRawInputFn;
|
|
330
|
-
meta: TMeta | undefined;
|
|
331
|
-
signal: AbortSignal | undefined;
|
|
332
|
-
/**
|
|
333
|
-
* The index of this call in a batch request.
|
|
334
|
-
*/
|
|
335
|
-
batchIndex: number;
|
|
336
|
-
next: {
|
|
337
|
-
(): Promise<MiddlewareResult<TContextOverridesIn>>;
|
|
338
|
-
<$ContextOverride>(opts: {
|
|
339
|
-
ctx?: $ContextOverride;
|
|
340
|
-
input?: unknown;
|
|
341
|
-
}): Promise<MiddlewareResult<$ContextOverride>>;
|
|
342
|
-
(opts: {
|
|
343
|
-
getRawInput: GetRawInputFn;
|
|
344
|
-
}): Promise<MiddlewareResult<TContextOverridesIn>>;
|
|
345
|
-
};
|
|
346
|
-
}): Promise<MiddlewareResult<$ContextOverridesOut>>;
|
|
347
|
-
_type?: string | undefined;
|
|
348
|
-
};
|
|
349
|
-
type AnyMiddlewareFunction = MiddlewareFunction<any, any, any, any, any>;
|
|
350
|
-
type AnyMiddlewareBuilder = MiddlewareBuilder<any, any, any, any>;
|
|
351
|
-
/**
|
|
352
|
-
* @internal
|
|
353
|
-
*/
|
|
354
|
-
declare function createMiddlewareFactory<TContext, TMeta, TInputOut = unknown>(): <$ContextOverrides>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, TInputOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverrides, TInputOut>;
|
|
355
|
-
/**
|
|
356
|
-
* Create a standalone middleware
|
|
357
|
-
* @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
358
|
-
* @deprecated use `.concat()` instead
|
|
359
|
-
*/
|
|
360
|
-
declare const experimental_standaloneMiddleware: <TCtx extends {
|
|
361
|
-
ctx?: object;
|
|
362
|
-
meta?: object;
|
|
363
|
-
input?: unknown;
|
|
364
|
-
}>() => {
|
|
365
|
-
create: <$ContextOverrides>(fn: MiddlewareFunction<TCtx extends {
|
|
366
|
-
ctx: infer T extends object;
|
|
367
|
-
} ? T : any, TCtx extends {
|
|
368
|
-
meta: infer T_1 extends object;
|
|
369
|
-
} ? T_1 : object, object, $ContextOverrides, TCtx extends {
|
|
370
|
-
input: infer T_2;
|
|
371
|
-
} ? T_2 : unknown>) => MiddlewareBuilder<TCtx extends {
|
|
372
|
-
ctx: infer T extends object;
|
|
373
|
-
} ? T : any, TCtx extends {
|
|
374
|
-
meta: infer T_1 extends object;
|
|
375
|
-
} ? T_1 : object, $ContextOverrides, TCtx extends {
|
|
376
|
-
input: infer T_2;
|
|
377
|
-
} ? T_2 : unknown>;
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* @internal
|
|
381
|
-
* Please note, `trpc-openapi` uses this function.
|
|
382
|
-
*/
|
|
383
|
-
declare function createInputMiddleware<TInput>(parse: ParseFn<TInput>): AnyMiddlewareFunction;
|
|
339
|
+
abortController: AbortController;
|
|
340
|
+
}): Promise<readonly [Awaited<THead>]>;
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/unstable-core-do-not-import/stream/sse.types.d.ts
|
|
384
343
|
/**
|
|
385
344
|
* @internal
|
|
386
345
|
*/
|
|
387
|
-
declare
|
|
346
|
+
declare namespace EventSourceLike {
|
|
347
|
+
export interface InitDict {
|
|
348
|
+
withCredentials?: boolean;
|
|
349
|
+
}
|
|
350
|
+
export interface MessageEvent extends Event {
|
|
351
|
+
data: any;
|
|
352
|
+
lastEventId?: string;
|
|
353
|
+
}
|
|
354
|
+
export interface Event {}
|
|
355
|
+
type EventSourceListenerLike = (event: Event) => void;
|
|
356
|
+
export type AnyConstructorLike<TInit extends InitDict> = new (url: string, eventSourceInitDict?: TInit) => Instance;
|
|
357
|
+
export interface Instance {
|
|
358
|
+
readonly CLOSED: number;
|
|
359
|
+
readonly CONNECTING: number;
|
|
360
|
+
readonly OPEN: number;
|
|
361
|
+
addEventListener(type: string, listener: EventSourceListenerLike): void;
|
|
362
|
+
removeEventListener(type: string, listener: EventSourceListenerLike): void;
|
|
363
|
+
close: () => void;
|
|
364
|
+
readyState: number;
|
|
365
|
+
}
|
|
366
|
+
export type AnyConstructor = AnyConstructorLike<any>;
|
|
367
|
+
export type ListenerOf<T extends AnyConstructor> = Parameters<InstanceType<T>['addEventListener']>[1];
|
|
368
|
+
export type EventOf<T extends AnyConstructor> = Parameters<ListenerOf<T>>[0];
|
|
369
|
+
export type InitDictOf<T extends AnyConstructor> = ConstructorParameters<T>[1];
|
|
370
|
+
export {};
|
|
371
|
+
}
|
|
388
372
|
//#endregion
|
|
389
373
|
//#region src/unstable-core-do-not-import/stream/tracked.d.ts
|
|
390
374
|
declare const trackedSymbol: unique symbol;
|
|
@@ -417,288 +401,302 @@ declare function isTrackedEnvelope<TData>(value: unknown): value is TrackedEnvel
|
|
|
417
401
|
declare function tracked<TData>(id: string, data: TData): TrackedEnvelope<TData>;
|
|
418
402
|
type inferTrackedOutput<TData> = TData extends TrackedEnvelope<infer $Data> ? TrackedData<$Data> : TData;
|
|
419
403
|
//#endregion
|
|
420
|
-
//#region src/unstable-core-do-not-import/
|
|
421
|
-
|
|
422
|
-
type
|
|
423
|
-
__brand: 'unsetMarker';
|
|
424
|
-
};
|
|
425
|
-
/**
|
|
426
|
-
* Ensures there are no duplicate keys when building a procedure.
|
|
427
|
-
* @internal
|
|
428
|
-
*/
|
|
429
|
-
declare function mergeWithoutOverrides<TType extends Record<string, unknown>>(obj1: TType, ...objs: Partial<TType>[]): TType;
|
|
430
|
-
/**
|
|
431
|
-
* Check that value is object
|
|
432
|
-
* @internal
|
|
433
|
-
*/
|
|
434
|
-
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
435
|
-
type AnyFn = ((...args: any[]) => unknown) & Record<keyof any, unknown>;
|
|
436
|
-
declare function isFunction(fn: unknown): fn is AnyFn;
|
|
404
|
+
//#region src/unstable-core-do-not-import/stream/sse.d.ts
|
|
405
|
+
type Serialize$1 = (value: any) => any;
|
|
406
|
+
type Deserialize = (value: any) => any;
|
|
437
407
|
/**
|
|
438
|
-
* Create an object without inheriting anything from `Object.prototype`
|
|
439
408
|
* @internal
|
|
440
409
|
*/
|
|
441
|
-
|
|
442
|
-
declare function isAsyncIterable<TValue>(value: unknown): value is AsyncIterable<TValue>;
|
|
443
|
-
/**
|
|
444
|
-
* Run an IIFE
|
|
445
|
-
*/
|
|
446
|
-
declare const run: <TValue>(fn: () => TValue) => TValue;
|
|
447
|
-
declare function noop(): void;
|
|
448
|
-
declare function identity<T>(it: T): T;
|
|
449
|
-
/**
|
|
450
|
-
* Generic runtime assertion function. Throws, if the condition is not `true`.
|
|
451
|
-
*
|
|
452
|
-
* Can be used as a slightly less dangerous variant of type assertions. Code
|
|
453
|
-
* mistakes would be revealed at runtime then (hopefully during testing).
|
|
454
|
-
*/
|
|
455
|
-
declare function assert(condition: boolean, msg?: string): asserts condition;
|
|
456
|
-
declare function sleep(ms?: number): Promise<void>;
|
|
457
|
-
/**
|
|
458
|
-
* Ponyfill for
|
|
459
|
-
* [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).
|
|
460
|
-
*/
|
|
461
|
-
declare function abortSignalsAnyPonyfill(signals: AbortSignal[]): AbortSignal;
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/unstable-core-do-not-import/procedureBuilder.d.ts
|
|
464
|
-
type IntersectIfDefined<TType, TWith> = TType extends UnsetMarker ? TWith : TWith extends UnsetMarker ? TType : Simplify<TType & TWith>;
|
|
465
|
-
type DefaultValue<TValue, TFallback> = TValue extends UnsetMarker ? TFallback : TValue;
|
|
466
|
-
type inferAsyncIterable<TOutput> = TOutput extends AsyncIterable<infer $Yield, infer $Return, infer $Next> ? {
|
|
467
|
-
yield: $Yield;
|
|
468
|
-
return: $Return;
|
|
469
|
-
next: $Next;
|
|
470
|
-
} : never;
|
|
471
|
-
type inferSubscriptionOutput$1<TOutput> = TOutput extends AsyncIterable<any> ? AsyncIterable<inferTrackedOutput<inferAsyncIterable<TOutput>['yield']>, inferAsyncIterable<TOutput>['return'], inferAsyncIterable<TOutput>['next']> : TypeError<'Subscription output could not be inferred'>;
|
|
472
|
-
type CallerOverride<TContext> = (opts: {
|
|
473
|
-
args: unknown[];
|
|
474
|
-
invoke: (opts: ProcedureCallOptions<TContext>) => Promise<unknown>;
|
|
475
|
-
_def: AnyProcedure['_def'];
|
|
476
|
-
}) => Promise<unknown>;
|
|
477
|
-
type ProcedureBuilderDef<TMeta> = {
|
|
478
|
-
procedure: true;
|
|
479
|
-
inputs: Parser[];
|
|
480
|
-
output?: Parser;
|
|
481
|
-
meta?: TMeta;
|
|
482
|
-
resolver?: ProcedureBuilderResolver;
|
|
483
|
-
middlewares: AnyMiddlewareFunction[];
|
|
410
|
+
interface SSEPingOptions {
|
|
484
411
|
/**
|
|
485
|
-
*
|
|
412
|
+
* Enable ping comments sent from the server
|
|
413
|
+
* @default false
|
|
486
414
|
*/
|
|
487
|
-
|
|
415
|
+
enabled: boolean;
|
|
488
416
|
/**
|
|
489
|
-
*
|
|
417
|
+
* Interval in milliseconds
|
|
418
|
+
* @default 1000
|
|
490
419
|
*/
|
|
491
|
-
|
|
420
|
+
intervalMs?: number;
|
|
421
|
+
}
|
|
422
|
+
interface SSEClientOptions {
|
|
492
423
|
/**
|
|
493
|
-
*
|
|
424
|
+
* Timeout and reconnect after inactivity in milliseconds
|
|
425
|
+
* @default undefined
|
|
494
426
|
*/
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
* @internal
|
|
503
|
-
*/
|
|
504
|
-
interface ProcedureResolverOptions<TContext, _TMeta, TContextOverridesIn, TInputOut> {
|
|
505
|
-
ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;
|
|
506
|
-
input: TInputOut extends UnsetMarker ? undefined : TInputOut;
|
|
427
|
+
reconnectAfterInactivityMs?: number;
|
|
428
|
+
}
|
|
429
|
+
interface SSEStreamProducerOptions<TValue = unknown> {
|
|
430
|
+
serialize?: Serialize$1;
|
|
431
|
+
data: AsyncIterable<TValue>;
|
|
432
|
+
maxDepth?: number;
|
|
433
|
+
ping?: SSEPingOptions;
|
|
507
434
|
/**
|
|
508
|
-
*
|
|
435
|
+
* Maximum duration in milliseconds for the request before ending the stream
|
|
436
|
+
* @default undefined
|
|
509
437
|
*/
|
|
510
|
-
|
|
438
|
+
maxDurationMs?: number;
|
|
511
439
|
/**
|
|
512
|
-
*
|
|
440
|
+
* End the request immediately after data is sent
|
|
441
|
+
* Only useful for serverless runtimes that do not support streaming responses
|
|
442
|
+
* @default false
|
|
513
443
|
*/
|
|
514
|
-
|
|
444
|
+
emitAndEndImmediately?: boolean;
|
|
445
|
+
formatError?: (opts: {
|
|
446
|
+
error: unknown;
|
|
447
|
+
}) => unknown;
|
|
515
448
|
/**
|
|
516
|
-
*
|
|
517
|
-
*
|
|
449
|
+
* Client-specific options - these will be sent to the client as part of the first message
|
|
450
|
+
* @default {}
|
|
518
451
|
*/
|
|
519
|
-
|
|
452
|
+
client?: SSEClientOptions;
|
|
520
453
|
}
|
|
521
454
|
/**
|
|
522
|
-
*
|
|
455
|
+
*
|
|
456
|
+
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
523
457
|
*/
|
|
524
|
-
|
|
525
|
-
|
|
458
|
+
declare function sseStreamProducer<TValue = unknown>(opts: SSEStreamProducerOptions<TValue>): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
459
|
+
interface ConsumerStreamResultBase<TConfig extends ConsumerConfig> {
|
|
460
|
+
eventSource: InstanceType<TConfig['EventSource']> | null;
|
|
461
|
+
}
|
|
462
|
+
interface ConsumerStreamResultData<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
463
|
+
type: 'data';
|
|
464
|
+
data: inferTrackedOutput<TConfig['data']>;
|
|
465
|
+
}
|
|
466
|
+
interface ConsumerStreamResultError<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
467
|
+
type: 'serialized-error';
|
|
468
|
+
error: TConfig['error'];
|
|
469
|
+
}
|
|
470
|
+
interface ConsumerStreamResultConnecting<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
471
|
+
type: 'connecting';
|
|
472
|
+
event: EventSourceLike.EventOf<TConfig['EventSource']> | null;
|
|
473
|
+
}
|
|
474
|
+
interface ConsumerStreamResultTimeout<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
475
|
+
type: 'timeout';
|
|
476
|
+
ms: number;
|
|
477
|
+
}
|
|
478
|
+
interface ConsumerStreamResultPing<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
479
|
+
type: 'ping';
|
|
480
|
+
}
|
|
481
|
+
interface ConsumerStreamResultConnected<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
482
|
+
type: 'connected';
|
|
483
|
+
options: SSEClientOptions;
|
|
484
|
+
}
|
|
485
|
+
type ConsumerStreamResult<TConfig extends ConsumerConfig> = ConsumerStreamResultData<TConfig> | ConsumerStreamResultError<TConfig> | ConsumerStreamResultConnecting<TConfig> | ConsumerStreamResultTimeout<TConfig> | ConsumerStreamResultPing<TConfig> | ConsumerStreamResultConnected<TConfig>;
|
|
486
|
+
interface SSEStreamConsumerOptions<TConfig extends ConsumerConfig> {
|
|
487
|
+
url: () => MaybePromise<string>;
|
|
488
|
+
init: () => MaybePromise<EventSourceLike.InitDictOf<TConfig['EventSource']>> | undefined;
|
|
489
|
+
signal: AbortSignal;
|
|
490
|
+
deserialize?: Deserialize;
|
|
491
|
+
EventSource: TConfig['EventSource'];
|
|
492
|
+
}
|
|
493
|
+
interface ConsumerConfig {
|
|
494
|
+
data: unknown;
|
|
495
|
+
error: unknown;
|
|
496
|
+
EventSource: EventSourceLike.AnyConstructor;
|
|
497
|
+
}
|
|
526
498
|
/**
|
|
527
|
-
*
|
|
528
|
-
* Useful to create common helper functions for different procedures
|
|
499
|
+
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
529
500
|
*/
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
501
|
+
declare function sseStreamConsumer<TConfig extends ConsumerConfig>(opts: SSEStreamConsumerOptions<TConfig>): AsyncIterable<ConsumerStreamResult<TConfig>>;
|
|
502
|
+
declare const sseHeaders: {
|
|
503
|
+
readonly 'Content-Type': 'text/event-stream';
|
|
504
|
+
readonly 'Cache-Control': 'no-cache, no-transform';
|
|
505
|
+
readonly 'X-Accel-Buffering': 'no';
|
|
506
|
+
readonly Connection: 'keep-alive';
|
|
507
|
+
};
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/unstable-core-do-not-import/rootConfig.d.ts
|
|
510
|
+
/**
|
|
511
|
+
* The initial generics that are used in the init function
|
|
512
|
+
* @internal
|
|
513
|
+
*/
|
|
514
|
+
interface RootTypes {
|
|
515
|
+
ctx: object;
|
|
516
|
+
meta: object;
|
|
517
|
+
errorShape: DefaultErrorShape;
|
|
518
|
+
transformer: boolean;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* The default check to see if we're in a server
|
|
522
|
+
*/
|
|
523
|
+
declare const isServerDefault: boolean;
|
|
524
|
+
/**
|
|
525
|
+
* The default check to see if we're in development
|
|
526
|
+
*/
|
|
527
|
+
declare function isDevDefault(): boolean;
|
|
528
|
+
/**
|
|
529
|
+
* The tRPC root config
|
|
530
|
+
* @internal
|
|
531
|
+
*/
|
|
532
|
+
interface RootConfig<TTypes extends RootTypes> {
|
|
557
533
|
/**
|
|
558
|
-
*
|
|
534
|
+
* The types that are used in the config
|
|
535
|
+
* @internal
|
|
559
536
|
*/
|
|
560
|
-
|
|
537
|
+
$types: TTypes;
|
|
561
538
|
/**
|
|
562
|
-
*
|
|
539
|
+
* Use a data transformer
|
|
540
|
+
* @see https://trpc.io/docs/v11/data-transformers
|
|
563
541
|
*/
|
|
564
|
-
|
|
542
|
+
transformer: CombinedDataTransformer;
|
|
565
543
|
/**
|
|
566
|
-
*
|
|
567
|
-
* @see https://trpc.io/docs/v11/
|
|
544
|
+
* Use custom error formatting
|
|
545
|
+
* @see https://trpc.io/docs/v11/error-formatting
|
|
568
546
|
*/
|
|
569
|
-
|
|
570
|
-
input: DefaultValue<TInputIn, void>;
|
|
571
|
-
output: DefaultValue<TOutputOut, $Output>;
|
|
572
|
-
meta: TMeta;
|
|
573
|
-
}>;
|
|
547
|
+
errorFormatter: ErrorFormatter<TTypes['ctx'], TTypes['errorShape']>;
|
|
574
548
|
/**
|
|
575
|
-
*
|
|
576
|
-
* @
|
|
549
|
+
* Allow `@trpc/server` to run in non-server environments
|
|
550
|
+
* @warning **Use with caution**, this should likely mainly be used within testing.
|
|
551
|
+
* @default false
|
|
577
552
|
*/
|
|
578
|
-
|
|
579
|
-
input: DefaultValue<TInputIn, void>;
|
|
580
|
-
output: DefaultValue<TOutputOut, $Output>;
|
|
581
|
-
meta: TMeta;
|
|
582
|
-
}>;
|
|
553
|
+
allowOutsideOfServer: boolean;
|
|
583
554
|
/**
|
|
584
|
-
*
|
|
585
|
-
* @
|
|
555
|
+
* Is this a server environment?
|
|
556
|
+
* @warning **Use with caution**, this should likely mainly be used within testing.
|
|
557
|
+
* @default typeof window === 'undefined' || 'Deno' in window || process.env.NODE_ENV === 'test'
|
|
586
558
|
*/
|
|
587
|
-
|
|
588
|
-
input: DefaultValue<TInputIn, void>;
|
|
589
|
-
output: inferSubscriptionOutput$1<DefaultValue<TOutputOut, $Output>>;
|
|
590
|
-
meta: TMeta;
|
|
591
|
-
}>;
|
|
559
|
+
isServer: boolean;
|
|
592
560
|
/**
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
* @
|
|
561
|
+
* Is this development?
|
|
562
|
+
* Will be used to decide if the API should return stack traces
|
|
563
|
+
* @default process.env.NODE_ENV !== 'production'
|
|
596
564
|
*/
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
output: inferObservableValue<DefaultValue<TOutputOut, $Output>>;
|
|
600
|
-
meta: TMeta;
|
|
601
|
-
}>;
|
|
565
|
+
isDev: boolean;
|
|
566
|
+
defaultMeta?: TTypes['meta'] extends object ? TTypes['meta'] : never;
|
|
602
567
|
/**
|
|
603
|
-
*
|
|
604
|
-
*
|
|
568
|
+
* Options for server-sent events (SSE) subscriptions
|
|
569
|
+
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
|
605
570
|
*/
|
|
606
|
-
|
|
571
|
+
sse?: {
|
|
572
|
+
/**
|
|
573
|
+
* Enable server-sent events (SSE) subscriptions
|
|
574
|
+
* @default true
|
|
575
|
+
*/
|
|
576
|
+
enabled?: boolean;
|
|
577
|
+
} & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs' | 'client'>;
|
|
607
578
|
/**
|
|
608
|
-
*
|
|
579
|
+
* Options for batch stream
|
|
580
|
+
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
609
581
|
*/
|
|
610
|
-
|
|
582
|
+
jsonl?: Pick<JSONLProducerOptions, 'pingMs'>;
|
|
583
|
+
experimental?: {};
|
|
611
584
|
}
|
|
612
|
-
type ProcedureBuilderResolver = (opts: ProcedureResolverOptions<any, any, any, any>) => Promise<unknown>;
|
|
613
|
-
declare function createBuilder<TContext, TMeta>(initDef?: Partial<AnyProcedureBuilderDef>): ProcedureBuilder<TContext, TMeta, object, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, false>;
|
|
614
585
|
/**
|
|
615
586
|
* @internal
|
|
616
587
|
*/
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
588
|
+
type CreateRootTypes<TGenerics extends RootTypes> = TGenerics;
|
|
589
|
+
type AnyRootTypes = CreateRootTypes<{
|
|
590
|
+
ctx: any;
|
|
591
|
+
meta: any;
|
|
592
|
+
errorShape: any;
|
|
593
|
+
transformer: any;
|
|
594
|
+
}>;
|
|
595
|
+
type PartialIf<TCondition extends boolean, TType> = TCondition extends true ? Partial<TType> : TType;
|
|
596
|
+
/**
|
|
597
|
+
* Adds a `createContext` option with a given callback function
|
|
598
|
+
* If context is the default value, then the `createContext` option is optional
|
|
599
|
+
*/
|
|
600
|
+
type CreateContextCallback<TContext, TFunction extends (...args: any[]) => any> = PartialIf<object extends TContext ? true : false, {
|
|
624
601
|
/**
|
|
625
|
-
*
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
602
|
+
* @see https://trpc.io/docs/v11/context
|
|
603
|
+
**/
|
|
604
|
+
createContext: TFunction;
|
|
605
|
+
}>;
|
|
629
606
|
//#endregion
|
|
630
|
-
//#region src/unstable-core-do-not-import/
|
|
631
|
-
|
|
607
|
+
//#region src/unstable-core-do-not-import/router.d.ts
|
|
608
|
+
interface RouterRecord {
|
|
609
|
+
[key: string]: AnyProcedure | RouterRecord;
|
|
610
|
+
}
|
|
611
|
+
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>>;
|
|
632
612
|
/**
|
|
633
|
-
* @
|
|
613
|
+
* @internal
|
|
634
614
|
*/
|
|
635
|
-
type
|
|
636
|
-
interface BuiltProcedureDef {
|
|
637
|
-
meta: unknown;
|
|
638
|
-
input: unknown;
|
|
639
|
-
output: unknown;
|
|
640
|
-
}
|
|
615
|
+
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; };
|
|
641
616
|
/**
|
|
642
|
-
*
|
|
643
617
|
* @internal
|
|
644
618
|
*/
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
619
|
+
type RouterCallerErrorHandler<TContext> = (opts: ErrorHandlerOptions<TContext>) => void;
|
|
620
|
+
/**
|
|
621
|
+
* @internal
|
|
622
|
+
*/
|
|
623
|
+
type RouterCaller<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = (
|
|
624
|
+
/**
|
|
625
|
+
* @note
|
|
626
|
+
* If passing a function, we recommend it's a cached function
|
|
627
|
+
* e.g. wrapped in `React.cache` to avoid unnecessary computations
|
|
628
|
+
*/
|
|
629
|
+
ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>), options?: {
|
|
630
|
+
onError?: RouterCallerErrorHandler<TRoot['ctx']>;
|
|
631
|
+
signal?: AbortSignal;
|
|
632
|
+
}) => DecorateRouterRecord<TRecord>;
|
|
633
|
+
type Lazy<TAny> = (() => Promise<TAny>) & {};
|
|
634
|
+
type LazyLoader<TAny> = {
|
|
635
|
+
load: () => Promise<void>;
|
|
636
|
+
ref: Lazy<TAny>;
|
|
637
|
+
};
|
|
638
|
+
/**
|
|
639
|
+
* Lazy load a router
|
|
640
|
+
* @see https://trpc.io/docs/server/merging-routers#lazy-load
|
|
641
|
+
*/
|
|
642
|
+
declare function lazy<TRouter extends AnyRouter>(importRouter: () => Promise<TRouter | {
|
|
643
|
+
[key: string]: TRouter;
|
|
644
|
+
}>): Lazy<NoInfer<TRouter>>;
|
|
645
|
+
/**
|
|
646
|
+
* @internal
|
|
647
|
+
*/
|
|
648
|
+
interface RouterDef<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
|
|
649
|
+
_config: RootConfig<TRoot>;
|
|
650
|
+
router: true;
|
|
651
|
+
procedure?: never;
|
|
652
|
+
procedures: TRecord;
|
|
653
|
+
record: TRecord;
|
|
654
|
+
lazy: Record<string, LazyLoader<AnyRouter>>;
|
|
655
|
+
}
|
|
656
|
+
interface Router<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
|
|
657
|
+
_def: RouterDef<TRoot, TRecord>;
|
|
669
658
|
/**
|
|
670
|
-
* @
|
|
659
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
671
660
|
*/
|
|
672
|
-
|
|
661
|
+
createCaller: RouterCaller<TRoot, TRecord>;
|
|
673
662
|
}
|
|
674
|
-
|
|
675
|
-
interface
|
|
676
|
-
|
|
663
|
+
type BuiltRouter<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = Router<TRoot, TRecord> & TRecord;
|
|
664
|
+
interface RouterBuilder<TRoot extends AnyRootTypes> {
|
|
665
|
+
<TIn extends CreateRouterOptions>(_: TIn): BuiltRouter<TRoot, DecorateCreateRouterOptions<TIn>>;
|
|
666
|
+
}
|
|
667
|
+
type AnyRouter = Router<any, any>;
|
|
668
|
+
type inferRouterRootTypes<TRouter extends AnyRouter> = TRouter['_def']['_config']['$types'];
|
|
669
|
+
type inferRouterContext<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['ctx'];
|
|
670
|
+
type inferRouterError<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['errorShape'];
|
|
671
|
+
type inferRouterMeta<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['meta'];
|
|
672
|
+
/** @internal */
|
|
673
|
+
type CreateRouterOptions = {
|
|
674
|
+
[key: string]: AnyProcedure | AnyRouter | CreateRouterOptions | Lazy<AnyRouter>;
|
|
675
|
+
};
|
|
676
|
+
/** @internal */
|
|
677
|
+
type DecorateCreateRouterOptions<TRouterOptions extends CreateRouterOptions> = { [K in keyof TRouterOptions]: TRouterOptions[K] extends (infer $Value) ? $Value extends AnyProcedure ? $Value : $Value extends Router<any, infer TRecord> ? TRecord : $Value extends Lazy<Router<any, infer TRecord>> ? TRecord : $Value extends CreateRouterOptions ? DecorateCreateRouterOptions<$Value> : never : never; };
|
|
677
678
|
/**
|
|
678
|
-
* @
|
|
679
|
+
* @internal
|
|
679
680
|
*/
|
|
680
|
-
|
|
681
|
-
_observable: true;
|
|
682
|
-
}
|
|
683
|
-
type AnyQueryProcedure = QueryProcedure<any>;
|
|
684
|
-
type AnyMutationProcedure = MutationProcedure<any>;
|
|
685
|
-
type AnySubscriptionProcedure = SubscriptionProcedure<any> | LegacyObservableSubscriptionProcedure<any>;
|
|
686
|
-
type AnyProcedure = AnyQueryProcedure | AnyMutationProcedure | AnySubscriptionProcedure;
|
|
687
|
-
type inferProcedureInput<TProcedure extends AnyProcedure> = undefined extends inferProcedureParams<TProcedure>['$types']['input'] ? void | inferProcedureParams<TProcedure>['$types']['input'] : inferProcedureParams<TProcedure>['$types']['input'];
|
|
688
|
-
type inferProcedureParams<TProcedure> = TProcedure extends AnyProcedure ? TProcedure['_def'] : never;
|
|
689
|
-
type inferProcedureOutput<TProcedure> = inferProcedureParams<TProcedure>['$types']['output'];
|
|
690
|
-
type inferSubscriptionInput<TProcedure extends AnySubscriptionProcedure> = inferProcedureInput<TProcedure>;
|
|
691
|
-
type inferSubscriptionOutput<TProcedure extends AnySubscriptionProcedure> = TProcedure extends LegacyObservableSubscriptionProcedure<any> ? inferProcedureOutput<TProcedure> : inferAsyncIterableYield<inferProcedureOutput<TProcedure>>;
|
|
681
|
+
declare function createRouterFactory<TRoot extends AnyRootTypes>(config: RootConfig<TRoot>): <TInput extends CreateRouterOptions>(input: TInput) => BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>>;
|
|
692
682
|
/**
|
|
693
683
|
* @internal
|
|
694
684
|
*/
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
685
|
+
declare function getProcedureAtPath(router: Pick<Router<any, any>, '_def'>, path: string): Promise<AnyProcedure | null>;
|
|
686
|
+
/**
|
|
687
|
+
* @internal
|
|
688
|
+
*/
|
|
689
|
+
declare function callProcedure(opts: ProcedureCallOptions<unknown> & {
|
|
690
|
+
router: AnyRouter;
|
|
691
|
+
allowMethodOverride?: boolean;
|
|
692
|
+
}): Promise<any>;
|
|
693
|
+
interface RouterCallerFactory<TRoot extends AnyRootTypes> {
|
|
694
|
+
<TRecord extends RouterRecord>(router: Pick<Router<TRoot, TRecord>, '_def'>): RouterCaller<TRoot, TRecord>;
|
|
701
695
|
}
|
|
696
|
+
declare function createCallerFactory<TRoot extends AnyRootTypes>(): RouterCallerFactory<TRoot>;
|
|
697
|
+
/** @internal */
|
|
698
|
+
type MergeRouters<TRouters extends AnyRouter[], TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'], TRecord extends RouterRecord = {}> = TRouters extends [infer Head extends AnyRouter, ...infer Tail extends AnyRouter[]] ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord> : BuiltRouter<TRoot, TRecord>;
|
|
699
|
+
declare function mergeRouters<TRouters extends AnyRouter[]>(...routerList: [...TRouters]): MergeRouters<TRouters>;
|
|
702
700
|
//#endregion
|
|
703
701
|
//#region src/unstable-core-do-not-import/http/types.d.ts
|
|
704
702
|
/**
|
|
@@ -1017,13 +1015,13 @@ declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResp
|
|
|
1017
1015
|
declare function transformResultInner<TRouter extends AnyRouter, TOutput>(response: TRPCResponse<TOutput, inferRouterError<TRouter>> | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>, transformer: DataTransformer): {
|
|
1018
1016
|
readonly ok: false;
|
|
1019
1017
|
readonly error: {
|
|
1018
|
+
readonly error: inferRouterError<TRouter>;
|
|
1020
1019
|
readonly id?: JSONRPC2.RequestId;
|
|
1021
1020
|
readonly jsonrpc?: '2.0';
|
|
1022
|
-
readonly error: inferRouterError<TRouter>;
|
|
1023
1021
|
} | {
|
|
1022
|
+
readonly error: inferRouterError<TRouter>;
|
|
1024
1023
|
readonly jsonrpc?: '2.0';
|
|
1025
1024
|
readonly id: JSONRPC2.RequestId;
|
|
1026
|
-
readonly error: inferRouterError<TRouter>;
|
|
1027
1025
|
};
|
|
1028
1026
|
readonly result?: undefined;
|
|
1029
1027
|
} | {
|
|
@@ -1051,14 +1049,26 @@ declare function parseTRPCMessage(obj: unknown, transformer: CombinedDataTransfo
|
|
|
1051
1049
|
/**
|
|
1052
1050
|
* @internal
|
|
1053
1051
|
*/
|
|
1054
|
-
|
|
1052
|
+
interface ErrorFormatterOptions<TContext> {
|
|
1055
1053
|
error: TRPCError;
|
|
1056
1054
|
type: ProcedureType | 'unknown';
|
|
1057
1055
|
path: string | undefined;
|
|
1058
1056
|
input: unknown;
|
|
1059
|
-
ctx: TContext
|
|
1057
|
+
ctx: TContext;
|
|
1060
1058
|
shape: DefaultErrorShape;
|
|
1061
|
-
}
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* @internal
|
|
1062
|
+
*/
|
|
1063
|
+
type ErrorFormatter<TContext, TShape extends TRPCErrorShape> = (opts: ErrorFormatterOptions<TContext | undefined>) => TShape;
|
|
1064
|
+
/**
|
|
1065
|
+
* @internal
|
|
1066
|
+
*/
|
|
1067
|
+
type ProcedureErrorFormatter<TContext, TContextOverrides, TShape extends TRPCErrorShape | undefined | void> = (opts: ErrorFormatterOptions<Simplify<Overwrite<TContext, TContextOverrides>>>) => TShape;
|
|
1068
|
+
/**
|
|
1069
|
+
* @internal
|
|
1070
|
+
*/
|
|
1071
|
+
type AnyProcedureErrorFormatter = ProcedureErrorFormatter<any, any, any>;
|
|
1062
1072
|
/**
|
|
1063
1073
|
* @internal
|
|
1064
1074
|
*/
|
|
@@ -1082,390 +1092,447 @@ interface DefaultErrorShape extends TRPCErrorShape<DefaultErrorData> {
|
|
|
1082
1092
|
code: TRPC_ERROR_CODE_NUMBER;
|
|
1083
1093
|
}
|
|
1084
1094
|
declare const defaultFormatter: ErrorFormatter<any, any>;
|
|
1085
|
-
//#endregion
|
|
1086
|
-
//#region src/unstable-core-do-not-import/stream/jsonl.d.ts
|
|
1087
1095
|
/**
|
|
1088
|
-
*
|
|
1089
|
-
* @see ReadableStream from lib.dom.d.ts
|
|
1096
|
+
* @internal
|
|
1090
1097
|
*/
|
|
1091
|
-
|
|
1092
|
-
|
|
1098
|
+
declare function getDefaultErrorShape(opts: {
|
|
1099
|
+
error: TRPCError;
|
|
1100
|
+
path: string | undefined;
|
|
1101
|
+
isDev: boolean;
|
|
1102
|
+
}): DefaultErrorShape;
|
|
1103
|
+
declare const formattedShapeSymbol: unique symbol;
|
|
1104
|
+
/**
|
|
1105
|
+
* @internal
|
|
1106
|
+
*/
|
|
1107
|
+
declare function setFormattedErrorShape(error: TRPCError, shape: TRPCErrorShape): asserts error is TRPCError & {
|
|
1108
|
+
[formattedShapeSymbol]: TRPCErrorShape;
|
|
1093
1109
|
};
|
|
1094
|
-
|
|
1095
|
-
|
|
1110
|
+
/**
|
|
1111
|
+
* @internal
|
|
1112
|
+
*/
|
|
1113
|
+
declare function getFormattedErrorShape(error: TRPCError): TRPCErrorShape | undefined;
|
|
1114
|
+
declare function isFormattedErrorShape(error: TRPCError): error is TRPCError & {
|
|
1115
|
+
[formattedShapeSymbol]: TRPCErrorShape;
|
|
1096
1116
|
};
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
interface JSONLProducerOptions {
|
|
1106
|
-
serialize?: Serialize$2;
|
|
1107
|
-
data: Record<string, unknown> | unknown[];
|
|
1108
|
-
onError?: ProducerOnError;
|
|
1109
|
-
formatError?: (opts: {
|
|
1110
|
-
error: unknown;
|
|
1111
|
-
path: PathArray;
|
|
1112
|
-
}) => unknown;
|
|
1113
|
-
maxDepth?: number;
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region src/unstable-core-do-not-import/middleware.d.ts
|
|
1119
|
+
/** @internal */
|
|
1120
|
+
declare const middlewareMarker: 'middlewareMarker' & {
|
|
1121
|
+
__brand: 'middlewareMarker';
|
|
1122
|
+
};
|
|
1123
|
+
type MiddlewareMarker = typeof middlewareMarker;
|
|
1124
|
+
interface MiddlewareResultBase {
|
|
1114
1125
|
/**
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1117
|
-
* @default undefined
|
|
1126
|
+
* All middlewares should pass through their `next()`'s output.
|
|
1127
|
+
* Requiring this marker makes sure that can't be forgotten at compile-time.
|
|
1118
1128
|
*/
|
|
1119
|
-
|
|
1129
|
+
readonly marker: MiddlewareMarker;
|
|
1130
|
+
}
|
|
1131
|
+
interface MiddlewareOKResult<_TContextOverride> extends MiddlewareResultBase {
|
|
1132
|
+
ok: true;
|
|
1133
|
+
data: unknown;
|
|
1134
|
+
}
|
|
1135
|
+
interface MiddlewareErrorResult<_TContextOverride> extends MiddlewareResultBase {
|
|
1136
|
+
ok: false;
|
|
1137
|
+
error: TRPCError;
|
|
1120
1138
|
}
|
|
1121
1139
|
/**
|
|
1122
|
-
*
|
|
1123
|
-
* @see https://jsonlines.org/
|
|
1140
|
+
* @internal
|
|
1124
1141
|
*/
|
|
1125
|
-
|
|
1126
|
-
type ConsumerOnError = (opts: {
|
|
1127
|
-
error: unknown;
|
|
1128
|
-
}) => void;
|
|
1142
|
+
type MiddlewareResult<_TContextOverride> = MiddlewareErrorResult<_TContextOverride> | MiddlewareOKResult<_TContextOverride>;
|
|
1129
1143
|
/**
|
|
1130
|
-
*
|
|
1131
|
-
* @see https://jsonlines.org/
|
|
1144
|
+
* @internal
|
|
1132
1145
|
*/
|
|
1133
|
-
|
|
1134
|
-
from: NodeJSReadableStreamEsque | WebReadableStreamEsque;
|
|
1135
|
-
deserialize?: Deserialize$1;
|
|
1136
|
-
onError?: ConsumerOnError;
|
|
1137
|
-
formatError?: (opts: {
|
|
1138
|
-
error: unknown;
|
|
1139
|
-
}) => Error;
|
|
1146
|
+
interface MiddlewareBuilder<TContext, TMeta, TContextOverrides, TInputOut> {
|
|
1140
1147
|
/**
|
|
1141
|
-
*
|
|
1148
|
+
* Create a new builder based on the current middleware builder
|
|
1142
1149
|
*/
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1150
|
+
unstable_pipe<$ContextOverridesOut>(fn: MiddlewareFunction<TContext, TMeta, TContextOverrides, $ContextOverridesOut, TInputOut> | MiddlewareBuilder<Overwrite<TContext, TContextOverrides>, TMeta, $ContextOverridesOut, TInputOut>): MiddlewareBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverridesOut>, TInputOut>;
|
|
1151
|
+
/**
|
|
1152
|
+
* List of middlewares within this middleware builder
|
|
1153
|
+
*/
|
|
1154
|
+
_middlewares: MiddlewareFunction<TContext, TMeta, TContextOverrides, object, TInputOut>[];
|
|
1155
|
+
}
|
|
1147
1156
|
/**
|
|
1148
1157
|
* @internal
|
|
1149
1158
|
*/
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1159
|
+
type MiddlewareFunction<TContext, TMeta, TContextOverridesIn, $ContextOverridesOut, TInputOut> = {
|
|
1160
|
+
(opts: {
|
|
1161
|
+
ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;
|
|
1162
|
+
type: ProcedureType;
|
|
1163
|
+
path: string;
|
|
1164
|
+
input: TInputOut;
|
|
1165
|
+
getRawInput: GetRawInputFn;
|
|
1166
|
+
meta: TMeta | undefined;
|
|
1167
|
+
signal: AbortSignal | undefined;
|
|
1168
|
+
/**
|
|
1169
|
+
* The index of this call in a batch request.
|
|
1170
|
+
*/
|
|
1171
|
+
batchIndex: number;
|
|
1172
|
+
next: {
|
|
1173
|
+
(): Promise<MiddlewareResult<TContextOverridesIn>>;
|
|
1174
|
+
<$ContextOverride>(opts: {
|
|
1175
|
+
ctx?: $ContextOverride;
|
|
1176
|
+
input?: unknown;
|
|
1177
|
+
}): Promise<MiddlewareResult<$ContextOverride>>;
|
|
1178
|
+
(opts: {
|
|
1179
|
+
getRawInput: GetRawInputFn;
|
|
1180
|
+
}): Promise<MiddlewareResult<TContextOverridesIn>>;
|
|
1181
|
+
};
|
|
1182
|
+
}): Promise<MiddlewareResult<$ContextOverridesOut>>;
|
|
1183
|
+
_type?: string | undefined;
|
|
1184
|
+
};
|
|
1185
|
+
type AnyMiddlewareFunction = MiddlewareFunction<any, any, any, any, any>;
|
|
1186
|
+
type AnyMiddlewareBuilder = MiddlewareBuilder<any, any, any, any>;
|
|
1187
|
+
/**
|
|
1188
|
+
* @internal
|
|
1189
|
+
*/
|
|
1190
|
+
declare function createMiddlewareFactory<TContext, TMeta, TInputOut = unknown>(): <$ContextOverrides>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, TInputOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverrides, TInputOut>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Create a standalone middleware
|
|
1193
|
+
* @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
1194
|
+
* @deprecated use `.concat()` instead
|
|
1195
|
+
*/
|
|
1196
|
+
declare const experimental_standaloneMiddleware: <TCtx extends {
|
|
1197
|
+
ctx?: object;
|
|
1198
|
+
meta?: object;
|
|
1199
|
+
input?: unknown;
|
|
1200
|
+
}>() => {
|
|
1201
|
+
create: <$ContextOverrides>(fn: MiddlewareFunction<TCtx extends {
|
|
1202
|
+
ctx: infer T extends object;
|
|
1203
|
+
} ? T : any, TCtx extends {
|
|
1204
|
+
meta: infer T_1 extends object;
|
|
1205
|
+
} ? T_1 : object, object, $ContextOverrides, TCtx extends {
|
|
1206
|
+
input: infer T_2;
|
|
1207
|
+
} ? T_2 : unknown>) => MiddlewareBuilder<TCtx extends {
|
|
1208
|
+
ctx: infer T extends object;
|
|
1209
|
+
} ? T : any, TCtx extends {
|
|
1210
|
+
meta: infer T_1 extends object;
|
|
1211
|
+
} ? T_1 : object, $ContextOverrides, TCtx extends {
|
|
1212
|
+
input: infer T_2;
|
|
1213
|
+
} ? T_2 : unknown>;
|
|
1214
|
+
};
|
|
1215
|
+
/**
|
|
1216
|
+
* @internal
|
|
1217
|
+
* Please note, `trpc-openapi` uses this function.
|
|
1218
|
+
*/
|
|
1219
|
+
declare function createInputMiddleware<TInput>(parse: ParseFn<TInput>): AnyMiddlewareFunction;
|
|
1220
|
+
/**
|
|
1221
|
+
* @internal
|
|
1222
|
+
*/
|
|
1223
|
+
declare function createErrorFormatterMiddleware(formatter: AnyProcedureErrorFormatter, isDev: boolean): AnyMiddlewareFunction;
|
|
1224
|
+
/**
|
|
1225
|
+
* @internal
|
|
1226
|
+
*/
|
|
1227
|
+
declare function createOutputMiddleware<TOutput>(parse: ParseFn<TOutput>): AnyMiddlewareFunction;
|
|
1176
1228
|
//#endregion
|
|
1177
|
-
//#region src/unstable-core-do-not-import/
|
|
1178
|
-
|
|
1179
|
-
type
|
|
1229
|
+
//#region src/unstable-core-do-not-import/utils.d.ts
|
|
1230
|
+
/** @internal */
|
|
1231
|
+
type UnsetMarker = 'unsetMarker' & {
|
|
1232
|
+
__brand: 'unsetMarker';
|
|
1233
|
+
};
|
|
1234
|
+
/**
|
|
1235
|
+
* Ensures there are no duplicate keys when building a procedure.
|
|
1236
|
+
* @internal
|
|
1237
|
+
*/
|
|
1238
|
+
declare function mergeWithoutOverrides<TType extends Record<string, unknown>>(obj1: TType, ...objs: Partial<TType>[]): TType;
|
|
1180
1239
|
/**
|
|
1240
|
+
* Check that value is object
|
|
1181
1241
|
* @internal
|
|
1182
1242
|
*/
|
|
1183
|
-
|
|
1243
|
+
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
1244
|
+
type AnyFn = ((...args: any[]) => unknown) & Record<keyof any, unknown>;
|
|
1245
|
+
declare function isFunction(fn: unknown): fn is AnyFn;
|
|
1246
|
+
/**
|
|
1247
|
+
* Create an object without inheriting anything from `Object.prototype`
|
|
1248
|
+
* @internal
|
|
1249
|
+
*/
|
|
1250
|
+
declare function emptyObject<TObj extends Record<string, unknown>>(): TObj;
|
|
1251
|
+
declare function isAsyncIterable<TValue>(value: unknown): value is AsyncIterable<TValue>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Run an IIFE
|
|
1254
|
+
*/
|
|
1255
|
+
declare const run: <TValue>(fn: () => TValue) => TValue;
|
|
1256
|
+
declare function noop(): void;
|
|
1257
|
+
declare function identity<T>(it: T): T;
|
|
1258
|
+
/**
|
|
1259
|
+
* Generic runtime assertion function. Throws, if the condition is not `true`.
|
|
1260
|
+
*
|
|
1261
|
+
* Can be used as a slightly less dangerous variant of type assertions. Code
|
|
1262
|
+
* mistakes would be revealed at runtime then (hopefully during testing).
|
|
1263
|
+
*/
|
|
1264
|
+
declare function assert(condition: boolean, msg?: string): asserts condition;
|
|
1265
|
+
declare function assertNever(value: never): never;
|
|
1266
|
+
declare function sleep(ms?: number): Promise<void>;
|
|
1267
|
+
/**
|
|
1268
|
+
* Ponyfill for
|
|
1269
|
+
* [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).
|
|
1270
|
+
*/
|
|
1271
|
+
declare function abortSignalsAnyPonyfill(signals: AbortSignal[]): AbortSignal;
|
|
1272
|
+
//#endregion
|
|
1273
|
+
//#region src/unstable-core-do-not-import/procedureBuilder.d.ts
|
|
1274
|
+
type IntersectIfDefined<TType, TWith> = TType extends UnsetMarker ? TWith : TWith extends UnsetMarker ? TType : Simplify<TType & TWith>;
|
|
1275
|
+
type DefaultValue<TValue, TFallback> = TValue extends UnsetMarker ? TFallback : TValue;
|
|
1276
|
+
type FoldErrorShape<TErrorShape, $Shape> = Extract<$Shape, TRPCErrorShape> | TErrorShape;
|
|
1277
|
+
type inferAsyncIterable<TOutput> = TOutput extends AsyncIterable<infer $Yield, infer $Return, infer $Next> ? {
|
|
1278
|
+
yield: $Yield;
|
|
1279
|
+
return: $Return;
|
|
1280
|
+
next: $Next;
|
|
1281
|
+
} : never;
|
|
1282
|
+
type inferSubscriptionOutput$1<TOutput> = TOutput extends AsyncIterable<any> ? AsyncIterable<inferTrackedOutput<inferAsyncIterable<TOutput>['yield']>, inferAsyncIterable<TOutput>['return'], inferAsyncIterable<TOutput>['next']> : TypeError<'Subscription output could not be inferred'>;
|
|
1283
|
+
type CallerOverride<TContext> = (opts: {
|
|
1284
|
+
args: unknown[];
|
|
1285
|
+
invoke: (opts: ProcedureCallOptions<TContext>) => Promise<unknown>;
|
|
1286
|
+
_def: AnyProcedure['_def'];
|
|
1287
|
+
}) => Promise<unknown>;
|
|
1288
|
+
type ProcedureBuilderDef<TMeta> = {
|
|
1289
|
+
procedure: true;
|
|
1290
|
+
inputs: Parser[];
|
|
1291
|
+
output?: Parser;
|
|
1292
|
+
meta?: TMeta;
|
|
1293
|
+
resolver?: ProcedureBuilderResolver;
|
|
1294
|
+
middlewares: AnyMiddlewareFunction[];
|
|
1184
1295
|
/**
|
|
1185
|
-
*
|
|
1186
|
-
* @default false
|
|
1296
|
+
* @deprecated use `type` instead
|
|
1187
1297
|
*/
|
|
1188
|
-
|
|
1298
|
+
mutation?: boolean;
|
|
1189
1299
|
/**
|
|
1190
|
-
*
|
|
1191
|
-
* @default 1000
|
|
1300
|
+
* @deprecated use `type` instead
|
|
1192
1301
|
*/
|
|
1193
|
-
|
|
1194
|
-
}
|
|
1195
|
-
interface SSEClientOptions {
|
|
1302
|
+
query?: boolean;
|
|
1196
1303
|
/**
|
|
1197
|
-
*
|
|
1198
|
-
* @default undefined
|
|
1304
|
+
* @deprecated use `type` instead
|
|
1199
1305
|
*/
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1306
|
+
subscription?: boolean;
|
|
1307
|
+
type?: ProcedureType;
|
|
1308
|
+
caller?: CallerOverride<unknown>;
|
|
1309
|
+
config?: RootConfig<AnyRootTypes>;
|
|
1310
|
+
};
|
|
1311
|
+
type AnyProcedureBuilderDef = ProcedureBuilderDef<any>;
|
|
1312
|
+
/**
|
|
1313
|
+
* Procedure resolver options (what the `.query()`, `.mutation()`, and `.subscription()` functions receive)
|
|
1314
|
+
* @internal
|
|
1315
|
+
*/
|
|
1316
|
+
interface ProcedureResolverOptions<TContext, _TMeta, TContextOverridesIn, TInputOut> {
|
|
1317
|
+
ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;
|
|
1318
|
+
input: TInputOut extends UnsetMarker ? undefined : TInputOut;
|
|
1207
1319
|
/**
|
|
1208
|
-
*
|
|
1209
|
-
* @default undefined
|
|
1320
|
+
* The AbortSignal of the request
|
|
1210
1321
|
*/
|
|
1211
|
-
|
|
1322
|
+
signal: AbortSignal | undefined;
|
|
1212
1323
|
/**
|
|
1213
|
-
*
|
|
1214
|
-
* Only useful for serverless runtimes that do not support streaming responses
|
|
1215
|
-
* @default false
|
|
1324
|
+
* The path of the procedure
|
|
1216
1325
|
*/
|
|
1217
|
-
|
|
1218
|
-
formatError?: (opts: {
|
|
1219
|
-
error: unknown;
|
|
1220
|
-
}) => unknown;
|
|
1326
|
+
path: string;
|
|
1221
1327
|
/**
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1328
|
+
* The index of this call in a batch request.
|
|
1329
|
+
* Will be set when the procedure is called as part of a batch.
|
|
1224
1330
|
*/
|
|
1225
|
-
|
|
1226
|
-
}
|
|
1227
|
-
/**
|
|
1228
|
-
*
|
|
1229
|
-
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
1230
|
-
*/
|
|
1231
|
-
declare function sseStreamProducer<TValue = unknown>(opts: SSEStreamProducerOptions<TValue>): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
1232
|
-
interface ConsumerStreamResultBase<TConfig extends ConsumerConfig> {
|
|
1233
|
-
eventSource: InstanceType<TConfig['EventSource']> | null;
|
|
1234
|
-
}
|
|
1235
|
-
interface ConsumerStreamResultData<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
1236
|
-
type: 'data';
|
|
1237
|
-
data: inferTrackedOutput<TConfig['data']>;
|
|
1238
|
-
}
|
|
1239
|
-
interface ConsumerStreamResultError<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
1240
|
-
type: 'serialized-error';
|
|
1241
|
-
error: TConfig['error'];
|
|
1242
|
-
}
|
|
1243
|
-
interface ConsumerStreamResultConnecting<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
1244
|
-
type: 'connecting';
|
|
1245
|
-
event: EventSourceLike.EventOf<TConfig['EventSource']> | null;
|
|
1246
|
-
}
|
|
1247
|
-
interface ConsumerStreamResultTimeout<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
1248
|
-
type: 'timeout';
|
|
1249
|
-
ms: number;
|
|
1250
|
-
}
|
|
1251
|
-
interface ConsumerStreamResultPing<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
1252
|
-
type: 'ping';
|
|
1253
|
-
}
|
|
1254
|
-
interface ConsumerStreamResultConnected<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
1255
|
-
type: 'connected';
|
|
1256
|
-
options: SSEClientOptions;
|
|
1257
|
-
}
|
|
1258
|
-
type ConsumerStreamResult<TConfig extends ConsumerConfig> = ConsumerStreamResultData<TConfig> | ConsumerStreamResultError<TConfig> | ConsumerStreamResultConnecting<TConfig> | ConsumerStreamResultTimeout<TConfig> | ConsumerStreamResultPing<TConfig> | ConsumerStreamResultConnected<TConfig>;
|
|
1259
|
-
interface SSEStreamConsumerOptions<TConfig extends ConsumerConfig> {
|
|
1260
|
-
url: () => MaybePromise<string>;
|
|
1261
|
-
init: () => MaybePromise<EventSourceLike.InitDictOf<TConfig['EventSource']>> | undefined;
|
|
1262
|
-
signal: AbortSignal;
|
|
1263
|
-
deserialize?: Deserialize;
|
|
1264
|
-
EventSource: TConfig['EventSource'];
|
|
1265
|
-
}
|
|
1266
|
-
interface ConsumerConfig {
|
|
1267
|
-
data: unknown;
|
|
1268
|
-
error: unknown;
|
|
1269
|
-
EventSource: EventSourceLike.AnyConstructor;
|
|
1331
|
+
batchIndex?: number;
|
|
1270
1332
|
}
|
|
1271
1333
|
/**
|
|
1272
|
-
*
|
|
1273
|
-
*/
|
|
1274
|
-
declare function sseStreamConsumer<TConfig extends ConsumerConfig>(opts: SSEStreamConsumerOptions<TConfig>): AsyncIterable<ConsumerStreamResult<TConfig>>;
|
|
1275
|
-
declare const sseHeaders: {
|
|
1276
|
-
readonly 'Content-Type': 'text/event-stream';
|
|
1277
|
-
readonly 'Cache-Control': 'no-cache, no-transform';
|
|
1278
|
-
readonly 'X-Accel-Buffering': 'no';
|
|
1279
|
-
readonly Connection: 'keep-alive';
|
|
1280
|
-
};
|
|
1281
|
-
//#endregion
|
|
1282
|
-
//#region src/unstable-core-do-not-import/rootConfig.d.ts
|
|
1283
|
-
/**
|
|
1284
|
-
* The initial generics that are used in the init function
|
|
1285
|
-
* @internal
|
|
1334
|
+
* A procedure resolver
|
|
1286
1335
|
*/
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
meta: object;
|
|
1290
|
-
errorShape: DefaultErrorShape;
|
|
1291
|
-
transformer: boolean;
|
|
1292
|
-
}
|
|
1336
|
+
type ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputParserIn, $Output> = (opts: ProcedureResolverOptions<TContext, TMeta, TContextOverrides, TInputOut>) => MaybePromise<DefaultValue<TOutputParserIn, $Output>>;
|
|
1337
|
+
type AnyProcedureBuilder = ProcedureBuilder<any, any, any, any, any, any, any, any, any>;
|
|
1293
1338
|
/**
|
|
1294
|
-
*
|
|
1339
|
+
* Infer the context type from a procedure builder
|
|
1340
|
+
* Useful to create common helper functions for different procedures
|
|
1295
1341
|
*/
|
|
1296
|
-
|
|
1342
|
+
type inferProcedureBuilderResolverOptions<TProcedureBuilder extends AnyProcedureBuilder> = TProcedureBuilder extends ProcedureBuilder<infer TContext, infer TMeta, infer TContextOverrides, infer _TInputIn, infer TInputOut, infer _TOutputIn, infer _TOutputOut, infer _TCaller, infer _TErrorShape> ? ProcedureResolverOptions<TContext, TMeta, TContextOverrides, TInputOut extends UnsetMarker ? unknown : TInputOut extends object ? Simplify<TInputOut & {
|
|
1343
|
+
/**
|
|
1344
|
+
* Extra input params might have been added by a `.input()` further down the chain
|
|
1345
|
+
*/
|
|
1346
|
+
[keyAddedByInputCallFurtherDown: string]: unknown;
|
|
1347
|
+
}> : TInputOut> : never;
|
|
1348
|
+
interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller extends boolean,
|
|
1297
1349
|
/**
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1350
|
+
* Defaults to `unknown` so that an annotation written without it falls back
|
|
1351
|
+
* to the router-wide error shape rather than pinning the procedure to the
|
|
1352
|
+
* default one.
|
|
1353
|
+
* @see inferProcedureErrorShape
|
|
1300
1354
|
*/
|
|
1301
|
-
|
|
1355
|
+
TErrorShape = unknown> {
|
|
1356
|
+
/**
|
|
1357
|
+
* Add an input parser to the procedure.
|
|
1358
|
+
* @see https://trpc.io/docs/v11/server/validators
|
|
1359
|
+
*/
|
|
1360
|
+
input<$Parser extends Parser>(schema: TInputOut extends UnsetMarker ? $Parser : inferParser<$Parser>['out'] extends Record<string, unknown> | undefined ? TInputOut extends Record<string, unknown> | undefined ? undefined extends inferParser<$Parser>['out'] ? undefined extends TInputOut ? $Parser : TypeError<'Cannot chain an optional parser to a required parser'> : $Parser : TypeError<'All input parsers did not resolve to an object'> : TypeError<'All input parsers did not resolve to an object'>): ProcedureBuilder<TContext, TMeta, TContextOverrides, IntersectIfDefined<TInputIn, inferParser<$Parser>['in']>, IntersectIfDefined<TInputOut, inferParser<$Parser>['out']>, TOutputIn, TOutputOut, TCaller, TErrorShape>;
|
|
1302
1361
|
/**
|
|
1303
|
-
*
|
|
1304
|
-
* @
|
|
1362
|
+
* Add an output parser to the procedure.
|
|
1363
|
+
* @see https://trpc.io/docs/v11/server/validators
|
|
1305
1364
|
*/
|
|
1306
|
-
$
|
|
1365
|
+
output<$Parser extends Parser>(schema: $Parser): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, IntersectIfDefined<TOutputIn, inferParser<$Parser>['in']>, IntersectIfDefined<TOutputOut, inferParser<$Parser>['out']>, TCaller, TErrorShape>;
|
|
1307
1366
|
/**
|
|
1308
|
-
*
|
|
1309
|
-
* @see https://trpc.io/docs/v11/
|
|
1367
|
+
* Add a meta data to the procedure.
|
|
1368
|
+
* @see https://trpc.io/docs/v11/server/metadata
|
|
1310
1369
|
*/
|
|
1311
|
-
|
|
1370
|
+
meta(meta: TMeta): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller, TErrorShape>;
|
|
1312
1371
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1372
|
+
* Add per procedure error formatters.
|
|
1373
|
+
*
|
|
1374
|
+
* An error will bubble until a `.errors()` handler returns a shape
|
|
1375
|
+
* or it reaches the global errorFormatter
|
|
1376
|
+
*
|
|
1377
|
+
* @see https://trpc.io/docs/v11/server/error-formatting
|
|
1315
1378
|
*/
|
|
1316
|
-
|
|
1379
|
+
errors<$Shape extends TRPCErrorShape | undefined | void>(formatter: ProcedureErrorFormatter<TContext, TContextOverrides, $Shape>): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller, FoldErrorShape<TErrorShape, $Shape>>;
|
|
1317
1380
|
/**
|
|
1318
|
-
*
|
|
1319
|
-
* @
|
|
1320
|
-
* @default false
|
|
1381
|
+
* Add a middleware to the procedure.
|
|
1382
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
1321
1383
|
*/
|
|
1322
|
-
|
|
1384
|
+
use<$ContextOverridesOut>(fn: MiddlewareBuilder<Overwrite<TContext, TContextOverrides>, TMeta, $ContextOverridesOut, TInputOut> | MiddlewareFunction<TContext, TMeta, TContextOverrides, $ContextOverridesOut, TInputOut>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverridesOut>, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller, TErrorShape>;
|
|
1323
1385
|
/**
|
|
1324
|
-
*
|
|
1325
|
-
* @warning **Use with caution**, this should likely mainly be used within testing.
|
|
1326
|
-
* @default typeof window === 'undefined' || 'Deno' in window || process.env.NODE_ENV === 'test'
|
|
1386
|
+
* @deprecated use {@link concat} instead
|
|
1327
1387
|
*/
|
|
1328
|
-
|
|
1388
|
+
unstable_concat<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, $ErrorShape>(builder: Overwrite<TContext, TContextOverrides> extends $Context ? TMeta extends $Meta ? ProcedureBuilder<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, TCaller, $ErrorShape> : TypeError<'Meta mismatch'> : TypeError<'Context mismatch'>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverrides>, IntersectIfDefined<TInputIn, $InputIn>, IntersectIfDefined<TInputOut, $InputOut>, IntersectIfDefined<TOutputIn, $OutputIn>, IntersectIfDefined<TOutputOut, $OutputOut>, TCaller, FoldErrorShape<TErrorShape, $ErrorShape>>;
|
|
1329
1389
|
/**
|
|
1330
|
-
*
|
|
1331
|
-
* Will be used to decide if the API should return stack traces
|
|
1332
|
-
* @default process.env.NODE_ENV !== 'production'
|
|
1390
|
+
* Combine two procedure builders
|
|
1333
1391
|
*/
|
|
1334
|
-
|
|
1335
|
-
defaultMeta?: TTypes['meta'] extends object ? TTypes['meta'] : never;
|
|
1392
|
+
concat<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, $ErrorShape>(builder: Overwrite<TContext, TContextOverrides> extends $Context ? TMeta extends $Meta ? ProcedureBuilder<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, TCaller, $ErrorShape> : TypeError<'Meta mismatch'> : TypeError<'Context mismatch'>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverrides>, IntersectIfDefined<TInputIn, $InputIn>, IntersectIfDefined<TInputOut, $InputOut>, IntersectIfDefined<TOutputIn, $OutputIn>, IntersectIfDefined<TOutputOut, $OutputOut>, TCaller, FoldErrorShape<TErrorShape, $ErrorShape>>;
|
|
1336
1393
|
/**
|
|
1337
|
-
*
|
|
1338
|
-
* @see https://trpc.io/docs/
|
|
1394
|
+
* Query procedure
|
|
1395
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
1339
1396
|
*/
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
} & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs' | 'client'>;
|
|
1397
|
+
query<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? (input: DefaultValue<TInputIn, void>) => Promise<DefaultValue<TOutputOut, $Output>> : QueryProcedure<{
|
|
1398
|
+
input: DefaultValue<TInputIn, void>;
|
|
1399
|
+
output: DefaultValue<TOutputOut, $Output>;
|
|
1400
|
+
meta: TMeta;
|
|
1401
|
+
errorShape: TErrorShape;
|
|
1402
|
+
}>;
|
|
1347
1403
|
/**
|
|
1348
|
-
*
|
|
1349
|
-
* @see https://trpc.io/docs/
|
|
1404
|
+
* Mutation procedure
|
|
1405
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
1350
1406
|
*/
|
|
1351
|
-
|
|
1352
|
-
|
|
1407
|
+
mutation<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? (input: DefaultValue<TInputIn, void>) => Promise<DefaultValue<TOutputOut, $Output>> : MutationProcedure<{
|
|
1408
|
+
input: DefaultValue<TInputIn, void>;
|
|
1409
|
+
output: DefaultValue<TOutputOut, $Output>;
|
|
1410
|
+
meta: TMeta;
|
|
1411
|
+
errorShape: TErrorShape;
|
|
1412
|
+
}>;
|
|
1413
|
+
/**
|
|
1414
|
+
* Subscription procedure
|
|
1415
|
+
* @see https://trpc.io/docs/v11/server/subscriptions
|
|
1416
|
+
*/
|
|
1417
|
+
subscription<$Output extends AsyncIterable<any, void, any>>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? TypeError<'Not implemented'> : SubscriptionProcedure<{
|
|
1418
|
+
input: DefaultValue<TInputIn, void>;
|
|
1419
|
+
output: inferSubscriptionOutput$1<DefaultValue<TOutputOut, $Output>>;
|
|
1420
|
+
meta: TMeta;
|
|
1421
|
+
errorShape: TErrorShape;
|
|
1422
|
+
}>;
|
|
1423
|
+
/**
|
|
1424
|
+
* @deprecated Using subscriptions with an observable is deprecated. Use an async generator instead.
|
|
1425
|
+
* This feature will be removed in v12 of tRPC.
|
|
1426
|
+
* @see https://trpc.io/docs/v11/server/subscriptions
|
|
1427
|
+
*/
|
|
1428
|
+
subscription<$Output extends Observable<any, any>>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? TypeError<'Not implemented'> : LegacyObservableSubscriptionProcedure<{
|
|
1429
|
+
input: DefaultValue<TInputIn, void>;
|
|
1430
|
+
output: inferObservableValue<DefaultValue<TOutputOut, $Output>>;
|
|
1431
|
+
meta: TMeta;
|
|
1432
|
+
errorShape: TErrorShape;
|
|
1433
|
+
}>;
|
|
1434
|
+
/**
|
|
1435
|
+
* Overrides the way a procedure is invoked
|
|
1436
|
+
* Do not use this unless you know what you're doing - this is an experimental API
|
|
1437
|
+
*/
|
|
1438
|
+
experimental_caller(caller: CallerOverride<TContext>): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, true, TErrorShape>;
|
|
1439
|
+
/**
|
|
1440
|
+
* @internal
|
|
1441
|
+
*/
|
|
1442
|
+
_def: ProcedureBuilderDef<TMeta>;
|
|
1353
1443
|
}
|
|
1444
|
+
type ProcedureBuilderResolver = (opts: ProcedureResolverOptions<any, any, any, any>) => Promise<unknown>;
|
|
1445
|
+
declare function createBuilder<TContext, TMeta, TErrorShape = unknown>(initDef?: Partial<AnyProcedureBuilderDef>): ProcedureBuilder<TContext, TMeta, object, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, false, TErrorShape>;
|
|
1354
1446
|
/**
|
|
1355
1447
|
* @internal
|
|
1356
1448
|
*/
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
type PartialIf<TCondition extends boolean, TType> = TCondition extends true ? Partial<TType> : TType;
|
|
1365
|
-
/**
|
|
1366
|
-
* Adds a `createContext` option with a given callback function
|
|
1367
|
-
* If context is the default value, then the `createContext` option is optional
|
|
1368
|
-
*/
|
|
1369
|
-
type CreateContextCallback<TContext, TFunction extends (...args: any[]) => any> = PartialIf<object extends TContext ? true : false, {
|
|
1449
|
+
interface ProcedureCallOptions<TContext> {
|
|
1450
|
+
ctx: TContext;
|
|
1451
|
+
getRawInput: GetRawInputFn;
|
|
1452
|
+
input?: unknown;
|
|
1453
|
+
path: string;
|
|
1454
|
+
type: ProcedureType;
|
|
1455
|
+
signal: AbortSignal | undefined;
|
|
1370
1456
|
/**
|
|
1371
|
-
*
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
}>;
|
|
1375
|
-
//#endregion
|
|
1376
|
-
//#region src/unstable-core-do-not-import/router.d.ts
|
|
1377
|
-
interface RouterRecord {
|
|
1378
|
-
[key: string]: AnyProcedure | RouterRecord;
|
|
1457
|
+
* The index of this call in a batch request.
|
|
1458
|
+
*/
|
|
1459
|
+
batchIndex: number;
|
|
1379
1460
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
*/
|
|
1384
|
-
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; };
|
|
1385
|
-
/**
|
|
1386
|
-
* @internal
|
|
1387
|
-
*/
|
|
1388
|
-
type RouterCallerErrorHandler<TContext> = (opts: ErrorHandlerOptions<TContext>) => void;
|
|
1389
|
-
/**
|
|
1390
|
-
* @internal
|
|
1391
|
-
*/
|
|
1392
|
-
type RouterCaller<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = (
|
|
1393
|
-
/**
|
|
1394
|
-
* @note
|
|
1395
|
-
* If passing a function, we recommend it's a cached function
|
|
1396
|
-
* e.g. wrapped in `React.cache` to avoid unnecessary computations
|
|
1397
|
-
*/
|
|
1398
|
-
ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>), options?: {
|
|
1399
|
-
onError?: RouterCallerErrorHandler<TRoot['ctx']>;
|
|
1400
|
-
signal?: AbortSignal;
|
|
1401
|
-
}) => DecorateRouterRecord<TRecord>;
|
|
1402
|
-
type Lazy<TAny> = (() => Promise<TAny>) & {};
|
|
1403
|
-
type LazyLoader<TAny> = {
|
|
1404
|
-
load: () => Promise<void>;
|
|
1405
|
-
ref: Lazy<TAny>;
|
|
1406
|
-
};
|
|
1461
|
+
//#endregion
|
|
1462
|
+
//#region src/unstable-core-do-not-import/procedure.d.ts
|
|
1463
|
+
declare const procedureTypes: readonly ['query', 'mutation', 'subscription'];
|
|
1407
1464
|
/**
|
|
1408
|
-
*
|
|
1409
|
-
* @see https://trpc.io/docs/server/merging-routers#lazy-load
|
|
1465
|
+
* @public
|
|
1410
1466
|
*/
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1467
|
+
type ProcedureType = (typeof procedureTypes)[number];
|
|
1468
|
+
interface BuiltProcedureDef {
|
|
1469
|
+
meta: unknown;
|
|
1470
|
+
input: unknown;
|
|
1471
|
+
output: unknown;
|
|
1472
|
+
errorShape?: unknown;
|
|
1473
|
+
}
|
|
1414
1474
|
/**
|
|
1475
|
+
*
|
|
1415
1476
|
* @internal
|
|
1416
1477
|
*/
|
|
1417
|
-
interface
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1478
|
+
interface Procedure<TType extends ProcedureType, TDef extends BuiltProcedureDef> {
|
|
1479
|
+
_def: {
|
|
1480
|
+
/**
|
|
1481
|
+
* These are just types, they can't be used at runtime
|
|
1482
|
+
* @internal
|
|
1483
|
+
*/
|
|
1484
|
+
$types: {
|
|
1485
|
+
input: TDef['input'];
|
|
1486
|
+
output: TDef['output'];
|
|
1487
|
+
errorShape: TDef['errorShape'];
|
|
1488
|
+
};
|
|
1489
|
+
procedure: true;
|
|
1490
|
+
type: TType;
|
|
1491
|
+
/**
|
|
1492
|
+
* @internal
|
|
1493
|
+
* Meta is not inferrable on individual procedures, only on the router
|
|
1494
|
+
*/
|
|
1495
|
+
meta: unknown;
|
|
1496
|
+
experimental_caller: boolean;
|
|
1497
|
+
/**
|
|
1498
|
+
* The input parsers for the procedure
|
|
1499
|
+
*/
|
|
1500
|
+
inputs: Parser[];
|
|
1501
|
+
};
|
|
1502
|
+
meta: TDef['meta'];
|
|
1427
1503
|
/**
|
|
1428
|
-
* @
|
|
1504
|
+
* @internal
|
|
1429
1505
|
*/
|
|
1430
|
-
|
|
1431
|
-
}
|
|
1432
|
-
type BuiltRouter<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = Router<TRoot, TRecord> & TRecord;
|
|
1433
|
-
interface RouterBuilder<TRoot extends AnyRootTypes> {
|
|
1434
|
-
<TIn extends CreateRouterOptions>(_: TIn): BuiltRouter<TRoot, DecorateCreateRouterOptions<TIn>>;
|
|
1506
|
+
(opts: ProcedureCallOptions<unknown>): Promise<TDef['output']>;
|
|
1435
1507
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
type inferRouterError<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['errorShape'];
|
|
1440
|
-
type inferRouterMeta<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['meta'];
|
|
1441
|
-
/** @internal */
|
|
1442
|
-
type CreateRouterOptions = {
|
|
1443
|
-
[key: string]: AnyProcedure | AnyRouter | CreateRouterOptions | Lazy<AnyRouter>;
|
|
1444
|
-
};
|
|
1445
|
-
/** @internal */
|
|
1446
|
-
type DecorateCreateRouterOptions<TRouterOptions extends CreateRouterOptions> = { [K in keyof TRouterOptions]: TRouterOptions[K] extends (infer $Value) ? $Value extends AnyProcedure ? $Value : $Value extends Router<any, infer TRecord> ? TRecord : $Value extends Lazy<Router<any, infer TRecord>> ? TRecord : $Value extends CreateRouterOptions ? DecorateCreateRouterOptions<$Value> : never : never; };
|
|
1447
|
-
/**
|
|
1448
|
-
* @internal
|
|
1449
|
-
*/
|
|
1450
|
-
declare function createRouterFactory<TRoot extends AnyRootTypes>(config: RootConfig<TRoot>): <TInput extends CreateRouterOptions>(input: TInput) => BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>>;
|
|
1508
|
+
interface QueryProcedure<TDef extends BuiltProcedureDef> extends Procedure<'query', TDef> {}
|
|
1509
|
+
interface MutationProcedure<TDef extends BuiltProcedureDef> extends Procedure<'mutation', TDef> {}
|
|
1510
|
+
interface SubscriptionProcedure<TDef extends BuiltProcedureDef> extends Procedure<'subscription', TDef> {}
|
|
1451
1511
|
/**
|
|
1452
|
-
* @
|
|
1512
|
+
* @deprecated
|
|
1453
1513
|
*/
|
|
1454
|
-
|
|
1514
|
+
interface LegacyObservableSubscriptionProcedure<TDef extends BuiltProcedureDef> extends SubscriptionProcedure<TDef> {
|
|
1515
|
+
_observable: true;
|
|
1516
|
+
}
|
|
1517
|
+
type AnyQueryProcedure = QueryProcedure<any>;
|
|
1518
|
+
type AnyMutationProcedure = MutationProcedure<any>;
|
|
1519
|
+
type AnySubscriptionProcedure = SubscriptionProcedure<any> | LegacyObservableSubscriptionProcedure<any>;
|
|
1520
|
+
type AnyProcedure = AnyQueryProcedure | AnyMutationProcedure | AnySubscriptionProcedure;
|
|
1521
|
+
type inferProcedureInput<TProcedure extends AnyProcedure> = undefined extends inferProcedureParams<TProcedure>['$types']['input'] ? void | inferProcedureParams<TProcedure>['$types']['input'] : inferProcedureParams<TProcedure>['$types']['input'];
|
|
1522
|
+
type inferProcedureParams<TProcedure> = TProcedure extends AnyProcedure ? TProcedure['_def'] : never;
|
|
1523
|
+
type inferProcedureOutput<TProcedure> = inferProcedureParams<TProcedure>['$types']['output'];
|
|
1524
|
+
type inferSubscriptionInput<TProcedure extends AnySubscriptionProcedure> = inferProcedureInput<TProcedure>;
|
|
1525
|
+
type inferSubscriptionOutput<TProcedure extends AnySubscriptionProcedure> = TProcedure extends LegacyObservableSubscriptionProcedure<any> ? inferProcedureOutput<TProcedure> : inferAsyncIterableYield<inferProcedureOutput<TProcedure>>;
|
|
1455
1526
|
/**
|
|
1456
1527
|
* @internal
|
|
1457
1528
|
*/
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1529
|
+
interface ErrorHandlerOptions<TContext> {
|
|
1530
|
+
error: TRPCError;
|
|
1531
|
+
type: ProcedureType | 'unknown';
|
|
1532
|
+
path: string | undefined;
|
|
1533
|
+
input: unknown;
|
|
1534
|
+
ctx: TContext | undefined;
|
|
1464
1535
|
}
|
|
1465
|
-
declare function createCallerFactory<TRoot extends AnyRootTypes>(): RouterCallerFactory<TRoot>;
|
|
1466
|
-
/** @internal */
|
|
1467
|
-
type MergeRouters<TRouters extends AnyRouter[], TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'], TRecord extends RouterRecord = {}> = TRouters extends [infer Head extends AnyRouter, ...infer Tail extends AnyRouter[]] ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord> : BuiltRouter<TRoot, TRecord>;
|
|
1468
|
-
declare function mergeRouters<TRouters extends AnyRouter[]>(...routerList: [...TRouters]): MergeRouters<TRouters>;
|
|
1469
1536
|
//#endregion
|
|
1470
1537
|
//#region src/unstable-core-do-not-import/clientish/inferrable.d.ts
|
|
1471
1538
|
type AnyClientTypes = Pick<AnyRootTypes, 'errorShape' | 'transformer'>;
|
|
@@ -1565,6 +1632,10 @@ type UndefinedToOptional<T extends object> = Pick<WithoutIndexSignature<T>, Filt
|
|
|
1565
1632
|
* @internal
|
|
1566
1633
|
*/
|
|
1567
1634
|
type inferTransformedProcedureOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = inferClientTypes<TInferrable>['transformer'] extends false ? Serialize<inferProcedureOutput<TProcedure>> : inferProcedureOutput<TProcedure>;
|
|
1635
|
+
/**
|
|
1636
|
+
* @internal
|
|
1637
|
+
*/
|
|
1638
|
+
type inferProcedureErrorShape<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = TProcedure['_def']['$types']['errorShape'] extends (infer $Shape) ? unknown extends $Shape ? inferClientTypes<TInferrable>['errorShape'] : $Shape : never;
|
|
1568
1639
|
/** @internal */
|
|
1569
1640
|
type inferTransformedSubscriptionOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = inferClientTypes<TInferrable>['transformer'] extends false ? Serialize<inferObservableValue<inferProcedureOutput<TProcedure>>> : inferObservableValue<inferProcedureOutput<TProcedure>>;
|
|
1570
1641
|
type GetInferenceHelpers<TType extends 'input' | 'output', TRoot extends AnyClientTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? TType extends 'input' ? inferProcedureInput<$Value> : inferTransformedProcedureOutput<TRoot, $Value> : $Value extends RouterRecord ? GetInferenceHelpers<TType, TRoot, $Value> : never : never; };
|
|
@@ -1701,7 +1772,7 @@ interface TRPCRootObject<TContext extends object, TMeta extends object, TOptions
|
|
|
1701
1772
|
* Builder object for creating procedures
|
|
1702
1773
|
* @see https://trpc.io/docs/v11/server/procedures
|
|
1703
1774
|
*/
|
|
1704
|
-
procedure: ProcedureBuilder<TContext, TMeta, object, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, false>;
|
|
1775
|
+
procedure: ProcedureBuilder<TContext, TMeta, object, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, false, $Root['errorShape']>;
|
|
1705
1776
|
/**
|
|
1706
1777
|
* Create reusable middlewares
|
|
1707
1778
|
* @see https://trpc.io/docs/v11/server/middlewares
|
|
@@ -1940,5 +2011,5 @@ declare class Unpromise<T> implements ProxyPromise<T> {
|
|
|
1940
2011
|
static raceReferences<TPromise extends Promise<unknown>>(promises: readonly TPromise[]): Promise<readonly [TPromise]>;
|
|
1941
2012
|
}
|
|
1942
2013
|
//#endregion
|
|
1943
|
-
export {
|
|
1944
|
-
//# sourceMappingURL=unstable-core-do-not-import-
|
|
2014
|
+
export { ErrorHandlerOptions as $, inferRouterContext as $n, TRPC_ERROR_CODES_BY_KEY as $r, setFormattedErrorShape as $t, OctetInput as A, ResponseMeta as An, WebReadableStreamEsque as Ar, run as At, inferRouterInputs as B, Lazy as Bn, ParserStandardSchemaEsque as Br, createOutputMiddleware as Bt, JSONRPC2_TO_HTTP_CODE as C, ValidateShape as Ci, TRPCResultMessage as Cn, sse as Cr, emptyObject as Ct, getStatusKeyFromCode as D, inferAsyncIterableYield as Di, HTTPBaseHandlerOptions as Dn, JSONLProducerOptions as Dr, isObject as Dt, getStatusCodeFromKey as E, coerceAsyncIterableToArray as Ei, BaseHandlerOptions as En, ConsumerOnError as Er, isFunction as Et, getErrorShape as F, AnyRouter as Fn, Parser as Fr, MiddlewareFunction as Ft, SerializeObject as G, RouterCallerErrorHandler as Gn, ParserYupEsque as Gr, DefaultErrorShape as Gt, inferTransformedProcedureOutput as H, Router as Hn, ParserValibotEsque as Hr, middlewareMarker as Ht, createFlatProxy as I, BuiltRouter as In, ParserArkTypeEsque as Ir, MiddlewareResult as It, inferClientTypes as J, RouterRecord as Jn, inferParser as Jr, ProcedureErrorFormatter as Jt, AnyClientTypes as K, RouterCallerFactory as Kn, ParserZodEsque as Kr, ErrorFormatter as Kt, createRecursiveProxy as L, CreateRouterOptions as Ln, ParserCustomValidatorEsque as Lr, createErrorFormatterMiddleware as Lt, octetInputParser as M, TRPCAcceptHeader as Mn, jsonlStreamConsumer as Mr, AnyMiddlewareBuilder as Mt, getAcceptHeader as N, TRPCRequestInfo as Nn, jsonlStreamProducer as Nr, AnyMiddlewareFunction as Nt, formDataToObject as O, HTTPErrorHandler as On, NodeJSReadableStreamEsque as Or, mergeWithoutOverrides as Ot, getRequestInfo as P, TRPCRequestInfoProcedureCall as Pn, ParseFn as Pr, MiddlewareBuilder as Pt, AnySubscriptionProcedure as Q, getProcedureAtPath as Qn, getTRPCErrorFromUnknown as Qr, isFormattedErrorShape as Qt, GetInferenceHelpers as R, DecorateCreateRouterOptions as Rn, ParserMyZodEsque as Rr, createInputMiddleware as Rt, HTTP_CODE_TO_JSONRPC2 as S, Unwrap as Si, TRPCResult as Sn, isTrackedEnvelope as Sr, assertNever as St, getHTTPStatusCodeFromError as T, WithoutIndexSignature as Ti, TRPCSuccessResponse as Tn, EventSourceLike as Tr, isAsyncIterable as Tt, inferTransformedSubscriptionOutput as U, RouterBuilder as Un, ParserWithInputOutput as Ur, AnyProcedureErrorFormatter as Ut, inferRouterOutputs as V, MergeRouters as Vn, ParserSuperstructEsque as Vr, experimental_standaloneMiddleware as Vt, Serialize as W, RouterCaller as Wn, ParserWithoutInput as Wr, DefaultErrorData as Wt, AnyProcedure as X, createCallerFactory as Xn, TRPCError as Xr, getDefaultErrorShape as Xt, AnyMutationProcedure as Y, callProcedure as Yn, StandardSchemaV1 as Yr, defaultFormatter as Yt, AnyQueryProcedure as Z, createRouterFactory as Zn, getCauseFromUnknown as Zr, getFormattedErrorShape as Zt, resolveResponse as _, PickFirstDefined as _i, TRPCReconnectNotification as _n, sseStreamConsumer as _r, createBuilder as _t, SubscribedPromise as a, Dict as ai, defaultTransformer as an, AnyRootTypes as ar, SubscriptionProcedure as at, isAbortError as b, Simplify as bi, TRPCResponse as bn, TrackedEnvelope as br, abortSignalsAnyPonyfill as bt, takeWithGrace as c, Filter as ci, transformTRPCResponse as cn, RootConfig as cr, inferProcedureParams as ct, Deferred as d, IntersectionError as di, TRPCClientIncomingRequest as dn, isServerDefault as dr, procedureTypes as dt, TRPC_ERROR_CODES_BY_NUMBER as ei, parseTRPCMessage as en, inferRouterError as er, LegacyObservableSubscriptionProcedure as et, createDeferred as f, InvertKeyValue as fi, TRPCClientOutgoingMessage as fn, SSEClientOptions as fr, AnyProcedureBuilder as ft, initTRPC as g, Overwrite as gi, TRPCErrorShape as gn, sseHeaders as gr, ProcedureResolverOptions as gt, TRPCRootObject as h, MaybePromise as hi, TRPCErrorResponse as hn, SSEStreamProducerOptions as hr, ProcedureCallOptions as ht, ProxyPromise as i, DeepPartial as ii, DataTransformerOptions as in, mergeRouters as ir, QueryProcedure as it, UtilityParser as j, ResponseMetaFn as jn, isPromise as jr, sleep as jt, FileLike as k, ResolveHTTPRequestOptionsContextFn as kn, ProducerOnError as kr, noop as kt, makeAsyncResource as l, FilterKeys as li, JSONRPC2 as ln, RootTypes as lr, inferSubscriptionInput as lt, TRPCBuilder as m, Maybe as mi, TRPCConnectionParamsMessage as mn, SSEStreamConsumerOptions as mr, ProcedureBuilder as mt, PromiseExecutor as n, TRPC_ERROR_CODE_NUMBER as ni, CombinedDataTransformerClient as nn, inferRouterRootTypes as nr, Procedure as nt, StandardSchemaV1Error as o, DistributiveOmit as oi, getDataTransformer as on, CreateContextCallback as or, inferProcedureInput as ot, RuntimeConfigOptions as p, KeyFromValue as pi, TRPCClientOutgoingRequest as pn, SSEPingOptions as pr, CallerOverride as pt, InferrableClientTypes as q, RouterDef as qn, getParseFn as qr, ErrorFormatterOptions as qt, PromiseWithResolvers as r, retryableRpcCodes as ri, DataTransformer as rn, lazy as rr, ProcedureType as rt, iteratorResource as s, ErrorSymbol as si, transformResult as sn, CreateRootTypes as sr, inferProcedureOutput as st, Unpromise as t, TRPC_ERROR_CODE_KEY as ti, CombinedDataTransformer as tn, inferRouterMeta as tr, MutationProcedure as tt, makeResource as u, GetRawInputFn as ui, TRPCClientIncomingMessage as un, isDevDefault as ur, inferSubscriptionOutput as ut, parseConnectionParamsFromString as v, ProtectedIntersection as vi, TRPCRequest as vn, sseStreamProducer as vr, inferProcedureBuilderResolverOptions as vt, getHTTPStatusCode as w, ValueOf as wi, TRPCSubscriptionStopNotification as wn, tracked as wr, identity as wt, throwAbortError as x, TypeError as xi, TRPCResponseMessage as xn, inferTrackedOutput as xr, assert as xt, parseConnectionParamsFromUnknown as y, Result$1 as yi, TRPCRequestMessage as yn, TrackedData as yr, UnsetMarker as yt, inferProcedureErrorShape as z, DecorateRouterRecord as zn, ParserScaleEsque as zr, createMiddlewareFactory as zt };
|
|
2015
|
+
//# sourceMappingURL=unstable-core-do-not-import-Jynlfuqc.d.cts.map
|