@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.219 → 11.0.0-alpha-tmp-export-from-main.211
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-core-unstable-do-not-import-this-please.d.ts +9 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
- package/dist/@trpc-server/http.d.ts +1 -1
- package/dist/@trpc-server/http.d.ts.map +1 -1
- package/dist/@trpc-server.d.ts +3 -3
- package/dist/@trpc-server.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.ts +1 -1
- package/dist/adapters/aws-lambda/index.js +7 -13
- package/dist/adapters/aws-lambda/index.mjs +3 -9
- package/dist/adapters/aws-lambda/utils.d.ts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +2 -9
- package/dist/adapters/express.mjs +2 -9
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/index.js +4 -13
- package/dist/adapters/fastify/index.mjs +2 -11
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -1
- package/dist/adapters/fetch/index.js +4 -11
- package/dist/adapters/fetch/index.mjs +2 -9
- package/dist/adapters/fetch/types.d.ts +1 -1
- package/dist/adapters/next.d.ts +1 -1
- package/dist/adapters/next.js +5 -12
- package/dist/adapters/next.mjs +3 -10
- package/dist/adapters/node-http/content-type/json/index.js +3 -6
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -4
- package/dist/adapters/node-http/index.js +2 -9
- package/dist/adapters/node-http/index.mjs +2 -9
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
- package/dist/adapters/node-http/types.d.ts +2 -2
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -1
- package/dist/adapters/standalone.js +2 -9
- package/dist/adapters/standalone.mjs +2 -9
- package/dist/adapters/ws.d.ts +1 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +26 -32
- package/dist/adapters/ws.mjs +1 -7
- package/dist/http.d.ts +6 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +21 -13
- package/dist/http.mjs +1 -8
- package/dist/index.js +41 -16
- package/dist/index.mjs +1 -6
- package/dist/{nodeHTTPRequestHandler-d8558115.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -4
- package/dist/{nodeHTTPRequestHandler-0bc1dc41.js → nodeHTTPRequestHandler-55f05150.js} +4 -6
- package/dist/{nodeHTTPRequestHandler-c7d41cde.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
- package/dist/observable.d.ts +3 -0
- package/dist/observable.d.ts.map +1 -0
- package/dist/observable.js +32 -0
- package/dist/observable.mjs +1 -0
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +13 -6
- package/dist/rpc.mjs +1 -3
- package/dist/shared.js +9 -5
- package/dist/shared.mjs +1 -3
- package/package.json +125 -53
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +9 -0
- package/src/@trpc-server/http.ts +1 -2
- package/src/@trpc-server.ts +3 -3
- package/src/adapters/aws-lambda/index.ts +1 -1
- package/src/adapters/aws-lambda/utils.ts +1 -1
- package/src/adapters/express.ts +2 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +1 -1
- package/src/adapters/fetch/types.ts +1 -1
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +1 -1
- package/src/adapters/node-http/types.ts +3 -2
- package/src/adapters/standalone.ts +1 -1
- package/src/adapters/ws.ts +10 -9
- package/src/http.ts +6 -6
- package/src/observable.ts +16 -0
- package/src/rpc.ts +2 -2
- package/dist/TRPCError-57838b33.js +0 -67
- package/dist/TRPCError-af754aba.mjs +0 -63
- package/dist/TRPCError-ebbde27d.js +0 -61
- package/dist/batchStreamFormatter-1971db27.js +0 -32
- package/dist/batchStreamFormatter-378277dc.mjs +0 -30
- package/dist/batchStreamFormatter-4375dc8b.js +0 -31
- package/dist/bundle-analysis.json +0 -770
- package/dist/contentType-9756da28.js +0 -59
- package/dist/contentType-b31eab56.js +0 -54
- package/dist/contentType-f93c6ba8.mjs +0 -52
- package/dist/createProxy-7293f632.mjs +0 -121
- package/dist/createProxy-c5cd21e8.js +0 -127
- package/dist/createProxy-f6960c7b.js +0 -116
- package/dist/initTRPC-6c16fa27.mjs +0 -377
- package/dist/initTRPC-8b5714ea.js +0 -385
- package/dist/initTRPC-b65b35e2.js +0 -372
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -111
- package/dist/observable/index.mjs +0 -102
- package/dist/observable/observable.d.ts +0 -13
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/operators.d.ts +0 -8
- package/dist/observable/operators.d.ts.map +0 -1
- package/dist/observable/types.d.ts +0 -26
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/observable-7233bd21.mjs +0 -121
- package/dist/observable-7865c812.js +0 -125
- package/dist/observable-cbbc588a.js +0 -125
- package/dist/parseTRPCMessage-3ae1b295.js +0 -67
- package/dist/parseTRPCMessage-abbd6862.mjs +0 -62
- package/dist/parseTRPCMessage-c6022e94.js +0 -65
- package/dist/resolveHTTPResponse-3133d603.js +0 -265
- package/dist/resolveHTTPResponse-80c99f62.mjs +0 -291
- package/dist/resolveHTTPResponse-9e260431.js +0 -293
- package/dist/rootConfig-a1ad09d0.js +0 -48
- package/dist/rootConfig-db88d377.js +0 -44
- package/dist/rootConfig-f741a4e7.mjs +0 -40
- package/dist/router-68063d64.mjs +0 -252
- package/dist/router-7a7bb4fd.js +0 -262
- package/dist/router-c5bd7780.js +0 -259
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.d.ts +0 -34
- package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.js +0 -44
- package/dist/unstable-core-do-not-import/index.mjs +0 -10
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.d.ts +0 -85
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/types.d.ts +0 -98
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -31
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/dist/utils-42a3ba6d.js +0 -50
- package/dist/utils-cf6178ec.mjs +0 -44
- package/dist/utils-e1d51fac.js +0 -49
- package/src/observable/index.ts +0 -10
- package/src/observable/observable.ts +0 -155
- package/src/observable/operators.ts +0 -119
- package/src/observable/types.ts +0 -76
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
- package/src/unstable-core-do-not-import/createProxy.ts +0 -59
- package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
- package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
- package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
- package/src/unstable-core-do-not-import/http/index.ts +0 -23
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
- package/src/unstable-core-do-not-import/http/types.ts +0 -111
- package/src/unstable-core-do-not-import/index.ts +0 -107
- package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
- package/src/unstable-core-do-not-import/middleware.ts +0 -233
- package/src/unstable-core-do-not-import/parser.ts +0 -94
- package/src/unstable-core-do-not-import/procedure.ts +0 -108
- package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
- package/src/unstable-core-do-not-import/router.ts +0 -370
- package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
- package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
- package/src/unstable-core-do-not-import/serialize.ts +0 -122
- package/src/unstable-core-do-not-import/transformer.ts +0 -202
- package/src/unstable-core-do-not-import/types.ts +0 -151
- package/src/unstable-core-do-not-import/utils.ts +0 -66
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var createProxy = require('./createProxy-c5cd21e8.js');
|
|
4
|
-
var TRPCError = require('./TRPCError-57838b33.js');
|
|
5
|
-
var router = require('./router-7a7bb4fd.js');
|
|
6
|
-
var contentType = require('./contentType-b31eab56.js');
|
|
7
|
-
|
|
8
|
-
const HTTP_METHOD_PROCEDURE_TYPE_MAP = {
|
|
9
|
-
GET: 'query',
|
|
10
|
-
POST: 'mutation'
|
|
11
|
-
};
|
|
12
|
-
const fallbackContentTypeHandler = {
|
|
13
|
-
getInputs: contentType.getJsonContentTypeInputs
|
|
14
|
-
};
|
|
15
|
-
function initResponse(initOpts) {
|
|
16
|
-
const { ctx , paths , type , responseMeta , untransformedJSON , errors =[] , } = initOpts;
|
|
17
|
-
let status = untransformedJSON ? createProxy.getHTTPStatusCode(untransformedJSON) : 200;
|
|
18
|
-
const headers = {
|
|
19
|
-
'Content-Type': 'application/json'
|
|
20
|
-
};
|
|
21
|
-
const eagerGeneration = !untransformedJSON;
|
|
22
|
-
const data = eagerGeneration ? [] : Array.isArray(untransformedJSON) ? untransformedJSON : [
|
|
23
|
-
untransformedJSON
|
|
24
|
-
];
|
|
25
|
-
const meta = responseMeta?.({
|
|
26
|
-
ctx,
|
|
27
|
-
paths,
|
|
28
|
-
type,
|
|
29
|
-
data,
|
|
30
|
-
errors,
|
|
31
|
-
eagerGeneration
|
|
32
|
-
}) ?? {};
|
|
33
|
-
for (const [key, value] of Object.entries(meta.headers ?? {})){
|
|
34
|
-
headers[key] = value;
|
|
35
|
-
}
|
|
36
|
-
if (meta.status) {
|
|
37
|
-
status = meta.status;
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
status,
|
|
41
|
-
headers
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
async function inputToProcedureCall(procedureOpts) {
|
|
45
|
-
const { opts , ctx , type , input , path } = procedureOpts;
|
|
46
|
-
try {
|
|
47
|
-
const data = await router.callProcedure({
|
|
48
|
-
procedures: opts.router._def.procedures,
|
|
49
|
-
path,
|
|
50
|
-
getRawInput: async ()=>input,
|
|
51
|
-
ctx,
|
|
52
|
-
type
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
result: {
|
|
56
|
-
data
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
} catch (cause) {
|
|
60
|
-
const error = TRPCError.getTRPCErrorFromUnknown(cause);
|
|
61
|
-
opts.onError?.({
|
|
62
|
-
error,
|
|
63
|
-
path,
|
|
64
|
-
input,
|
|
65
|
-
ctx,
|
|
66
|
-
type: type,
|
|
67
|
-
req: opts.req
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
error: createProxy.getErrorShape({
|
|
71
|
-
config: opts.router._def._config,
|
|
72
|
-
error,
|
|
73
|
-
type,
|
|
74
|
-
path,
|
|
75
|
-
input,
|
|
76
|
-
ctx
|
|
77
|
-
})
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function caughtErrorToData(cause, errorOpts) {
|
|
82
|
-
const { router: router$1 , req , onError } = errorOpts.opts;
|
|
83
|
-
const error = TRPCError.getTRPCErrorFromUnknown(cause);
|
|
84
|
-
onError?.({
|
|
85
|
-
error,
|
|
86
|
-
path: errorOpts.path,
|
|
87
|
-
input: errorOpts.input,
|
|
88
|
-
ctx: errorOpts.ctx,
|
|
89
|
-
type: errorOpts.type,
|
|
90
|
-
req
|
|
91
|
-
});
|
|
92
|
-
const untransformedJSON = {
|
|
93
|
-
error: createProxy.getErrorShape({
|
|
94
|
-
config: router$1._def._config,
|
|
95
|
-
error,
|
|
96
|
-
type: errorOpts.type,
|
|
97
|
-
path: errorOpts.path,
|
|
98
|
-
input: errorOpts.input,
|
|
99
|
-
ctx: errorOpts.ctx
|
|
100
|
-
})
|
|
101
|
-
};
|
|
102
|
-
const transformedJSON = router.transformTRPCResponse(router$1._def._config, untransformedJSON);
|
|
103
|
-
const body = JSON.stringify(transformedJSON);
|
|
104
|
-
return {
|
|
105
|
-
error,
|
|
106
|
-
untransformedJSON,
|
|
107
|
-
body
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
// implementation
|
|
111
|
-
async function resolveHTTPResponse(opts) {
|
|
112
|
-
const { router: router$1 , req , unstable_onHead , unstable_onChunk } = opts;
|
|
113
|
-
if (req.method === 'HEAD') {
|
|
114
|
-
// can be used for lambda warmup
|
|
115
|
-
const headResponse = {
|
|
116
|
-
status: 204
|
|
117
|
-
};
|
|
118
|
-
unstable_onHead?.(headResponse, false);
|
|
119
|
-
unstable_onChunk?.([
|
|
120
|
-
-1,
|
|
121
|
-
''
|
|
122
|
-
]);
|
|
123
|
-
return headResponse;
|
|
124
|
-
}
|
|
125
|
-
const contentTypeHandler = opts.contentTypeHandler ?? fallbackContentTypeHandler;
|
|
126
|
-
const batchingEnabled = opts.batching?.enabled ?? true;
|
|
127
|
-
const type = HTTP_METHOD_PROCEDURE_TYPE_MAP[req.method] ?? 'unknown';
|
|
128
|
-
let ctx = undefined;
|
|
129
|
-
let paths;
|
|
130
|
-
const isBatchCall = !!req.query.get('batch');
|
|
131
|
-
const isStreamCall = isBatchCall && unstable_onHead && unstable_onChunk && req.headers['trpc-batch-mode'] === 'stream';
|
|
132
|
-
try {
|
|
133
|
-
if (opts.error) {
|
|
134
|
-
throw opts.error;
|
|
135
|
-
}
|
|
136
|
-
if (isBatchCall && !batchingEnabled) {
|
|
137
|
-
throw new Error(`Batching is not enabled on the server`);
|
|
138
|
-
}
|
|
139
|
-
/* istanbul ignore if -- @preserve */ if (type === 'subscription') {
|
|
140
|
-
throw new TRPCError.TRPCError({
|
|
141
|
-
message: 'Subscriptions should use wsLink',
|
|
142
|
-
code: 'METHOD_NOT_SUPPORTED'
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (type === 'unknown') {
|
|
146
|
-
throw new TRPCError.TRPCError({
|
|
147
|
-
message: `Unexpected request method ${req.method}`,
|
|
148
|
-
code: 'METHOD_NOT_SUPPORTED'
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
const inputs = await contentTypeHandler.getInputs({
|
|
152
|
-
isBatchCall,
|
|
153
|
-
req,
|
|
154
|
-
router: router$1,
|
|
155
|
-
preprocessedBody: opts.preprocessedBody ?? false
|
|
156
|
-
});
|
|
157
|
-
paths = isBatchCall ? decodeURIComponent(opts.path).split(',') : [
|
|
158
|
-
opts.path
|
|
159
|
-
];
|
|
160
|
-
const info = {
|
|
161
|
-
isBatchCall,
|
|
162
|
-
calls: paths.map((path, idx)=>({
|
|
163
|
-
path,
|
|
164
|
-
type,
|
|
165
|
-
input: inputs[idx] ?? undefined
|
|
166
|
-
}))
|
|
167
|
-
};
|
|
168
|
-
ctx = await opts.createContext({
|
|
169
|
-
info
|
|
170
|
-
});
|
|
171
|
-
const promises = paths.map((path, index)=>inputToProcedureCall({
|
|
172
|
-
opts,
|
|
173
|
-
ctx,
|
|
174
|
-
type,
|
|
175
|
-
input: inputs[index],
|
|
176
|
-
path
|
|
177
|
-
}));
|
|
178
|
-
if (!isStreamCall) {
|
|
179
|
-
/**
|
|
180
|
-
* Non-streaming response:
|
|
181
|
-
* - await all responses in parallel, blocking on the slowest one
|
|
182
|
-
* - create headers with known response body
|
|
183
|
-
* - return a complete HTTPResponse
|
|
184
|
-
*/ const untransformedJSON = await Promise.all(promises);
|
|
185
|
-
const errors = untransformedJSON.flatMap((response)=>'error' in response ? [
|
|
186
|
-
response.error
|
|
187
|
-
] : []);
|
|
188
|
-
const headResponse1 = initResponse({
|
|
189
|
-
ctx,
|
|
190
|
-
paths,
|
|
191
|
-
type,
|
|
192
|
-
responseMeta: opts.responseMeta,
|
|
193
|
-
untransformedJSON,
|
|
194
|
-
errors
|
|
195
|
-
});
|
|
196
|
-
unstable_onHead?.(headResponse1, false);
|
|
197
|
-
// return body stuff
|
|
198
|
-
const result = isBatchCall ? untransformedJSON : untransformedJSON[0]; // eslint-disable-line @typescript-eslint/no-non-null-assertion -- `untransformedJSON` should be the length of `paths` which should be at least 1 otherwise there wouldn't be a request at all
|
|
199
|
-
const transformedJSON = router.transformTRPCResponse(router$1._def._config, result);
|
|
200
|
-
const body = JSON.stringify(transformedJSON);
|
|
201
|
-
unstable_onChunk?.([
|
|
202
|
-
-1,
|
|
203
|
-
body
|
|
204
|
-
]);
|
|
205
|
-
return {
|
|
206
|
-
status: headResponse1.status,
|
|
207
|
-
headers: headResponse1.headers,
|
|
208
|
-
body
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Streaming response:
|
|
213
|
-
* - block on none, call `onChunk` as soon as each response is ready
|
|
214
|
-
* - create headers with minimal data (cannot know the response body in advance)
|
|
215
|
-
* - return void
|
|
216
|
-
*/ const headResponse2 = initResponse({
|
|
217
|
-
ctx,
|
|
218
|
-
paths,
|
|
219
|
-
type,
|
|
220
|
-
responseMeta: opts.responseMeta
|
|
221
|
-
});
|
|
222
|
-
unstable_onHead(headResponse2, true);
|
|
223
|
-
const indexedPromises = new Map(promises.map((promise, index)=>[
|
|
224
|
-
index,
|
|
225
|
-
promise.then((r)=>[
|
|
226
|
-
index,
|
|
227
|
-
r
|
|
228
|
-
])
|
|
229
|
-
]));
|
|
230
|
-
for (const _ of paths){
|
|
231
|
-
const [index, untransformedJSON1] = await Promise.race(indexedPromises.values());
|
|
232
|
-
indexedPromises.delete(index);
|
|
233
|
-
try {
|
|
234
|
-
const transformedJSON1 = router.transformTRPCResponse(router$1._def._config, untransformedJSON1);
|
|
235
|
-
const body1 = JSON.stringify(transformedJSON1);
|
|
236
|
-
unstable_onChunk([
|
|
237
|
-
index,
|
|
238
|
-
body1
|
|
239
|
-
]);
|
|
240
|
-
} catch (cause) {
|
|
241
|
-
const path = paths[index];
|
|
242
|
-
const input = inputs[index];
|
|
243
|
-
const { body: body2 } = caughtErrorToData(cause, {
|
|
244
|
-
opts,
|
|
245
|
-
ctx,
|
|
246
|
-
type,
|
|
247
|
-
path,
|
|
248
|
-
input
|
|
249
|
-
});
|
|
250
|
-
unstable_onChunk([
|
|
251
|
-
index,
|
|
252
|
-
body2
|
|
253
|
-
]);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return;
|
|
257
|
-
} catch (cause1) {
|
|
258
|
-
// we get here if
|
|
259
|
-
// - batching is called when it's not enabled
|
|
260
|
-
// - `createContext()` throws
|
|
261
|
-
// - `router._def._config.transformer.output.serialize()` throws
|
|
262
|
-
// - post body is too large
|
|
263
|
-
// - input deserialization fails
|
|
264
|
-
// - `errorFormatter` return value is malformed
|
|
265
|
-
const { error , untransformedJSON: untransformedJSON2 , body: body3 } = caughtErrorToData(cause1, {
|
|
266
|
-
opts,
|
|
267
|
-
ctx,
|
|
268
|
-
type
|
|
269
|
-
});
|
|
270
|
-
const headResponse3 = initResponse({
|
|
271
|
-
ctx,
|
|
272
|
-
paths,
|
|
273
|
-
type,
|
|
274
|
-
responseMeta: opts.responseMeta,
|
|
275
|
-
untransformedJSON: untransformedJSON2,
|
|
276
|
-
errors: [
|
|
277
|
-
error
|
|
278
|
-
]
|
|
279
|
-
});
|
|
280
|
-
unstable_onHead?.(headResponse3, false);
|
|
281
|
-
unstable_onChunk?.([
|
|
282
|
-
-1,
|
|
283
|
-
body3
|
|
284
|
-
]);
|
|
285
|
-
return {
|
|
286
|
-
status: headResponse3.status,
|
|
287
|
-
headers: headResponse3.headers,
|
|
288
|
-
body: body3
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
exports.resolveHTTPResponse = resolveHTTPResponse;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { i as invert } from './utils-e1d51fac.js';
|
|
2
|
-
|
|
3
|
-
// reference: https://www.jsonrpc.org/specification
|
|
4
|
-
/**
|
|
5
|
-
* JSON-RPC 2.0 Error codes
|
|
6
|
-
*
|
|
7
|
-
* `-32000` to `-32099` are reserved for implementation-defined server-errors.
|
|
8
|
-
* For tRPC we're copying the last digits of HTTP 4XX errors.
|
|
9
|
-
*/
|
|
10
|
-
const TRPC_ERROR_CODES_BY_KEY = {
|
|
11
|
-
/**
|
|
12
|
-
* Invalid JSON was received by the server.
|
|
13
|
-
* An error occurred on the server while parsing the JSON text.
|
|
14
|
-
*/
|
|
15
|
-
PARSE_ERROR: -32700,
|
|
16
|
-
/**
|
|
17
|
-
* The JSON sent is not a valid Request object.
|
|
18
|
-
*/
|
|
19
|
-
BAD_REQUEST: -32600, // 400
|
|
20
|
-
// Internal JSON-RPC error
|
|
21
|
-
INTERNAL_SERVER_ERROR: -32603,
|
|
22
|
-
NOT_IMPLEMENTED: -32603,
|
|
23
|
-
// Implementation specific errors
|
|
24
|
-
UNAUTHORIZED: -32001, // 401
|
|
25
|
-
FORBIDDEN: -32003, // 403
|
|
26
|
-
NOT_FOUND: -32004, // 404
|
|
27
|
-
METHOD_NOT_SUPPORTED: -32005, // 405
|
|
28
|
-
TIMEOUT: -32008, // 408
|
|
29
|
-
CONFLICT: -32009, // 409
|
|
30
|
-
PRECONDITION_FAILED: -32012, // 412
|
|
31
|
-
PAYLOAD_TOO_LARGE: -32013, // 413
|
|
32
|
-
UNPROCESSABLE_CONTENT: -32022, // 422
|
|
33
|
-
TOO_MANY_REQUESTS: -32029, // 429
|
|
34
|
-
CLIENT_CLOSED_REQUEST: -32099, // 499
|
|
35
|
-
};
|
|
36
|
-
const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The default check to see if we're in a server
|
|
40
|
-
*/
|
|
41
|
-
const isServerDefault = typeof window === 'undefined' ||
|
|
42
|
-
'Deno' in window ||
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
44
|
-
globalThis.process?.env?.['NODE_ENV'] === 'test' ||
|
|
45
|
-
!!globalThis.process?.env?.['JEST_WORKER_ID'] ||
|
|
46
|
-
!!globalThis.process?.env?.['VITEST_WORKER_ID'];
|
|
47
|
-
|
|
48
|
-
export { TRPC_ERROR_CODES_BY_NUMBER as T, TRPC_ERROR_CODES_BY_KEY as a, isServerDefault as i };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('./utils-42a3ba6d.js');
|
|
4
|
-
|
|
5
|
-
// reference: https://www.jsonrpc.org/specification
|
|
6
|
-
/**
|
|
7
|
-
* JSON-RPC 2.0 Error codes
|
|
8
|
-
*
|
|
9
|
-
* `-32000` to `-32099` are reserved for implementation-defined server-errors.
|
|
10
|
-
* For tRPC we're copying the last digits of HTTP 4XX errors.
|
|
11
|
-
*/ const TRPC_ERROR_CODES_BY_KEY = {
|
|
12
|
-
/**
|
|
13
|
-
* Invalid JSON was received by the server.
|
|
14
|
-
* An error occurred on the server while parsing the JSON text.
|
|
15
|
-
*/ PARSE_ERROR: -32700,
|
|
16
|
-
/**
|
|
17
|
-
* The JSON sent is not a valid Request object.
|
|
18
|
-
*/ BAD_REQUEST: -32600,
|
|
19
|
-
// Internal JSON-RPC error
|
|
20
|
-
INTERNAL_SERVER_ERROR: -32603,
|
|
21
|
-
NOT_IMPLEMENTED: -32603,
|
|
22
|
-
// Implementation specific errors
|
|
23
|
-
UNAUTHORIZED: -32001,
|
|
24
|
-
FORBIDDEN: -32003,
|
|
25
|
-
NOT_FOUND: -32004,
|
|
26
|
-
METHOD_NOT_SUPPORTED: -32005,
|
|
27
|
-
TIMEOUT: -32008,
|
|
28
|
-
CONFLICT: -32009,
|
|
29
|
-
PRECONDITION_FAILED: -32012,
|
|
30
|
-
PAYLOAD_TOO_LARGE: -32013,
|
|
31
|
-
UNPROCESSABLE_CONTENT: -32022,
|
|
32
|
-
TOO_MANY_REQUESTS: -32029,
|
|
33
|
-
CLIENT_CLOSED_REQUEST: -32099
|
|
34
|
-
};
|
|
35
|
-
const TRPC_ERROR_CODES_BY_NUMBER = utils.invert(TRPC_ERROR_CODES_BY_KEY);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The default check to see if we're in a server
|
|
39
|
-
*/ const isServerDefault = typeof window === 'undefined' || 'Deno' in window || // eslint-disable-next-line @typescript-eslint/dot-notation
|
|
40
|
-
globalThis.process?.env?.['NODE_ENV'] === 'test' || !!globalThis.process?.env?.['JEST_WORKER_ID'] || !!globalThis.process?.env?.['VITEST_WORKER_ID'];
|
|
41
|
-
|
|
42
|
-
exports.TRPC_ERROR_CODES_BY_KEY = TRPC_ERROR_CODES_BY_KEY;
|
|
43
|
-
exports.TRPC_ERROR_CODES_BY_NUMBER = TRPC_ERROR_CODES_BY_NUMBER;
|
|
44
|
-
exports.isServerDefault = isServerDefault;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { i as invert } from './utils-cf6178ec.mjs';
|
|
2
|
-
|
|
3
|
-
// reference: https://www.jsonrpc.org/specification
|
|
4
|
-
/**
|
|
5
|
-
* JSON-RPC 2.0 Error codes
|
|
6
|
-
*
|
|
7
|
-
* `-32000` to `-32099` are reserved for implementation-defined server-errors.
|
|
8
|
-
* For tRPC we're copying the last digits of HTTP 4XX errors.
|
|
9
|
-
*/ const TRPC_ERROR_CODES_BY_KEY = {
|
|
10
|
-
/**
|
|
11
|
-
* Invalid JSON was received by the server.
|
|
12
|
-
* An error occurred on the server while parsing the JSON text.
|
|
13
|
-
*/ PARSE_ERROR: -32700,
|
|
14
|
-
/**
|
|
15
|
-
* The JSON sent is not a valid Request object.
|
|
16
|
-
*/ BAD_REQUEST: -32600,
|
|
17
|
-
// Internal JSON-RPC error
|
|
18
|
-
INTERNAL_SERVER_ERROR: -32603,
|
|
19
|
-
NOT_IMPLEMENTED: -32603,
|
|
20
|
-
// Implementation specific errors
|
|
21
|
-
UNAUTHORIZED: -32001,
|
|
22
|
-
FORBIDDEN: -32003,
|
|
23
|
-
NOT_FOUND: -32004,
|
|
24
|
-
METHOD_NOT_SUPPORTED: -32005,
|
|
25
|
-
TIMEOUT: -32008,
|
|
26
|
-
CONFLICT: -32009,
|
|
27
|
-
PRECONDITION_FAILED: -32012,
|
|
28
|
-
PAYLOAD_TOO_LARGE: -32013,
|
|
29
|
-
UNPROCESSABLE_CONTENT: -32022,
|
|
30
|
-
TOO_MANY_REQUESTS: -32029,
|
|
31
|
-
CLIENT_CLOSED_REQUEST: -32099
|
|
32
|
-
};
|
|
33
|
-
const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The default check to see if we're in a server
|
|
37
|
-
*/ const isServerDefault = typeof window === 'undefined' || 'Deno' in window || // eslint-disable-next-line @typescript-eslint/dot-notation
|
|
38
|
-
globalThis.process?.env?.['NODE_ENV'] === 'test' || !!globalThis.process?.env?.['JEST_WORKER_ID'] || !!globalThis.process?.env?.['VITEST_WORKER_ID'];
|
|
39
|
-
|
|
40
|
-
export { TRPC_ERROR_CODES_BY_NUMBER as T, TRPC_ERROR_CODES_BY_KEY as a, isServerDefault as i };
|
package/dist/router-68063d64.mjs
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { c as createRecursiveProxy } from './createProxy-7293f632.mjs';
|
|
2
|
-
import { T as TRPCError } from './TRPCError-af754aba.mjs';
|
|
3
|
-
import { a as isObject, m as mergeWithoutOverrides, o as omitPrototype } from './utils-cf6178ec.mjs';
|
|
4
|
-
|
|
5
|
-
const defaultFormatter = ({ shape })=>{
|
|
6
|
-
return shape;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/ function getDataTransformer(transformer) {
|
|
12
|
-
if ('input' in transformer) {
|
|
13
|
-
return transformer;
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
input: transformer,
|
|
17
|
-
output: transformer
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/ const defaultTransformer = {
|
|
23
|
-
_default: true,
|
|
24
|
-
input: {
|
|
25
|
-
serialize: (obj)=>obj,
|
|
26
|
-
deserialize: (obj)=>obj
|
|
27
|
-
},
|
|
28
|
-
output: {
|
|
29
|
-
serialize: (obj)=>obj,
|
|
30
|
-
deserialize: (obj)=>obj
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
function transformTRPCResponseItem(config, item) {
|
|
34
|
-
if ('error' in item) {
|
|
35
|
-
return {
|
|
36
|
-
...item,
|
|
37
|
-
error: config.transformer.output.serialize(item.error)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
if ('data' in item.result) {
|
|
41
|
-
return {
|
|
42
|
-
...item,
|
|
43
|
-
result: {
|
|
44
|
-
...item.result,
|
|
45
|
-
data: config.transformer.output.serialize(item.result.data)
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return item;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
|
|
53
|
-
**/ function transformTRPCResponse(config, itemOrItems) {
|
|
54
|
-
return Array.isArray(itemOrItems) ? itemOrItems.map((item)=>transformTRPCResponseItem(config, item)) : transformTRPCResponseItem(config, itemOrItems);
|
|
55
|
-
}
|
|
56
|
-
// FIXME:
|
|
57
|
-
// - the generics here are probably unnecessary
|
|
58
|
-
// - the RPC-spec could probably be simplified to combine HTTP + WS
|
|
59
|
-
/** @internal */ function transformResultInner(response, transformer) {
|
|
60
|
-
if ('error' in response) {
|
|
61
|
-
const error = transformer.deserialize(response.error);
|
|
62
|
-
return {
|
|
63
|
-
ok: false,
|
|
64
|
-
error: {
|
|
65
|
-
...response,
|
|
66
|
-
error
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const result = {
|
|
71
|
-
...response.result,
|
|
72
|
-
...(!response.result.type || response.result.type === 'data') && {
|
|
73
|
-
type: 'data',
|
|
74
|
-
data: transformer.deserialize(response.result.data)
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
ok: true,
|
|
79
|
-
result
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
class TransformResultError extends Error {
|
|
83
|
-
constructor(){
|
|
84
|
-
super('Unable to transform response from server');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Transforms and validates that the result is a valid TRPCResponse
|
|
89
|
-
* @internal
|
|
90
|
-
*/ function transformResult(response, transformer) {
|
|
91
|
-
let result;
|
|
92
|
-
try {
|
|
93
|
-
// Use the data transformers on the JSON-response
|
|
94
|
-
result = transformResultInner(response, transformer);
|
|
95
|
-
} catch (err) {
|
|
96
|
-
throw new TransformResultError();
|
|
97
|
-
}
|
|
98
|
-
// check that output of the transformers is a valid TRPCResponse
|
|
99
|
-
if (!result.ok && (!isObject(result.error.error) || typeof result.error.error['code'] !== 'number')) {
|
|
100
|
-
throw new TransformResultError();
|
|
101
|
-
}
|
|
102
|
-
if (result.ok && !isObject(result.result)) {
|
|
103
|
-
throw new TransformResultError();
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function isRouter(procedureOrRouter) {
|
|
109
|
-
return 'router' in procedureOrRouter._def;
|
|
110
|
-
}
|
|
111
|
-
const emptyRouter = {
|
|
112
|
-
_ctx: null,
|
|
113
|
-
_errorShape: null,
|
|
114
|
-
_meta: null,
|
|
115
|
-
queries: {},
|
|
116
|
-
mutations: {},
|
|
117
|
-
subscriptions: {},
|
|
118
|
-
errorFormatter: defaultFormatter,
|
|
119
|
-
transformer: defaultTransformer
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Reserved words that can't be used as router or procedure names
|
|
123
|
-
*/ const reservedWords = [
|
|
124
|
-
/**
|
|
125
|
-
* Then is a reserved word because otherwise we can't return a promise that returns a Proxy
|
|
126
|
-
* since JS will think that `.then` is something that exists
|
|
127
|
-
*/ 'then'
|
|
128
|
-
];
|
|
129
|
-
/**
|
|
130
|
-
* @internal
|
|
131
|
-
*/ function createRouterFactory(config) {
|
|
132
|
-
return function createRouterInner(procedures) {
|
|
133
|
-
const reservedWordsUsed = new Set(Object.keys(procedures).filter((v)=>reservedWords.includes(v)));
|
|
134
|
-
if (reservedWordsUsed.size > 0) {
|
|
135
|
-
throw new Error('Reserved words used in `router({})` call: ' + Array.from(reservedWordsUsed).join(', '));
|
|
136
|
-
}
|
|
137
|
-
const routerProcedures = omitPrototype({});
|
|
138
|
-
function recursiveGetPaths(procedures, path = '') {
|
|
139
|
-
for (const [key, procedureOrRouter] of Object.entries(procedures ?? {})){
|
|
140
|
-
const newPath = `${path}${key}`;
|
|
141
|
-
if (isRouter(procedureOrRouter)) {
|
|
142
|
-
recursiveGetPaths(procedureOrRouter._def.procedures, `${newPath}.`);
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (routerProcedures[newPath]) {
|
|
146
|
-
throw new Error(`Duplicate key: ${newPath}`);
|
|
147
|
-
}
|
|
148
|
-
routerProcedures[newPath] = procedureOrRouter;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
recursiveGetPaths(procedures);
|
|
152
|
-
const _def = {
|
|
153
|
-
_config: config,
|
|
154
|
-
router: true,
|
|
155
|
-
procedures: routerProcedures,
|
|
156
|
-
...emptyRouter,
|
|
157
|
-
record: procedures
|
|
158
|
-
};
|
|
159
|
-
const router = {
|
|
160
|
-
...procedures,
|
|
161
|
-
_def,
|
|
162
|
-
createCaller (ctx) {
|
|
163
|
-
const proxy = createRecursiveProxy(({ path , args })=>{
|
|
164
|
-
const fullPath = path.join('.');
|
|
165
|
-
const procedure = _def.procedures[fullPath];
|
|
166
|
-
return procedure({
|
|
167
|
-
path: fullPath,
|
|
168
|
-
getRawInput: async ()=>args[0],
|
|
169
|
-
ctx,
|
|
170
|
-
type: procedure._def.type
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
return proxy;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
return router;
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function isProcedure(procedureOrRouter) {
|
|
180
|
-
return !!procedureOrRouter._def.procedure;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* @internal
|
|
184
|
-
*/ function callProcedure(opts) {
|
|
185
|
-
const { type , path } = opts;
|
|
186
|
-
const proc = opts.procedures[path];
|
|
187
|
-
if (!proc || !isProcedure(proc) || proc._def.type !== type) {
|
|
188
|
-
throw new TRPCError({
|
|
189
|
-
code: 'NOT_FOUND',
|
|
190
|
-
message: `No "${type}"-procedure on path "${path}"`
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return proc(opts);
|
|
194
|
-
}
|
|
195
|
-
function createCallerFactory() {
|
|
196
|
-
return function createCallerInner(router) {
|
|
197
|
-
const _def = router._def;
|
|
198
|
-
return function createCaller(maybeContext) {
|
|
199
|
-
const proxy = createRecursiveProxy(({ path , args })=>{
|
|
200
|
-
const fullPath = path.join('.');
|
|
201
|
-
const procedure = _def.procedures[fullPath];
|
|
202
|
-
const callProc = (ctx)=>procedure({
|
|
203
|
-
path: fullPath,
|
|
204
|
-
getRawInput: async ()=>args[0],
|
|
205
|
-
ctx,
|
|
206
|
-
type: procedure._def.type
|
|
207
|
-
});
|
|
208
|
-
if (typeof maybeContext === 'function') {
|
|
209
|
-
const context = maybeContext();
|
|
210
|
-
if (context instanceof Promise) {
|
|
211
|
-
return context.then(callProc);
|
|
212
|
-
}
|
|
213
|
-
return callProc(context);
|
|
214
|
-
}
|
|
215
|
-
return callProc(maybeContext);
|
|
216
|
-
});
|
|
217
|
-
return proxy;
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
function mergeRouters(...routerList) {
|
|
222
|
-
const record = mergeWithoutOverrides({}, ...routerList.map((r)=>r._def.record));
|
|
223
|
-
const errorFormatter = routerList.reduce((currentErrorFormatter, nextRouter)=>{
|
|
224
|
-
if (nextRouter._def._config.errorFormatter && nextRouter._def._config.errorFormatter !== defaultFormatter) {
|
|
225
|
-
if (currentErrorFormatter !== defaultFormatter && currentErrorFormatter !== nextRouter._def._config.errorFormatter) {
|
|
226
|
-
throw new Error('You seem to have several error formatters');
|
|
227
|
-
}
|
|
228
|
-
return nextRouter._def._config.errorFormatter;
|
|
229
|
-
}
|
|
230
|
-
return currentErrorFormatter;
|
|
231
|
-
}, defaultFormatter);
|
|
232
|
-
const transformer = routerList.reduce((prev, current)=>{
|
|
233
|
-
if (current._def._config.transformer && current._def._config.transformer !== defaultTransformer) {
|
|
234
|
-
if (prev !== defaultTransformer && prev !== current._def._config.transformer) {
|
|
235
|
-
throw new Error('You seem to have several transformers');
|
|
236
|
-
}
|
|
237
|
-
return current._def._config.transformer;
|
|
238
|
-
}
|
|
239
|
-
return prev;
|
|
240
|
-
}, defaultTransformer);
|
|
241
|
-
const router = createRouterFactory({
|
|
242
|
-
errorFormatter,
|
|
243
|
-
transformer,
|
|
244
|
-
isDev: routerList.some((r)=>r._def._config.isDev),
|
|
245
|
-
allowOutsideOfServer: routerList.some((r)=>r._def._config.allowOutsideOfServer),
|
|
246
|
-
isServer: routerList.some((r)=>r._def._config.isServer),
|
|
247
|
-
$types: routerList[0]?._def._config.$types
|
|
248
|
-
})(record);
|
|
249
|
-
return router;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export { defaultTransformer as a, createRouterFactory as b, callProcedure as c, defaultFormatter as d, createCallerFactory as e, transformResult as f, getDataTransformer as g, mergeRouters as m, transformTRPCResponse as t };
|