@trpc/server 11.0.0-rc.361 → 11.0.0-rc.363
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 +7 -5
- package/dist/@trpc/server/http.d.ts.map +1 -1
- package/dist/@trpc/server/index.d.ts +1 -2
- package/dist/@trpc/server/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts +13 -0
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/getPlanner.js +143 -0
- package/dist/adapters/aws-lambda/getPlanner.mjs +141 -0
- package/dist/adapters/aws-lambda/index.d.ts +12 -9
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +8 -77
- package/dist/adapters/aws-lambda/index.mjs +9 -72
- package/dist/adapters/express.js +1 -0
- package/dist/adapters/express.mjs +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +19 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +22 -64
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +22 -64
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -0
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +29 -86
- package/dist/adapters/fetch/fetchRequestHandler.mjs +29 -86
- package/dist/adapters/fetch/types.d.ts +2 -2
- package/dist/adapters/fetch/types.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 +18 -0
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -0
- package/dist/adapters/node-http/incomingMessageToRequest.js +71 -0
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +69 -0
- package/dist/adapters/node-http/index.d.ts +1 -0
- package/dist/adapters/node-http/index.d.ts.map +1 -1
- package/dist/adapters/node-http/index.js +2 -0
- package/dist/adapters/node-http/index.mjs +1 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +28 -71
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +28 -71
- package/dist/adapters/node-http/types.d.ts +7 -8
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +174 -271
- package/dist/http.js +4 -2
- package/dist/http.mjs +2 -1
- package/dist/index.js +2 -4
- package/dist/index.mjs +1 -2
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +8 -20
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +180 -0
- package/dist/unstable-core-do-not-import/http/contentType.mjs +178 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts +14 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.js +14 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +12 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +1 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts +15 -0
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/{resolveHTTPResponse.js → resolveResponse.js} +119 -134
- package/dist/unstable-core-do-not-import/http/{resolveHTTPResponse.mjs → resolveResponse.mjs} +119 -134
- package/dist/unstable-core-do-not-import/http/types.d.ts +25 -27
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +1 -3
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -2
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +1 -2
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -9
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +3 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +2 -0
- package/dist/unstable-core-do-not-import/utils.mjs +2 -1
- package/dist/unstable-core-do-not-import.d.ts +9 -3
- package/dist/unstable-core-do-not-import.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import.js +12 -8
- package/dist/unstable-core-do-not-import.mjs +7 -5
- package/package.json +3 -13
- package/src/@trpc/server/http.ts +7 -12
- package/src/@trpc/server/index.ts +0 -3
- package/src/adapters/aws-lambda/getPlanner.ts +191 -0
- package/src/adapters/aws-lambda/index.ts +43 -107
- package/src/adapters/express.ts +1 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +43 -90
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +4 -3
- package/src/adapters/fetch/fetchRequestHandler.ts +35 -111
- package/src/adapters/fetch/types.ts +4 -2
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/incomingMessageToRequest.ts +94 -0
- package/src/adapters/node-http/index.ts +1 -0
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +31 -97
- package/src/adapters/node-http/types.ts +27 -37
- package/src/adapters/standalone.ts +1 -1
- package/src/unstable-core-do-not-import/http/contentType.ts +214 -22
- package/src/unstable-core-do-not-import/http/contentTypeParsers.ts +29 -0
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +2 -2
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +386 -0
- package/src/unstable-core-do-not-import/http/types.ts +25 -30
- package/src/unstable-core-do-not-import/procedureBuilder.ts +2 -4
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -10
- package/src/unstable-core-do-not-import/utils.ts +4 -0
- package/src/unstable-core-do-not-import.ts +9 -3
- package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
- package/adapters/node-http/content-type/form-data/index.js +0 -1
- package/adapters/node-http/content-type/json/index.d.ts +0 -1
- package/adapters/node-http/content-type/json/index.js +0 -1
- package/dist/adapters/aws-lambda/content-type/json/index.d.ts +0 -10
- package/dist/adapters/aws-lambda/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/content-type/json/index.js +0 -62
- package/dist/adapters/aws-lambda/content-type/json/index.mjs +0 -60
- package/dist/adapters/aws-lambda/utils.d.ts +0 -31
- package/dist/adapters/aws-lambda/utils.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/utils.js +0 -111
- package/dist/adapters/aws-lambda/utils.mjs +0 -103
- package/dist/adapters/content-handlers/concurrentCache.d.ts +0 -7
- package/dist/adapters/content-handlers/concurrentCache.d.ts.map +0 -1
- package/dist/adapters/content-handlers/concurrentCache.js +0 -17
- package/dist/adapters/content-handlers/concurrentCache.mjs +0 -15
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts +0 -10
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts.map +0 -1
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.js +0 -33
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs +0 -31
- package/dist/adapters/fastify/content-type/json/index.d.ts +0 -8
- package/dist/adapters/fastify/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/fastify/content-type/json/index.js +0 -62
- package/dist/adapters/fastify/content-type/json/index.mjs +0 -60
- package/dist/adapters/fastify/types.d.ts +0 -11
- package/dist/adapters/fastify/types.d.ts.map +0 -1
- package/dist/adapters/fetch/content-type/json/index.d.ts +0 -9
- package/dist/adapters/fetch/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/fetch/content-type/json/index.js +0 -55
- package/dist/adapters/fetch/content-type/json/index.mjs +0 -53
- package/dist/adapters/node-http/content-type/form-data/index.d.ts +0 -5
- package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/form-data/index.js +0 -32
- package/dist/adapters/node-http/content-type/form-data/index.mjs +0 -30
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +0 -7
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +0 -45
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +0 -43
- package/dist/adapters/node-http/content-type/json/index.d.ts +0 -5
- package/dist/adapters/node-http/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/json/index.js +0 -68
- package/dist/adapters/node-http/content-type/json/index.mjs +0 -66
- package/dist/adapters/node-http/content-type/octet/index.d.ts +0 -5
- package/dist/adapters/node-http/content-type/octet/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/octet/index.js +0 -19
- package/dist/adapters/node-http/content-type/octet/index.mjs +0 -17
- package/dist/adapters/node-http/content-type/types.d.ts +0 -8
- package/dist/adapters/node-http/content-type/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts +0 -16
- package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/contentTypeParsers.js +0 -23
- package/dist/unstable-core-do-not-import/contentTypeParsers.mjs +0 -21
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -11
- 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/src/adapters/aws-lambda/content-type/json/index.ts +0 -108
- package/src/adapters/aws-lambda/utils.ts +0 -170
- package/src/adapters/content-handlers/concurrentCache.ts +0 -16
- package/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts +0 -45
- package/src/adapters/fastify/content-type/json/index.ts +0 -106
- package/src/adapters/fastify/types.ts +0 -22
- package/src/adapters/fetch/content-type/json/index.ts +0 -90
- package/src/adapters/node-http/content-type/form-data/index.ts +0 -37
- package/src/adapters/node-http/content-type/json/getPostBody.ts +0 -49
- package/src/adapters/node-http/content-type/json/index.ts +0 -100
- package/src/adapters/node-http/content-type/octet/index.ts +0 -27
- package/src/adapters/node-http/content-type/types.ts +0 -19
- package/src/unstable-core-do-not-import/contentTypeParsers.ts +0 -37
- package/src/unstable-core-do-not-import/http/index.ts +0 -28
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -461
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var TRPCError = require('../../../../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
|
-
require('../../../../unstable-core-do-not-import/rootConfig.js');
|
|
5
|
-
var concurrentCache = require('../../../content-handlers/concurrentCache.js');
|
|
6
|
-
|
|
7
|
-
// @trpc/server
|
|
8
|
-
const getFetchHTTPJSONContentTypeHandler = ()=>{
|
|
9
|
-
const cache = concurrentCache.createConcurrentCache();
|
|
10
|
-
return {
|
|
11
|
-
name: 'fetch-json',
|
|
12
|
-
isMatch: (headers)=>{
|
|
13
|
-
return !!headers.get('content-type')?.startsWith('application/json');
|
|
14
|
-
},
|
|
15
|
-
getInputs: async (opts, info)=>{
|
|
16
|
-
async function getRawProcedureInputOrThrow() {
|
|
17
|
-
try {
|
|
18
|
-
if (opts.url.searchParams.has('input')) {
|
|
19
|
-
const input = opts.url.searchParams.get('input');
|
|
20
|
-
if (!input) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
return JSON.parse(input);
|
|
24
|
-
}
|
|
25
|
-
return await opts.req.json();
|
|
26
|
-
} catch (cause) {
|
|
27
|
-
throw new TRPCError.TRPCError({
|
|
28
|
-
code: 'PARSE_ERROR',
|
|
29
|
-
cause
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const deserializeInputValue = (rawValue, transformer)=>{
|
|
34
|
-
return typeof rawValue !== 'undefined' ? transformer.input.deserialize(rawValue) : rawValue;
|
|
35
|
-
};
|
|
36
|
-
const rawInput = await cache.concurrentSafeGet('rawInput', ()=>getRawProcedureInputOrThrow());
|
|
37
|
-
if (rawInput === undefined) {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
const transformer = opts.router._def._config.transformer;
|
|
41
|
-
if (!info.isBatchCall) {
|
|
42
|
-
return cache.concurrentSafeGet('input', ()=>deserializeInputValue(rawInput, transformer));
|
|
43
|
-
}
|
|
44
|
-
/* istanbul ignore if */ if (rawInput == null || typeof rawInput !== 'object' || Array.isArray(rawInput)) {
|
|
45
|
-
throw new TRPCError.TRPCError({
|
|
46
|
-
code: 'BAD_REQUEST',
|
|
47
|
-
message: '"input" needs to be an object when doing a batch call'
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return cache.concurrentSafeGet(String(info.batch), ()=>deserializeInputValue(rawInput[info.batch], transformer));
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
exports.getFetchHTTPJSONContentTypeHandler = getFetchHTTPJSONContentTypeHandler;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from '../../../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
2
|
-
import '../../../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
|
-
import { createConcurrentCache } from '../../../content-handlers/concurrentCache.mjs';
|
|
4
|
-
|
|
5
|
-
// @trpc/server
|
|
6
|
-
const getFetchHTTPJSONContentTypeHandler = ()=>{
|
|
7
|
-
const cache = createConcurrentCache();
|
|
8
|
-
return {
|
|
9
|
-
name: 'fetch-json',
|
|
10
|
-
isMatch: (headers)=>{
|
|
11
|
-
return !!headers.get('content-type')?.startsWith('application/json');
|
|
12
|
-
},
|
|
13
|
-
getInputs: async (opts, info)=>{
|
|
14
|
-
async function getRawProcedureInputOrThrow() {
|
|
15
|
-
try {
|
|
16
|
-
if (opts.url.searchParams.has('input')) {
|
|
17
|
-
const input = opts.url.searchParams.get('input');
|
|
18
|
-
if (!input) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return JSON.parse(input);
|
|
22
|
-
}
|
|
23
|
-
return await opts.req.json();
|
|
24
|
-
} catch (cause) {
|
|
25
|
-
throw new TRPCError({
|
|
26
|
-
code: 'PARSE_ERROR',
|
|
27
|
-
cause
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const deserializeInputValue = (rawValue, transformer)=>{
|
|
32
|
-
return typeof rawValue !== 'undefined' ? transformer.input.deserialize(rawValue) : rawValue;
|
|
33
|
-
};
|
|
34
|
-
const rawInput = await cache.concurrentSafeGet('rawInput', ()=>getRawProcedureInputOrThrow());
|
|
35
|
-
if (rawInput === undefined) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
const transformer = opts.router._def._config.transformer;
|
|
39
|
-
if (!info.isBatchCall) {
|
|
40
|
-
return cache.concurrentSafeGet('input', ()=>deserializeInputValue(rawInput, transformer));
|
|
41
|
-
}
|
|
42
|
-
/* istanbul ignore if */ if (rawInput == null || typeof rawInput !== 'object' || Array.isArray(rawInput)) {
|
|
43
|
-
throw new TRPCError({
|
|
44
|
-
code: 'BAD_REQUEST',
|
|
45
|
-
message: '"input" needs to be an object when doing a batch call'
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return cache.concurrentSafeGet(String(info.batch), ()=>deserializeInputValue(rawInput[info.batch], transformer));
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { getFetchHTTPJSONContentTypeHandler };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AnyRouter } from '../../../../@trpc/server';
|
|
2
|
-
import type { NodeHTTPRequest, NodeHTTPResponse } from '../../types';
|
|
3
|
-
import type { NodeHTTPContentTypeHandler } from '../types';
|
|
4
|
-
export declare const getFormDataContentTypeHandler: <TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>() => NodeHTTPContentTypeHandler<TRouter, TRequest, TResponse>;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/form-data/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE3D,eAAO,MAAM,6BAA6B,EAAE,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,OAC7B,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CA0B5D,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var node_stream = require('node:stream');
|
|
4
|
-
|
|
5
|
-
const getFormDataContentTypeHandler = ()=>({
|
|
6
|
-
name: 'node-http-formdata',
|
|
7
|
-
isMatch: (headers)=>{
|
|
8
|
-
return !!headers.get('content-type')?.startsWith('multipart/form-data');
|
|
9
|
-
},
|
|
10
|
-
async getInputs (opts, inputOpts) {
|
|
11
|
-
if (inputOpts.isBatchCall) {
|
|
12
|
-
throw new Error('Batch calls not supported for form-data');
|
|
13
|
-
}
|
|
14
|
-
const contentType = opts.req.headers['content-type'];
|
|
15
|
-
if (!contentType) {
|
|
16
|
-
// Should be unreachable given the isMatch check
|
|
17
|
-
throw new Error('No content-type header found');
|
|
18
|
-
}
|
|
19
|
-
const form = await new Request('https://unused.com', {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
headers: {
|
|
22
|
-
'content-type': contentType
|
|
23
|
-
},
|
|
24
|
-
body: node_stream.Readable.toWeb(opts.req),
|
|
25
|
-
// @ts-expect-error - outdated types? this exists
|
|
26
|
-
duplex: 'half'
|
|
27
|
-
}).formData();
|
|
28
|
-
return form;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
exports.getFormDataContentTypeHandler = getFormDataContentTypeHandler;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Readable } from 'node:stream';
|
|
2
|
-
|
|
3
|
-
const getFormDataContentTypeHandler = ()=>({
|
|
4
|
-
name: 'node-http-formdata',
|
|
5
|
-
isMatch: (headers)=>{
|
|
6
|
-
return !!headers.get('content-type')?.startsWith('multipart/form-data');
|
|
7
|
-
},
|
|
8
|
-
async getInputs (opts, inputOpts) {
|
|
9
|
-
if (inputOpts.isBatchCall) {
|
|
10
|
-
throw new Error('Batch calls not supported for form-data');
|
|
11
|
-
}
|
|
12
|
-
const contentType = opts.req.headers['content-type'];
|
|
13
|
-
if (!contentType) {
|
|
14
|
-
// Should be unreachable given the isMatch check
|
|
15
|
-
throw new Error('No content-type header found');
|
|
16
|
-
}
|
|
17
|
-
const form = await new Request('https://unused.com', {
|
|
18
|
-
method: 'POST',
|
|
19
|
-
headers: {
|
|
20
|
-
'content-type': contentType
|
|
21
|
-
},
|
|
22
|
-
body: Readable.toWeb(opts.req),
|
|
23
|
-
// @ts-expect-error - outdated types? this exists
|
|
24
|
-
duplex: 'half'
|
|
25
|
-
}).formData();
|
|
26
|
-
return form;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export { getFormDataContentTypeHandler };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { BodyResult } from '../../../../@trpc/server/http';
|
|
2
|
-
import type { NodeHTTPRequest } from '../../types';
|
|
3
|
-
export declare function getPostBody(opts: {
|
|
4
|
-
req: NodeHTTPRequest;
|
|
5
|
-
maxBodySize?: number;
|
|
6
|
-
}): Promise<BodyResult>;
|
|
7
|
-
//# sourceMappingURL=getPostBody.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPostBody.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/getPostBody.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,EAAE,eAAe,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,CAwCtB"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var TRPCError = require('../../../../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
|
-
require('../../../../unstable-core-do-not-import/rootConfig.js');
|
|
5
|
-
|
|
6
|
-
// @trpc/server
|
|
7
|
-
async function getPostBody(opts) {
|
|
8
|
-
const { req , maxBodySize =Infinity } = opts;
|
|
9
|
-
return new Promise((resolve)=>{
|
|
10
|
-
if ('body' in req) {
|
|
11
|
-
resolve({
|
|
12
|
-
ok: true,
|
|
13
|
-
data: req.body,
|
|
14
|
-
// If the request headers specifies a content-type, we assume that the body has been preprocessed
|
|
15
|
-
preprocessed: !!req.headers['content-type']?.startsWith('application/json')
|
|
16
|
-
});
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
let body = '';
|
|
20
|
-
let hasBody = false;
|
|
21
|
-
function onData(data) {
|
|
22
|
-
body += data;
|
|
23
|
-
hasBody = true;
|
|
24
|
-
if (body.length > maxBodySize) {
|
|
25
|
-
req.off('data', onData);
|
|
26
|
-
resolve({
|
|
27
|
-
ok: false,
|
|
28
|
-
error: new TRPCError.TRPCError({
|
|
29
|
-
code: 'PAYLOAD_TOO_LARGE'
|
|
30
|
-
})
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
req.on('data', onData);
|
|
35
|
-
req.on('end', ()=>{
|
|
36
|
-
resolve({
|
|
37
|
-
ok: true,
|
|
38
|
-
data: hasBody ? body : undefined,
|
|
39
|
-
preprocessed: false
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.getPostBody = getPostBody;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from '../../../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
2
|
-
import '../../../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
|
-
|
|
4
|
-
// @trpc/server
|
|
5
|
-
async function getPostBody(opts) {
|
|
6
|
-
const { req , maxBodySize =Infinity } = opts;
|
|
7
|
-
return new Promise((resolve)=>{
|
|
8
|
-
if ('body' in req) {
|
|
9
|
-
resolve({
|
|
10
|
-
ok: true,
|
|
11
|
-
data: req.body,
|
|
12
|
-
// If the request headers specifies a content-type, we assume that the body has been preprocessed
|
|
13
|
-
preprocessed: !!req.headers['content-type']?.startsWith('application/json')
|
|
14
|
-
});
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
let body = '';
|
|
18
|
-
let hasBody = false;
|
|
19
|
-
function onData(data) {
|
|
20
|
-
body += data;
|
|
21
|
-
hasBody = true;
|
|
22
|
-
if (body.length > maxBodySize) {
|
|
23
|
-
req.off('data', onData);
|
|
24
|
-
resolve({
|
|
25
|
-
ok: false,
|
|
26
|
-
error: new TRPCError({
|
|
27
|
-
code: 'PAYLOAD_TOO_LARGE'
|
|
28
|
-
})
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
req.on('data', onData);
|
|
33
|
-
req.on('end', ()=>{
|
|
34
|
-
resolve({
|
|
35
|
-
ok: true,
|
|
36
|
-
data: hasBody ? body : undefined,
|
|
37
|
-
preprocessed: false
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { getPostBody };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AnyRouter } from '../../../../@trpc/server';
|
|
2
|
-
import type { NodeHTTPRequest, NodeHTTPResponse } from '../../types';
|
|
3
|
-
import type { NodeHTTPContentTypeHandler } from '../types';
|
|
4
|
-
export declare const getNodeHTTPJSONContentTypeHandler: <TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>() => NodeHTTPContentTypeHandler<TRouter, TRequest, TResponse>;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EAEV,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAG3D,eAAO,MAAM,iCAAiC,EAAE,CAC9C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,OAC7B,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAoF7D,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var TRPCError = require('../../../../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
|
-
require('../../../../unstable-core-do-not-import/rootConfig.js');
|
|
5
|
-
var concurrentCache = require('../../../content-handlers/concurrentCache.js');
|
|
6
|
-
var getPostBody = require('./getPostBody.js');
|
|
7
|
-
|
|
8
|
-
// @trpc/server
|
|
9
|
-
const getNodeHTTPJSONContentTypeHandler = ()=>{
|
|
10
|
-
const cache = concurrentCache.createConcurrentCache();
|
|
11
|
-
return {
|
|
12
|
-
name: 'node-http-json',
|
|
13
|
-
isMatch: (headers)=>{
|
|
14
|
-
return !!headers.get('content-type')?.startsWith('application/json');
|
|
15
|
-
},
|
|
16
|
-
getInputs: async (opts, info)=>{
|
|
17
|
-
async function getRawProcedureInputOrThrow() {
|
|
18
|
-
const bodyResult = await getPostBody.getPostBody(opts);
|
|
19
|
-
if (!bodyResult.ok) {
|
|
20
|
-
throw bodyResult.error;
|
|
21
|
-
}
|
|
22
|
-
const preprocessedBody = bodyResult.preprocessed;
|
|
23
|
-
const body = bodyResult.data;
|
|
24
|
-
try {
|
|
25
|
-
if (opts.req.method === 'GET') {
|
|
26
|
-
const input = opts.query.get('input');
|
|
27
|
-
if (!input) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
return JSON.parse(input);
|
|
31
|
-
}
|
|
32
|
-
if (preprocessedBody || typeof body !== 'string') {
|
|
33
|
-
// Some tools like nextjs may parse json
|
|
34
|
-
// requests before they reach us. So we just use them as is
|
|
35
|
-
return body;
|
|
36
|
-
} else {
|
|
37
|
-
return JSON.parse(body);
|
|
38
|
-
}
|
|
39
|
-
} catch (cause) {
|
|
40
|
-
throw new TRPCError.TRPCError({
|
|
41
|
-
code: 'PARSE_ERROR',
|
|
42
|
-
cause
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const deserializeInputValue = (rawValue, transformer)=>{
|
|
47
|
-
return typeof rawValue !== 'undefined' ? transformer.input.deserialize(rawValue) : rawValue;
|
|
48
|
-
};
|
|
49
|
-
const rawInput = await cache.concurrentSafeGet('rawInput', ()=>getRawProcedureInputOrThrow());
|
|
50
|
-
if (rawInput === undefined) {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
const transformer = opts.router._def._config.transformer;
|
|
54
|
-
if (!info.isBatchCall) {
|
|
55
|
-
return cache.concurrentSafeGet('input', ()=>deserializeInputValue(rawInput, transformer));
|
|
56
|
-
}
|
|
57
|
-
/* istanbul ignore if */ if (rawInput == null || typeof rawInput !== 'object' || Array.isArray(rawInput)) {
|
|
58
|
-
throw new TRPCError.TRPCError({
|
|
59
|
-
code: 'BAD_REQUEST',
|
|
60
|
-
message: '"input" needs to be an object when doing a batch call'
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return cache.concurrentSafeGet(String(info.batch), ()=>deserializeInputValue(rawInput[info.batch], transformer));
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
exports.getNodeHTTPJSONContentTypeHandler = getNodeHTTPJSONContentTypeHandler;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from '../../../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
2
|
-
import '../../../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
|
-
import { createConcurrentCache } from '../../../content-handlers/concurrentCache.mjs';
|
|
4
|
-
import { getPostBody } from './getPostBody.mjs';
|
|
5
|
-
|
|
6
|
-
// @trpc/server
|
|
7
|
-
const getNodeHTTPJSONContentTypeHandler = ()=>{
|
|
8
|
-
const cache = createConcurrentCache();
|
|
9
|
-
return {
|
|
10
|
-
name: 'node-http-json',
|
|
11
|
-
isMatch: (headers)=>{
|
|
12
|
-
return !!headers.get('content-type')?.startsWith('application/json');
|
|
13
|
-
},
|
|
14
|
-
getInputs: async (opts, info)=>{
|
|
15
|
-
async function getRawProcedureInputOrThrow() {
|
|
16
|
-
const bodyResult = await getPostBody(opts);
|
|
17
|
-
if (!bodyResult.ok) {
|
|
18
|
-
throw bodyResult.error;
|
|
19
|
-
}
|
|
20
|
-
const preprocessedBody = bodyResult.preprocessed;
|
|
21
|
-
const body = bodyResult.data;
|
|
22
|
-
try {
|
|
23
|
-
if (opts.req.method === 'GET') {
|
|
24
|
-
const input = opts.query.get('input');
|
|
25
|
-
if (!input) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
return JSON.parse(input);
|
|
29
|
-
}
|
|
30
|
-
if (preprocessedBody || typeof body !== 'string') {
|
|
31
|
-
// Some tools like nextjs may parse json
|
|
32
|
-
// requests before they reach us. So we just use them as is
|
|
33
|
-
return body;
|
|
34
|
-
} else {
|
|
35
|
-
return JSON.parse(body);
|
|
36
|
-
}
|
|
37
|
-
} catch (cause) {
|
|
38
|
-
throw new TRPCError({
|
|
39
|
-
code: 'PARSE_ERROR',
|
|
40
|
-
cause
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const deserializeInputValue = (rawValue, transformer)=>{
|
|
45
|
-
return typeof rawValue !== 'undefined' ? transformer.input.deserialize(rawValue) : rawValue;
|
|
46
|
-
};
|
|
47
|
-
const rawInput = await cache.concurrentSafeGet('rawInput', ()=>getRawProcedureInputOrThrow());
|
|
48
|
-
if (rawInput === undefined) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
const transformer = opts.router._def._config.transformer;
|
|
52
|
-
if (!info.isBatchCall) {
|
|
53
|
-
return cache.concurrentSafeGet('input', ()=>deserializeInputValue(rawInput, transformer));
|
|
54
|
-
}
|
|
55
|
-
/* istanbul ignore if */ if (rawInput == null || typeof rawInput !== 'object' || Array.isArray(rawInput)) {
|
|
56
|
-
throw new TRPCError({
|
|
57
|
-
code: 'BAD_REQUEST',
|
|
58
|
-
message: '"input" needs to be an object when doing a batch call'
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return cache.concurrentSafeGet(String(info.batch), ()=>deserializeInputValue(rawInput[info.batch], transformer));
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export { getNodeHTTPJSONContentTypeHandler };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AnyRouter } from '../../../../@trpc/server';
|
|
2
|
-
import type { NodeHTTPRequest, NodeHTTPResponse } from '../../types';
|
|
3
|
-
import type { NodeHTTPContentTypeHandler } from '../types';
|
|
4
|
-
export declare const getOctetContentTypeHandler: <TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse>() => NodeHTTPContentTypeHandler<TRouter, TRequest, TResponse>;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/octet/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE3D,eAAO,MAAM,0BAA0B,EAAE,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,OAC7B,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAgB5D,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var node_stream = require('node:stream');
|
|
4
|
-
|
|
5
|
-
const getOctetContentTypeHandler = ()=>({
|
|
6
|
-
name: 'node-http-octet',
|
|
7
|
-
isMatch: (headers)=>{
|
|
8
|
-
return !!headers.get('content-type')?.startsWith('application/octet-stream');
|
|
9
|
-
},
|
|
10
|
-
async getInputs (opts, inputOpts) {
|
|
11
|
-
if (inputOpts.isBatchCall) {
|
|
12
|
-
throw new Error('Batch calls not supported for octet-stream');
|
|
13
|
-
}
|
|
14
|
-
const stream = node_stream.Stream.Readable.toWeb(opts.req);
|
|
15
|
-
return stream;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
exports.getOctetContentTypeHandler = getOctetContentTypeHandler;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Stream } from 'node:stream';
|
|
2
|
-
|
|
3
|
-
const getOctetContentTypeHandler = ()=>({
|
|
4
|
-
name: 'node-http-octet',
|
|
5
|
-
isMatch: (headers)=>{
|
|
6
|
-
return !!headers.get('content-type')?.startsWith('application/octet-stream');
|
|
7
|
-
},
|
|
8
|
-
async getInputs (opts, inputOpts) {
|
|
9
|
-
if (inputOpts.isBatchCall) {
|
|
10
|
-
throw new Error('Batch calls not supported for octet-stream');
|
|
11
|
-
}
|
|
12
|
-
const stream = Stream.Readable.toWeb(opts.req);
|
|
13
|
-
return stream;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export { getOctetContentTypeHandler };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AnyRouter } from '../../../@trpc/server';
|
|
2
|
-
import type { BaseContentTypeHandler } from '../../../@trpc/server/http';
|
|
3
|
-
import type { NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse } from '../types';
|
|
4
|
-
export interface NodeHTTPContentTypeHandler<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> extends BaseContentTypeHandler<NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse> & {
|
|
5
|
-
query: URLSearchParams;
|
|
6
|
-
}> {
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/adapters/node-http/content-type/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,0BAA0B,CACzC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,CAClC,SAAQ,sBAAsB,CAC5B,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IAC5D,KAAK,EAAE,eAAe,CAAC;CACxB,CACF;CAAG"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ParserZodEsque } from './parser';
|
|
2
|
-
export type UtilityParser<TInput, TOutput> = ParserZodEsque<TInput, TOutput> & {
|
|
3
|
-
parse: (input: unknown) => TOutput;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* File is only available from Node19+ but it always extends Blob so we can use that as a type until we eventually drop Node18
|
|
7
|
-
*/
|
|
8
|
-
interface FileLike extends Blob {
|
|
9
|
-
readonly name: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* When expecting a supported octet type to be passed from the frontend, this parser may be used to validate the type for your procedure. Note: the output is always a `Readable` stream.
|
|
13
|
-
*/
|
|
14
|
-
export declare function parseOctetInput<TInput extends Blob | Uint8Array | FileLike>(): UtilityParser<TInput, ReadableStream>;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=contentTypeParsers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contentTypeParsers.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/contentTypeParsers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,aAAa,CAAC,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC7E,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CACpC,CAAC;AAIF;;GAEG;AACH,UAAU,QAAS,SAAQ,IAAI;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,SAAS,IAAI,GAAG,UAAU,GAAG,QAAQ,KACxC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,CAezC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var TRPCError = require('./error/TRPCError.js');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* When expecting a supported octet type to be passed from the frontend, this parser may be used to validate the type for your procedure. Note: the output is always a `Readable` stream.
|
|
7
|
-
*/ function parseOctetInput() {
|
|
8
|
-
return {
|
|
9
|
-
_input: null,
|
|
10
|
-
_output: null,
|
|
11
|
-
parse (input) {
|
|
12
|
-
if (input instanceof ReadableStream) {
|
|
13
|
-
return input;
|
|
14
|
-
}
|
|
15
|
-
throw new TRPCError.TRPCError({
|
|
16
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
17
|
-
cause: `Parsed input was expected to be a ReadableStream but was: ${typeof input}`
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.parseOctetInput = parseOctetInput;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from './error/TRPCError.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* When expecting a supported octet type to be passed from the frontend, this parser may be used to validate the type for your procedure. Note: the output is always a `Readable` stream.
|
|
5
|
-
*/ function parseOctetInput() {
|
|
6
|
-
return {
|
|
7
|
-
_input: null,
|
|
8
|
-
_output: null,
|
|
9
|
-
parse (input) {
|
|
10
|
-
if (input instanceof ReadableStream) {
|
|
11
|
-
return input;
|
|
12
|
-
}
|
|
13
|
-
throw new TRPCError({
|
|
14
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
15
|
-
cause: `Parsed input was expected to be a ReadableStream but was: ${typeof input}`
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { parseOctetInput };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { getHTTPStatusCode, getHTTPStatusCodeFromError, } from './getHTTPStatusCode';
|
|
2
|
-
export { resolveHTTPResponse } from './resolveHTTPResponse';
|
|
3
|
-
export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPRequest, HTTPResponse,
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use `HTTPErrorHandler` instead
|
|
6
|
-
*/
|
|
7
|
-
HTTPErrorHandler as OnErrorFunction, HTTPErrorHandler, ProcedureCall, ResolveHTTPRequestOptionsContextFn, ResponseChunk, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from './types';
|
|
8
|
-
export { getBatchStreamFormatter } from './batchStreamFormatter';
|
|
9
|
-
export type { BaseContentTypeHandler, BodyResult } from './contentType';
|
|
10
|
-
export { toURL } from './toURL';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY;AACZ;;GAEG;AACH,gBAAgB,IAAI,eAAe,EACnC,gBAAgB,EAChB,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from '../error/TRPCError';
|
|
2
|
-
import type { AnyRouter } from '../router';
|
|
3
|
-
import type { HTTPBaseHandlerOptions, HTTPRequest, HTTPResponse, ResolveHTTPRequestOptionsContextFn, ResponseChunk } from './types';
|
|
4
|
-
interface ResolveHTTPRequestOptions<TRouter extends AnyRouter, TRequest extends HTTPRequest> extends HTTPBaseHandlerOptions<TRouter, TRequest> {
|
|
5
|
-
createContext: ResolveHTTPRequestOptionsContextFn<TRouter>;
|
|
6
|
-
req: TRequest;
|
|
7
|
-
path: string;
|
|
8
|
-
getInput: (opts: {
|
|
9
|
-
isBatchCall: boolean;
|
|
10
|
-
batch: number;
|
|
11
|
-
}) => Promise<unknown>;
|
|
12
|
-
error?: TRPCError;
|
|
13
|
-
/**
|
|
14
|
-
* Called as soon as the response head is known.
|
|
15
|
-
* When streaming, headers will have been generated
|
|
16
|
-
* **without** knowing the response body.
|
|
17
|
-
*
|
|
18
|
-
* Without this callback, streaming is disabled.
|
|
19
|
-
*/
|
|
20
|
-
unstable_onHead: (headResponse: Omit<HTTPResponse, 'body'>, isStreaming: boolean) => void;
|
|
21
|
-
/**
|
|
22
|
-
* Called for every procedure with `[index, result]`.
|
|
23
|
-
*
|
|
24
|
-
* Will be called a single time with `index = -1` if
|
|
25
|
-
* - response is an error
|
|
26
|
-
* - response is empty (HEAD request)
|
|
27
|
-
*
|
|
28
|
-
* Without this callback, streaming is disabled.
|
|
29
|
-
*/
|
|
30
|
-
unstable_onChunk: (chunk: ResponseChunk) => void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Since `resolveHTTPResponse` is a public API (community adapters),
|
|
34
|
-
* let's give it a strong type signature to increase discoverability.
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* Non-streaming signature for `resolveHTTPResponse`:
|
|
38
|
-
* @param opts.unstable_onHead `undefined`
|
|
39
|
-
* @param opts.unstable_onChunk `undefined`
|
|
40
|
-
* @returns `Promise<HTTPResponse>`
|
|
41
|
-
*/
|
|
42
|
-
export declare function resolveHTTPResponse<TRouter extends AnyRouter, TRequest extends HTTPRequest>(opts: Omit<ResolveHTTPRequestOptions<TRouter, TRequest>, 'unstable_onChunk' | 'unstable_onHead'>): Promise<HTTPResponse>;
|
|
43
|
-
/**
|
|
44
|
-
* Streaming signature for `resolveHTTPResponse`:
|
|
45
|
-
* @param opts.unstable_onHead called as soon as the response head is known
|
|
46
|
-
* @param opts.unstable_onChunk called for every procedure with `[index, result]`
|
|
47
|
-
* @returns `Promise<void>` since the response is streamed
|
|
48
|
-
*/
|
|
49
|
-
export declare function resolveHTTPResponse<TRouter extends AnyRouter, TRequest extends HTTPRequest>(opts: ResolveHTTPRequestOptions<TRouter, TRequest>): Promise<void>;
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=resolveHTTPResponse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveHTTPResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,KAAK,EACV,SAAS,EAGV,MAAM,WAAW,CAAC;AAKnB,OAAO,KAAK,EACV,sBAAsB,EAEtB,WAAW,EACX,YAAY,EACZ,kCAAkC,EAClC,aAAa,EAEd,MAAM,SAAS,CAAC;AAgBjB,UAAU,yBAAyB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,CAC5B,SAAQ,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC;IACjD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;OAMG;IACH,eAAe,EAAE,CACf,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EACxC,WAAW,EAAE,OAAO,KACjB,IAAI,CAAC;IACV;;;;;;;;OAQG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD;AA4GD;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAE5B,IAAI,EAAE,IAAI,CACR,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC5C,kBAAkB,GAAG,iBAAiB,CACvC,GACA,OAAO,CAAC,YAAY,CAAC,CAAC;AACzB;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAC5B,IAAI,EAAE,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|