@trpc/server 9.24.0 → 9.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export * from "../../../dist/declarations/src/adapters/lambda/index";
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('../../../dist/router-2f54c292.cjs.dev.js');
6
+ require('events');
7
+ var transformTRPCResponse = require('../../../dist/transformTRPCResponse-c654ea92.cjs.dev.js');
8
+ require('http');
9
+ require('url');
10
+ require('../../../dist/nodeHTTPRequestHandler-36ddaba2.cjs.dev.js');
11
+ var resolveHTTPResponse = require('../../../dist/resolveHTTPResponse-55b2c9bd.cjs.dev.js');
12
+ require('../../../dist/codes-130e62df.cjs.dev.js');
13
+
14
+ function isPayloadV1(event) {
15
+ return determinePayloadFormat(event) == '1.0';
16
+ }
17
+ function isPayloadV2(event) {
18
+ return determinePayloadFormat(event) == '2.0';
19
+ }
20
+
21
+ function determinePayloadFormat(event) {
22
+ // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
23
+ // According to AWS support, version is is extracted from the version property in the event.
24
+ // If there is no version property, then the version is implied as 1.0
25
+ const unknownEvent = event;
26
+
27
+ if (typeof unknownEvent.version === 'undefined') {
28
+ return '1.0';
29
+ } else {
30
+ if (['1.0', '2.0'].includes(unknownEvent.version)) {
31
+ return unknownEvent.version;
32
+ } else {
33
+ return 'custom';
34
+ }
35
+ }
36
+ }
37
+
38
+ const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = 'Custom payload format version not handled by this adapter. Please use either 1.0 or 2.0. More information here' + 'https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html';
39
+
40
+ function lambdaEventToHTTPRequest(event) {
41
+ const query = new URLSearchParams();
42
+
43
+ for (const [key, value] of Object.entries((_event$queryStringPar = event.queryStringParameters) !== null && _event$queryStringPar !== void 0 ? _event$queryStringPar : {})) {
44
+ var _event$queryStringPar;
45
+
46
+ if (typeof value !== 'undefined') {
47
+ query.append(key, value);
48
+ }
49
+ }
50
+
51
+ return {
52
+ method: getHTTPMethod(event),
53
+ query: query,
54
+ headers: event.headers,
55
+ body: event.body
56
+ };
57
+ }
58
+
59
+ function getHTTPMethod(event) {
60
+ if (isPayloadV1(event)) {
61
+ return event.httpMethod;
62
+ }
63
+
64
+ if (isPayloadV2(event)) {
65
+ return event.requestContext.http.method;
66
+ }
67
+
68
+ throw new transformTRPCResponse.TRPCError({
69
+ code: 'INTERNAL_SERVER_ERROR',
70
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
71
+ });
72
+ }
73
+
74
+ function getPath(event) {
75
+ if (isPayloadV1(event)) {
76
+ return event.path.slice(1);
77
+ }
78
+
79
+ if (isPayloadV2(event)) {
80
+ return event.rawPath.slice(1);
81
+ }
82
+
83
+ throw new transformTRPCResponse.TRPCError({
84
+ code: 'INTERNAL_SERVER_ERROR',
85
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
86
+ });
87
+ }
88
+
89
+ function transformHeaders(headers) {
90
+ const obj = {};
91
+
92
+ for (const [key, value] of Object.entries(headers)) {
93
+ if (typeof value === 'undefined') {
94
+ continue;
95
+ }
96
+
97
+ obj[key] = Array.isArray(value) ? value.join(',') : value;
98
+ }
99
+
100
+ return obj;
101
+ }
102
+
103
+ function tRPCOutputToAPIGatewayOutput(event, response) {
104
+ if (isPayloadV1(event)) {
105
+ var _response$body, _response$headers;
106
+
107
+ const resp = {
108
+ statusCode: response.status,
109
+ body: (_response$body = response.body) !== null && _response$body !== void 0 ? _response$body : '',
110
+ headers: transformHeaders((_response$headers = response.headers) !== null && _response$headers !== void 0 ? _response$headers : {})
111
+ };
112
+ return resp;
113
+ } else if (isPayloadV2(event)) {
114
+ var _response$body2, _response$headers2;
115
+
116
+ const resp = {
117
+ statusCode: response.status,
118
+ body: (_response$body2 = response.body) !== null && _response$body2 !== void 0 ? _response$body2 : undefined,
119
+ headers: transformHeaders((_response$headers2 = response.headers) !== null && _response$headers2 !== void 0 ? _response$headers2 : {})
120
+ };
121
+ return resp;
122
+ } else {
123
+ throw new transformTRPCResponse.TRPCError({
124
+ code: 'INTERNAL_SERVER_ERROR',
125
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
126
+ });
127
+ }
128
+ }
129
+ /** Will check the createContext of the TRouter and get the parameter of event.
130
+ * @internal
131
+ **/
132
+
133
+
134
+ function lambdaRequestHandler(opts) {
135
+ return async (event, context) => {
136
+ const req = lambdaEventToHTTPRequest(event);
137
+ const path = getPath(event);
138
+
139
+ const createContext = async function _createContext() {
140
+ var _opts$createContext;
141
+
142
+ return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, {
143
+ event,
144
+ context
145
+ }));
146
+ };
147
+
148
+ const response = await resolveHTTPResponse.resolveHTTPResponse({
149
+ router: opts.router,
150
+ batching: opts.batching,
151
+ responseMeta: opts === null || opts === void 0 ? void 0 : opts.responseMeta,
152
+ createContext,
153
+ req,
154
+ path,
155
+ error: null,
156
+
157
+ onError(o) {
158
+ var _opts$onError;
159
+
160
+ opts === null || opts === void 0 ? void 0 : (_opts$onError = opts.onError) === null || _opts$onError === void 0 ? void 0 : _opts$onError.call(opts, { ...o,
161
+ req: event
162
+ });
163
+ }
164
+
165
+ });
166
+ return tRPCOutputToAPIGatewayOutput(event, response);
167
+ };
168
+ }
169
+
170
+ exports.lambdaRequestHandler = lambdaRequestHandler;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./trpc-server-adapters-lambda.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./trpc-server-adapters-lambda.cjs.dev.js");
7
+ }
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('../../../dist/router-459409c8.cjs.prod.js');
6
+ require('events');
7
+ var transformTRPCResponse = require('../../../dist/transformTRPCResponse-1e125b28.cjs.prod.js');
8
+ require('http');
9
+ require('url');
10
+ require('../../../dist/nodeHTTPRequestHandler-91e7ca3d.cjs.prod.js');
11
+ var resolveHTTPResponse = require('../../../dist/resolveHTTPResponse-02e61299.cjs.prod.js');
12
+ require('../../../dist/codes-aff770a3.cjs.prod.js');
13
+
14
+ function isPayloadV1(event) {
15
+ return determinePayloadFormat(event) == '1.0';
16
+ }
17
+ function isPayloadV2(event) {
18
+ return determinePayloadFormat(event) == '2.0';
19
+ }
20
+
21
+ function determinePayloadFormat(event) {
22
+ // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
23
+ // According to AWS support, version is is extracted from the version property in the event.
24
+ // If there is no version property, then the version is implied as 1.0
25
+ const unknownEvent = event;
26
+
27
+ if (typeof unknownEvent.version === 'undefined') {
28
+ return '1.0';
29
+ } else {
30
+ if (['1.0', '2.0'].includes(unknownEvent.version)) {
31
+ return unknownEvent.version;
32
+ } else {
33
+ return 'custom';
34
+ }
35
+ }
36
+ }
37
+
38
+ const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = 'Custom payload format version not handled by this adapter. Please use either 1.0 or 2.0. More information here' + 'https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html';
39
+
40
+ function lambdaEventToHTTPRequest(event) {
41
+ const query = new URLSearchParams();
42
+
43
+ for (const [key, value] of Object.entries((_event$queryStringPar = event.queryStringParameters) !== null && _event$queryStringPar !== void 0 ? _event$queryStringPar : {})) {
44
+ var _event$queryStringPar;
45
+
46
+ if (typeof value !== 'undefined') {
47
+ query.append(key, value);
48
+ }
49
+ }
50
+
51
+ return {
52
+ method: getHTTPMethod(event),
53
+ query: query,
54
+ headers: event.headers,
55
+ body: event.body
56
+ };
57
+ }
58
+
59
+ function getHTTPMethod(event) {
60
+ if (isPayloadV1(event)) {
61
+ return event.httpMethod;
62
+ }
63
+
64
+ if (isPayloadV2(event)) {
65
+ return event.requestContext.http.method;
66
+ }
67
+
68
+ throw new transformTRPCResponse.TRPCError({
69
+ code: 'INTERNAL_SERVER_ERROR',
70
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
71
+ });
72
+ }
73
+
74
+ function getPath(event) {
75
+ if (isPayloadV1(event)) {
76
+ return event.path.slice(1);
77
+ }
78
+
79
+ if (isPayloadV2(event)) {
80
+ return event.rawPath.slice(1);
81
+ }
82
+
83
+ throw new transformTRPCResponse.TRPCError({
84
+ code: 'INTERNAL_SERVER_ERROR',
85
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
86
+ });
87
+ }
88
+
89
+ function transformHeaders(headers) {
90
+ const obj = {};
91
+
92
+ for (const [key, value] of Object.entries(headers)) {
93
+ if (typeof value === 'undefined') {
94
+ continue;
95
+ }
96
+
97
+ obj[key] = Array.isArray(value) ? value.join(',') : value;
98
+ }
99
+
100
+ return obj;
101
+ }
102
+
103
+ function tRPCOutputToAPIGatewayOutput(event, response) {
104
+ if (isPayloadV1(event)) {
105
+ var _response$body, _response$headers;
106
+
107
+ const resp = {
108
+ statusCode: response.status,
109
+ body: (_response$body = response.body) !== null && _response$body !== void 0 ? _response$body : '',
110
+ headers: transformHeaders((_response$headers = response.headers) !== null && _response$headers !== void 0 ? _response$headers : {})
111
+ };
112
+ return resp;
113
+ } else if (isPayloadV2(event)) {
114
+ var _response$body2, _response$headers2;
115
+
116
+ const resp = {
117
+ statusCode: response.status,
118
+ body: (_response$body2 = response.body) !== null && _response$body2 !== void 0 ? _response$body2 : undefined,
119
+ headers: transformHeaders((_response$headers2 = response.headers) !== null && _response$headers2 !== void 0 ? _response$headers2 : {})
120
+ };
121
+ return resp;
122
+ } else {
123
+ throw new transformTRPCResponse.TRPCError({
124
+ code: 'INTERNAL_SERVER_ERROR',
125
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
126
+ });
127
+ }
128
+ }
129
+ /** Will check the createContext of the TRouter and get the parameter of event.
130
+ * @internal
131
+ **/
132
+
133
+
134
+ function lambdaRequestHandler(opts) {
135
+ return async (event, context) => {
136
+ const req = lambdaEventToHTTPRequest(event);
137
+ const path = getPath(event);
138
+
139
+ const createContext = async function _createContext() {
140
+ var _opts$createContext;
141
+
142
+ return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, {
143
+ event,
144
+ context
145
+ }));
146
+ };
147
+
148
+ const response = await resolveHTTPResponse.resolveHTTPResponse({
149
+ router: opts.router,
150
+ batching: opts.batching,
151
+ responseMeta: opts === null || opts === void 0 ? void 0 : opts.responseMeta,
152
+ createContext,
153
+ req,
154
+ path,
155
+ error: null,
156
+
157
+ onError(o) {
158
+ var _opts$onError;
159
+
160
+ opts === null || opts === void 0 ? void 0 : (_opts$onError = opts.onError) === null || _opts$onError === void 0 ? void 0 : _opts$onError.call(opts, { ...o,
161
+ req: event
162
+ });
163
+ }
164
+
165
+ });
166
+ return tRPCOutputToAPIGatewayOutput(event, response);
167
+ };
168
+ }
169
+
170
+ exports.lambdaRequestHandler = lambdaRequestHandler;
@@ -0,0 +1,166 @@
1
+ import '../../../dist/router-93491dae.esm.js';
2
+ import 'events';
3
+ import { T as TRPCError } from '../../../dist/transformTRPCResponse-45c225c3.esm.js';
4
+ import 'http';
5
+ import 'url';
6
+ import '../../../dist/nodeHTTPRequestHandler-372a4a4f.esm.js';
7
+ import { r as resolveHTTPResponse } from '../../../dist/resolveHTTPResponse-ddb56677.esm.js';
8
+ import '../../../dist/codes-5678cc97.esm.js';
9
+
10
+ function isPayloadV1(event) {
11
+ return determinePayloadFormat(event) == '1.0';
12
+ }
13
+ function isPayloadV2(event) {
14
+ return determinePayloadFormat(event) == '2.0';
15
+ }
16
+
17
+ function determinePayloadFormat(event) {
18
+ // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
19
+ // According to AWS support, version is is extracted from the version property in the event.
20
+ // If there is no version property, then the version is implied as 1.0
21
+ const unknownEvent = event;
22
+
23
+ if (typeof unknownEvent.version === 'undefined') {
24
+ return '1.0';
25
+ } else {
26
+ if (['1.0', '2.0'].includes(unknownEvent.version)) {
27
+ return unknownEvent.version;
28
+ } else {
29
+ return 'custom';
30
+ }
31
+ }
32
+ }
33
+
34
+ const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = 'Custom payload format version not handled by this adapter. Please use either 1.0 or 2.0. More information here' + 'https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html';
35
+
36
+ function lambdaEventToHTTPRequest(event) {
37
+ const query = new URLSearchParams();
38
+
39
+ for (const [key, value] of Object.entries((_event$queryStringPar = event.queryStringParameters) !== null && _event$queryStringPar !== void 0 ? _event$queryStringPar : {})) {
40
+ var _event$queryStringPar;
41
+
42
+ if (typeof value !== 'undefined') {
43
+ query.append(key, value);
44
+ }
45
+ }
46
+
47
+ return {
48
+ method: getHTTPMethod(event),
49
+ query: query,
50
+ headers: event.headers,
51
+ body: event.body
52
+ };
53
+ }
54
+
55
+ function getHTTPMethod(event) {
56
+ if (isPayloadV1(event)) {
57
+ return event.httpMethod;
58
+ }
59
+
60
+ if (isPayloadV2(event)) {
61
+ return event.requestContext.http.method;
62
+ }
63
+
64
+ throw new TRPCError({
65
+ code: 'INTERNAL_SERVER_ERROR',
66
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
67
+ });
68
+ }
69
+
70
+ function getPath(event) {
71
+ if (isPayloadV1(event)) {
72
+ return event.path.slice(1);
73
+ }
74
+
75
+ if (isPayloadV2(event)) {
76
+ return event.rawPath.slice(1);
77
+ }
78
+
79
+ throw new TRPCError({
80
+ code: 'INTERNAL_SERVER_ERROR',
81
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
82
+ });
83
+ }
84
+
85
+ function transformHeaders(headers) {
86
+ const obj = {};
87
+
88
+ for (const [key, value] of Object.entries(headers)) {
89
+ if (typeof value === 'undefined') {
90
+ continue;
91
+ }
92
+
93
+ obj[key] = Array.isArray(value) ? value.join(',') : value;
94
+ }
95
+
96
+ return obj;
97
+ }
98
+
99
+ function tRPCOutputToAPIGatewayOutput(event, response) {
100
+ if (isPayloadV1(event)) {
101
+ var _response$body, _response$headers;
102
+
103
+ const resp = {
104
+ statusCode: response.status,
105
+ body: (_response$body = response.body) !== null && _response$body !== void 0 ? _response$body : '',
106
+ headers: transformHeaders((_response$headers = response.headers) !== null && _response$headers !== void 0 ? _response$headers : {})
107
+ };
108
+ return resp;
109
+ } else if (isPayloadV2(event)) {
110
+ var _response$body2, _response$headers2;
111
+
112
+ const resp = {
113
+ statusCode: response.status,
114
+ body: (_response$body2 = response.body) !== null && _response$body2 !== void 0 ? _response$body2 : undefined,
115
+ headers: transformHeaders((_response$headers2 = response.headers) !== null && _response$headers2 !== void 0 ? _response$headers2 : {})
116
+ };
117
+ return resp;
118
+ } else {
119
+ throw new TRPCError({
120
+ code: 'INTERNAL_SERVER_ERROR',
121
+ message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
122
+ });
123
+ }
124
+ }
125
+ /** Will check the createContext of the TRouter and get the parameter of event.
126
+ * @internal
127
+ **/
128
+
129
+
130
+ function lambdaRequestHandler(opts) {
131
+ return async (event, context) => {
132
+ const req = lambdaEventToHTTPRequest(event);
133
+ const path = getPath(event);
134
+
135
+ const createContext = async function _createContext() {
136
+ var _opts$createContext;
137
+
138
+ return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, {
139
+ event,
140
+ context
141
+ }));
142
+ };
143
+
144
+ const response = await resolveHTTPResponse({
145
+ router: opts.router,
146
+ batching: opts.batching,
147
+ responseMeta: opts === null || opts === void 0 ? void 0 : opts.responseMeta,
148
+ createContext,
149
+ req,
150
+ path,
151
+ error: null,
152
+
153
+ onError(o) {
154
+ var _opts$onError;
155
+
156
+ opts === null || opts === void 0 ? void 0 : (_opts$onError = opts.onError) === null || _opts$onError === void 0 ? void 0 : _opts$onError.call(opts, { ...o,
157
+ req: event
158
+ });
159
+ }
160
+
161
+ });
162
+ return tRPCOutputToAPIGatewayOutput(event, response);
163
+ };
164
+ }
165
+
166
+ export { lambdaRequestHandler };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/trpc-server-adapters-lambda.cjs.js",
3
+ "module": "dist/trpc-server-adapters-lambda.esm.js"
4
+ }
@@ -0,0 +1,14 @@
1
+ import type { Context as APIGWContext, APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2 } from 'aws-lambda';
2
+ import { AnyRouter } from '../../router';
3
+ import { APIGatewayEvent, AWSLambdaOptions } from './utils';
4
+ export type { CreateLambdaContextOptions, AWSLambdaOptions } from './utils';
5
+ /** Will check the createContext of the TRouter and get the parameter of event.
6
+ * @internal
7
+ **/
8
+ declare type inferAPIGWEvent<TRouter extends AnyRouter, TEvent extends APIGatewayEvent> = AWSLambdaOptions<TRouter, TEvent>['createContext'] extends NonNullable<AWSLambdaOptions<TRouter, TEvent>['createContext']> ? Parameters<AWSLambdaOptions<TRouter, TEvent>['createContext']>[0]['event'] : APIGatewayEvent;
9
+ /** 1:1 mapping of v1 or v2 input events, deduces which is which.
10
+ * @internal
11
+ **/
12
+ declare type inferAPIGWReturn<T> = T extends APIGatewayProxyEvent ? APIGatewayProxyResult : T extends APIGatewayProxyEventV2 ? APIGatewayProxyStructuredResultV2 : never;
13
+ export declare function lambdaRequestHandler<TRouter extends AnyRouter, TEvent extends inferAPIGWEvent<TRouter, TEvent>, TResult extends inferAPIGWReturn<TEvent>>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: APIGWContext) => Promise<TResult>;
14
+ //# sourceMappingURL=index.d.ts.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{ Context as APIGWContext, APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2 } from 'aws-lambda';
2
+ import type { ResponseMetaFn } from '../../http/internals/types';
3
+ import type { AnyRouter, inferRouterContext } from '../../router';
4
+ export declare type APIGatewayEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
5
+ export declare type APIGatewayResult = APIGatewayProxyResult | APIGatewayProxyStructuredResultV2;
6
+ export declare type CreateLambdaContextOptions<T extends APIGatewayEvent> = {
7
+ event: T;
8
+ context: APIGWContext;
9
+ };
10
+ export declare type LambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends APIGatewayEvent> = ({ event, context, }: CreateLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
11
+ export declare type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends APIGatewayEvent> = ({
12
+ router: TRouter;
13
+ batching?: {
14
+ enabled: boolean;
15
+ };
16
+ onError?: (options: Record<string, unknown>) => void;
17
+ responseMeta?: ResponseMetaFn<TRouter>;
18
+ } & ({
19
+ /**
20
+ * @link https://trpc.io/docs/context
21
+ **/
22
+ createContext: LambdaCreateContextFn<TRouter, TEvent>;
23
+ } | {
24
+ /**
25
+ * @link https://trpc.io/docs/context
26
+ **/
27
+ createContext?: LambdaCreateContextFn<TRouter, TEvent>;
28
+ }));
29
+ export declare function isPayloadV1(event: APIGatewayEvent): event is APIGatewayProxyEvent;
30
+ export declare function isPayloadV2(event: APIGatewayEvent): event is APIGatewayProxyEventV2;
31
+ export declare type DefinedAPIGatewayPayloadFormats = '1.0' | '2.0';
32
+ export declare type APIGatewayPayloadFormatVersion = DefinedAPIGatewayPayloadFormats | 'custom';
33
+ export declare const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE: string;
34
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"../../../../../src/adapters/lamb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,EAAE,MAAM,CAAC,CAAC;CACxD,CACJ,CAAA,CAAC;AAEN,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,GACrB,KAAK,IAAI,oBAAoB,CAE/B;AACD,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,GACrB,KAAK,IAAI,sBAAsB,CAEjC;AAmBD,oBAAY,+BAA+B,GAAG,KAAK,GAAG,KAAK,CAAC;AAC5D,oBAAY,8BAA8B,GACtC,+BAA+B,GAC/B,QAAQ,CAAC;AAEb,eAAO,MAAM,4CAA4C,QAEiD,CAAC"}
@@ -15,7 +15,7 @@ export interface HTTPRequest {
15
15
  headers: HTTPHeaders;
16
16
  body: unknown;
17
17
  }
18
- declare type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
18
+ export declare type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
19
19
  data: TRPCResponse<unknown, inferRouterError<TRouter>>[];
20
20
  ctx?: inferRouterContext<TRouter>;
21
21
  /**
@@ -36,5 +36,4 @@ export interface HTTPBaseHandlerOptions<TRouter extends AnyRouter, TRequest> ext
36
36
  */
37
37
  responseMeta?: ResponseMetaFn<TRouter>;
38
38
  }
39
- export {};
40
39
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/http/internals","sources":["types.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,oBAAY,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,MAAM,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