@trpc/server 11.0.0-rc.752 → 11.0.0-rc.754
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/dist/@trpc/server/index.d.ts +3 -7
- package/dist/@trpc/server/index.d.ts.map +1 -1
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +54 -54
- package/dist/index.js +0 -1
- package/dist/index.mjs +1 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +3 -3
- package/dist/unstable-core-do-not-import/http/contentType.mjs +3 -3
- package/dist/unstable-core-do-not-import/router.d.ts +5 -3
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.js +7 -4
- package/dist/unstable-core-do-not-import/router.mjs +7 -4
- package/package.json +2 -2
- package/src/@trpc/server/index.ts +1 -6
- package/src/adapters/ws.ts +3 -3
- package/src/unstable-core-do-not-import/http/contentType.ts +3 -3
- package/src/unstable-core-do-not-import/router.ts +9 -6
|
@@ -2,11 +2,11 @@ export { TRPCError,
|
|
|
2
2
|
/**
|
|
3
3
|
* @deprecated use `experimental_trpcMiddleware` instead
|
|
4
4
|
*/
|
|
5
|
-
experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC,
|
|
5
|
+
experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC, getTRPCErrorFromUnknown, transformTRPCResponse, createFlatProxy as createTRPCFlatProxy, type inferProcedureInput, type inferProcedureOutput, type inferProcedureBuilderResolverOptions, type inferRouterError, type inferRouterInputs, type inferRouterOutputs, type inferRouterContext, type inferClientTypes as inferTRPCClientTypes, type AnyClientTypes as AnyTRPCClientTypes, type inferTransformedProcedureOutput, type inferTransformedSubscriptionOutput, type AnyProcedure as AnyTRPCProcedure, type AnyRouter as AnyTRPCRouter, type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction, type CombinedDataTransformer as TRPCCombinedDataTransformer, type ProcedureType as TRPCProcedureType, type AnyMutationProcedure as AnyTRPCMutationProcedure, type AnyQueryProcedure as AnyTRPCQueryProcedure, type RouterRecord as TRPCRouterRecord, type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure, type CreateContextCallback, type MutationProcedure as TRPCMutationProcedure, type QueryProcedure as TRPCQueryProcedure, type SubscriptionProcedure as TRPCSubscriptionProcedure, type TRPCBuilder, StandardSchemaV1Error,
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated use `tracked(id, data)` instead
|
|
8
8
|
*/
|
|
9
|
-
sse, tracked, type TrackedEnvelope, isTrackedEnvelope, lazy as experimental_lazy, } from '../../unstable-core-do-not-import';
|
|
9
|
+
sse, tracked, type TrackedEnvelope, isTrackedEnvelope, lazy as experimental_lazy, callProcedure as callTRPCProcedure, } from '../../unstable-core-do-not-import';
|
|
10
10
|
export type {
|
|
11
11
|
/**
|
|
12
12
|
* @deprecated use `AnyTRPCProcedure` instead
|
|
@@ -52,11 +52,7 @@ export {
|
|
|
52
52
|
/**
|
|
53
53
|
* @deprecated use `getTRPCErrorShape` instead
|
|
54
54
|
*/
|
|
55
|
-
getErrorShape,
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated use `callTRPCProcedure` instead
|
|
58
|
-
*/
|
|
59
|
-
callProcedure, } from '../../unstable-core-do-not-import';
|
|
55
|
+
getErrorShape, } from '../../unstable-core-do-not-import';
|
|
60
56
|
/**
|
|
61
57
|
* @deprecated
|
|
62
58
|
* Use `Awaited<ReturnType<typeof myFunction>>` instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS;AACT;;GAEG;AACH,iCAAiC,EACjC,iCAAiC,IAAI,2BAA2B,EAChE,QAAQ,EAER,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/@trpc/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oBAAoB;AAEpB;;GAEG;AACH,iBAAiB;AACjB;;GAEG;AACH,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAE3C,OAAO;AACL;;GAEG;AACH,aAAa,GACd,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACxE,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
package/dist/adapters/ws.js
CHANGED
|
@@ -180,7 +180,7 @@ function getWSConnectionHandler(opts) {
|
|
|
180
180
|
await ctxPromise; // asserts context has been set
|
|
181
181
|
const abortController = new AbortController();
|
|
182
182
|
const result = await router.callProcedure({
|
|
183
|
-
|
|
183
|
+
router: router$1,
|
|
184
184
|
path,
|
|
185
185
|
getRawInput: async ()=>input,
|
|
186
186
|
ctx,
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -178,7 +178,7 @@ function getWSConnectionHandler(opts) {
|
|
|
178
178
|
await ctxPromise; // asserts context has been set
|
|
179
179
|
const abortController = new AbortController();
|
|
180
180
|
const result = await callProcedure({
|
|
181
|
-
|
|
181
|
+
router,
|
|
182
182
|
path,
|
|
183
183
|
getRawInput: async ()=>input,
|
|
184
184
|
ctx,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 13.
|
|
2
|
+
"bundleSize": 199016,
|
|
3
|
+
"bundleOrigSize": 230676,
|
|
4
|
+
"bundleReduction": 13.72,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"id": "/src/adapters/ws.ts",
|
|
22
|
-
"size":
|
|
23
|
-
"origSize":
|
|
22
|
+
"size": 20148,
|
|
23
|
+
"origSize": 15935,
|
|
24
24
|
"renderedExports": [
|
|
25
25
|
"getWSConnectionHandler",
|
|
26
26
|
"handleKeepAlive",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependents": [
|
|
31
31
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
32
32
|
],
|
|
33
|
-
"percent": 10.
|
|
33
|
+
"percent": 10.12,
|
|
34
34
|
"reduction": 0
|
|
35
35
|
},
|
|
36
36
|
{
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
"id": "/src/unstable-core-do-not-import/router.ts",
|
|
85
|
-
"size":
|
|
86
|
-
"origSize":
|
|
85
|
+
"size": 10167,
|
|
86
|
+
"origSize": 14423,
|
|
87
87
|
"renderedExports": [
|
|
88
88
|
"lazy",
|
|
89
89
|
"createRouterFactory",
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
99
99
|
"/src/unstable-core-do-not-import/http/contentType.ts"
|
|
100
100
|
],
|
|
101
|
-
"percent": 5.
|
|
102
|
-
"reduction": 29.
|
|
101
|
+
"percent": 5.11,
|
|
102
|
+
"reduction": 29.51
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
"id": "/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts",
|
|
@@ -117,8 +117,8 @@
|
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"id": "/src/unstable-core-do-not-import/http/contentType.ts",
|
|
120
|
-
"size":
|
|
121
|
-
"origSize":
|
|
120
|
+
"size": 7874,
|
|
121
|
+
"origSize": 7940,
|
|
122
122
|
"renderedExports": [
|
|
123
123
|
"getRequestInfo"
|
|
124
124
|
],
|
|
@@ -246,7 +246,7 @@
|
|
|
246
246
|
"dependents": [
|
|
247
247
|
"/src/observable/index.ts"
|
|
248
248
|
],
|
|
249
|
-
"percent": 1.
|
|
249
|
+
"percent": 1.96,
|
|
250
250
|
"reduction": 1.66
|
|
251
251
|
},
|
|
252
252
|
{
|
|
@@ -291,9 +291,9 @@
|
|
|
291
291
|
"removedExports": [],
|
|
292
292
|
"dependents": [
|
|
293
293
|
"/src/unstable-core-do-not-import.ts",
|
|
294
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
294
295
|
"/src/unstable-core-do-not-import/router.ts",
|
|
295
|
-
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
296
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
296
|
+
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
297
297
|
],
|
|
298
298
|
"percent": 1.38,
|
|
299
299
|
"reduction": 45.98
|
|
@@ -353,17 +353,17 @@
|
|
|
353
353
|
"removedExports": [],
|
|
354
354
|
"dependents": [
|
|
355
355
|
"/src/unstable-core-do-not-import.ts",
|
|
356
|
+
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
357
|
+
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
358
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
356
359
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
357
360
|
"/src/unstable-core-do-not-import/router.ts",
|
|
358
361
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
359
362
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
360
|
-
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
361
|
-
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
362
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
363
|
-
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
364
363
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
365
364
|
"/src/unstable-core-do-not-import/http/abortError.ts",
|
|
366
365
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
366
|
+
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
367
367
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
368
368
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
369
369
|
],
|
|
@@ -382,10 +382,10 @@
|
|
|
382
382
|
"removedExports": [],
|
|
383
383
|
"dependents": [
|
|
384
384
|
"/src/unstable-core-do-not-import.ts",
|
|
385
|
-
"/src/unstable-core-do-not-import/router.ts",
|
|
386
|
-
"/src/unstable-core-do-not-import/middleware.ts",
|
|
387
385
|
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
388
386
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
387
|
+
"/src/unstable-core-do-not-import/router.ts",
|
|
388
|
+
"/src/unstable-core-do-not-import/middleware.ts",
|
|
389
389
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
390
390
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
391
391
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
@@ -452,8 +452,8 @@
|
|
|
452
452
|
"removedExports": [],
|
|
453
453
|
"dependents": [
|
|
454
454
|
"/src/unstable-core-do-not-import.ts",
|
|
455
|
-
"/src/unstable-core-do-not-import/
|
|
456
|
-
"/src/unstable-core-do-not-import/
|
|
455
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
456
|
+
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
457
457
|
],
|
|
458
458
|
"percent": 1.05,
|
|
459
459
|
"reduction": 18.54
|
|
@@ -859,6 +859,18 @@
|
|
|
859
859
|
"percent": 0.03,
|
|
860
860
|
"reduction": 93.9
|
|
861
861
|
},
|
|
862
|
+
{
|
|
863
|
+
"id": "/src/http.ts",
|
|
864
|
+
"size": 0,
|
|
865
|
+
"origSize": 37,
|
|
866
|
+
"renderedExports": [],
|
|
867
|
+
"removedExports": [],
|
|
868
|
+
"dependents": [
|
|
869
|
+
"/src/adapters/ws.ts"
|
|
870
|
+
],
|
|
871
|
+
"percent": 0,
|
|
872
|
+
"reduction": 100
|
|
873
|
+
},
|
|
862
874
|
{
|
|
863
875
|
"id": "/src/index.ts",
|
|
864
876
|
"size": 0,
|
|
@@ -870,13 +882,19 @@
|
|
|
870
882
|
"reduction": 100
|
|
871
883
|
},
|
|
872
884
|
{
|
|
873
|
-
"id": "/src/
|
|
885
|
+
"id": "/src/unstable-core-do-not-import.ts",
|
|
874
886
|
"size": 0,
|
|
875
|
-
"origSize":
|
|
887
|
+
"origSize": 2584,
|
|
876
888
|
"renderedExports": [],
|
|
877
889
|
"removedExports": [],
|
|
878
890
|
"dependents": [
|
|
879
|
-
"/src/adapters/
|
|
891
|
+
"/src/adapters/express.ts",
|
|
892
|
+
"/src/adapters/next.ts",
|
|
893
|
+
"/src/adapters/standalone.ts",
|
|
894
|
+
"/src/adapters/ws.ts",
|
|
895
|
+
"/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
896
|
+
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
897
|
+
"/src/adapters/node-http/writeResponse.ts"
|
|
880
898
|
],
|
|
881
899
|
"percent": 0,
|
|
882
900
|
"reduction": 100
|
|
@@ -901,24 +919,6 @@
|
|
|
901
919
|
"percent": 0,
|
|
902
920
|
"reduction": 100
|
|
903
921
|
},
|
|
904
|
-
{
|
|
905
|
-
"id": "/src/unstable-core-do-not-import.ts",
|
|
906
|
-
"size": 0,
|
|
907
|
-
"origSize": 2584,
|
|
908
|
-
"renderedExports": [],
|
|
909
|
-
"removedExports": [],
|
|
910
|
-
"dependents": [
|
|
911
|
-
"/src/adapters/express.ts",
|
|
912
|
-
"/src/adapters/next.ts",
|
|
913
|
-
"/src/adapters/standalone.ts",
|
|
914
|
-
"/src/adapters/ws.ts",
|
|
915
|
-
"/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
916
|
-
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
917
|
-
"/src/adapters/node-http/writeResponse.ts"
|
|
918
|
-
],
|
|
919
|
-
"percent": 0,
|
|
920
|
-
"reduction": 100
|
|
921
|
-
},
|
|
922
922
|
{
|
|
923
923
|
"id": "/src/adapters/next-app-dir.ts",
|
|
924
924
|
"size": 0,
|
|
@@ -951,16 +951,6 @@
|
|
|
951
951
|
"percent": 0,
|
|
952
952
|
"reduction": 100
|
|
953
953
|
},
|
|
954
|
-
{
|
|
955
|
-
"id": "/src/adapters/fetch/index.ts",
|
|
956
|
-
"size": 0,
|
|
957
|
-
"origSize": 64,
|
|
958
|
-
"renderedExports": [],
|
|
959
|
-
"removedExports": [],
|
|
960
|
-
"dependents": [],
|
|
961
|
-
"percent": 0,
|
|
962
|
-
"reduction": 100
|
|
963
|
-
},
|
|
964
954
|
{
|
|
965
955
|
"id": "/src/adapters/node-http/index.ts",
|
|
966
956
|
"size": 0,
|
|
@@ -976,6 +966,16 @@
|
|
|
976
966
|
],
|
|
977
967
|
"percent": 0,
|
|
978
968
|
"reduction": 100
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
972
|
+
"size": 0,
|
|
973
|
+
"origSize": 64,
|
|
974
|
+
"renderedExports": [],
|
|
975
|
+
"removedExports": [],
|
|
976
|
+
"dependents": [],
|
|
977
|
+
"percent": 0,
|
|
978
|
+
"reduction": 100
|
|
979
979
|
}
|
|
980
980
|
],
|
|
981
981
|
"moduleCount": 63
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,6 @@ exports.createTRPCFlatProxy = createProxy.createFlatProxy;
|
|
|
19
19
|
exports.getErrorShape = getErrorShape.getErrorShape;
|
|
20
20
|
exports.TRPCError = TRPCError.TRPCError;
|
|
21
21
|
exports.getTRPCErrorFromUnknown = TRPCError.getTRPCErrorFromUnknown;
|
|
22
|
-
exports.callProcedure = router.callProcedure;
|
|
23
22
|
exports.callTRPCProcedure = router.callProcedure;
|
|
24
23
|
exports.experimental_lazy = router.lazy;
|
|
25
24
|
exports.isTrackedEnvelope = tracked.isTrackedEnvelope;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createFlatProxy as createTRPCFlatProxy } from './unstable-core-do-not-import/createProxy.mjs';
|
|
2
2
|
export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
3
3
|
export { TRPCError, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
|
|
4
|
-
export { callProcedure
|
|
4
|
+
export { callProcedure as callTRPCProcedure, lazy as experimental_lazy } from './unstable-core-do-not-import/router.mjs';
|
|
5
5
|
import './vendor/unpromise/unpromise.mjs';
|
|
6
6
|
import './unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
7
7
|
export { isTrackedEnvelope, sse, tracked } from './unstable-core-do-not-import/stream/tracked.mjs';
|
|
@@ -86,7 +86,7 @@ const jsonContentTypeHandler = {
|
|
|
86
86
|
return acc;
|
|
87
87
|
});
|
|
88
88
|
const calls = await Promise.all(paths.map(async (path, index)=>{
|
|
89
|
-
const procedure = await router.getProcedureAtPath(opts.router
|
|
89
|
+
const procedure = await router.getProcedureAtPath(opts.router, path);
|
|
90
90
|
return {
|
|
91
91
|
path,
|
|
92
92
|
procedure,
|
|
@@ -152,7 +152,7 @@ const formDataContentTypeHandler = {
|
|
|
152
152
|
const fd = await req.formData();
|
|
153
153
|
return fd;
|
|
154
154
|
});
|
|
155
|
-
const procedure = await router.getProcedureAtPath(opts.router
|
|
155
|
+
const procedure = await router.getProcedureAtPath(opts.router, opts.path);
|
|
156
156
|
return {
|
|
157
157
|
accept: null,
|
|
158
158
|
calls: [
|
|
@@ -192,7 +192,7 @@ const octetStreamContentTypeHandler = {
|
|
|
192
192
|
path: opts.path,
|
|
193
193
|
getRawInput: getInputs.read,
|
|
194
194
|
result: getInputs.result,
|
|
195
|
-
procedure: await router.getProcedureAtPath(opts.router
|
|
195
|
+
procedure: await router.getProcedureAtPath(opts.router, opts.path)
|
|
196
196
|
}
|
|
197
197
|
],
|
|
198
198
|
isBatchCall: false,
|
|
@@ -84,7 +84,7 @@ const jsonContentTypeHandler = {
|
|
|
84
84
|
return acc;
|
|
85
85
|
});
|
|
86
86
|
const calls = await Promise.all(paths.map(async (path, index)=>{
|
|
87
|
-
const procedure = await getProcedureAtPath(opts.router
|
|
87
|
+
const procedure = await getProcedureAtPath(opts.router, path);
|
|
88
88
|
return {
|
|
89
89
|
path,
|
|
90
90
|
procedure,
|
|
@@ -150,7 +150,7 @@ const formDataContentTypeHandler = {
|
|
|
150
150
|
const fd = await req.formData();
|
|
151
151
|
return fd;
|
|
152
152
|
});
|
|
153
|
-
const procedure = await getProcedureAtPath(opts.router
|
|
153
|
+
const procedure = await getProcedureAtPath(opts.router, opts.path);
|
|
154
154
|
return {
|
|
155
155
|
accept: null,
|
|
156
156
|
calls: [
|
|
@@ -190,7 +190,7 @@ const octetStreamContentTypeHandler = {
|
|
|
190
190
|
path: opts.path,
|
|
191
191
|
getRawInput: getInputs.read,
|
|
192
192
|
result: getInputs.result,
|
|
193
|
-
procedure: await getProcedureAtPath(opts.router
|
|
193
|
+
procedure: await getProcedureAtPath(opts.router, opts.path)
|
|
194
194
|
}
|
|
195
195
|
],
|
|
196
196
|
isBatchCall: false,
|
|
@@ -56,7 +56,6 @@ export interface Router<TRoot extends AnyRootTypes, TRecord extends RouterRecord
|
|
|
56
56
|
lazy: Record<string, LazyLoader<AnyRouter>>;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
|
-
* @deprecated use `t.createCallerFactory(router)` instead
|
|
60
59
|
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
61
60
|
*/
|
|
62
61
|
createCaller: RouterCaller<TRoot, TRecord>;
|
|
@@ -77,12 +76,15 @@ export type DecorateCreateRouterOptions<TRouterOptions extends CreateRouterOptio
|
|
|
77
76
|
* @internal
|
|
78
77
|
*/
|
|
79
78
|
export declare function createRouterFactory<TRoot extends AnyRootTypes>(config: RootConfig<TRoot>): <TInput extends CreateRouterOptions>(input: TInput) => BuiltRouter<TRoot, DecorateCreateRouterOptions<TInput>>;
|
|
80
|
-
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export declare function getProcedureAtPath(router: Pick<Router<any, any>, '_def'>, path: string): Promise<AnyProcedure | null>;
|
|
81
83
|
/**
|
|
82
84
|
* @internal
|
|
83
85
|
*/
|
|
84
86
|
export declare function callProcedure(opts: ProcedureCallOptions<unknown> & {
|
|
85
|
-
|
|
87
|
+
router: AnyRouter;
|
|
86
88
|
allowMethodOverride?: boolean;
|
|
87
89
|
}): Promise<any>;
|
|
88
90
|
export declare function createCallerFactory<TRoot extends AnyRootTypes>(): <TRecord extends RouterRecord>(router: Pick<Router<TRoot, TRecord>, "_def">) => RouterCaller<TRoot, TRecord>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAA2B,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,qCAAqC,EACtC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,SAAS,CAAC;AAQrD,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;CAC5C;AAED,KAAK,iBAAiB,CAAC,UAAU,SAAS,YAAY,IAAI,CACxD,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,KACnC,OAAO,CACV,UAAU,C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outer === 'function';
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
/**
|
|
172
|
+
* @internal
|
|
173
|
+
*/ async function getProcedureAtPath(router, path) {
|
|
174
|
+
const { _def } = router;
|
|
172
175
|
let procedure = _def.procedures[path];
|
|
173
176
|
while(!procedure){
|
|
174
177
|
const key = Object.keys(_def.lazy).find((key)=>path.startsWith(key));
|
|
@@ -188,7 +191,7 @@ async function getProcedureAtPath(_def, path) {
|
|
|
188
191
|
* @internal
|
|
189
192
|
*/ async function callProcedure(opts) {
|
|
190
193
|
const { type, path } = opts;
|
|
191
|
-
const proc = await getProcedureAtPath(opts.
|
|
194
|
+
const proc = await getProcedureAtPath(opts.router, path);
|
|
192
195
|
if (!proc || !isProcedure(proc) || proc._def.type !== type && !opts.allowMethodOverride) {
|
|
193
196
|
throw new TRPCError.TRPCError({
|
|
194
197
|
code: 'NOT_FOUND',
|
|
@@ -205,14 +208,14 @@ async function getProcedureAtPath(_def, path) {
|
|
|
205
208
|
}
|
|
206
209
|
function createCallerFactory() {
|
|
207
210
|
return function createCallerInner(router) {
|
|
208
|
-
const _def = router
|
|
211
|
+
const { _def } = router;
|
|
209
212
|
return function createCaller(ctxOrCallback, opts) {
|
|
210
213
|
return createProxy.createRecursiveProxy(async ({ path, args })=>{
|
|
211
214
|
const fullPath = path.join('.');
|
|
212
215
|
if (path.length === 1 && path[0] === '_def') {
|
|
213
216
|
return _def;
|
|
214
217
|
}
|
|
215
|
-
const procedure = await getProcedureAtPath(
|
|
218
|
+
const procedure = await getProcedureAtPath(router, fullPath);
|
|
216
219
|
let ctx = undefined;
|
|
217
220
|
try {
|
|
218
221
|
if (!procedure) {
|
|
@@ -166,7 +166,10 @@ const emptyRouter = {
|
|
|
166
166
|
function isProcedure(procedureOrRouter) {
|
|
167
167
|
return typeof procedureOrRouter === 'function';
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
*/ async function getProcedureAtPath(router, path) {
|
|
172
|
+
const { _def } = router;
|
|
170
173
|
let procedure = _def.procedures[path];
|
|
171
174
|
while(!procedure){
|
|
172
175
|
const key = Object.keys(_def.lazy).find((key)=>path.startsWith(key));
|
|
@@ -186,7 +189,7 @@ async function getProcedureAtPath(_def, path) {
|
|
|
186
189
|
* @internal
|
|
187
190
|
*/ async function callProcedure(opts) {
|
|
188
191
|
const { type, path } = opts;
|
|
189
|
-
const proc = await getProcedureAtPath(opts.
|
|
192
|
+
const proc = await getProcedureAtPath(opts.router, path);
|
|
190
193
|
if (!proc || !isProcedure(proc) || proc._def.type !== type && !opts.allowMethodOverride) {
|
|
191
194
|
throw new TRPCError({
|
|
192
195
|
code: 'NOT_FOUND',
|
|
@@ -203,14 +206,14 @@ async function getProcedureAtPath(_def, path) {
|
|
|
203
206
|
}
|
|
204
207
|
function createCallerFactory() {
|
|
205
208
|
return function createCallerInner(router) {
|
|
206
|
-
const _def = router
|
|
209
|
+
const { _def } = router;
|
|
207
210
|
return function createCaller(ctxOrCallback, opts) {
|
|
208
211
|
return createRecursiveProxy(async ({ path, args })=>{
|
|
209
212
|
const fullPath = path.join('.');
|
|
210
213
|
if (path.length === 1 && path[0] === '_def') {
|
|
211
214
|
return _def;
|
|
212
215
|
}
|
|
213
|
-
const procedure = await getProcedureAtPath(
|
|
216
|
+
const procedure = await getProcedureAtPath(router, fullPath);
|
|
214
217
|
let ctx = undefined;
|
|
215
218
|
try {
|
|
216
219
|
if (!procedure) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.754+9e15916e9",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -152,5 +152,5 @@
|
|
|
152
152
|
"peerDependencies": {
|
|
153
153
|
"typescript": ">=5.7.2"
|
|
154
154
|
},
|
|
155
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "9e15916e9fc26a08c9936c4c706e996321d42958"
|
|
156
156
|
}
|
|
@@ -7,7 +7,6 @@ export {
|
|
|
7
7
|
experimental_standaloneMiddleware as experimental_trpcMiddleware,
|
|
8
8
|
initTRPC,
|
|
9
9
|
// --- FIXME a bunch of these exports are only useful for plugins - move them somewhere else? ----
|
|
10
|
-
callProcedure as callTRPCProcedure,
|
|
11
10
|
getTRPCErrorFromUnknown,
|
|
12
11
|
transformTRPCResponse,
|
|
13
12
|
createFlatProxy as createTRPCFlatProxy,
|
|
@@ -45,6 +44,7 @@ export {
|
|
|
45
44
|
type TrackedEnvelope,
|
|
46
45
|
isTrackedEnvelope,
|
|
47
46
|
lazy as experimental_lazy,
|
|
47
|
+
callProcedure as callTRPCProcedure,
|
|
48
48
|
} from '../../unstable-core-do-not-import';
|
|
49
49
|
|
|
50
50
|
export type {
|
|
@@ -98,11 +98,6 @@ export {
|
|
|
98
98
|
* @deprecated use `getTRPCErrorShape` instead
|
|
99
99
|
*/
|
|
100
100
|
getErrorShape,
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated use `callTRPCProcedure` instead
|
|
104
|
-
*/
|
|
105
|
-
callProcedure,
|
|
106
101
|
} from '../../unstable-core-do-not-import';
|
|
107
102
|
|
|
108
103
|
/**
|
package/src/adapters/ws.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
inferRouterContext,
|
|
7
7
|
} from '../@trpc/server';
|
|
8
8
|
import {
|
|
9
|
-
|
|
9
|
+
callTRPCProcedure,
|
|
10
10
|
getErrorShape,
|
|
11
11
|
getTRPCErrorFromUnknown,
|
|
12
12
|
transformTRPCResponse,
|
|
@@ -218,8 +218,8 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
218
218
|
await ctxPromise; // asserts context has been set
|
|
219
219
|
|
|
220
220
|
const abortController = new AbortController();
|
|
221
|
-
const result = await
|
|
222
|
-
|
|
221
|
+
const result = await callTRPCProcedure({
|
|
222
|
+
router,
|
|
223
223
|
path,
|
|
224
224
|
getRawInput: async () => input,
|
|
225
225
|
ctx,
|
|
@@ -113,7 +113,7 @@ const jsonContentTypeHandler: ContentTypeHandler = {
|
|
|
113
113
|
const calls = await Promise.all(
|
|
114
114
|
paths.map(
|
|
115
115
|
async (path, index): Promise<TRPCRequestInfo['calls'][number]> => {
|
|
116
|
-
const procedure = await getProcedureAtPath(opts.router
|
|
116
|
+
const procedure = await getProcedureAtPath(opts.router, path);
|
|
117
117
|
return {
|
|
118
118
|
path,
|
|
119
119
|
procedure,
|
|
@@ -201,7 +201,7 @@ const formDataContentTypeHandler: ContentTypeHandler = {
|
|
|
201
201
|
const fd = await req.formData();
|
|
202
202
|
return fd;
|
|
203
203
|
});
|
|
204
|
-
const procedure = await getProcedureAtPath(opts.router
|
|
204
|
+
const procedure = await getProcedureAtPath(opts.router, opts.path);
|
|
205
205
|
return {
|
|
206
206
|
accept: null,
|
|
207
207
|
calls: [
|
|
@@ -245,7 +245,7 @@ const octetStreamContentTypeHandler: ContentTypeHandler = {
|
|
|
245
245
|
path: opts.path,
|
|
246
246
|
getRawInput: getInputs.read,
|
|
247
247
|
result: getInputs.result,
|
|
248
|
-
procedure: await getProcedureAtPath(opts.router
|
|
248
|
+
procedure: await getProcedureAtPath(opts.router, opts.path),
|
|
249
249
|
},
|
|
250
250
|
],
|
|
251
251
|
isBatchCall: false,
|
|
@@ -145,7 +145,6 @@ export interface Router<
|
|
|
145
145
|
lazy: Record<string, LazyLoader<AnyRouter>>;
|
|
146
146
|
};
|
|
147
147
|
/**
|
|
148
|
-
* @deprecated use `t.createCallerFactory(router)` instead
|
|
149
148
|
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
150
149
|
*/
|
|
151
150
|
createCaller: RouterCaller<TRoot, TRecord>;
|
|
@@ -346,10 +345,14 @@ function isProcedure(
|
|
|
346
345
|
return typeof procedureOrRouter === 'function';
|
|
347
346
|
}
|
|
348
347
|
|
|
348
|
+
/**
|
|
349
|
+
* @internal
|
|
350
|
+
*/
|
|
349
351
|
export async function getProcedureAtPath(
|
|
350
|
-
|
|
352
|
+
router: Pick<Router<any, any>, '_def'>,
|
|
351
353
|
path: string,
|
|
352
354
|
): Promise<AnyProcedure | null> {
|
|
355
|
+
const { _def } = router;
|
|
353
356
|
let procedure = _def.procedures[path];
|
|
354
357
|
|
|
355
358
|
while (!procedure) {
|
|
@@ -375,12 +378,12 @@ export async function getProcedureAtPath(
|
|
|
375
378
|
*/
|
|
376
379
|
export async function callProcedure(
|
|
377
380
|
opts: ProcedureCallOptions<unknown> & {
|
|
378
|
-
|
|
381
|
+
router: AnyRouter;
|
|
379
382
|
allowMethodOverride?: boolean;
|
|
380
383
|
},
|
|
381
384
|
) {
|
|
382
385
|
const { type, path } = opts;
|
|
383
|
-
const proc = await getProcedureAtPath(opts.
|
|
386
|
+
const proc = await getProcedureAtPath(opts.router, path);
|
|
384
387
|
if (
|
|
385
388
|
!proc ||
|
|
386
389
|
!isProcedure(proc) ||
|
|
@@ -411,7 +414,7 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
|
411
414
|
return function createCallerInner<TRecord extends RouterRecord>(
|
|
412
415
|
router: Pick<Router<TRoot, TRecord>, '_def'>,
|
|
413
416
|
): RouterCaller<TRoot, TRecord> {
|
|
414
|
-
const _def = router
|
|
417
|
+
const { _def } = router;
|
|
415
418
|
type Context = TRoot['ctx'];
|
|
416
419
|
|
|
417
420
|
return function createCaller(ctxOrCallback, opts) {
|
|
@@ -423,7 +426,7 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
|
423
426
|
return _def;
|
|
424
427
|
}
|
|
425
428
|
|
|
426
|
-
const procedure = await getProcedureAtPath(
|
|
429
|
+
const procedure = await getProcedureAtPath(router, fullPath);
|
|
427
430
|
|
|
428
431
|
let ctx: Context | undefined = undefined;
|
|
429
432
|
try {
|