@trpc/server 9.20.3 → 9.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapters/express/dist/trpc-server-adapters-express.cjs.dev.js +2 -2
- package/adapters/express/dist/trpc-server-adapters-express.cjs.prod.js +2 -2
- package/adapters/express/dist/trpc-server-adapters-express.esm.js +2 -2
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.dev.js +15 -8
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.prod.js +15 -8
- package/adapters/fastify/dist/trpc-server-adapters-fastify.esm.js +15 -8
- package/adapters/ws/dist/trpc-server-adapters-ws.cjs.dev.js +3 -3
- package/adapters/ws/dist/trpc-server-adapters-ws.cjs.prod.js +3 -3
- package/adapters/ws/dist/trpc-server-adapters-ws.esm.js +3 -3
- package/dist/declarations/src/adapters/fastify/fastifyRequestHandler.d.ts +3 -3
- package/dist/declarations/src/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/declarations/src/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/declarations/src/adapters/next.d.ts +1 -1
- package/dist/declarations/src/adapters/next.d.ts.map +1 -1
- package/dist/declarations/src/internals/procedure.d.ts +37 -30
- package/dist/declarations/src/internals/procedure.d.ts.map +1 -1
- package/dist/declarations/src/router.d.ts +17 -17
- package/dist/declarations/src/router.d.ts.map +1 -1
- package/dist/{subscription-c2e0bfbc.cjs.prod.js → subscription-12fb50be.cjs.prod.js} +1 -1
- package/dist/{subscription-b8831081.cjs.dev.js → subscription-9e007280.cjs.dev.js} +1 -1
- package/dist/{subscription-fbda2888.esm.js → subscription-a81120d6.esm.js} +1 -1
- package/dist/trpc-server.cjs.dev.js +35 -15
- package/dist/trpc-server.cjs.prod.js +35 -15
- package/dist/trpc-server.esm.js +35 -15
- package/package.json +2 -2
- package/src/adapters/express.ts +2 -2
- package/src/adapters/fastify/fastifyRequestHandler.ts +8 -9
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +11 -3
- package/src/adapters/next.ts +5 -1
- package/src/adapters/ws.ts +2 -2
- package/src/internals/procedure.ts +123 -63
- package/src/router.ts +93 -37
- package/src/subscription.ts +1 -1
- package/ws/dist/trpc-server-ws.cjs.dev.js +1 -1
- package/ws/dist/trpc-server-ws.cjs.prod.js +1 -1
- package/ws/dist/trpc-server-ws.esm.js +1 -1
|
@@ -10,9 +10,9 @@ require('../../../dist/codes-33cef953.cjs.dev.js');
|
|
|
10
10
|
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
12
|
function createExpressMiddleware(opts) {
|
|
13
|
-
return (req, res) => {
|
|
13
|
+
return async (req, res) => {
|
|
14
14
|
const endpoint = req.path.slice(1);
|
|
15
|
-
nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
|
|
15
|
+
await nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
|
|
16
16
|
req,
|
|
17
17
|
res,
|
|
18
18
|
path: endpoint
|
|
@@ -10,9 +10,9 @@ require('../../../dist/codes-e0df67c4.cjs.prod.js');
|
|
|
10
10
|
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
12
|
function createExpressMiddleware(opts) {
|
|
13
|
-
return (req, res) => {
|
|
13
|
+
return async (req, res) => {
|
|
14
14
|
const endpoint = req.path.slice(1);
|
|
15
|
-
nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
|
|
15
|
+
await nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
|
|
16
16
|
req,
|
|
17
17
|
res,
|
|
18
18
|
path: endpoint
|
|
@@ -6,9 +6,9 @@ import '../../../dist/codes-fe07bf82.esm.js';
|
|
|
6
6
|
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
8
|
function createExpressMiddleware(opts) {
|
|
9
|
-
return (req, res) => {
|
|
9
|
+
return async (req, res) => {
|
|
10
10
|
const endpoint = req.path.slice(1);
|
|
11
|
-
nodeHTTPRequestHandler({ ...opts,
|
|
11
|
+
await nodeHTTPRequestHandler({ ...opts,
|
|
12
12
|
req,
|
|
13
13
|
res,
|
|
14
14
|
path: endpoint
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var url = require('url');
|
|
6
5
|
var resolveHTTPResponse = require('../../../dist/resolveHTTPResponse-3867844c.cjs.dev.js');
|
|
6
|
+
var url = require('url');
|
|
7
7
|
var adapters_ws_dist_trpcServerAdaptersWs = require('../../ws/dist/trpc-server-adapters-ws.cjs.dev.js');
|
|
8
8
|
require('../../../dist/transformTRPCResponse-8248515e.cjs.dev.js');
|
|
9
9
|
require('../../../dist/codes-33cef953.cjs.dev.js');
|
|
10
|
-
require('../../../dist/subscription-
|
|
10
|
+
require('../../../dist/subscription-9e007280.cjs.dev.js');
|
|
11
11
|
require('events');
|
|
12
12
|
|
|
13
13
|
resolveHTTPResponse.assertNotBrowser();
|
|
@@ -59,10 +59,10 @@ async function fastifyRequestHandler(opts) {
|
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
res.header(key, value);
|
|
62
|
+
void res.header(key, value);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
res.send(result.body);
|
|
65
|
+
await res.send(result.body);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/// <reference types="fastify-websocket" />
|
|
@@ -74,9 +74,16 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
74
74
|
}, function (_, body, _done) {
|
|
75
75
|
_done(null, body);
|
|
76
76
|
});
|
|
77
|
-
|
|
77
|
+
let prefix = (_opts$prefix = opts.prefix) !== null && _opts$prefix !== void 0 ? _opts$prefix : ''; // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
|
|
78
|
+
// @ts-expect-error property 'default' does not exists on type ...
|
|
79
|
+
|
|
80
|
+
if (typeof fastifyTRPCPlugin.default !== 'function') {
|
|
81
|
+
prefix = ''; // handled by fastify internally
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fastify.all(`${prefix}/:path`, async (req, res) => {
|
|
78
85
|
const path = req.params.path;
|
|
79
|
-
fastifyRequestHandler({ ...opts.trpcOptions,
|
|
86
|
+
await fastifyRequestHandler({ ...opts.trpcOptions,
|
|
80
87
|
req,
|
|
81
88
|
res,
|
|
82
89
|
path
|
|
@@ -84,13 +91,13 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
84
91
|
});
|
|
85
92
|
|
|
86
93
|
if (opts.useWSS) {
|
|
87
|
-
var
|
|
94
|
+
var _prefix;
|
|
88
95
|
|
|
89
96
|
adapters_ws_dist_trpcServerAdaptersWs.applyWSSHandler({ ...opts.trpcOptions,
|
|
90
97
|
wss: fastify.websocketServer
|
|
91
98
|
}); // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
92
99
|
|
|
93
|
-
fastify.get((
|
|
100
|
+
fastify.get((_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : '/', {
|
|
94
101
|
websocket: true
|
|
95
102
|
}, () => {});
|
|
96
103
|
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var url = require('url');
|
|
6
5
|
var resolveHTTPResponse = require('../../../dist/resolveHTTPResponse-562c3d62.cjs.prod.js');
|
|
6
|
+
var url = require('url');
|
|
7
7
|
var adapters_ws_dist_trpcServerAdaptersWs = require('../../ws/dist/trpc-server-adapters-ws.cjs.prod.js');
|
|
8
8
|
require('../../../dist/transformTRPCResponse-dcbf66c5.cjs.prod.js');
|
|
9
9
|
require('../../../dist/codes-e0df67c4.cjs.prod.js');
|
|
10
|
-
require('../../../dist/subscription-
|
|
10
|
+
require('../../../dist/subscription-12fb50be.cjs.prod.js');
|
|
11
11
|
require('events');
|
|
12
12
|
|
|
13
13
|
resolveHTTPResponse.assertNotBrowser();
|
|
@@ -59,10 +59,10 @@ async function fastifyRequestHandler(opts) {
|
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
res.header(key, value);
|
|
62
|
+
void res.header(key, value);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
res.send(result.body);
|
|
65
|
+
await res.send(result.body);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/// <reference types="fastify-websocket" />
|
|
@@ -74,9 +74,16 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
74
74
|
}, function (_, body, _done) {
|
|
75
75
|
_done(null, body);
|
|
76
76
|
});
|
|
77
|
-
|
|
77
|
+
let prefix = (_opts$prefix = opts.prefix) !== null && _opts$prefix !== void 0 ? _opts$prefix : ''; // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
|
|
78
|
+
// @ts-expect-error property 'default' does not exists on type ...
|
|
79
|
+
|
|
80
|
+
if (typeof fastifyTRPCPlugin.default !== 'function') {
|
|
81
|
+
prefix = ''; // handled by fastify internally
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fastify.all(`${prefix}/:path`, async (req, res) => {
|
|
78
85
|
const path = req.params.path;
|
|
79
|
-
fastifyRequestHandler({ ...opts.trpcOptions,
|
|
86
|
+
await fastifyRequestHandler({ ...opts.trpcOptions,
|
|
80
87
|
req,
|
|
81
88
|
res,
|
|
82
89
|
path
|
|
@@ -84,13 +91,13 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
84
91
|
});
|
|
85
92
|
|
|
86
93
|
if (opts.useWSS) {
|
|
87
|
-
var
|
|
94
|
+
var _prefix;
|
|
88
95
|
|
|
89
96
|
adapters_ws_dist_trpcServerAdaptersWs.applyWSSHandler({ ...opts.trpcOptions,
|
|
90
97
|
wss: fastify.websocketServer
|
|
91
98
|
}); // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
92
99
|
|
|
93
|
-
fastify.get((
|
|
100
|
+
fastify.get((_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : '/', {
|
|
94
101
|
websocket: true
|
|
95
102
|
}, () => {});
|
|
96
103
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { URLSearchParams } from 'url';
|
|
2
1
|
import { a as assertNotBrowser, r as resolveHTTPResponse } from '../../../dist/resolveHTTPResponse-85f3f5df.esm.js';
|
|
2
|
+
import { URLSearchParams } from 'url';
|
|
3
3
|
import { applyWSSHandler } from '../../ws/dist/trpc-server-adapters-ws.esm.js';
|
|
4
4
|
import '../../../dist/transformTRPCResponse-f73dc4a2.esm.js';
|
|
5
5
|
import '../../../dist/codes-fe07bf82.esm.js';
|
|
6
|
-
import '../../../dist/subscription-
|
|
6
|
+
import '../../../dist/subscription-a81120d6.esm.js';
|
|
7
7
|
import 'events';
|
|
8
8
|
|
|
9
9
|
assertNotBrowser();
|
|
@@ -55,10 +55,10 @@ async function fastifyRequestHandler(opts) {
|
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
res.header(key, value);
|
|
58
|
+
void res.header(key, value);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
res.send(result.body);
|
|
61
|
+
await res.send(result.body);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/// <reference types="fastify-websocket" />
|
|
@@ -70,9 +70,16 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
70
70
|
}, function (_, body, _done) {
|
|
71
71
|
_done(null, body);
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
let prefix = (_opts$prefix = opts.prefix) !== null && _opts$prefix !== void 0 ? _opts$prefix : ''; // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
|
|
74
|
+
// @ts-expect-error property 'default' does not exists on type ...
|
|
75
|
+
|
|
76
|
+
if (typeof fastifyTRPCPlugin.default !== 'function') {
|
|
77
|
+
prefix = ''; // handled by fastify internally
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fastify.all(`${prefix}/:path`, async (req, res) => {
|
|
74
81
|
const path = req.params.path;
|
|
75
|
-
fastifyRequestHandler({ ...opts.trpcOptions,
|
|
82
|
+
await fastifyRequestHandler({ ...opts.trpcOptions,
|
|
76
83
|
req,
|
|
77
84
|
res,
|
|
78
85
|
path
|
|
@@ -80,13 +87,13 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
80
87
|
});
|
|
81
88
|
|
|
82
89
|
if (opts.useWSS) {
|
|
83
|
-
var
|
|
90
|
+
var _prefix;
|
|
84
91
|
|
|
85
92
|
applyWSSHandler({ ...opts.trpcOptions,
|
|
86
93
|
wss: fastify.websocketServer
|
|
87
94
|
}); // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
88
95
|
|
|
89
|
-
fastify.get((
|
|
96
|
+
fastify.get((_prefix = prefix) !== null && _prefix !== void 0 ? _prefix : '/', {
|
|
90
97
|
websocket: true
|
|
91
98
|
}, () => {});
|
|
92
99
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var transformTRPCResponse = require('../../../dist/transformTRPCResponse-8248515e.cjs.dev.js');
|
|
6
|
-
var subscription = require('../../../dist/subscription-
|
|
6
|
+
var subscription = require('../../../dist/subscription-9e007280.cjs.dev.js');
|
|
7
7
|
require('events');
|
|
8
8
|
|
|
9
9
|
/* istanbul ignore next */
|
|
@@ -96,7 +96,7 @@ function applyWSSHandler(opts) {
|
|
|
96
96
|
const {
|
|
97
97
|
transformer
|
|
98
98
|
} = router._def;
|
|
99
|
-
wss.on('connection', (client, req) => {
|
|
99
|
+
wss.on('connection', async (client, req) => {
|
|
100
100
|
const clientSubscriptions = new Map();
|
|
101
101
|
|
|
102
102
|
function respond(untransformedJSON) {
|
|
@@ -323,7 +323,7 @@ function applyWSSHandler(opts) {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
createContextAsync();
|
|
326
|
+
await createContextAsync();
|
|
327
327
|
});
|
|
328
328
|
return {
|
|
329
329
|
broadcastReconnectNotification: () => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var transformTRPCResponse = require('../../../dist/transformTRPCResponse-dcbf66c5.cjs.prod.js');
|
|
6
|
-
var subscription = require('../../../dist/subscription-
|
|
6
|
+
var subscription = require('../../../dist/subscription-12fb50be.cjs.prod.js');
|
|
7
7
|
require('events');
|
|
8
8
|
|
|
9
9
|
/* istanbul ignore next */
|
|
@@ -96,7 +96,7 @@ function applyWSSHandler(opts) {
|
|
|
96
96
|
const {
|
|
97
97
|
transformer
|
|
98
98
|
} = router._def;
|
|
99
|
-
wss.on('connection', (client, req) => {
|
|
99
|
+
wss.on('connection', async (client, req) => {
|
|
100
100
|
const clientSubscriptions = new Map();
|
|
101
101
|
|
|
102
102
|
function respond(untransformedJSON) {
|
|
@@ -323,7 +323,7 @@ function applyWSSHandler(opts) {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
createContextAsync();
|
|
326
|
+
await createContextAsync();
|
|
327
327
|
});
|
|
328
328
|
return {
|
|
329
329
|
broadcastReconnectNotification: () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { T as TRPCError, t as transformTRPCResponse, c as callProcedure, g as getErrorFromUnknown } from '../../../dist/transformTRPCResponse-f73dc4a2.esm.js';
|
|
2
|
-
import { S as Subscription } from '../../../dist/subscription-
|
|
2
|
+
import { S as Subscription } from '../../../dist/subscription-a81120d6.esm.js';
|
|
3
3
|
import 'events';
|
|
4
4
|
|
|
5
5
|
/* istanbul ignore next */
|
|
@@ -92,7 +92,7 @@ function applyWSSHandler(opts) {
|
|
|
92
92
|
const {
|
|
93
93
|
transformer
|
|
94
94
|
} = router._def;
|
|
95
|
-
wss.on('connection', (client, req) => {
|
|
95
|
+
wss.on('connection', async (client, req) => {
|
|
96
96
|
const clientSubscriptions = new Map();
|
|
97
97
|
|
|
98
98
|
function respond(untransformedJSON) {
|
|
@@ -319,7 +319,7 @@ function applyWSSHandler(opts) {
|
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
createContextAsync();
|
|
322
|
+
await createContextAsync();
|
|
323
323
|
});
|
|
324
324
|
return {
|
|
325
325
|
broadcastReconnectNotification: () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FastifyReply, FastifyRequest } from 'fastify';
|
|
2
|
-
import { NodeHTTPCreateContextOption } from '../node-http';
|
|
3
|
-
import { AnyRouter } from '../../router';
|
|
4
1
|
import { HTTPBaseHandlerOptions } from '../../http/internals/types';
|
|
2
|
+
import { AnyRouter } from '../../router';
|
|
3
|
+
import { NodeHTTPCreateContextOption } from '../node-http';
|
|
4
|
+
import { FastifyReply, FastifyRequest } from 'fastify';
|
|
5
5
|
export declare type FastifyHandlerOptions<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply> = HTTPBaseHandlerOptions<TRouter, TRequest> & NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;
|
|
6
6
|
declare type FastifyRequestHandlerOptions<TRouter extends AnyRouter, TRequest extends FastifyRequest, TResponse extends FastifyReply> = {
|
|
7
7
|
req: TRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"../../../../../src/adapters/fastify","sources":["fastifyRequestHandler.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"../../../../../src/adapters/fastify","sources":["fastifyRequestHandler.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EAEvB,MAAM,4BAA4B,CAAC;AAEpC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C,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,oBAAY,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"../../../../../src/adapters/fastify","sources":["fastifyTRPCPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExE,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,oBAAY,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAiC5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
1
|
+
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next/types';
|
|
2
2
|
import { AnyRouter } from '../router';
|
|
3
3
|
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from './node-http';
|
|
4
4
|
export declare type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiRequest, NextApiResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"../../../../src/adapters","sources":["next.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"../../../../src/adapters","sources":["next.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,oBAAY,wBAAwB,GAAG,8BAA8B,CACnE,cAAc,EACd,eAAe,CAChB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,SAAS,EAC5D,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,cAAc,EAAE,eAAe,CAAC,GACrE,cAAc,CAyChB"}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { ProcedureType } from '../router';
|
|
2
2
|
import { MiddlewareFunction } from './middlewares';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type ProcedureParserZodEsque<TInput, TOutput> = {
|
|
4
4
|
_input: TInput;
|
|
5
|
-
_output:
|
|
5
|
+
_output: TOutput;
|
|
6
6
|
};
|
|
7
|
-
export declare type
|
|
8
|
-
parse: (input: any) =>
|
|
7
|
+
export declare type ProcedureParserMyZodEsque<T> = {
|
|
8
|
+
parse: (input: any) => T;
|
|
9
9
|
};
|
|
10
|
-
export declare type
|
|
11
|
-
create: (input: unknown) =>
|
|
10
|
+
export declare type ProcedureParserSuperstructEsque<T> = {
|
|
11
|
+
create: (input: unknown) => T;
|
|
12
12
|
};
|
|
13
|
-
export declare type
|
|
14
|
-
export declare type
|
|
15
|
-
validateSync: (input: unknown) =>
|
|
13
|
+
export declare type ProcedureParserCustomValidatorEsque<T> = (input: unknown) => T | Promise<T>;
|
|
14
|
+
export declare type ProcedureParserYupEsque<T> = {
|
|
15
|
+
validateSync: (input: unknown) => T;
|
|
16
16
|
};
|
|
17
|
-
export declare type
|
|
18
|
-
export declare type
|
|
19
|
-
export declare type ProcedureResolver<TContext,
|
|
17
|
+
export declare type ProcedureParserWithInputOutput<TInput, TOutput> = ProcedureParserZodEsque<TInput, TOutput>;
|
|
18
|
+
export declare type ProcedureParser<T> = ProcedureParserYupEsque<T> | ProcedureParserSuperstructEsque<T> | ProcedureParserCustomValidatorEsque<T> | ProcedureParserMyZodEsque<T>;
|
|
19
|
+
export declare type ProcedureResolver<TContext, TInput, TOutput> = (opts: {
|
|
20
20
|
ctx: TContext;
|
|
21
|
-
input:
|
|
21
|
+
input: TInput;
|
|
22
22
|
type: ProcedureType;
|
|
23
23
|
}) => Promise<TOutput> | TOutput;
|
|
24
|
-
interface ProcedureOptions<TContext,
|
|
24
|
+
interface ProcedureOptions<TContext, TInput, TOutput, TParsedOutput> {
|
|
25
25
|
middlewares: Array<MiddlewareFunction<any, any>>;
|
|
26
|
-
resolver: ProcedureResolver<TContext,
|
|
27
|
-
inputParser:
|
|
26
|
+
resolver: ProcedureResolver<TContext, TInput, TOutput>;
|
|
27
|
+
inputParser: ProcedureParser<TInput>;
|
|
28
|
+
outputParser: ProcedureParser<TParsedOutput>;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* @internal
|
|
@@ -38,37 +39,43 @@ export interface ProcedureCallOptions<TContext> {
|
|
|
38
39
|
/**
|
|
39
40
|
* @internal
|
|
40
41
|
*/
|
|
41
|
-
export declare class Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput> {
|
|
42
|
+
export declare class Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput, TParsedOutput, TFinalOutput = unknown extends TParsedOutput ? TOutput : TParsedOutput> {
|
|
42
43
|
private middlewares;
|
|
43
44
|
private resolver;
|
|
44
45
|
private readonly inputParser;
|
|
45
|
-
private
|
|
46
|
-
|
|
46
|
+
private parseInputFn;
|
|
47
|
+
private readonly outputParser;
|
|
48
|
+
private parseOutputFn;
|
|
49
|
+
constructor(opts: ProcedureOptions<TContext, TParsedInput, TOutput, TFinalOutput>);
|
|
47
50
|
private parseInput;
|
|
51
|
+
private parseOutput;
|
|
48
52
|
/**
|
|
49
|
-
* Trigger middlewares in order, parse raw input &
|
|
53
|
+
* Trigger middlewares in order, parse raw input, call resolver & parse raw output
|
|
50
54
|
* @internal
|
|
51
55
|
*/
|
|
52
|
-
call(opts: ProcedureCallOptions<TInputContext>): Promise<
|
|
56
|
+
call(opts: ProcedureCallOptions<TInputContext>): Promise<TFinalOutput>;
|
|
53
57
|
/**
|
|
54
58
|
* Create new procedure with passed middlewares
|
|
55
59
|
* @param middlewares
|
|
56
60
|
*/
|
|
57
61
|
inheritMiddlewares(middlewares: MiddlewareFunction<TInputContext, TContext>[]): this;
|
|
58
62
|
}
|
|
59
|
-
export declare type CreateProcedureWithInput<TContext, TInput,
|
|
60
|
-
input:
|
|
61
|
-
|
|
63
|
+
export declare type CreateProcedureWithInput<TContext, TInput, TOutput> = {
|
|
64
|
+
input: ProcedureParser<TInput>;
|
|
65
|
+
output?: ProcedureParser<TOutput>;
|
|
66
|
+
resolve: ProcedureResolver<TContext, TInput, TOutput>;
|
|
62
67
|
};
|
|
63
|
-
export declare type CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput> = {
|
|
64
|
-
input:
|
|
68
|
+
export declare type CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput> = {
|
|
69
|
+
input: ProcedureParserWithInputOutput<TInput, TParsedInput>;
|
|
70
|
+
output?: ProcedureParserWithInputOutput<TOutput, TParsedOutput>;
|
|
65
71
|
resolve: ProcedureResolver<TContext, TParsedInput, TOutput>;
|
|
66
72
|
};
|
|
67
|
-
export declare type CreateProcedureWithoutInput<TContext, TOutput> = {
|
|
73
|
+
export declare type CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput> = {
|
|
74
|
+
output?: ProcedureParserWithInputOutput<TOutput, TParsedOutput> | ProcedureParser<TOutput>;
|
|
68
75
|
resolve: ProcedureResolver<TContext, undefined, TOutput>;
|
|
69
76
|
};
|
|
70
|
-
export declare type CreateProcedureOptions<TContext, TInput = undefined, TParsedInput = undefined, TOutput = undefined> =
|
|
71
|
-
export declare function createProcedure<TContext, TInput, TParsedInput, TOutput>(opts: CreateProcedureOptions<TContext, TInput, TParsedInput, TOutput>): Procedure<unknown, TContext, TInput, TParsedInput, TOutput>;
|
|
72
|
-
export declare type inferProcedureFromOptions<TInputContext, TOptions extends CreateProcedureOptions<any, any, any, any>> = TOptions extends CreateProcedureOptions<infer TContext, infer TInput, infer TParsedInput, infer TOutput> ? Procedure<TInputContext, TContext, unknown extends TInput ? undefined : TInput, unknown extends TParsedInput ? undefined : TParsedInput, TOutput> : never;
|
|
77
|
+
export declare type CreateProcedureOptions<TContext, TInput = undefined, TParsedInput = undefined, TOutput = undefined, TParsedOutput = undefined> = CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput> | CreateProcedureWithInput<TContext, TInput, TOutput> | CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput>;
|
|
78
|
+
export declare function createProcedure<TContext, TInput, TParsedInput, TOutput, TParsedOutput>(opts: CreateProcedureOptions<TContext, TInput, TParsedInput, TOutput, TParsedOutput>): Procedure<unknown, TContext, TInput, TParsedInput, TOutput, TParsedOutput>;
|
|
79
|
+
export declare type inferProcedureFromOptions<TInputContext, TOptions extends CreateProcedureOptions<any, any, any, any, any>> = TOptions extends CreateProcedureOptions<infer TContext, infer TInput, infer TParsedInput, infer TOutput, infer TParsedOutput> ? Procedure<TInputContext, TContext, unknown extends TInput ? undefined : TInput, unknown extends TParsedInput ? undefined : TParsedInput, TOutput, TParsedOutput> : never;
|
|
73
80
|
export {};
|
|
74
81
|
//# sourceMappingURL=procedure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedure.d.ts","sourceRoot":"../../../../src/internals","sources":["procedure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"procedure.d.ts","sourceRoot":"../../../../src/internals","sources":["procedure.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAoB,MAAM,eAAe,CAAC;AAKrE,oBAAY,uBAAuB,CAAC,MAAM,EAAE,OAAO,IAAI;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,oBAAY,yBAAyB,CAAC,CAAC,IAAI;IACzC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,+BAA+B,CAAC,CAAC,IAAI;IAC/C,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC;CAC/B,CAAC;AAEF,oBAAY,mCAAmC,CAAC,CAAC,IAAI,CACnD,KAAK,EAAE,OAAO,KACX,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEpB,oBAAY,uBAAuB,CAAC,CAAC,IAAI;IACvC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC;CACrC,CAAC;AAEF,oBAAY,8BAA8B,CAAC,MAAM,EAAE,OAAO,IACxD,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,oBAAY,eAAe,CAAC,CAAC,IACzB,uBAAuB,CAAC,CAAC,CAAC,GAC1B,+BAA+B,CAAC,CAA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IAEvB,oCAAoC,CAClC,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,aAAa,CACd,GACD,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,GACnD,2BAA2B,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;AAElE,wBAAgB,eAAe,CAC7B,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,aAAa,EAEb,IAAI,EAAE,sBAAsB,CAC1B,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,aAAa,CACd,GACA,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,CAAC,CAyB5E;AAED,oBAAY,yBAAyB,CACnC,aAAa,EACb,QAAQ,SAAS,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAC9D,QAAQ,SAAS,sBAAsB,CACzC,MAAM,QAAQ,EACd,MAAM,MAAM,EACZ,MAAM,YAAY,EAClB,MAAM,OAAO,EACb,MAAM,aAAa,CACpB,GACG,SAAS,CACP,aAAa,EACb,QAAQ,EACR,OAAO,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,EAC3C,OAAO,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,EACvD,OAAO,EACP,aAAa,CACd,GACD,KAAK,CAAC"}
|
|
@@ -12,11 +12,11 @@ export declare type ProcedureType = 'query' | 'mutation' | 'subscription';
|
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
export declare type ProcedureRecord<TInputContext = any, TContext = any, TInput = any, TParsedInput = any, TOutput = any> = Record<string, Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput>>;
|
|
15
|
+
export declare type ProcedureRecord<TInputContext = any, TContext = any, TInput = any, TParsedInput = any, TOutput = any, TParsedOutput = any> = Record<string, Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput, TParsedOutput>>;
|
|
16
16
|
/**
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
|
-
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer Input, any, any> ? undefined extends Input ? Input | null | void : Input : undefined;
|
|
19
|
+
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer Input, any, any, any> ? undefined extends Input ? Input | null | void : Input : undefined;
|
|
20
20
|
/**
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
@@ -24,7 +24,7 @@ export declare type inferAsyncReturnType<TFunction extends (...args: any) => any
|
|
|
24
24
|
/**
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
|
-
export declare type inferProcedureOutput<TProcedure extends Procedure<any, any, any, any, any>> = inferAsyncReturnType<TProcedure['call']>;
|
|
27
|
+
export declare type inferProcedureOutput<TProcedure extends Procedure<any, any, any, any, any, any>> = inferAsyncReturnType<TProcedure['call']>;
|
|
28
28
|
/**
|
|
29
29
|
* @public
|
|
30
30
|
* @beta
|
|
@@ -33,7 +33,7 @@ export declare type inferSubscriptionOutput<TRouter extends AnyRouter, TPath ext
|
|
|
33
33
|
/**
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
36
|
-
export declare type inferHandlerInput<TProcedure extends Procedure<any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer TInput, any, any> ? undefined extends TInput ? unknown extends TInput ? [(null | undefined)?] : [(TInput | null | undefined)?] : [TInput] : [(undefined | null)?];
|
|
36
|
+
export declare type inferHandlerInput<TProcedure extends Procedure<any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer TInput, any, any, any> ? undefined extends TInput ? unknown extends TInput ? [(null | undefined)?] : [(TInput | null | undefined)?] : [TInput] : [(undefined | null)?];
|
|
37
37
|
declare type inferHandlerFn<TProcedures extends ProcedureRecord> = <TProcedure extends TProcedures[TPath], TPath extends keyof TProcedures & string>(path: TPath, ...args: inferHandlerInput<TProcedure>) => Promise<inferProcedureOutput<TProcedures[TPath]>>;
|
|
38
38
|
/**
|
|
39
39
|
* @internal
|
|
@@ -71,14 +71,14 @@ export interface DefaultErrorShape extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER
|
|
|
71
71
|
message: string;
|
|
72
72
|
code: TRPC_ERROR_CODE_NUMBER;
|
|
73
73
|
}
|
|
74
|
-
declare type SwapProcedureContext<TProcedure extends Procedure<any, any, any, any, any>, TNewContext> = TProcedure extends Procedure<infer TInputContext, infer _TOldContext, infer TInput, infer TParsedInput, infer TOutput> ? Procedure<TInputContext, TNewContext, TInput, TParsedInput, TOutput> : never;
|
|
75
|
-
declare type SwapContext<TObj extends ProcedureRecord<any, any, any, any>, TNewContext> = {
|
|
74
|
+
declare type SwapProcedureContext<TProcedure extends Procedure<any, any, any, any, any, any>, TNewContext> = TProcedure extends Procedure<infer TInputContext, infer _TOldContext, infer TInput, infer TParsedInput, infer TOutput, infer TParsedOutput> ? Procedure<TInputContext, TNewContext, TInput, TParsedInput, TOutput, TParsedOutput> : never;
|
|
75
|
+
declare type SwapContext<TObj extends ProcedureRecord<any, any, any, any, any, any>, TNewContext> = {
|
|
76
76
|
[P in keyof TObj]: SwapProcedureContext<TObj[P], TNewContext>;
|
|
77
77
|
};
|
|
78
78
|
/**
|
|
79
79
|
* @internal The type signature of this class may change without warning.
|
|
80
80
|
*/
|
|
81
|
-
export declare class Router<TInputContext, TContext, TQueries extends ProcedureRecord<TInputContext, TContext>, TMutations extends ProcedureRecord<TInputContext, TContext>, TSubscriptions extends ProcedureRecord<TInputContext, TContext, unknown, Subscription<unknown
|
|
81
|
+
export declare class Router<TInputContext, TContext, TQueries extends ProcedureRecord<TInputContext, TContext, any, any, any, any>, TMutations extends ProcedureRecord<TInputContext, TContext, any, any, any, any>, TSubscriptions extends ProcedureRecord<TInputContext, TContext, unknown, unknown, Subscription<unknown>, unknown>, TErrorShape extends TRPCErrorShape<number>> {
|
|
82
82
|
readonly _def: {
|
|
83
83
|
queries: TQueries;
|
|
84
84
|
mutations: TMutations;
|
|
@@ -96,24 +96,24 @@ export declare class Router<TInputContext, TContext, TQueries extends ProcedureR
|
|
|
96
96
|
transformer?: CombinedDataTransformer;
|
|
97
97
|
});
|
|
98
98
|
private static prefixProcedures;
|
|
99
|
-
query<TPath extends string, TInput, TParsedInput, TOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
100
|
-
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput,
|
|
101
|
-
query<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
102
|
-
mutation<TPath extends string, TInput, TParsedInput, TOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
103
|
-
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput,
|
|
104
|
-
mutation<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
99
|
+
query<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
100
|
+
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
101
|
+
query<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
102
|
+
mutation<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
103
|
+
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
104
|
+
mutation<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
105
105
|
/**
|
|
106
106
|
* @beta Might change without a major version bump
|
|
107
107
|
*/
|
|
108
|
-
subscription<TPath extends string, TInput, TParsedInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
108
|
+
subscription<TPath extends string, TInput, TParsedInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: Omit<CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, unknown>, 'output'>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
109
109
|
/**
|
|
110
110
|
* @beta Might change without a major version bump
|
|
111
111
|
*/
|
|
112
|
-
subscription<TPath extends string, TInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput,
|
|
112
|
+
subscription<TPath extends string, TInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: Omit<CreateProcedureWithInput<TContext, TInput, TOutput>, 'output'>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
113
113
|
/**
|
|
114
114
|
* @beta Might change without a major version bump
|
|
115
115
|
*/
|
|
116
|
-
subscription<TPath extends string, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
116
|
+
subscription<TPath extends string, TOutput extends Subscription<unknown>>(path: TPath, procedure: Omit<CreateProcedureWithoutInput<TContext, TOutput, unknown>, 'output'>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
117
117
|
/**
|
|
118
118
|
* Merge router with other router
|
|
119
119
|
* @param router
|
|
@@ -169,7 +169,7 @@ export declare class Router<TInputContext, TContext, TQueries extends ProcedureR
|
|
|
169
169
|
*
|
|
170
170
|
* @deprecated
|
|
171
171
|
*/
|
|
172
|
-
export declare class LegacyRouter<TContext, TQueries extends ProcedureRecord<TContext, TContext>, TMutations extends ProcedureRecord<TContext, TContext>, TSubscriptions extends ProcedureRecord<TContext, TContext, unknown, Subscription<unknown
|
|
172
|
+
export declare class LegacyRouter<TContext, TQueries extends ProcedureRecord<TContext, TContext, any, any, any, any>, TMutations extends ProcedureRecord<TContext, TContext, any, any, any, any>, TSubscriptions extends ProcedureRecord<TContext, TContext, unknown, unknown, Subscription<unknown>, unknown>, TErrorShape extends TRPCErrorShape<number>> extends Router<TContext, TContext, TQueries, TMutations, TSubscriptions, TErrorShape> {
|
|
173
173
|
}
|
|
174
174
|
export declare function router<TContext>(): Router<TContext, TContext, {}, {}, {}, DefaultErrorShape>;
|
|
175
175
|
export {};
|