@trpc/server 11.18.1-canary.2 → 11.18.1-canary.30
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/adapters/aws-lambda/index.cjs +16 -26
- package/dist/adapters/aws-lambda/index.d.cts +6 -16
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +6 -16
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
- package/dist/adapters/aws-lambda/index.mjs +13 -23
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +7 -16
- package/dist/adapters/express.d.cts +4 -11
- package/dist/adapters/express.d.cts.map +1 -1
- package/dist/adapters/express.d.mts +4 -11
- package/dist/adapters/express.d.mts.map +1 -1
- package/dist/adapters/express.mjs +6 -15
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify/index.cjs +11 -24
- package/dist/adapters/fastify/index.d.cts +7 -14
- package/dist/adapters/fastify/index.d.cts.map +1 -1
- package/dist/adapters/fastify/index.d.mts +7 -14
- package/dist/adapters/fastify/index.d.mts.map +1 -1
- package/dist/adapters/fastify/index.mjs +10 -23
- package/dist/adapters/fastify/index.mjs.map +1 -1
- package/dist/adapters/fetch/index.cjs +7 -12
- package/dist/adapters/fetch/index.d.cts +7 -15
- package/dist/adapters/fetch/index.d.cts.map +1 -1
- package/dist/adapters/fetch/index.d.mts +7 -15
- package/dist/adapters/fetch/index.d.mts.map +1 -1
- package/dist/adapters/fetch/index.mjs +6 -11
- package/dist/adapters/fetch/index.mjs.map +1 -1
- package/dist/adapters/next-app-dir.cjs +13 -3145
- package/dist/adapters/next-app-dir.d.cts +3 -12
- package/dist/adapters/next-app-dir.d.cts.map +1 -1
- package/dist/adapters/next-app-dir.d.mts +3 -12
- package/dist/adapters/next-app-dir.d.mts.map +1 -1
- package/dist/adapters/next-app-dir.mjs +31 -3165
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +8 -16
- package/dist/adapters/next.d.cts +5 -15
- package/dist/adapters/next.d.cts.map +1 -1
- package/dist/adapters/next.d.mts +5 -15
- package/dist/adapters/next.d.mts.map +1 -1
- package/dist/adapters/next.mjs +7 -15
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/adapters/node-http/index.cjs +3 -12
- package/dist/adapters/node-http/index.d.cts +1 -4
- package/dist/adapters/node-http/index.d.mts +1 -4
- package/dist/adapters/node-http/index.mjs +2 -12
- package/dist/adapters/standalone.cjs +21 -21
- package/dist/adapters/standalone.d.cts +9 -14
- package/dist/adapters/standalone.d.cts.map +1 -1
- package/dist/adapters/standalone.d.mts +9 -14
- package/dist/adapters/standalone.d.mts.map +1 -1
- package/dist/adapters/standalone.mjs +17 -19
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +3 -15
- package/dist/adapters/ws.d.cts +12 -17
- package/dist/adapters/ws.d.cts.map +1 -1
- package/dist/adapters/ws.d.mts +12 -17
- package/dist/adapters/ws.d.mts.map +1 -1
- package/dist/adapters/ws.mjs +2 -15
- package/dist/{codes-BfZsPdy-.cjs → codes-C6ZIq69A.cjs} +78 -74
- package/dist/{codes-DagpWZLc.mjs → codes-D5Ya6_Bi.mjs} +10 -4
- package/dist/codes-D5Ya6_Bi.mjs.map +1 -0
- package/dist/{contentTypeParsers-iAFF_pJG.cjs → contentTypeParsers-DUzXRHT1.cjs} +6 -8
- package/dist/{contentTypeParsers-SN4WL9ze.mjs → contentTypeParsers-KFMy_fwz.mjs} +3 -3
- package/dist/contentTypeParsers-KFMy_fwz.mjs.map +1 -0
- package/dist/getErrorShape-B0JBUs-i.mjs +209 -0
- package/dist/getErrorShape-B0JBUs-i.mjs.map +1 -0
- package/dist/getErrorShape-DeIapApr.cjs +272 -0
- package/dist/http.cjs +5 -9
- package/dist/http.d.cts +2 -3
- package/dist/http.d.mts +2 -3
- package/dist/http.mjs +4 -9
- package/dist/{index.d-DhhodpGb.d.mts → index-BHatz_Pu.d.cts} +3 -8
- package/dist/index-BHatz_Pu.d.cts.map +1 -0
- package/dist/{index.d-BiUz7kM_.d.cts → index-BMimGNYb.d.cts} +2 -5
- package/dist/index-BMimGNYb.d.cts.map +1 -0
- package/dist/{index.d-D4qZxQJh.d.mts → index-BMimGNYb.d.mts} +2 -5
- package/dist/index-BMimGNYb.d.mts.map +1 -0
- package/dist/{index.d-fBAdSX6g.d.cts → index-_jAhoJQ7.d.mts} +3 -8
- package/dist/index-_jAhoJQ7.d.mts.map +1 -0
- package/dist/index.cjs +5 -6
- package/dist/index.d.cts +10 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +10 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -6
- package/dist/{initTRPC-BRf4imah.mjs → initTRPC-B259os3T.mjs} +85 -83
- package/dist/initTRPC-B259os3T.mjs.map +1 -0
- package/dist/{initTRPC-_cqIfGlH.cjs → initTRPC-B7UdX-c3.cjs} +133 -132
- package/dist/{node-http-gyWQuCv2.mjs → node-http-BUlb5EdB.mjs} +29 -26
- package/dist/node-http-BUlb5EdB.mjs.map +1 -0
- package/dist/{node-http-bPWQbKlA.cjs → node-http-CikCqjt6.cjs} +48 -46
- package/dist/observable/index.cjs +4 -4
- package/dist/observable/index.d.cts +2 -2
- package/dist/observable/index.d.mts +2 -2
- package/dist/observable/index.mjs +3 -4
- package/dist/{observable-B1Nk6r1H.cjs → observable-CIyO2eSm.cjs} +28 -32
- package/dist/{observable-CUiPknO-.mjs → observable-CSprJVOf.mjs} +6 -10
- package/dist/observable-CSprJVOf.mjs.map +1 -0
- package/dist/{observable-BVzLuBs6.cjs → observable-D8mqXlHG.cjs} +34 -39
- package/dist/{observable-UMO3vUa_.mjs → observable-DwUFSuKv.mjs} +10 -12
- package/dist/observable-DwUFSuKv.mjs.map +1 -0
- package/dist/{parseTRPCMessage-7Ltmq-Fb.cjs → parseTRPCMessage-BxAIUx49.cjs} +14 -18
- package/dist/{parseTRPCMessage-CTow-umk.mjs → parseTRPCMessage-MJWDg1vX.mjs} +6 -9
- package/dist/parseTRPCMessage-MJWDg1vX.mjs.map +1 -0
- package/dist/{resolveResponse-BCkjJQIz.cjs → resolveResponse-DLpzHrPG.cjs} +507 -585
- package/dist/{resolveResponse-CdASWfAV.mjs → resolveResponse-JtMyT9TQ.mjs} +414 -491
- package/dist/resolveResponse-JtMyT9TQ.mjs.map +1 -0
- package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
- package/dist/rpc.cjs +4 -4
- package/dist/rpc.d.cts +2 -3
- package/dist/rpc.d.mts +2 -3
- package/dist/rpc.mjs +3 -4
- package/dist/shared.cjs +3 -4
- package/dist/shared.d.cts +2 -4
- package/dist/shared.d.mts +2 -4
- package/dist/shared.mjs +2 -4
- package/dist/{tracked-DFxm8M2u.cjs → tracked-BQJb0ANk.cjs} +125 -142
- package/dist/{tracked-DWInO6EQ.mjs → tracked-D4jU_Hb3.mjs} +42 -58
- package/dist/tracked-D4jU_Hb3.mjs.map +1 -0
- package/dist/{unstable-core-do-not-import.d-BdVSvUCr.d.mts → unstable-core-do-not-import-B9ZnrQAU.d.cts} +37 -69
- package/dist/unstable-core-do-not-import-B9ZnrQAU.d.cts.map +1 -0
- package/dist/{unstable-core-do-not-import.d-Dh9CT5RO.d.cts → unstable-core-do-not-import-BK_OKrtM.d.mts} +37 -69
- package/dist/unstable-core-do-not-import-BK_OKrtM.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.cjs +33 -12
- package/dist/unstable-core-do-not-import.d.cts +2 -3
- package/dist/unstable-core-do-not-import.d.mts +2 -3
- package/dist/unstable-core-do-not-import.mjs +32 -10
- package/dist/unstable-core-do-not-import.mjs.map +1 -0
- package/dist/{ws-CTzlBSdd.cjs → ws-BMSSVFiW.cjs} +59 -65
- package/dist/{ws-BoiCYrkt.mjs → ws-C7ZOJJeA.mjs} +41 -46
- package/dist/ws-C7ZOJJeA.mjs.map +1 -0
- package/package.json +12 -12
- package/src/@trpc/server/index.ts +4 -0
- package/src/adapters/aws-lambda/getPlanner.ts +1 -2
- package/src/adapters/aws-lambda/index.ts +1 -2
- package/src/adapters/ws.ts +3 -2
- package/src/adapters/wsEncoder.ts +1 -1
- package/src/observable/behaviorSubject.ts +4 -2
- package/src/observable/types.ts +4 -2
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +1 -4
- package/src/unstable-core-do-not-import/http/contentType.ts +1 -1
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +4 -9
- package/src/unstable-core-do-not-import/http/types.ts +8 -4
- package/src/unstable-core-do-not-import/initTRPC.ts +10 -10
- package/src/unstable-core-do-not-import/middleware.ts +3 -2
- package/src/unstable-core-do-not-import/procedure.ts +11 -11
- package/src/unstable-core-do-not-import/router.ts +4 -5
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +33 -34
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +2 -3
- package/src/unstable-core-do-not-import/stream/jsonl.ts +1 -2
- package/src/unstable-core-do-not-import/stream/sse.ts +18 -12
- package/src/unstable-core-do-not-import/stream/utils/disposable.ts +2 -2
- package/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts +5 -2
- package/src/unstable-core-do-not-import/stream/utils/withPing.ts +1 -3
- package/src/unstable-core-do-not-import/transformer.ts +1 -4
- package/src/unstable-core-do-not-import/types.ts +9 -10
- package/dist/codes-DagpWZLc.mjs.map +0 -1
- package/dist/contentTypeParsers-SN4WL9ze.mjs.map +0 -1
- package/dist/getErrorShape-BPSzUA7W.mjs +0 -269
- package/dist/getErrorShape-BPSzUA7W.mjs.map +0 -1
- package/dist/getErrorShape-Ed1OwssN.cjs +0 -345
- package/dist/http-CWyjOa1l.mjs +0 -0
- package/dist/http-DXy3XyhL.cjs +0 -0
- package/dist/index.d-BiUz7kM_.d.cts.map +0 -1
- package/dist/index.d-CvZXeEyR.d.cts +0 -11
- package/dist/index.d-CvZXeEyR.d.cts.map +0 -1
- package/dist/index.d-D4qZxQJh.d.mts.map +0 -1
- package/dist/index.d-DhhodpGb.d.mts.map +0 -1
- package/dist/index.d-fBAdSX6g.d.cts.map +0 -1
- package/dist/index.d-vq_QHko2.d.mts +0 -11
- package/dist/index.d-vq_QHko2.d.mts.map +0 -1
- package/dist/initTRPC-BRf4imah.mjs.map +0 -1
- package/dist/node-http-gyWQuCv2.mjs.map +0 -1
- package/dist/observable-CUiPknO-.mjs.map +0 -1
- package/dist/observable-UMO3vUa_.mjs.map +0 -1
- package/dist/parseTRPCMessage-CTow-umk.mjs.map +0 -1
- package/dist/resolveResponse-CdASWfAV.mjs.map +0 -1
- package/dist/tracked-DWInO6EQ.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-9NNw8uQM.mjs +0 -31
- package/dist/unstable-core-do-not-import-9NNw8uQM.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-fsjhEhgh.cjs +0 -35
- package/dist/unstable-core-do-not-import.d-BdVSvUCr.d.mts.map +0 -1
- package/dist/unstable-core-do-not-import.d-Dh9CT5RO.d.cts.map +0 -1
- package/dist/ws-BoiCYrkt.mjs.map +0 -1
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
require(
|
|
4
|
-
|
|
5
|
-
require(
|
|
6
|
-
const node_stream = require_getErrorShape.__toESM(require("node:stream"));
|
|
7
|
-
const node_stream_promises = require_getErrorShape.__toESM(require("node:stream/promises"));
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_getErrorShape = require("../../getErrorShape-DeIapApr.cjs");
|
|
3
|
+
const require_resolveResponse = require("../../resolveResponse-DLpzHrPG.cjs");
|
|
4
|
+
let node_stream = require("node:stream");
|
|
5
|
+
let node_stream_promises = require("node:stream/promises");
|
|
9
6
|
//#region src/vendor/cookie-es/set-cookie/split.ts
|
|
10
7
|
/**
|
|
11
8
|
* Based on https://github.com/unjs/cookie-es/tree/v1.2.2
|
|
@@ -64,10 +61,8 @@ function splitSetCookieString(cookiesString) {
|
|
|
64
61
|
}
|
|
65
62
|
return cookiesStrings;
|
|
66
63
|
}
|
|
67
|
-
|
|
68
64
|
//#endregion
|
|
69
65
|
//#region src/adapters/aws-lambda/getPlanner.ts
|
|
70
|
-
var import_objectSpread2$1 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
|
|
71
66
|
function determinePayloadFormat(event) {
|
|
72
67
|
const unknownEvent = event;
|
|
73
68
|
if (typeof unknownEvent.version === "undefined") return "1.0";
|
|
@@ -88,7 +83,7 @@ const v1Processor = {
|
|
|
88
83
|
var _event$path$split$pop;
|
|
89
84
|
return (_event$path$split$pop = event.path.split("/").pop()) !== null && _event$path$split$pop !== void 0 ? _event$path$split$pop : "";
|
|
90
85
|
}
|
|
91
|
-
const matches = event.resource.matchAll(
|
|
86
|
+
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
92
87
|
for (const match of matches) {
|
|
93
88
|
const group = match[1];
|
|
94
89
|
if (group.includes("+") && event.pathParameters) {
|
|
@@ -120,12 +115,11 @@ const v1Processor = {
|
|
|
120
115
|
getMethod: (event) => event.httpMethod,
|
|
121
116
|
toResult: async (response) => {
|
|
122
117
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
123
|
-
|
|
118
|
+
return require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, cookies.length && { multiValueHeaders: { "set-cookie": cookies } }), {}, {
|
|
124
119
|
statusCode: response.status,
|
|
125
120
|
body: await response.text(),
|
|
126
121
|
headers
|
|
127
122
|
});
|
|
128
|
-
return result;
|
|
129
123
|
},
|
|
130
124
|
toStream: async (response, stream) => {
|
|
131
125
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
@@ -141,7 +135,7 @@ const v1Processor = {
|
|
|
141
135
|
};
|
|
142
136
|
const v2Processor = {
|
|
143
137
|
getTRPCPath: (event) => {
|
|
144
|
-
const matches = event.routeKey.matchAll(
|
|
138
|
+
const matches = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
145
139
|
for (const match of matches) {
|
|
146
140
|
const group = match[1];
|
|
147
141
|
if (group.includes("+") && event.pathParameters) {
|
|
@@ -168,13 +162,12 @@ const v2Processor = {
|
|
|
168
162
|
getMethod: (event) => event.requestContext.http.method,
|
|
169
163
|
toResult: async (response) => {
|
|
170
164
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
171
|
-
|
|
165
|
+
return {
|
|
172
166
|
cookies,
|
|
173
167
|
statusCode: response.status,
|
|
174
168
|
body: await response.text(),
|
|
175
169
|
headers
|
|
176
170
|
};
|
|
177
|
-
return result;
|
|
178
171
|
},
|
|
179
172
|
toStream: async (response, stream) => {
|
|
180
173
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
@@ -216,28 +209,26 @@ function getPlanner(event) {
|
|
|
216
209
|
toStream: processor.toStream
|
|
217
210
|
};
|
|
218
211
|
}
|
|
219
|
-
|
|
220
212
|
//#endregion
|
|
221
213
|
//#region src/adapters/aws-lambda/index.ts
|
|
222
|
-
var import_objectSpread2 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
|
|
223
214
|
function awsLambdaRequestHandler(opts) {
|
|
224
215
|
return async (event, context) => {
|
|
225
216
|
const planner = getPlanner(event);
|
|
226
217
|
const createContext = async (innerOpts) => {
|
|
227
218
|
var _opts$createContext;
|
|
228
|
-
return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts,
|
|
219
|
+
return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, require_getErrorShape._objectSpread2({
|
|
229
220
|
event,
|
|
230
221
|
context
|
|
231
222
|
}, innerOpts)));
|
|
232
223
|
};
|
|
233
|
-
const response = await require_resolveResponse.resolveResponse(
|
|
224
|
+
const response = await require_resolveResponse.resolveResponse(require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, opts), {}, {
|
|
234
225
|
createContext,
|
|
235
226
|
req: planner.request,
|
|
236
227
|
path: planner.path,
|
|
237
228
|
error: null,
|
|
238
229
|
onError(o) {
|
|
239
230
|
var _opts$onError;
|
|
240
|
-
opts === null || opts === void 0 || (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts,
|
|
231
|
+
opts === null || opts === void 0 || (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, o), {}, { req: event }));
|
|
241
232
|
}
|
|
242
233
|
}));
|
|
243
234
|
return await planner.toResult(response);
|
|
@@ -248,25 +239,24 @@ function awsLambdaStreamingRequestHandler(opts) {
|
|
|
248
239
|
const planner = getPlanner(event);
|
|
249
240
|
const createContext = async (innerOpts) => {
|
|
250
241
|
var _opts$createContext2;
|
|
251
|
-
return await ((_opts$createContext2 = opts.createContext) === null || _opts$createContext2 === void 0 ? void 0 : _opts$createContext2.call(opts,
|
|
242
|
+
return await ((_opts$createContext2 = opts.createContext) === null || _opts$createContext2 === void 0 ? void 0 : _opts$createContext2.call(opts, require_getErrorShape._objectSpread2({
|
|
252
243
|
event,
|
|
253
244
|
context
|
|
254
245
|
}, innerOpts)));
|
|
255
246
|
};
|
|
256
|
-
const response = await require_resolveResponse.resolveResponse(
|
|
247
|
+
const response = await require_resolveResponse.resolveResponse(require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, opts), {}, {
|
|
257
248
|
createContext,
|
|
258
249
|
req: planner.request,
|
|
259
250
|
path: planner.path,
|
|
260
251
|
error: null,
|
|
261
252
|
onError(o) {
|
|
262
253
|
var _opts$onError2;
|
|
263
|
-
opts === null || opts === void 0 || (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts,
|
|
254
|
+
opts === null || opts === void 0 || (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, o), {}, { req: event }));
|
|
264
255
|
}
|
|
265
256
|
}));
|
|
266
257
|
await planner.toStream(response, responseStream);
|
|
267
258
|
};
|
|
268
259
|
}
|
|
269
|
-
|
|
270
260
|
//#endregion
|
|
271
261
|
exports.awsLambdaRequestHandler = awsLambdaRequestHandler;
|
|
272
|
-
exports.awsLambdaStreamingRequestHandler = awsLambdaStreamingRequestHandler;
|
|
262
|
+
exports.awsLambdaStreamingRequestHandler = awsLambdaStreamingRequestHandler;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import { AnyRouter, CreateContextCallback, HTTPBaseHandlerOptions, TRPCRequestInfo, inferRouterContext } from "../../unstable-core-do-not-import.d-Dh9CT5RO.cjs";
|
|
3
|
-
import "../../index.d-CvZXeEyR.cjs";
|
|
1
|
+
import { Cn as TRPCRequestInfo, J as AnyRouter, _n as HTTPBaseHandlerOptions, ft as inferRouterContext, yt as CreateContextCallback } from "../../unstable-core-do-not-import-B9ZnrQAU.cjs";
|
|
4
2
|
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context, StreamifyHandler } from "aws-lambda";
|
|
5
|
-
|
|
6
3
|
//#region src/adapters/aws-lambda/getPlanner.d.ts
|
|
7
4
|
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
8
5
|
/** 1:1 mapping of v1 or v2 input events, deduces which is which.
|
|
@@ -11,21 +8,14 @@ type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
|
11
8
|
type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent ? APIGatewayProxyResult : TEvent extends APIGatewayProxyEventV2 ? APIGatewayProxyStructuredResultV2 : never;
|
|
12
9
|
//#endregion
|
|
13
10
|
//#region src/adapters/aws-lambda/index.d.ts
|
|
14
|
-
type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {
|
|
11
|
+
export type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {
|
|
15
12
|
event: TEvent;
|
|
16
13
|
context: Context;
|
|
17
14
|
info: TRPCRequestInfo;
|
|
18
15
|
};
|
|
19
|
-
type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends LambdaEvent> = HTTPBaseHandlerOptions<TRouter, TEvent> & CreateContextCallback<inferRouterContext<AnyRouter>, AWSLambdaCreateContextFn<TRouter, TEvent>>;
|
|
20
|
-
type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends LambdaEvent> = ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
info
|
|
24
|
-
}: CreateAWSLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
|
|
25
|
-
declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: Context) => Promise<inferAPIGWReturn<TEvent>>;
|
|
26
|
-
declare function awsLambdaStreamingRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent>;
|
|
27
|
-
//# sourceMappingURL=index.d.ts.map
|
|
28
|
-
|
|
16
|
+
export type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends LambdaEvent> = HTTPBaseHandlerOptions<TRouter, TEvent> & CreateContextCallback<inferRouterContext<AnyRouter>, AWSLambdaCreateContextFn<TRouter, TEvent>>;
|
|
17
|
+
export type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends LambdaEvent> = ({ event, context, info }: CreateAWSLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
|
|
18
|
+
export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: Context) => Promise<inferAPIGWReturn<TEvent>>;
|
|
19
|
+
export declare function awsLambdaStreamingRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent>;
|
|
29
20
|
//#endregion
|
|
30
|
-
export { AWSLambdaCreateContextFn, AWSLambdaOptions, CreateAWSLambdaContextOptions, awsLambdaRequestHandler, awsLambdaStreamingRequestHandler };
|
|
31
21
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"mappings":";;;KAUY,cAAc,uBAAuB;;;;KAoBrC,iBAAiB,UAAU,eAAe,uBAClD,wBACA,eAAe,yBACb;;;YCPM,8BAA8B,eAAe;EACvD,OAAO;EACP,SAAS;EACT,MAAM;;YAGI,iBACV,gBAAgB,WAChB,eAAe,eACb,uBAAuB,SAAS,UAClC,sBACE,mBAAmB,YACnB,yBAAyB,SAAS;YAG1B,yBACV,gBAAgB,WAChB,eAAe,kBAEf,OACA,SACA,QACC,8BAA8B,YAC/B,mBAAmB,WAAW,QAAQ,mBAAmB;wBAE3C,wBACd,gBAAgB,WAChB,eAAe,aAEf,MAAM,iBAAiB,SAAS,WAC9B,OAAO,QAAQ,SAAS,YAAiB,QAAQ,iBAAiB;wBA4BtD,iCACd,gBAAgB,WAChB,eAAe,aACf,MAAM,iBAAiB,SAAS,UAAU,iBAAiB"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import { AnyRouter, CreateContextCallback, HTTPBaseHandlerOptions, TRPCRequestInfo, inferRouterContext } from "../../unstable-core-do-not-import.d-BdVSvUCr.mjs";
|
|
3
|
-
import "../../index.d-vq_QHko2.mjs";
|
|
1
|
+
import { Cn as TRPCRequestInfo, J as AnyRouter, _n as HTTPBaseHandlerOptions, ft as inferRouterContext, yt as CreateContextCallback } from "../../unstable-core-do-not-import-BK_OKrtM.mjs";
|
|
4
2
|
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context, StreamifyHandler } from "aws-lambda";
|
|
5
|
-
|
|
6
3
|
//#region src/adapters/aws-lambda/getPlanner.d.ts
|
|
7
4
|
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
8
5
|
/** 1:1 mapping of v1 or v2 input events, deduces which is which.
|
|
@@ -11,21 +8,14 @@ type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
|
11
8
|
type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent ? APIGatewayProxyResult : TEvent extends APIGatewayProxyEventV2 ? APIGatewayProxyStructuredResultV2 : never;
|
|
12
9
|
//#endregion
|
|
13
10
|
//#region src/adapters/aws-lambda/index.d.ts
|
|
14
|
-
type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {
|
|
11
|
+
export type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {
|
|
15
12
|
event: TEvent;
|
|
16
13
|
context: Context;
|
|
17
14
|
info: TRPCRequestInfo;
|
|
18
15
|
};
|
|
19
|
-
type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends LambdaEvent> = HTTPBaseHandlerOptions<TRouter, TEvent> & CreateContextCallback<inferRouterContext<AnyRouter>, AWSLambdaCreateContextFn<TRouter, TEvent>>;
|
|
20
|
-
type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends LambdaEvent> = ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
info
|
|
24
|
-
}: CreateAWSLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
|
|
25
|
-
declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: Context) => Promise<inferAPIGWReturn<TEvent>>;
|
|
26
|
-
declare function awsLambdaStreamingRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent>;
|
|
27
|
-
//# sourceMappingURL=index.d.ts.map
|
|
28
|
-
|
|
16
|
+
export type AWSLambdaOptions<TRouter extends AnyRouter, TEvent extends LambdaEvent> = HTTPBaseHandlerOptions<TRouter, TEvent> & CreateContextCallback<inferRouterContext<AnyRouter>, AWSLambdaCreateContextFn<TRouter, TEvent>>;
|
|
17
|
+
export type AWSLambdaCreateContextFn<TRouter extends AnyRouter, TEvent extends LambdaEvent> = ({ event, context, info }: CreateAWSLambdaContextOptions<TEvent>) => inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;
|
|
18
|
+
export declare function awsLambdaRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): (event: TEvent, context: Context) => Promise<inferAPIGWReturn<TEvent>>;
|
|
19
|
+
export declare function awsLambdaStreamingRequestHandler<TRouter extends AnyRouter, TEvent extends LambdaEvent>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent>;
|
|
29
20
|
//#endregion
|
|
30
|
-
export { AWSLambdaCreateContextFn, AWSLambdaOptions, CreateAWSLambdaContextOptions, awsLambdaRequestHandler, awsLambdaStreamingRequestHandler };
|
|
31
21
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"mappings":";;;KAUY,cAAc,uBAAuB;;;;KAoBrC,iBAAiB,UAAU,eAAe,uBAClD,wBACA,eAAe,yBACb;;;YCPM,8BAA8B,eAAe;EACvD,OAAO;EACP,SAAS;EACT,MAAM;;YAGI,iBACV,gBAAgB,WAChB,eAAe,eACb,uBAAuB,SAAS,UAClC,sBACE,mBAAmB,YACnB,yBAAyB,SAAS;YAG1B,yBACV,gBAAgB,WAChB,eAAe,kBAEf,OACA,SACA,QACC,8BAA8B,YAC/B,mBAAmB,WAAW,QAAQ,mBAAmB;wBAE3C,wBACd,gBAAgB,WAChB,eAAe,aAEf,MAAM,iBAAiB,SAAS,WAC9B,OAAO,QAAQ,SAAS,YAAiB,QAAQ,iBAAiB;wBA4BtD,iCACd,gBAAgB,WAChB,eAAe,aACf,MAAM,iBAAiB,SAAS,UAAU,iBAAiB"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../
|
|
3
|
-
import "../../tracked-DWInO6EQ.mjs";
|
|
4
|
-
import { resolveResponse } from "../../resolveResponse-CdASWfAV.mjs";
|
|
5
|
-
import "../../observable-UMO3vUa_.mjs";
|
|
1
|
+
import { n as _objectSpread2 } from "../../getErrorShape-B0JBUs-i.mjs";
|
|
2
|
+
import { t as resolveResponse } from "../../resolveResponse-JtMyT9TQ.mjs";
|
|
6
3
|
import { Readable } from "node:stream";
|
|
7
4
|
import { pipeline } from "node:stream/promises";
|
|
8
|
-
|
|
9
5
|
//#region src/vendor/cookie-es/set-cookie/split.ts
|
|
10
6
|
/**
|
|
11
7
|
* Based on https://github.com/unjs/cookie-es/tree/v1.2.2
|
|
@@ -64,10 +60,8 @@ function splitSetCookieString(cookiesString) {
|
|
|
64
60
|
}
|
|
65
61
|
return cookiesStrings;
|
|
66
62
|
}
|
|
67
|
-
|
|
68
63
|
//#endregion
|
|
69
64
|
//#region src/adapters/aws-lambda/getPlanner.ts
|
|
70
|
-
var import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
|
|
71
65
|
function determinePayloadFormat(event) {
|
|
72
66
|
const unknownEvent = event;
|
|
73
67
|
if (typeof unknownEvent.version === "undefined") return "1.0";
|
|
@@ -88,7 +82,7 @@ const v1Processor = {
|
|
|
88
82
|
var _event$path$split$pop;
|
|
89
83
|
return (_event$path$split$pop = event.path.split("/").pop()) !== null && _event$path$split$pop !== void 0 ? _event$path$split$pop : "";
|
|
90
84
|
}
|
|
91
|
-
const matches = event.resource.matchAll(
|
|
85
|
+
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
92
86
|
for (const match of matches) {
|
|
93
87
|
const group = match[1];
|
|
94
88
|
if (group.includes("+") && event.pathParameters) {
|
|
@@ -120,12 +114,11 @@ const v1Processor = {
|
|
|
120
114
|
getMethod: (event) => event.httpMethod,
|
|
121
115
|
toResult: async (response) => {
|
|
122
116
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
123
|
-
|
|
117
|
+
return _objectSpread2(_objectSpread2({}, cookies.length && { multiValueHeaders: { "set-cookie": cookies } }), {}, {
|
|
124
118
|
statusCode: response.status,
|
|
125
119
|
body: await response.text(),
|
|
126
120
|
headers
|
|
127
121
|
});
|
|
128
|
-
return result;
|
|
129
122
|
},
|
|
130
123
|
toStream: async (response, stream) => {
|
|
131
124
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
@@ -141,7 +134,7 @@ const v1Processor = {
|
|
|
141
134
|
};
|
|
142
135
|
const v2Processor = {
|
|
143
136
|
getTRPCPath: (event) => {
|
|
144
|
-
const matches = event.routeKey.matchAll(
|
|
137
|
+
const matches = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
145
138
|
for (const match of matches) {
|
|
146
139
|
const group = match[1];
|
|
147
140
|
if (group.includes("+") && event.pathParameters) {
|
|
@@ -168,13 +161,12 @@ const v2Processor = {
|
|
|
168
161
|
getMethod: (event) => event.requestContext.http.method,
|
|
169
162
|
toResult: async (response) => {
|
|
170
163
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
171
|
-
|
|
164
|
+
return {
|
|
172
165
|
cookies,
|
|
173
166
|
statusCode: response.status,
|
|
174
167
|
body: await response.text(),
|
|
175
168
|
headers
|
|
176
169
|
};
|
|
177
|
-
return result;
|
|
178
170
|
},
|
|
179
171
|
toStream: async (response, stream) => {
|
|
180
172
|
const { headers, cookies } = getHeadersAndCookiesFromResponse(response);
|
|
@@ -216,28 +208,26 @@ function getPlanner(event) {
|
|
|
216
208
|
toStream: processor.toStream
|
|
217
209
|
};
|
|
218
210
|
}
|
|
219
|
-
|
|
220
211
|
//#endregion
|
|
221
212
|
//#region src/adapters/aws-lambda/index.ts
|
|
222
|
-
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
223
213
|
function awsLambdaRequestHandler(opts) {
|
|
224
214
|
return async (event, context) => {
|
|
225
215
|
const planner = getPlanner(event);
|
|
226
216
|
const createContext = async (innerOpts) => {
|
|
227
217
|
var _opts$createContext;
|
|
228
|
-
return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, (
|
|
218
|
+
return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, _objectSpread2({
|
|
229
219
|
event,
|
|
230
220
|
context
|
|
231
221
|
}, innerOpts)));
|
|
232
222
|
};
|
|
233
|
-
const response = await resolveResponse((
|
|
223
|
+
const response = await resolveResponse(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
234
224
|
createContext,
|
|
235
225
|
req: planner.request,
|
|
236
226
|
path: planner.path,
|
|
237
227
|
error: null,
|
|
238
228
|
onError(o) {
|
|
239
229
|
var _opts$onError;
|
|
240
|
-
opts === null || opts === void 0 || (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, (
|
|
230
|
+
opts === null || opts === void 0 || (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, _objectSpread2(_objectSpread2({}, o), {}, { req: event }));
|
|
241
231
|
}
|
|
242
232
|
}));
|
|
243
233
|
return await planner.toResult(response);
|
|
@@ -248,25 +238,25 @@ function awsLambdaStreamingRequestHandler(opts) {
|
|
|
248
238
|
const planner = getPlanner(event);
|
|
249
239
|
const createContext = async (innerOpts) => {
|
|
250
240
|
var _opts$createContext2;
|
|
251
|
-
return await ((_opts$createContext2 = opts.createContext) === null || _opts$createContext2 === void 0 ? void 0 : _opts$createContext2.call(opts, (
|
|
241
|
+
return await ((_opts$createContext2 = opts.createContext) === null || _opts$createContext2 === void 0 ? void 0 : _opts$createContext2.call(opts, _objectSpread2({
|
|
252
242
|
event,
|
|
253
243
|
context
|
|
254
244
|
}, innerOpts)));
|
|
255
245
|
};
|
|
256
|
-
const response = await resolveResponse((
|
|
246
|
+
const response = await resolveResponse(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
257
247
|
createContext,
|
|
258
248
|
req: planner.request,
|
|
259
249
|
path: planner.path,
|
|
260
250
|
error: null,
|
|
261
251
|
onError(o) {
|
|
262
252
|
var _opts$onError2;
|
|
263
|
-
opts === null || opts === void 0 || (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, (
|
|
253
|
+
opts === null || opts === void 0 || (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, _objectSpread2(_objectSpread2({}, o), {}, { req: event }));
|
|
264
254
|
}
|
|
265
255
|
}));
|
|
266
256
|
await planner.toStream(response, responseStream);
|
|
267
257
|
};
|
|
268
258
|
}
|
|
269
|
-
|
|
270
259
|
//#endregion
|
|
271
260
|
export { awsLambdaRequestHandler, awsLambdaStreamingRequestHandler };
|
|
261
|
+
|
|
272
262
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["cookiesString: string | string[]","cookiesStrings: string[]","pos: number","start: number","ch: string","lastComma: number","nextStart: number","cookiesSeparatorFound: boolean","event: LambdaEvent","response: Response","cookies: string[]","v1Processor: Processor<APIGatewayProxyEvent>","hostname: string","result: APIGatewayProxyResult","v2Processor: Processor<APIGatewayProxyEventV2>","result: APIGatewayProxyStructuredResultV2","event: TEvent","processor: Processor<TEvent>","init: RequestInit","opts: AWSLambdaOptions<TRouter, TEvent>","createContext: ResolveHTTPRequestOptionsContextFn<TRouter>"],"sources":["../../../src/vendor/cookie-es/set-cookie/split.ts","../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"sourcesContent":["/**\n * Based on https://github.com/unjs/cookie-es/tree/v1.2.2\n * MIT License\n * \n * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>\n * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser\n * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)\n * \n * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts\n */\n\n/**\n * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas\n * that are within a single set-cookie field-value, such as in the Expires portion.\n *\n * See https://tools.ietf.org/html/rfc2616#section-4.2\n */\nexport function splitSetCookieString(\n cookiesString: string | string[],\n ): string[] {\n if (Array.isArray(cookiesString)) {\n return cookiesString.flatMap((c) => splitSetCookieString(c));\n }\n \n if (typeof cookiesString !== \"string\") {\n return [];\n }\n \n const cookiesStrings: string[] = [];\n let pos: number = 0;\n let start: number;\n let ch: string;\n let lastComma: number;\n let nextStart: number;\n let cookiesSeparatorFound: boolean;\n \n const skipWhitespace = () => {\n while (pos < cookiesString.length && /\\s/.test(cookiesString.charAt(pos))) {\n pos += 1;\n }\n return pos < cookiesString.length;\n };\n \n const notSpecialChar = () => {\n ch = cookiesString.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n };\n \n while (pos < cookiesString.length) {\n start = pos;\n cookiesSeparatorFound = false;\n \n while (skipWhitespace()) {\n ch = cookiesString.charAt(pos);\n if (ch === \",\") {\n // ',' is a cookie separator if we have later first '=', not ';' or ','\n lastComma = pos;\n pos += 1;\n \n skipWhitespace();\n nextStart = pos;\n \n while (pos < cookiesString.length && notSpecialChar()) {\n pos += 1;\n }\n \n // currently special character\n if (pos < cookiesString.length && cookiesString.charAt(pos) === \"=\") {\n // we found cookies separator\n cookiesSeparatorFound = true;\n // pos is inside the next cookie, so back up and return it.\n pos = nextStart;\n cookiesStrings.push(cookiesString.slice(start, lastComma));\n start = pos;\n } else {\n // in param ',' or param separator ';',\n // we continue from that comma\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n \n if (!cookiesSeparatorFound || pos >= cookiesString.length) {\n cookiesStrings.push(cookiesString.slice(start));\n }\n }\n \n return cookiesStrings;\n }","import { Readable, type Writable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyResult,\n APIGatewayProxyStructuredResultV2,\n} from 'aws-lambda';\nimport { splitSetCookieString } from '../../vendor/cookie-es/set-cookie/split';\n\nexport type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;\n\nexport type APIGatewayResult =\n | APIGatewayProxyResult\n | APIGatewayProxyStructuredResultV2;\n\nfunction determinePayloadFormat(event: LambdaEvent): string {\n // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html\n // According to AWS support, version is is extracted from the version property in the event.\n // If there is no version property, then the version is implied as 1.0\n const unknownEvent = event as { version?: string };\n if (typeof unknownEvent.version === 'undefined') {\n return '1.0';\n } else {\n return unknownEvent.version;\n }\n}\n\n/** 1:1 mapping of v1 or v2 input events, deduces which is which.\n * @internal\n **/\nexport type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent\n ? APIGatewayProxyResult\n : TEvent extends APIGatewayProxyEventV2\n ? APIGatewayProxyStructuredResultV2\n : never;\n\ninterface Processor<TEvent extends LambdaEvent> {\n getTRPCPath: (event: TEvent) => string;\n url(event: TEvent): Pick<URL, 'hostname' | 'pathname' | 'search'>;\n getHeaders: (event: TEvent) => Headers;\n getMethod: (event: TEvent) => string;\n toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;\n toStream: (response: Response, stream: Writable) => Promise<void>;\n}\n\nfunction getHeadersAndCookiesFromResponse(response: Response) {\n const headers = Object.fromEntries(response.headers.entries());\n\n const cookies: string[] = splitSetCookieString(\n response.headers.getSetCookie(),\n ).map((cookie) => cookie.trim());\n\n delete headers['set-cookie'];\n\n return { headers, cookies };\n}\n\nconst v1Processor: Processor<APIGatewayProxyEvent> = {\n // same as getPath above\n getTRPCPath: (event) => {\n if (!event.pathParameters) {\n // Then this event was not triggered by a resource denoted with {proxy+}\n return event.path.split('/').pop() ?? '';\n }\n const matches = event.resource.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.path.slice(1);\n },\n url(event) {\n const hostname: string =\n event.requestContext.domainName ??\n event.headers['host'] ??\n event.multiValueHeaders?.['host']?.[0] ??\n 'localhost';\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(\n event.queryStringParameters ?? {},\n )) {\n if (value !== undefined) {\n searchParams.append(key, value);\n }\n }\n const qs = searchParams.toString();\n return {\n hostname,\n pathname: event.path,\n search: qs && `?${qs}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n\n // Process multiValueHeaders first (takes precedence per AWS docs)\n // This handles headers that can have multiple values\n for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})) {\n if (values) {\n values.forEach((v) => headers.append(k, v));\n }\n }\n\n // Then process single-value headers, but skip any that were already\n // added from multiValueHeaders to avoid duplication\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined && !headers.has(key)) {\n headers.append(key, value);\n }\n }\n\n return headers;\n },\n getMethod: (event) => event.httpMethod,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyResult = {\n ...(cookies.length && { multiValueHeaders: { 'set-cookie': cookies } }),\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nconst v2Processor: Processor<APIGatewayProxyEventV2> = {\n getTRPCPath: (event) => {\n const matches = event.routeKey.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.rawPath.slice(1);\n },\n url(event) {\n return {\n hostname: event.requestContext.domainName,\n pathname: event.rawPath,\n search: event.rawQueryString && `?${event.rawQueryString}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined) {\n headers.append(key, value);\n }\n }\n\n if (event.cookies) {\n headers.append('cookie', event.cookies.join('; '));\n }\n return headers;\n },\n getMethod: (event) => event.requestContext.http.method,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyStructuredResultV2 = {\n cookies,\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nexport function getPlanner<TEvent extends LambdaEvent>(event: TEvent) {\n const version = determinePayloadFormat(event);\n let processor: Processor<TEvent>;\n switch (version) {\n case '1.0':\n processor = v1Processor as Processor<TEvent>;\n break;\n case '2.0':\n processor = v2Processor as Processor<TEvent>;\n break;\n default:\n throw new Error(`Unsupported version: ${version}`);\n }\n\n const urlParts = processor.url(event);\n const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;\n\n const init: RequestInit = {\n headers: processor.getHeaders(event),\n method: processor.getMethod(event),\n // @ts-expect-error this is fine\n duplex: 'half',\n };\n if (event.body) {\n init.body = event.isBase64Encoded\n ? Buffer.from(event.body, 'base64')\n : event.body;\n }\n\n const request = new Request(url, init);\n\n return {\n path: processor.getTRPCPath(event),\n request,\n toResult: processor.toResult,\n toStream: processor.toStream,\n };\n}\n","/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { Context as APIGWContext, StreamifyHandler } from 'aws-lambda';\n// @trpc/server\nimport type {\n AnyRouter,\n CreateContextCallback,\n inferRouterContext,\n} from '../../@trpc/server';\n// @trpc/server\nimport type {\n HTTPBaseHandlerOptions,\n ResolveHTTPRequestOptionsContextFn,\n TRPCRequestInfo,\n} from '../../@trpc/server/http';\nimport { resolveResponse } from '../../@trpc/server/http';\nimport type { inferAPIGWReturn, LambdaEvent } from './getPlanner';\nimport { getPlanner } from './getPlanner';\n\nexport type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {\n event: TEvent;\n context: APIGWContext;\n info: TRPCRequestInfo;\n};\n\nexport type AWSLambdaOptions<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = HTTPBaseHandlerOptions<TRouter, TEvent> &\n CreateContextCallback<\n inferRouterContext<AnyRouter>,\n AWSLambdaCreateContextFn<TRouter, TEvent>\n >;\n\nexport type AWSLambdaCreateContextFn<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = ({\n event,\n context,\n info,\n}: CreateAWSLambdaContextOptions<TEvent>) =>\n | inferRouterContext<TRouter>\n | Promise<inferRouterContext<TRouter>>;\n\nexport function awsLambdaRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(\n opts: AWSLambdaOptions<TRouter, TEvent>,\n): (event: TEvent, context: APIGWContext) => Promise<inferAPIGWReturn<TEvent>> {\n return async (event, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n return await planner.toResult(response);\n };\n}\n\nexport function awsLambdaStreamingRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent> {\n return async (event, responseStream, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n await planner.toStream(response, responseStream);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,qBACZA,eACU;AACV,KAAI,MAAM,QAAQ,cAAc,CAC9B,QAAO,cAAc,QAAQ,CAAC,MAAM,qBAAqB,EAAE,CAAC;AAG9D,YAAW,kBAAkB,SAC3B,QAAO,CAAE;CAGX,MAAMC,iBAA2B,CAAE;CACnC,IAAIC,MAAc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AW,MAAM,wFAClB;GACH;GACA,KAAK,QAAQ;GACb,MAAM,QAAQ;GACd,OAAO;GACP,QAAQ,GAAG;;AACT,8DAAM,iDAAN,iGACK,UACH,KAAK,SACL;GACH;KACD;AAEF,SAAO,MAAM,QAAQ,SAAS,SAAS;CACxC;AACF;AAED,SAAgB,iCAGdD,MAAmE;AACnE,QAAO,OAAO,OAAO,gBAAgB,YAAY;EAC/C,MAAM,UAAU,WAAW,MAAM;EAEjC,MAAMC,gBAA6D,OACjE,cACG;;AACH,UAAO,+BAAM,KAAK,sEAAL;IAAuB;IAAO;MAAY,WAAY;EACpE;EAED,MAAM,WAAW,MAAM,wFAClB;GACH;GACA,KAAK,QAAQ;GACb,MAAM,QAAQ;GACd,OAAO;GACP,QAAQ,GAAG;;AACT,+DAAM,kDAAN,kGACK,UACH,KAAK,SACL;GACH;KACD;AAEF,QAAM,QAAQ,SAAS,UAAU,eAAe;CACjD;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/vendor/cookie-es/set-cookie/split.ts","../../../src/adapters/aws-lambda/getPlanner.ts","../../../src/adapters/aws-lambda/index.ts"],"sourcesContent":["/**\n * Based on https://github.com/unjs/cookie-es/tree/v1.2.2\n * MIT License\n * \n * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>\n * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser\n * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)\n * \n * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts\n */\n\n/**\n * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas\n * that are within a single set-cookie field-value, such as in the Expires portion.\n *\n * See https://tools.ietf.org/html/rfc2616#section-4.2\n */\nexport function splitSetCookieString(\n cookiesString: string | string[],\n ): string[] {\n if (Array.isArray(cookiesString)) {\n return cookiesString.flatMap((c) => splitSetCookieString(c));\n }\n \n if (typeof cookiesString !== \"string\") {\n return [];\n }\n \n const cookiesStrings: string[] = [];\n let pos: number = 0;\n let start: number;\n let ch: string;\n let lastComma: number;\n let nextStart: number;\n let cookiesSeparatorFound: boolean;\n \n const skipWhitespace = () => {\n while (pos < cookiesString.length && /\\s/.test(cookiesString.charAt(pos))) {\n pos += 1;\n }\n return pos < cookiesString.length;\n };\n \n const notSpecialChar = () => {\n ch = cookiesString.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n };\n \n while (pos < cookiesString.length) {\n start = pos;\n cookiesSeparatorFound = false;\n \n while (skipWhitespace()) {\n ch = cookiesString.charAt(pos);\n if (ch === \",\") {\n // ',' is a cookie separator if we have later first '=', not ';' or ','\n lastComma = pos;\n pos += 1;\n \n skipWhitespace();\n nextStart = pos;\n \n while (pos < cookiesString.length && notSpecialChar()) {\n pos += 1;\n }\n \n // currently special character\n if (pos < cookiesString.length && cookiesString.charAt(pos) === \"=\") {\n // we found cookies separator\n cookiesSeparatorFound = true;\n // pos is inside the next cookie, so back up and return it.\n pos = nextStart;\n cookiesStrings.push(cookiesString.slice(start, lastComma));\n start = pos;\n } else {\n // in param ',' or param separator ';',\n // we continue from that comma\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n \n if (!cookiesSeparatorFound || pos >= cookiesString.length) {\n cookiesStrings.push(cookiesString.slice(start));\n }\n }\n \n return cookiesStrings;\n }","import { Readable, type Writable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyResult,\n APIGatewayProxyStructuredResultV2,\n} from 'aws-lambda';\nimport { splitSetCookieString } from '../../vendor/cookie-es/set-cookie/split';\n\nexport type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;\n\nexport type APIGatewayResult =\n APIGatewayProxyResult | APIGatewayProxyStructuredResultV2;\n\nfunction determinePayloadFormat(event: LambdaEvent): string {\n // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html\n // According to AWS support, version is is extracted from the version property in the event.\n // If there is no version property, then the version is implied as 1.0\n const unknownEvent = event as { version?: string };\n if (typeof unknownEvent.version === 'undefined') {\n return '1.0';\n } else {\n return unknownEvent.version;\n }\n}\n\n/** 1:1 mapping of v1 or v2 input events, deduces which is which.\n * @internal\n **/\nexport type inferAPIGWReturn<TEvent> = TEvent extends APIGatewayProxyEvent\n ? APIGatewayProxyResult\n : TEvent extends APIGatewayProxyEventV2\n ? APIGatewayProxyStructuredResultV2\n : never;\n\ninterface Processor<TEvent extends LambdaEvent> {\n getTRPCPath: (event: TEvent) => string;\n url(event: TEvent): Pick<URL, 'hostname' | 'pathname' | 'search'>;\n getHeaders: (event: TEvent) => Headers;\n getMethod: (event: TEvent) => string;\n toResult: (response: Response) => Promise<inferAPIGWReturn<TEvent>>;\n toStream: (response: Response, stream: Writable) => Promise<void>;\n}\n\nfunction getHeadersAndCookiesFromResponse(response: Response) {\n const headers = Object.fromEntries(response.headers.entries());\n\n const cookies: string[] = splitSetCookieString(\n response.headers.getSetCookie(),\n ).map((cookie) => cookie.trim());\n\n delete headers['set-cookie'];\n\n return { headers, cookies };\n}\n\nconst v1Processor: Processor<APIGatewayProxyEvent> = {\n // same as getPath above\n getTRPCPath: (event) => {\n if (!event.pathParameters) {\n // Then this event was not triggered by a resource denoted with {proxy+}\n return event.path.split('/').pop() ?? '';\n }\n const matches = event.resource.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.path.slice(1);\n },\n url(event) {\n const hostname: string =\n event.requestContext.domainName ??\n event.headers['host'] ??\n event.multiValueHeaders?.['host']?.[0] ??\n 'localhost';\n\n const searchParams = new URLSearchParams();\n\n for (const [key, value] of Object.entries(\n event.queryStringParameters ?? {},\n )) {\n if (value !== undefined) {\n searchParams.append(key, value);\n }\n }\n const qs = searchParams.toString();\n return {\n hostname,\n pathname: event.path,\n search: qs && `?${qs}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n\n // Process multiValueHeaders first (takes precedence per AWS docs)\n // This handles headers that can have multiple values\n for (const [k, values] of Object.entries(event.multiValueHeaders ?? {})) {\n if (values) {\n values.forEach((v) => headers.append(k, v));\n }\n }\n\n // Then process single-value headers, but skip any that were already\n // added from multiValueHeaders to avoid duplication\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined && !headers.has(key)) {\n headers.append(key, value);\n }\n }\n\n return headers;\n },\n getMethod: (event) => event.httpMethod,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyResult = {\n ...(cookies.length && { multiValueHeaders: { 'set-cookie': cookies } }),\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nconst v2Processor: Processor<APIGatewayProxyEventV2> = {\n getTRPCPath: (event) => {\n const matches = event.routeKey.matchAll(/\\{(.*?)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const group = match[1]!;\n if (group.includes('+') && event.pathParameters) {\n return event.pathParameters[group.replace('+', '')] ?? '';\n }\n }\n return event.rawPath.slice(1);\n },\n url(event) {\n return {\n hostname: event.requestContext.domainName,\n pathname: event.rawPath,\n search: event.rawQueryString && `?${event.rawQueryString}`,\n };\n },\n getHeaders: (event) => {\n const headers = new Headers();\n for (const [key, value] of Object.entries(event.headers ?? {})) {\n if (value !== undefined) {\n headers.append(key, value);\n }\n }\n\n if (event.cookies) {\n headers.append('cookie', event.cookies.join('; '));\n }\n return headers;\n },\n getMethod: (event) => event.requestContext.http.method,\n toResult: async (response) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const result: APIGatewayProxyStructuredResultV2 = {\n cookies,\n statusCode: response.status,\n body: await response.text(),\n headers,\n };\n\n return result;\n },\n\n toStream: async (response, stream) => {\n const { headers, cookies } = getHeadersAndCookiesFromResponse(response);\n\n const metadata = {\n statusCode: response.status,\n headers,\n cookies,\n };\n\n const responseStream = awslambda.HttpResponseStream.from(stream, metadata);\n\n if (response.body) {\n await pipeline(Readable.fromWeb(response.body as any), responseStream);\n } else {\n responseStream.end();\n }\n },\n};\n\nexport function getPlanner<TEvent extends LambdaEvent>(event: TEvent) {\n const version = determinePayloadFormat(event);\n let processor: Processor<TEvent>;\n switch (version) {\n case '1.0':\n processor = v1Processor as Processor<TEvent>;\n break;\n case '2.0':\n processor = v2Processor as Processor<TEvent>;\n break;\n default:\n throw new Error(`Unsupported version: ${version}`);\n }\n\n const urlParts = processor.url(event);\n const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;\n\n const init: RequestInit = {\n headers: processor.getHeaders(event),\n method: processor.getMethod(event),\n // @ts-expect-error this is fine\n duplex: 'half',\n };\n if (event.body) {\n init.body = event.isBase64Encoded\n ? Buffer.from(event.body, 'base64')\n : event.body;\n }\n\n const request = new Request(url, init);\n\n return {\n path: processor.getTRPCPath(event),\n request,\n toResult: processor.toResult,\n toStream: processor.toStream,\n };\n}\n","/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { Context as APIGWContext, StreamifyHandler } from 'aws-lambda';\n// @trpc/server\nimport type {\n AnyRouter,\n CreateContextCallback,\n inferRouterContext,\n} from '../../@trpc/server';\n// @trpc/server\nimport type {\n HTTPBaseHandlerOptions,\n ResolveHTTPRequestOptionsContextFn,\n TRPCRequestInfo,\n} from '../../@trpc/server/http';\nimport { resolveResponse } from '../../@trpc/server/http';\nimport type { inferAPIGWReturn, LambdaEvent } from './getPlanner';\nimport { getPlanner } from './getPlanner';\n\nexport type CreateAWSLambdaContextOptions<TEvent extends LambdaEvent> = {\n event: TEvent;\n context: APIGWContext;\n info: TRPCRequestInfo;\n};\n\nexport type AWSLambdaOptions<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = HTTPBaseHandlerOptions<TRouter, TEvent> &\n CreateContextCallback<\n inferRouterContext<AnyRouter>,\n AWSLambdaCreateContextFn<TRouter, TEvent>\n >;\n\nexport type AWSLambdaCreateContextFn<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n> = ({\n event,\n context,\n info,\n}: CreateAWSLambdaContextOptions<TEvent>) =>\n inferRouterContext<TRouter> | Promise<inferRouterContext<TRouter>>;\n\nexport function awsLambdaRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(\n opts: AWSLambdaOptions<TRouter, TEvent>,\n): (event: TEvent, context: APIGWContext) => Promise<inferAPIGWReturn<TEvent>> {\n return async (event, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n return await planner.toResult(response);\n };\n}\n\nexport function awsLambdaStreamingRequestHandler<\n TRouter extends AnyRouter,\n TEvent extends LambdaEvent,\n>(opts: AWSLambdaOptions<TRouter, TEvent>): StreamifyHandler<TEvent> {\n return async (event, responseStream, context) => {\n const planner = getPlanner(event);\n\n const createContext: ResolveHTTPRequestOptionsContextFn<TRouter> = async (\n innerOpts,\n ) => {\n return await opts.createContext?.({ event, context, ...innerOpts });\n };\n\n const response = await resolveResponse({\n ...opts,\n createContext,\n req: planner.request,\n path: planner.path,\n error: null,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: event,\n });\n },\n });\n\n await planner.toStream(response, responseStream);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,qBACZ,eACU;CACV,IAAI,MAAM,QAAQ,aAAa,GAC7B,OAAO,cAAc,SAAS,MAAM,qBAAqB,CAAC,CAAC;CAG7D,IAAI,OAAO,kBAAkB,UAC3B,OAAO,CAAC;CAGV,MAAM,iBAA2B,CAAC;CAClC,IAAI,MAAc;CAClB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,uBAAuB;EAC3B,OAAO,MAAM,cAAc,UAAU,KAAK,KAAK,cAAc,OAAO,GAAG,CAAC,GACtE,OAAO;EAET,OAAO,MAAM,cAAc;CAC7B;CAEA,MAAM,uBAAuB;EAC3B,KAAK,cAAc,OAAO,GAAG;EAC7B,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO;CAC5C;CAEA,OAAO,MAAM,cAAc,QAAQ;EACjC,QAAQ;EACR,wBAAwB;EAExB,OAAO,eAAe,GAAG;GACvB,KAAK,cAAc,OAAO,GAAG;GAC7B,IAAI,OAAO,KAAK;IAEd,YAAY;IACZ,OAAO;IAEP,eAAe;IACf,YAAY;IAEZ,OAAO,MAAM,cAAc,UAAU,eAAe,GAClD,OAAO;IAIT,IAAI,MAAM,cAAc,UAAU,cAAc,OAAO,GAAG,MAAM,KAAK;KAEnE,wBAAwB;KAExB,MAAM;KACN,eAAe,KAAK,cAAc,MAAM,OAAO,SAAS,CAAC;KACzD,QAAQ;IACV,OAGE,MAAM,YAAY;GAEtB,OACE,OAAO;EAEX;EAEA,IAAI,CAAC,yBAAyB,OAAO,cAAc,QACjD,eAAe,KAAK,cAAc,MAAM,KAAK,CAAC;CAElD;CAEA,OAAO;AACT;;;AC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AAO,MAAM,QAAQ,SAAS,QAAQ;CACxC;AACF;AAEA,SAAgB,iCAGd,MAAmE;CACnE,OAAO,OAAO,OAAO,gBAAgB,YAAY;EAC/C,MAAM,UAAU,WAAW,KAAK;EAEhC,MAAM,gBAA6D,OACjE,cACG;;GACH,OAAO,QAAA,uBAAM,KAAK,mBAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAA,KAAA,MAAA,eAAA;IAAkB;IAAO;GAAY,GAAA,SAAU,CAAC;EACpE;EAEA,MAAM,WAAW,MAAM,gBAAA,eAAA,eAAA,CAAA,GAClB,IAAA,GAAA,CAAA,GAAA;GACH;GACA,KAAK,QAAQ;GACb,MAAM,QAAQ;GACd,OAAO;GACP,QAAQ,GAAG;;IACT,SAAA,QAAA,SAAA,KAAA,MAAA,iBAAA,KAAM,aAAA,QAAA,mBAAA,KAAA,KAAA,eAAA,KAAA,MAAA,eAAA,eAAA,CAAA,GACD,CAAA,GAAA,CAAA,GAAA,EACH,KAAK,MAAA,CACP,CAAC;GACH;EACF,CAAA,CAAC;EAED,MAAM,QAAQ,SAAS,UAAU,cAAc;CACjD;AACF"}
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
const require_codes = require(
|
|
3
|
-
require(
|
|
4
|
-
require(
|
|
5
|
-
require('../resolveResponse-BCkjJQIz.cjs');
|
|
6
|
-
require('../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
|
-
require('../unstable-core-do-not-import-fsjhEhgh.cjs');
|
|
8
|
-
require('../observable-B1Nk6r1H.cjs');
|
|
9
|
-
require('../initTRPC-_cqIfGlH.cjs');
|
|
10
|
-
const require_node_http = require('../node-http-bPWQbKlA.cjs');
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_codes = require("../codes-C6ZIq69A.cjs");
|
|
3
|
+
const require_getErrorShape = require("../getErrorShape-DeIapApr.cjs");
|
|
4
|
+
const require_node_http = require("../node-http-CikCqjt6.cjs");
|
|
12
5
|
//#region src/adapters/express.ts
|
|
13
|
-
var import_objectSpread2 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
|
|
14
6
|
function createExpressMiddleware(opts) {
|
|
15
7
|
return (req, res) => {
|
|
16
8
|
let path = "";
|
|
17
9
|
require_codes.run(async () => {
|
|
18
10
|
path = req.path.slice(req.path.lastIndexOf("/") + 1);
|
|
19
|
-
await require_node_http.nodeHTTPRequestHandler(
|
|
11
|
+
await require_node_http.nodeHTTPRequestHandler(require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, opts), {}, {
|
|
20
12
|
req,
|
|
21
13
|
res,
|
|
22
14
|
path
|
|
23
15
|
}));
|
|
24
|
-
}).catch(require_node_http.internal_exceptionHandler(
|
|
16
|
+
}).catch(require_node_http.internal_exceptionHandler(require_getErrorShape._objectSpread2({
|
|
25
17
|
req,
|
|
26
18
|
res,
|
|
27
19
|
path
|
|
28
20
|
}, opts)));
|
|
29
21
|
};
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
//#endregion
|
|
33
|
-
exports.createExpressMiddleware = createExpressMiddleware;
|
|
24
|
+
exports.createExpressMiddleware = createExpressMiddleware;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import "../index.d-CvZXeEyR.cjs";
|
|
4
|
-
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from "../index.d-fBAdSX6g.cjs";
|
|
1
|
+
import { J as AnyRouter } from "../unstable-core-do-not-import-B9ZnrQAU.cjs";
|
|
2
|
+
import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-BHatz_Pu.cjs";
|
|
5
3
|
import * as express from "express";
|
|
6
|
-
|
|
7
4
|
//#region src/adapters/express.d.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare function createExpressMiddleware<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>): express.Handler;
|
|
11
|
-
//# sourceMappingURL=express.d.ts.map
|
|
12
|
-
|
|
5
|
+
export type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<express.Request, express.Response>;
|
|
6
|
+
export declare function createExpressMiddleware<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>): express.Handler;
|
|
13
7
|
//#endregion
|
|
14
|
-
export { CreateExpressContextOptions, createExpressMiddleware };
|
|
15
8
|
//# sourceMappingURL=express.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.cts","names":[],"sources":["../../src/adapters/express.ts"],"
|
|
1
|
+
{"version":3,"file":"express.d.cts","names":[],"sources":["../../src/adapters/express.ts"],"mappings":";;;;YAmBY,8BAA8B,+BACxC,QAAQ,SACR,QAAQ;wBAGM,wBAAwB,gBAAgB,WACtD,MAAM,uBAAuB,SAAS,QAAQ,SAAS,QAAQ,YAC9D,QAAQ"}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import "../index.d-vq_QHko2.mjs";
|
|
4
|
-
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from "../index.d-DhhodpGb.mjs";
|
|
1
|
+
import { J as AnyRouter } from "../unstable-core-do-not-import-BK_OKrtM.mjs";
|
|
2
|
+
import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-_jAhoJQ7.mjs";
|
|
5
3
|
import * as express from "express";
|
|
6
|
-
|
|
7
4
|
//#region src/adapters/express.d.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare function createExpressMiddleware<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>): express.Handler;
|
|
11
|
-
//# sourceMappingURL=express.d.ts.map
|
|
12
|
-
|
|
5
|
+
export type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<express.Request, express.Response>;
|
|
6
|
+
export declare function createExpressMiddleware<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>): express.Handler;
|
|
13
7
|
//#endregion
|
|
14
|
-
export { CreateExpressContextOptions, createExpressMiddleware };
|
|
15
8
|
//# sourceMappingURL=express.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.mts","names":[],"sources":["../../src/adapters/express.ts"],"
|
|
1
|
+
{"version":3,"file":"express.d.mts","names":[],"sources":["../../src/adapters/express.ts"],"mappings":";;;;YAmBY,8BAA8B,+BACxC,QAAQ,SACR,QAAQ;wBAGM,wBAAwB,gBAAgB,WACtD,MAAM,uBAAuB,SAAS,QAAQ,SAAS,QAAQ,YAC9D,QAAQ"}
|
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "../
|
|
4
|
-
import "../parseTRPCMessage-CTow-umk.mjs";
|
|
5
|
-
import "../resolveResponse-CdASWfAV.mjs";
|
|
6
|
-
import "../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
|
-
import "../unstable-core-do-not-import-9NNw8uQM.mjs";
|
|
8
|
-
import "../observable-UMO3vUa_.mjs";
|
|
9
|
-
import "../initTRPC-BRf4imah.mjs";
|
|
10
|
-
import { internal_exceptionHandler, nodeHTTPRequestHandler } from "../node-http-gyWQuCv2.mjs";
|
|
11
|
-
|
|
1
|
+
import { p as run } from "../codes-D5Ya6_Bi.mjs";
|
|
2
|
+
import { n as _objectSpread2 } from "../getErrorShape-B0JBUs-i.mjs";
|
|
3
|
+
import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-BUlb5EdB.mjs";
|
|
12
4
|
//#region src/adapters/express.ts
|
|
13
|
-
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
14
5
|
function createExpressMiddleware(opts) {
|
|
15
6
|
return (req, res) => {
|
|
16
7
|
let path = "";
|
|
17
8
|
run(async () => {
|
|
18
9
|
path = req.path.slice(req.path.lastIndexOf("/") + 1);
|
|
19
|
-
await nodeHTTPRequestHandler((
|
|
10
|
+
await nodeHTTPRequestHandler(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
20
11
|
req,
|
|
21
12
|
res,
|
|
22
13
|
path
|
|
23
14
|
}));
|
|
24
|
-
}).catch(internal_exceptionHandler((
|
|
15
|
+
}).catch(internal_exceptionHandler(_objectSpread2({
|
|
25
16
|
req,
|
|
26
17
|
res,
|
|
27
18
|
path
|
|
28
19
|
}, opts)));
|
|
29
20
|
};
|
|
30
21
|
}
|
|
31
|
-
|
|
32
22
|
//#endregion
|
|
33
23
|
export { createExpressMiddleware };
|
|
24
|
+
|
|
34
25
|
//# sourceMappingURL=express.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.mjs","names":[
|
|
1
|
+
{"version":3,"file":"express.mjs","names":[],"sources":["../../src/adapters/express.ts"],"sourcesContent":["/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type * as express from 'express';\nimport type { AnyRouter } from '../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n} from './node-http';\nimport { internal_exceptionHandler, nodeHTTPRequestHandler } from './node-http';\n\nexport type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<\n express.Request,\n express.Response\n>;\n\nexport function createExpressMiddleware<TRouter extends AnyRouter>(\n opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>,\n): express.Handler {\n return (req, res) => {\n let path = '';\n run(async () => {\n path = req.path.slice(req.path.lastIndexOf('/') + 1);\n\n await nodeHTTPRequestHandler({\n ...(opts as any),\n req,\n res,\n path,\n });\n }).catch(\n internal_exceptionHandler({\n req,\n res,\n path,\n ...opts,\n }),\n );\n };\n}\n"],"mappings":";;;;AAwBA,SAAgB,wBACd,MACiB;CACjB,QAAQ,KAAK,QAAQ;EACnB,IAAI,OAAO;EACX,IAAI,YAAY;GACd,OAAO,IAAI,KAAK,MAAM,IAAI,KAAK,YAAY,GAAG,IAAI,CAAC;GAEnD,MAAM,uBAAA,eAAA,eAAA,CAAA,GACA,IAAA,GAAA,CAAA,GAAA;IACJ;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}
|