@trpc/server 11.0.0-alpha-tmp-app-router-example.388 → 11.0.0-alpha-tmp-issues-5851-take-two.448
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/http.d.ts +1 -2
- package/dist/@trpc/server/http.d.ts.map +1 -1
- package/dist/@trpc/server/index.d.ts +1 -1
- package/dist/@trpc/server/index.d.ts.map +1 -1
- package/dist/@trpc/server/rpc.d.ts +1 -1
- package/dist/@trpc/server/rpc.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.js +19 -2
- package/dist/adapters/aws-lambda/getPlanner.mjs +19 -2
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +1 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +1 -1
- package/dist/adapters/next-app-dir/redirect.d.ts.map +1 -1
- package/dist/adapters/next.js +1 -1
- package/dist/adapters/next.mjs +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +0 -1
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +3 -1
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +3 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +30 -7
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +30 -7
- package/dist/adapters/node-http/types.d.ts +0 -1
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +0 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/ws.d.ts +3 -4
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +172 -114
- package/dist/adapters/ws.mjs +172 -114
- package/dist/bundle-analysis.json +236 -155
- package/dist/http.js +3 -0
- package/dist/http.mjs +1 -0
- package/dist/index.js +7 -5
- package/dist/index.mjs +3 -2
- package/dist/observable/observable.d.ts +1 -0
- package/dist/observable/observable.d.ts.map +1 -1
- package/dist/observable/observable.js +55 -0
- package/dist/observable/observable.mjs +55 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +3 -3
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/createProxy.js +15 -6
- package/dist/unstable-core-do-not-import/createProxy.mjs +15 -6
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +7 -4
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +60 -17
- package/dist/unstable-core-do-not-import/http/contentType.mjs +61 -18
- package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/formDataToObject.js +40 -0
- package/dist/unstable-core-do-not-import/http/formDataToObject.mjs +38 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +4 -4
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +4 -4
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts +4 -0
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.js +42 -0
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.mjs +39 -0
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +302 -149
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +301 -148
- package/dist/unstable-core-do-not-import/http/types.d.ts +26 -2
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +12 -12
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/middleware.d.ts +3 -3
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +3 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +12 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.d.ts +2 -2
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.js +7 -2
- package/dist/unstable-core-do-not-import/router.mjs +7 -2
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +7 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +1 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/{stream.d.ts → jsonl.d.ts} +5 -5
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/{stream.js → jsonl.js} +148 -111
- package/dist/unstable-core-do-not-import/stream/{stream.mjs → jsonl.mjs} +147 -110
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +86 -0
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/sse.js +178 -0
- package/dist/unstable-core-do-not-import/stream/sse.mjs +172 -0
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts +18 -0
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.js +46 -0
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.mjs +43 -0
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts +10 -0
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.js +31 -0
- package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.mjs +29 -0
- package/dist/unstable-core-do-not-import/stream/utils/createServer.d.ts +7 -0
- package/dist/unstable-core-do-not-import/stream/utils/createServer.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts +5 -5
- package/dist/unstable-core-do-not-import/utils.d.ts +4 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +4 -0
- package/dist/unstable-core-do-not-import/utils.mjs +4 -1
- package/dist/unstable-core-do-not-import.d.ts +5 -2
- package/dist/unstable-core-do-not-import.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import.js +19 -7
- package/dist/unstable-core-do-not-import.mjs +6 -3
- package/package.json +6 -6
- package/src/@trpc/server/http.ts +7 -2
- package/src/@trpc/server/index.ts +1 -0
- package/src/@trpc/server/rpc.ts +1 -0
- package/src/adapters/aws-lambda/getPlanner.ts +21 -2
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +2 -1
- package/src/adapters/node-http/incomingMessageToRequest.ts +3 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +32 -7
- package/src/adapters/ws.ts +193 -107
- package/src/observable/observable.ts +63 -0
- package/src/unstable-core-do-not-import/createProxy.ts +23 -8
- package/src/unstable-core-do-not-import/http/contentType.ts +83 -21
- package/src/{adapters/next-app-dir → unstable-core-do-not-import/http}/formDataToObject.ts +18 -10
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +4 -7
- package/src/unstable-core-do-not-import/http/parseConnectionParams.ts +49 -0
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +333 -164
- package/src/unstable-core-do-not-import/http/types.ts +31 -2
- package/src/unstable-core-do-not-import/procedureBuilder.ts +8 -1
- package/src/unstable-core-do-not-import/rootConfig.ts +12 -0
- package/src/unstable-core-do-not-import/router.ts +47 -35
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +9 -0
- package/src/unstable-core-do-not-import/rpc/index.ts +1 -0
- package/src/unstable-core-do-not-import/stream/{stream.ts → jsonl.ts} +163 -110
- package/src/unstable-core-do-not-import/stream/sse.ts +288 -0
- package/src/unstable-core-do-not-import/stream/utils/createDeferred.ts +48 -0
- package/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts +31 -0
- package/src/unstable-core-do-not-import/stream/utils/createServer.ts +44 -0
- package/src/unstable-core-do-not-import/utils.ts +5 -0
- package/src/unstable-core-do-not-import.ts +5 -2
- package/dist/adapters/next-app-dir/formDataToObject.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/formDataToObject.js +0 -34
- package/dist/adapters/next-app-dir/formDataToObject.mjs +0 -32
- package/dist/unstable-core-do-not-import/stream/stream.d.ts.map +0 -1
- /package/dist/{adapters/next-app-dir → unstable-core-do-not-import/http}/formDataToObject.d.ts +0 -0
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { TRPCError } from '../error/TRPCError';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyProcedure, ProcedureType } from '../procedure';
|
|
3
|
+
import type { AnyRouter } from '../router';
|
|
3
4
|
import { isObject, unsetMarker } from '../utils';
|
|
4
|
-
import
|
|
5
|
+
import { parseConnectionParamsFromString } from './parseConnectionParams';
|
|
6
|
+
import type { TRPCAcceptHeader, TRPCRequestInfo } from './types';
|
|
7
|
+
|
|
8
|
+
type GetRequestInfoOptions = {
|
|
9
|
+
path: string;
|
|
10
|
+
req: Request;
|
|
11
|
+
searchParams: URLSearchParams;
|
|
12
|
+
headers: Headers;
|
|
13
|
+
router: AnyRouter;
|
|
14
|
+
};
|
|
5
15
|
|
|
6
16
|
type ContentTypeHandler = {
|
|
7
17
|
isMatch: (opts: Request) => boolean;
|
|
8
|
-
parse: (opts:
|
|
9
|
-
path: string;
|
|
10
|
-
req: Request;
|
|
11
|
-
searchParams: URLSearchParams;
|
|
12
|
-
config: RootConfig<any>;
|
|
13
|
-
}) => TRPCRequestInfo;
|
|
18
|
+
parse: (opts: GetRequestInfoOptions) => TRPCRequestInfo;
|
|
14
19
|
};
|
|
15
20
|
|
|
16
21
|
/**
|
|
@@ -82,7 +87,7 @@ const jsonContentTypeHandler: ContentTypeHandler = {
|
|
|
82
87
|
|
|
83
88
|
if (!isBatchCall) {
|
|
84
89
|
return {
|
|
85
|
-
0: opts.
|
|
90
|
+
0: opts.router._def._config.transformer.input.deserialize(inputs),
|
|
86
91
|
};
|
|
87
92
|
}
|
|
88
93
|
|
|
@@ -96,26 +101,80 @@ const jsonContentTypeHandler: ContentTypeHandler = {
|
|
|
96
101
|
for (const index of paths.keys()) {
|
|
97
102
|
const input = inputs[index];
|
|
98
103
|
if (input !== undefined) {
|
|
99
|
-
acc[index] =
|
|
104
|
+
acc[index] =
|
|
105
|
+
opts.router._def._config.transformer.input.deserialize(input);
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
return acc;
|
|
104
110
|
});
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
const calls = paths.map((path, index): TRPCRequestInfo['calls'][number] => {
|
|
113
|
+
const procedure: AnyProcedure | null =
|
|
114
|
+
opts.router._def.procedures[path] ?? null;
|
|
115
|
+
return {
|
|
109
116
|
path,
|
|
117
|
+
procedure,
|
|
110
118
|
getRawInput: async () => {
|
|
111
119
|
const inputs = await getInputs.read();
|
|
112
|
-
|
|
120
|
+
let input = inputs[index];
|
|
121
|
+
|
|
122
|
+
if (procedure?._def.type === 'subscription') {
|
|
123
|
+
const lastEventId =
|
|
124
|
+
opts.headers.get('last-event-id') ??
|
|
125
|
+
opts.searchParams.get('lastEventId') ??
|
|
126
|
+
opts.searchParams.get('Last-Event-Id');
|
|
127
|
+
|
|
128
|
+
if (lastEventId) {
|
|
129
|
+
if (isObject(input)) {
|
|
130
|
+
input = {
|
|
131
|
+
...input,
|
|
132
|
+
lastEventId: lastEventId,
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
input ??= {
|
|
136
|
+
lastEventId: lastEventId,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return input;
|
|
113
142
|
},
|
|
114
143
|
result: () => {
|
|
115
144
|
return getInputs.result()?.[index];
|
|
116
145
|
},
|
|
117
|
-
}
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const types = new Set(
|
|
150
|
+
calls.map((call) => call.procedure?._def.type).filter(Boolean),
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
/* istanbul ignore if -- @preserve */
|
|
154
|
+
if (types.size > 1) {
|
|
155
|
+
throw new TRPCError({
|
|
156
|
+
code: 'BAD_REQUEST',
|
|
157
|
+
message: `Cannot mix procedure types in call: ${Array.from(types).join(
|
|
158
|
+
', ',
|
|
159
|
+
)}`,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
const type: ProcedureType | 'unknown' =
|
|
163
|
+
types.values().next().value ?? 'unknown';
|
|
164
|
+
|
|
165
|
+
const connectionParamsStr = opts.searchParams.get('connectionParams');
|
|
166
|
+
|
|
167
|
+
const info: TRPCRequestInfo = {
|
|
168
|
+
isBatchCall,
|
|
169
|
+
accept: req.headers.get('trpc-accept') as TRPCAcceptHeader | null,
|
|
170
|
+
calls,
|
|
171
|
+
type,
|
|
172
|
+
connectionParams:
|
|
173
|
+
connectionParamsStr === null
|
|
174
|
+
? null
|
|
175
|
+
: parseConnectionParamsFromString(connectionParamsStr),
|
|
118
176
|
};
|
|
177
|
+
return info;
|
|
119
178
|
},
|
|
120
179
|
};
|
|
121
180
|
|
|
@@ -137,14 +196,18 @@ const formDataContentTypeHandler: ContentTypeHandler = {
|
|
|
137
196
|
return fd;
|
|
138
197
|
});
|
|
139
198
|
return {
|
|
199
|
+
accept: null,
|
|
140
200
|
calls: [
|
|
141
201
|
{
|
|
142
202
|
path: opts.path,
|
|
143
203
|
getRawInput: getInputs.read,
|
|
144
204
|
result: getInputs.result,
|
|
205
|
+
procedure: opts.router._def.procedures[opts.path] ?? null,
|
|
145
206
|
},
|
|
146
207
|
],
|
|
147
208
|
isBatchCall: false,
|
|
209
|
+
type: 'mutation',
|
|
210
|
+
connectionParams: null,
|
|
148
211
|
};
|
|
149
212
|
},
|
|
150
213
|
};
|
|
@@ -173,9 +236,13 @@ const octetStreamContentTypeHandler: ContentTypeHandler = {
|
|
|
173
236
|
path: opts.path,
|
|
174
237
|
getRawInput: getInputs.read,
|
|
175
238
|
result: getInputs.result,
|
|
239
|
+
procedure: opts.router._def.procedures[opts.path] ?? null,
|
|
176
240
|
},
|
|
177
241
|
],
|
|
178
242
|
isBatchCall: false,
|
|
243
|
+
accept: null,
|
|
244
|
+
type: 'mutation',
|
|
245
|
+
connectionParams: null,
|
|
179
246
|
};
|
|
180
247
|
},
|
|
181
248
|
};
|
|
@@ -205,12 +272,7 @@ function getContentTypeHandler(req: Request): ContentTypeHandler {
|
|
|
205
272
|
});
|
|
206
273
|
}
|
|
207
274
|
|
|
208
|
-
export function getRequestInfo(opts: {
|
|
209
|
-
path: string;
|
|
210
|
-
req: Request;
|
|
211
|
-
searchParams: URLSearchParams;
|
|
212
|
-
config: RootConfig<any>;
|
|
213
|
-
}): TRPCRequestInfo {
|
|
275
|
+
export function getRequestInfo(opts: GetRequestInfoOptions): TRPCRequestInfo {
|
|
214
276
|
const handler = getContentTypeHandler(opts.req);
|
|
215
277
|
return handler.parse(opts);
|
|
216
278
|
}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
+
|
|
3
|
+
const isNumberString = (str: string) => /^\d+$/.test(str);
|
|
4
|
+
|
|
2
5
|
function set(
|
|
3
6
|
obj: Record<string, any>,
|
|
4
|
-
path: string[]
|
|
7
|
+
path: readonly string[],
|
|
5
8
|
value: unknown,
|
|
6
9
|
): void {
|
|
7
|
-
if (typeof path === 'string') {
|
|
8
|
-
path = path.split(/[\.\[\]]/).filter(Boolean);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
10
|
if (path.length > 1) {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const newPath = [...path];
|
|
12
|
+
const key = newPath.shift()!;
|
|
13
|
+
const nextKey = newPath[0]!;
|
|
14
|
+
|
|
15
|
+
if (!obj[key]) {
|
|
16
|
+
obj[key] = isNumberString(nextKey) ? [] : {};
|
|
17
|
+
} else if (Array.isArray(obj[key]) && !isNumberString(nextKey)) {
|
|
18
|
+
obj[key] = Object.fromEntries(Object.entries(obj[key]));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
set(obj[key], newPath, value);
|
|
22
|
+
|
|
16
23
|
return;
|
|
17
24
|
}
|
|
18
25
|
const p = path[0]!;
|
|
@@ -29,7 +36,8 @@ export function formDataToObject(formData: FormData) {
|
|
|
29
36
|
const obj: Record<string, unknown> = {};
|
|
30
37
|
|
|
31
38
|
for (const [key, value] of formData.entries()) {
|
|
32
|
-
|
|
39
|
+
const parts = key.split(/[\.\[\]]/).filter(Boolean);
|
|
40
|
+
set(obj, parts, value);
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
return obj;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { DefaultErrorData } from '../error/formatter';
|
|
2
1
|
import type { TRPCError } from '../error/TRPCError';
|
|
3
2
|
import type { TRPC_ERROR_CODES_BY_KEY, TRPCResponse } from '../rpc';
|
|
4
3
|
import { TRPC_ERROR_CODES_BY_NUMBER } from '../rpc';
|
|
4
|
+
import { isObject } from '../utils';
|
|
5
5
|
|
|
6
6
|
const JSONRPC2_TO_HTTP_CODE: Record<
|
|
7
7
|
keyof typeof TRPC_ERROR_CODES_BY_KEY,
|
|
@@ -33,12 +33,9 @@ export function getHTTPStatusCode(json: TRPCResponse | TRPCResponse[]): number {
|
|
|
33
33
|
const arr = Array.isArray(json) ? json : [json];
|
|
34
34
|
const httpStatuses = new Set<number>(
|
|
35
35
|
arr.map((res) => {
|
|
36
|
-
if ('error' in res) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| DefaultErrorData;
|
|
40
|
-
if (typeof data.httpStatus === 'number') {
|
|
41
|
-
return data.httpStatus;
|
|
36
|
+
if ('error' in res && isObject(res.error.data)) {
|
|
37
|
+
if (typeof res.error.data?.['httpStatus'] === 'number') {
|
|
38
|
+
return res.error.data['httpStatus'];
|
|
42
39
|
}
|
|
43
40
|
const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
44
41
|
return getStatusCodeFromKey(code);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TRPCError } from '../error/TRPCError';
|
|
2
|
+
import { isObject } from '../utils';
|
|
3
|
+
import type { TRPCRequestInfo } from './types';
|
|
4
|
+
|
|
5
|
+
export function parseConnectionParamsFromUnknown(
|
|
6
|
+
parsed: unknown,
|
|
7
|
+
): TRPCRequestInfo['connectionParams'] {
|
|
8
|
+
try {
|
|
9
|
+
if (parsed === null) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (!isObject(parsed)) {
|
|
13
|
+
throw new Error('Expected object');
|
|
14
|
+
}
|
|
15
|
+
const nonStringValues = Object.entries(parsed).filter(
|
|
16
|
+
([_key, value]) => typeof value !== 'string',
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if (nonStringValues.length > 0) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Expected connectionParams to be string values. Got ${nonStringValues
|
|
22
|
+
.map(([key, value]) => `${key}: ${typeof value}`)
|
|
23
|
+
.join(', ')}`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return parsed as Record<string, string>;
|
|
27
|
+
} catch (cause) {
|
|
28
|
+
throw new TRPCError({
|
|
29
|
+
code: 'PARSE_ERROR',
|
|
30
|
+
message: 'Invalid connection params shape',
|
|
31
|
+
cause,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function parseConnectionParamsFromString(
|
|
36
|
+
str: string,
|
|
37
|
+
): TRPCRequestInfo['connectionParams'] {
|
|
38
|
+
let parsed: unknown;
|
|
39
|
+
try {
|
|
40
|
+
parsed = JSON.parse(str);
|
|
41
|
+
} catch (cause) {
|
|
42
|
+
throw new TRPCError({
|
|
43
|
+
code: 'PARSE_ERROR',
|
|
44
|
+
message: 'Not JSON-parsable query params',
|
|
45
|
+
cause,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return parseConnectionParamsFromUnknown(parsed);
|
|
49
|
+
}
|