@trpc/server 11.22.2-canary.9.85bcf328a → 11.23.1-canary.3.ae3beada3
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/README.md +0 -8
- package/dist/adapters/aws-lambda/index.cjs +1 -1
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
- package/dist/adapters/aws-lambda/index.mjs +1 -1
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +1 -1
- package/dist/adapters/express.mjs +1 -1
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify/index.cjs +3 -3
- package/dist/adapters/fastify/index.mjs +3 -3
- package/dist/adapters/fetch/index.cjs +1 -1
- package/dist/adapters/fetch/index.mjs +1 -1
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +1 -1
- package/dist/adapters/next.mjs +1 -1
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/adapters/node-http/index.cjs +1 -1
- package/dist/adapters/node-http/index.mjs +1 -1
- package/dist/adapters/standalone.cjs +9 -3
- package/dist/adapters/standalone.d.cts +0 -1
- package/dist/adapters/standalone.d.cts.map +1 -1
- package/dist/adapters/standalone.d.mts +0 -1
- package/dist/adapters/standalone.d.mts.map +1 -1
- package/dist/adapters/standalone.mjs +9 -3
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/asyncGeneratorDelegate-FcEJT04i.mjs.map +1 -1
- package/dist/codes-C9N0z0an.mjs.map +1 -1
- package/dist/getErrorShape-zlj81BiC.mjs.map +1 -1
- package/dist/http.cjs +1 -1
- package/dist/http.mjs +1 -1
- package/dist/initTRPC-RMeQIy9H.mjs.map +1 -1
- package/dist/{node-http-B5jkpWn7.mjs → node-http-ChhZEv1k.mjs} +2 -2
- package/dist/node-http-ChhZEv1k.mjs.map +1 -0
- package/dist/{node-http-BZ0HlzkC.cjs → node-http-X8RiQEuH.cjs} +1 -1
- package/dist/parseTRPCMessage-CJ4DJVBp.mjs.map +1 -1
- package/dist/{resolveResponse-b9D_SrLs.cjs → resolveResponse-CoGjFxK0.cjs} +8 -4
- package/dist/{resolveResponse-DH5L33sC.mjs → resolveResponse-DksrxZ2k.mjs} +9 -5
- package/dist/resolveResponse-DksrxZ2k.mjs.map +1 -0
- package/dist/unstable-core-do-not-import-B8epiErP.d.cts.map +1 -1
- package/dist/unstable-core-do-not-import-Dbo98mkh.d.mts.map +1 -1
- package/dist/unstable-core-do-not-import.cjs +1 -1
- package/dist/unstable-core-do-not-import.mjs +1 -1
- package/dist/unstable-core-do-not-import.mjs.map +1 -1
- package/dist/{ws-83TNWW-W.cjs → ws-7qWW7Uec.cjs} +2 -2
- package/dist/{ws-DJ2SSChC.mjs → ws-BYfo-HED.mjs} +3 -3
- package/dist/ws-BYfo-HED.mjs.map +1 -0
- package/package.json +9 -12
- package/skills/adapter-aws-lambda/SKILL.md +152 -134
- package/skills/adapter-express/SKILL.md +127 -113
- package/skills/adapter-fastify/SKILL.md +228 -136
- package/skills/adapter-fetch/SKILL.md +388 -111
- package/skills/adapter-standalone/SKILL.md +184 -94
- package/skills/auth/SKILL.md +327 -202
- package/skills/auth/references/client-cors.md +29 -0
- package/skills/caching/SKILL.md +58 -148
- package/skills/error-handling/SKILL.md +280 -174
- package/skills/middlewares/SKILL.md +320 -121
- package/skills/non-json-content-types/SKILL.md +149 -168
- package/skills/server-setup/SKILL.md +355 -253
- package/skills/server-setup/references/server-context.md +219 -0
- package/skills/server-setup/references/server-merging-routers.md +141 -0
- package/skills/server-setup/references/server-metadata.md +105 -0
- package/skills/server-setup/references/server-procedures.md +172 -0
- package/skills/server-setup/references/server-routers.md +123 -0
- package/skills/server-side-calls/SKILL.md +247 -152
- package/skills/service-oriented-architecture/SKILL.md +81 -177
- package/skills/subscriptions/SKILL.md +341 -297
- package/skills/subscriptions/references/client-links-httpSubscriptionLink.md +404 -0
- package/skills/subscriptions/references/client-links-wsLink.md +122 -0
- package/skills/subscriptions/references/server-websockets.md +297 -0
- package/skills/trpc-router/SKILL.md +156 -86
- package/skills/validators/SKILL.md +384 -128
- package/src/adapters/aws-lambda/getPlanner.ts +4 -3
- package/src/adapters/aws-lambda/index.ts +2 -1
- package/src/adapters/express.ts +1 -1
- package/src/adapters/next-app-dir/nextAppDirCaller.ts +4 -4
- package/src/adapters/next-app-dir/rethrowNextErrors.ts +1 -1
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/incomingMessageToRequest.ts +1 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +1 -1
- package/src/adapters/node-http/types.ts +1 -1
- package/src/adapters/node-http/writeResponse.ts +1 -1
- package/src/adapters/standalone.ts +12 -6
- package/src/adapters/ws.ts +5 -5
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +4 -1
- package/src/unstable-core-do-not-import/clientish/serialize.ts +4 -4
- package/src/unstable-core-do-not-import/error/TRPCError.ts +3 -3
- package/src/unstable-core-do-not-import/http/formDataToObject.ts +1 -1
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +1 -1
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +13 -2
- package/src/unstable-core-do-not-import/procedure.ts +5 -2
- package/src/unstable-core-do-not-import/procedureBuilder.ts +3 -2
- package/src/unstable-core-do-not-import/rootConfig.ts +2 -2
- package/src/unstable-core-do-not-import/router.ts +5 -2
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +3 -2
- package/src/unstable-core-do-not-import/stream/jsonl.ts +2 -1
- package/src/unstable-core-do-not-import/stream/sse.types.ts +1 -1
- package/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts +1 -1
- package/src/unstable-core-do-not-import/stream/utils/createDeferred.ts +1 -1
- package/src/unstable-core-do-not-import/stream/utils/disposable.ts +6 -6
- package/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts +2 -2
- package/src/unstable-core-do-not-import/stream/utils/withPing.ts +3 -1
- package/src/unstable-core-do-not-import/transformer.ts +4 -1
- package/src/unstable-core-do-not-import/types.ts +3 -2
- package/src/unstable-core-do-not-import/utils.ts +1 -1
- package/src/vendor/standard-schema-v1/spec.ts +2 -2
- package/src/vendor/unpromise/unpromise.ts +1 -1
- package/bin/intent.js +0 -20
- package/dist/node-http-B5jkpWn7.mjs.map +0 -1
- package/dist/resolveResponse-DH5L33sC.mjs.map +0 -1
- package/dist/ws-DJ2SSChC.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -38,14 +38,6 @@ bun add @trpc/server
|
|
|
38
38
|
|
|
39
39
|
We also recommend installing `zod` to validate procedure inputs.
|
|
40
40
|
|
|
41
|
-
## AI Agents
|
|
42
|
-
|
|
43
|
-
If you use an AI coding agent, install tRPC skills for better code generation:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npx @tanstack/intent@latest install
|
|
47
|
-
```
|
|
48
|
-
|
|
49
41
|
## Basic Example
|
|
50
42
|
|
|
51
43
|
```ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_getErrorShape = require("../../getErrorShape-hncV8cPE.cjs");
|
|
3
|
-
const require_resolveResponse = require("../../resolveResponse-
|
|
3
|
+
const require_resolveResponse = require("../../resolveResponse-CoGjFxK0.cjs");
|
|
4
4
|
let node_stream = require("node:stream");
|
|
5
5
|
let node_stream_promises = require("node:stream/promises");
|
|
6
6
|
//#region src/vendor/cookie-es/set-cookie/split.ts
|
|
@@ -1 +1 @@
|
|
|
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;;;;
|
|
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;;;;KAqBrC,iBAAiB,UAAU,eAAe,uBAClD,wBACA,eAAe,yBACb;;;YCRM,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,YAC7B,mBAAmB,WACnB,QAAQ,mBAAmB;wBAEf,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 +1 @@
|
|
|
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;;;;
|
|
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;;;;KAqBrC,iBAAiB,UAAU,eAAe,uBAClD,wBACA,eAAe,yBACb;;;YCRM,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,YAC7B,mBAAmB,WACnB,QAAQ,mBAAmB;wBAEf,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,5 +1,5 @@
|
|
|
1
1
|
import { n as _objectSpread2 } from "../../getErrorShape-zlj81BiC.mjs";
|
|
2
|
-
import { t as resolveResponse } from "../../resolveResponse-
|
|
2
|
+
import { t as resolveResponse } from "../../resolveResponse-DksrxZ2k.mjs";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
4
|
import { pipeline } from "node:stream/promises";
|
|
5
5
|
//#region src/vendor/cookie-es/set-cookie/split.ts
|
|
@@ -1 +1 @@
|
|
|
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 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"],"mapp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ACH,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
|
+
{"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\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 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 // oxlint-disable-next-line typescript/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 // oxlint-disable-next-line typescript/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,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;;;AC1EF,SAAS,uBAAuB,OAA4B;CAI1D,MAAM,eAAe;CACrB,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gB,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,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_codes = require("../codes-HK4UsP07.cjs");
|
|
3
3
|
const require_getErrorShape = require("../getErrorShape-hncV8cPE.cjs");
|
|
4
|
-
const require_node_http = require("../node-http-
|
|
4
|
+
const require_node_http = require("../node-http-X8RiQEuH.cjs");
|
|
5
5
|
//#region src/adapters/express.ts
|
|
6
6
|
function createExpressMiddleware(opts) {
|
|
7
7
|
return (req, res) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as run } from "../codes-C9N0z0an.mjs";
|
|
2
2
|
import { n as _objectSpread2 } from "../getErrorShape-zlj81BiC.mjs";
|
|
3
|
-
import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-
|
|
3
|
+
import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-ChhZEv1k.mjs";
|
|
4
4
|
//#region src/adapters/express.ts
|
|
5
5
|
function createExpressMiddleware(opts) {
|
|
6
6
|
return (req, res) => {
|
|
@@ -1 +1 @@
|
|
|
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//
|
|
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// oxlint-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,\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,GACD,IAAA,GAAA,CAAA,GAAA;IACH;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_getErrorShape = require("../../getErrorShape-hncV8cPE.cjs");
|
|
3
|
-
const require_resolveResponse = require("../../resolveResponse-
|
|
4
|
-
const require_node_http = require("../../node-http-
|
|
5
|
-
const require_ws = require("../../ws-
|
|
3
|
+
const require_resolveResponse = require("../../resolveResponse-CoGjFxK0.cjs");
|
|
4
|
+
const require_node_http = require("../../node-http-X8RiQEuH.cjs");
|
|
5
|
+
const require_ws = require("../../ws-7qWW7Uec.cjs");
|
|
6
6
|
//#region src/adapters/fastify/fastifyRequestHandler.ts
|
|
7
7
|
async function fastifyRequestHandler(opts) {
|
|
8
8
|
const createContext = async (innerOpts) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as _objectSpread2 } from "../../getErrorShape-zlj81BiC.mjs";
|
|
2
|
-
import { t as resolveResponse } from "../../resolveResponse-
|
|
3
|
-
import { i as incomingMessageToRequest } from "../../node-http-
|
|
4
|
-
import { n as getWSConnectionHandler } from "../../ws-
|
|
2
|
+
import { t as resolveResponse } from "../../resolveResponse-DksrxZ2k.mjs";
|
|
3
|
+
import { i as incomingMessageToRequest } from "../../node-http-ChhZEv1k.mjs";
|
|
4
|
+
import { n as getWSConnectionHandler } from "../../ws-BYfo-HED.mjs";
|
|
5
5
|
//#region src/adapters/fastify/fastifyRequestHandler.ts
|
|
6
6
|
async function fastifyRequestHandler(opts) {
|
|
7
7
|
const createContext = async (innerOpts) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_getErrorShape = require("../../getErrorShape-hncV8cPE.cjs");
|
|
3
|
-
const require_resolveResponse = require("../../resolveResponse-
|
|
3
|
+
const require_resolveResponse = require("../../resolveResponse-CoGjFxK0.cjs");
|
|
4
4
|
//#region src/adapters/fetch/fetchRequestHandler.ts
|
|
5
5
|
const trimSlashes = (path) => {
|
|
6
6
|
path = path.startsWith("/") ? path.slice(1) : path;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as _objectSpread2 } from "../../getErrorShape-zlj81BiC.mjs";
|
|
2
|
-
import { t as resolveResponse } from "../../resolveResponse-
|
|
2
|
+
import { t as resolveResponse } from "../../resolveResponse-DksrxZ2k.mjs";
|
|
3
3
|
//#region src/adapters/fetch/fetchRequestHandler.ts
|
|
4
4
|
const trimSlashes = (path) => {
|
|
5
5
|
path = path.startsWith("/") ? path.slice(1) : path;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-dir.mjs","names":[],"sources":["../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts","../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/notFound.ts"],"sourcesContent":["import type { RedirectType } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * @internal\n */\nexport class TRPCRedirectError extends TRPCError {\n public readonly args;\n constructor(url: URL | string, redirectType?: RedirectType) {\n super({\n // TODO(?): This should maybe a custom error code\n code: 'UNPROCESSABLE_CONTENT',\n message: `Redirect error to \"${url}\" that will be handled by Next.js`,\n });\n\n this.args = [url.toString(), redirectType] as const;\n }\n}\n\n/**\n * Like `next/navigation`'s `redirect()` but throws a `TRPCError` that later will be handled by Next.js\n * This provides better typesafety than the `next/navigation`'s `redirect()` since the action continues\n * to execute on the frontend even if Next's `redirect()` has a return type of `never`.\n * @public\n * @remark You should only use this if you're also using `nextAppDirCaller`.\n */\nexport const redirect = (url: URL | string, redirectType?: RedirectType) => {\n // We rethrow this internally so the returntype on the client is undefined.\n return new TRPCRedirectError(url, redirectType) as unknown as undefined;\n};\n","import * as nextNavigation from 'next/navigation';\nimport type { TRPCError } from '../../@trpc/server';\nimport { TRPCRedirectError } from './redirect';\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/redirect.ts#L97-L123\n */\nconst REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';\nfunction isRedirectError(error: unknown) {\n if (\n typeof error !== 'object' ||\n error === null ||\n !('digest' in error) ||\n typeof error.digest !== 'string'\n ) {\n return false;\n }\n const [errorCode, type, destination, status] = error.digest.split(';', 4);\n const statusCode = Number(status);\n return (\n errorCode === REDIRECT_ERROR_CODE &&\n (type === 'replace' || type === 'push') &&\n typeof destination === 'string' &&\n !isNaN(statusCode)\n );\n}\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/not-found.ts#L33-L39\n */\nconst NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';\nfunction isNotFoundError(error: unknown) {\n if (typeof error !== 'object' || error === null || !('digest' in error)) {\n return false;\n }\n return error.digest === NOT_FOUND_ERROR_CODE;\n}\n\n/**\n * Rethrow errors that should be handled by Next.js\n */\nexport const rethrowNextErrors = (error: TRPCError) => {\n if (error.code === 'NOT_FOUND') {\n nextNavigation.notFound();\n }\n if (error instanceof TRPCRedirectError) {\n nextNavigation.redirect(...error.args);\n }\n const { cause } = error;\n\n // Next.js 15 has `unstable_rethrow`. Use that if it exists.\n if (\n 'unstable_rethrow' in nextNavigation &&\n typeof nextNavigation.unstable_rethrow === 'function'\n ) {\n nextNavigation.unstable_rethrow(cause);\n }\n\n // Before Next.js 15, we have to check and rethrow the error manually.\n if (isRedirectError(cause) || isNotFoundError(cause)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n throw cause!;\n }\n};\n","import type { CreateContextCallback } from '../../@trpc/server';\nimport { getTRPCErrorFromUnknown, TRPCError } from '../../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { formDataToObject } from '../../unstable-core-do-not-import';\n// FIXME: fix lint rule, this is ok\n// eslint-disable-next-line no-restricted-imports\nimport type { ErrorHandlerOptions } from '../../unstable-core-do-not-import/procedure';\n// FIXME: fix lint rule, this is ok\n// eslint-disable-next-line no-restricted-imports\nimport type { CallerOverride } from '../../unstable-core-do-not-import/procedureBuilder';\n// FIXME: fix lint rule, this is ok\n// eslint-disable-next-line no-restricted-imports\nimport type {\n MaybePromise,\n Simplify,\n} from '../../unstable-core-do-not-import/types';\nimport { TRPCRedirectError } from './redirect';\nimport { rethrowNextErrors } from './rethrowNextErrors';\n\n/**\n * Create a caller that works with Next.js React Server Components & Server Actions\n */\nexport function nextAppDirCaller<TContext, TMeta>(\n config: Simplify<\n {\n /**\n * Extract the path from the procedure metadata\n */\n pathExtractor?: (opts: { meta: TMeta }) => string;\n /**\n * Transform form data to a `Record` before passing it to the procedure\n * @default true\n */\n normalizeFormData?: boolean;\n /**\n * Called when an error occurs in the handler\n */\n onError?: (opts: ErrorHandlerOptions<TContext>) => void;\n } & CreateContextCallback<TContext, () => MaybePromise<TContext>>\n >,\n): CallerOverride<TContext> {\n const {\n normalizeFormData = true,\n\n // rethrowNextErrors = true\n } = config;\n const createContext = async (): Promise<TContext> => {\n return config?.createContext?.() ?? ({} as TContext);\n };\n\n return async (opts) => {\n const path =\n config.pathExtractor?.({ meta: opts._def.meta as TMeta }) ?? '';\n const ctx: TContext = await createContext().catch((cause) => {\n const error = new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Failed to create context',\n cause,\n });\n\n throw error;\n });\n\n const handleError = (cause: unknown) => {\n const error = getTRPCErrorFromUnknown(cause);\n\n config.onError?.({\n ctx,\n error,\n input: opts.args[0],\n path,\n type: opts._def.type,\n });\n\n rethrowNextErrors(error);\n\n throw error;\n };\n switch (opts._def.type) {\n case 'mutation': {\n /**\n * When you wrap an action with useFormState, it gets an extra argument as its first argument.\n * The submitted form data is therefore its second argument instead of its first as it would usually be.\n * The new first argument that gets added is the current state of the form.\n * @see https://react.dev/reference/react-dom/hooks/useFormState#my-action-can-no-longer-read-the-submitted-form-data\n */\n let input = opts.args.length === 1 ? opts.args[0] : opts.args[1];\n if (normalizeFormData && input instanceof FormData) {\n input = formDataToObject(input);\n }\n\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'query': {\n const input = opts.args[0];\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'subscription':\n default: {\n throw new TRPCError({\n code: 'NOT_IMPLEMENTED',\n message: `Not implemented for type ${opts._def.type}`,\n });\n }\n }\n };\n}\n","import type { notFound as __notFound } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * Like `next/navigation`'s `notFound()` but throws a `TRPCError` that later will be handled by Next.js\n * @public\n */\nexport const notFound: typeof __notFound = () => {\n throw new TRPCError({\n code: 'NOT_FOUND',\n });\n};\n"],"mappings":";;;;;;;;AAMA,IAAa,oBAAb,cAAuC,UAAU;CAE/C,YAAY,KAAmB,cAA6B;EAC1D,MAAM;GAEJ,MAAM;GACN,SAAS,sBAAsB,IAAI;EACrC,CAAC;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,gBAAgB,mBAAmB,MAAM;KAC7C,OAAO;IACT,CAAC,CAAC,CACD,MAAM,WAAW;GACtB;GAEA,SACE,MAAM,IAAI,UAAU;IAClB,MAAM;IACN,SAAS,4BAA4B,KAAK,KAAK;GACjD,CAAC;EAEL;CACF;AACF;;;;;;;AC/HA,MAAa,iBAAoC;CAC/C,MAAM,IAAI,UAAU,EAClB,MAAM,YACR,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"next-app-dir.mjs","names":[],"sources":["../../src/adapters/next-app-dir/redirect.ts","../../src/adapters/next-app-dir/rethrowNextErrors.ts","../../src/adapters/next-app-dir/nextAppDirCaller.ts","../../src/adapters/next-app-dir/notFound.ts"],"sourcesContent":["import type { RedirectType } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * @internal\n */\nexport class TRPCRedirectError extends TRPCError {\n public readonly args;\n constructor(url: URL | string, redirectType?: RedirectType) {\n super({\n // TODO(?): This should maybe a custom error code\n code: 'UNPROCESSABLE_CONTENT',\n message: `Redirect error to \"${url}\" that will be handled by Next.js`,\n });\n\n this.args = [url.toString(), redirectType] as const;\n }\n}\n\n/**\n * Like `next/navigation`'s `redirect()` but throws a `TRPCError` that later will be handled by Next.js\n * This provides better typesafety than the `next/navigation`'s `redirect()` since the action continues\n * to execute on the frontend even if Next's `redirect()` has a return type of `never`.\n * @public\n * @remark You should only use this if you're also using `nextAppDirCaller`.\n */\nexport const redirect = (url: URL | string, redirectType?: RedirectType) => {\n // We rethrow this internally so the returntype on the client is undefined.\n return new TRPCRedirectError(url, redirectType) as unknown as undefined;\n};\n","import * as nextNavigation from 'next/navigation';\nimport type { TRPCError } from '../../@trpc/server';\nimport { TRPCRedirectError } from './redirect';\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/redirect.ts#L97-L123\n */\nconst REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';\nfunction isRedirectError(error: unknown) {\n if (\n typeof error !== 'object' ||\n error === null ||\n !('digest' in error) ||\n typeof error.digest !== 'string'\n ) {\n return false;\n }\n const [errorCode, type, destination, status] = error.digest.split(';', 4);\n const statusCode = Number(status);\n return (\n errorCode === REDIRECT_ERROR_CODE &&\n (type === 'replace' || type === 'push') &&\n typeof destination === 'string' &&\n !isNaN(statusCode)\n );\n}\n\n/**\n * @remarks The helpers from `next/dist/client/components/*` has been removed in Next.js 15.\n * Inlining them here instead...\n * @see https://github.com/vercel/next.js/blob/5ae286ffd664e5c76841ed64f6e2da85a0835922/packages/next/src/client/components/not-found.ts#L33-L39\n */\nconst NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';\nfunction isNotFoundError(error: unknown) {\n if (typeof error !== 'object' || error === null || !('digest' in error)) {\n return false;\n }\n return error.digest === NOT_FOUND_ERROR_CODE;\n}\n\n/**\n * Rethrow errors that should be handled by Next.js\n */\nexport const rethrowNextErrors = (error: TRPCError) => {\n if (error.code === 'NOT_FOUND') {\n nextNavigation.notFound();\n }\n if (error instanceof TRPCRedirectError) {\n nextNavigation.redirect(...error.args);\n }\n const { cause } = error;\n\n // Next.js 15 has `unstable_rethrow`. Use that if it exists.\n if (\n 'unstable_rethrow' in nextNavigation &&\n typeof nextNavigation.unstable_rethrow === 'function'\n ) {\n nextNavigation.unstable_rethrow(cause);\n }\n\n // Before Next.js 15, we have to check and rethrow the error manually.\n if (isRedirectError(cause) || isNotFoundError(cause)) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n throw cause!;\n }\n};\n","import type { CreateContextCallback } from '../../@trpc/server';\nimport { getTRPCErrorFromUnknown, TRPCError } from '../../@trpc/server';\n// oxlint-disable-next-line no-restricted-imports\nimport { formDataToObject } from '../../unstable-core-do-not-import';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type { ErrorHandlerOptions } from '../../unstable-core-do-not-import/procedure';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type { CallerOverride } from '../../unstable-core-do-not-import/procedureBuilder';\n// FIXME: fix lint rule, this is ok\n// oxlint-disable-next-line no-restricted-imports\nimport type {\n MaybePromise,\n Simplify,\n} from '../../unstable-core-do-not-import/types';\nimport { TRPCRedirectError } from './redirect';\nimport { rethrowNextErrors } from './rethrowNextErrors';\n\n/**\n * Create a caller that works with Next.js React Server Components & Server Actions\n */\nexport function nextAppDirCaller<TContext, TMeta>(\n config: Simplify<\n {\n /**\n * Extract the path from the procedure metadata\n */\n pathExtractor?: (opts: { meta: TMeta }) => string;\n /**\n * Transform form data to a `Record` before passing it to the procedure\n * @default true\n */\n normalizeFormData?: boolean;\n /**\n * Called when an error occurs in the handler\n */\n onError?: (opts: ErrorHandlerOptions<TContext>) => void;\n } & CreateContextCallback<TContext, () => MaybePromise<TContext>>\n >,\n): CallerOverride<TContext> {\n const {\n normalizeFormData = true,\n\n // rethrowNextErrors = true\n } = config;\n const createContext = async (): Promise<TContext> => {\n return config?.createContext?.() ?? ({} as TContext);\n };\n\n return async (opts) => {\n const path =\n config.pathExtractor?.({ meta: opts._def.meta as TMeta }) ?? '';\n const ctx: TContext = await createContext().catch((cause) => {\n const error = new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Failed to create context',\n cause,\n });\n\n throw error;\n });\n\n const handleError = (cause: unknown) => {\n const error = getTRPCErrorFromUnknown(cause);\n\n config.onError?.({\n ctx,\n error,\n input: opts.args[0],\n path,\n type: opts._def.type,\n });\n\n rethrowNextErrors(error);\n\n throw error;\n };\n switch (opts._def.type) {\n case 'mutation': {\n /**\n * When you wrap an action with useFormState, it gets an extra argument as its first argument.\n * The submitted form data is therefore its second argument instead of its first as it would usually be.\n * The new first argument that gets added is the current state of the form.\n * @see https://react.dev/reference/react-dom/hooks/useFormState#my-action-can-no-longer-read-the-submitted-form-data\n */\n let input = opts.args.length === 1 ? opts.args[0] : opts.args[1];\n if (normalizeFormData && input instanceof FormData) {\n input = formDataToObject(input);\n }\n\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'query': {\n const input = opts.args[0];\n return await opts\n .invoke({\n type: opts._def.type,\n ctx,\n getRawInput: async () => input,\n path,\n input,\n signal: undefined,\n batchIndex: 0,\n })\n .then((data) => {\n if (data instanceof TRPCRedirectError) throw data;\n return data;\n })\n .catch(handleError);\n }\n case 'subscription':\n default: {\n throw new TRPCError({\n code: 'NOT_IMPLEMENTED',\n message: `Not implemented for type ${opts._def.type}`,\n });\n }\n }\n };\n}\n","import type { notFound as __notFound } from 'next/navigation.js';\nimport { TRPCError } from '../../@trpc/server';\n\n/**\n * Like `next/navigation`'s `notFound()` but throws a `TRPCError` that later will be handled by Next.js\n * @public\n */\nexport const notFound: typeof __notFound = () => {\n throw new TRPCError({\n code: 'NOT_FOUND',\n });\n};\n"],"mappings":";;;;;;;;AAMA,IAAa,oBAAb,cAAuC,UAAU;CAE/C,YAAY,KAAmB,cAA6B;EAC1D,MAAM;GAEJ,MAAM;GACN,SAAS,sBAAsB,IAAI;EACrC,CAAC;EANa,gBAAA,MAAA,QAAA,KAAA,CAAA;EAQd,KAAK,OAAO,CAAC,IAAI,SAAS,GAAG,YAAY;CAC3C;AACF;;;;;;;;AASA,MAAa,YAAY,KAAmB,iBAAgC;CAE1E,OAAO,IAAI,kBAAkB,KAAK,YAAY;AAChD;;;;;;;;ACpBA,MAAM,sBAAsB;AAC5B,SAAS,gBAAgB,OAAgB;CACvC,IACE,OAAO,UAAU,YACjB,UAAU,QACV,EAAE,YAAY,UACd,OAAO,MAAM,WAAW,UAExB,OAAO;CAET,MAAM,CAAC,WAAW,MAAM,aAAa,UAAU,MAAM,OAAO,MAAM,KAAK,CAAC;CACxE,MAAM,aAA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;GAE3C,CAAA,kBAAA,OAAO,aAAA,QAAA,oBAAA,KAAA,KAAA,gBAAA,KAAA,QAAU;IACf;IACA;IACA,OAAO,KAAK,KAAK;IACjB;IACA,MAAM,KAAK,KAAK;GAClB,CAAC;GAED,kBAAkB,KAAK;GAEvB,MAAM;EACR;EACA,QAAQ,KAAK,KAAK,MAAlB;GACE,KAAK,YAAY;;;;;;;IAOf,IAAI,QAAQ,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,KAAK,KAAK,KAAK;IAC9D,IAAI,qBAAqB,iBAAiB,UACxC,QAAQ,iBAAiB,KAAK;IAGhC,OAAO,MAAM,KACV,OAAO;KACN,MAAM,KAAK,KAAK;KAChB;KACA,aAAa,YAAY;KACzB;KACA;KACA,QAAQ,KAAA;KACR,YAAY;IACd,CAAC,CAAC,CACD,MAAM,SAAS;KACd,IAAI,gBAAgB,mBAAmB,MAAM;KAC7C,OAAO;IACT,CAAC,CAAC,CACD,MAAM,WAAW;GACtB;GACA,KAAK,SAAS;IACZ,MAAM,QAAQ,KAAK,KAAK;IACxB,OAAO,MAAM,KACV,OAAO;KACN,MAAM,KAAK,KAAK;KAChB;KACA,aAAa,YAAY;KACzB;KACA;KACA,QAAQ,KAAA;KACR,YAAY;IACd,CAAC,CAAC,CACD,MAAM,SAAS;KACd,IAAI,gBAAgB,mBAAmB,MAAM;KAC7C,OAAO;IACT,CAAC,CAAC,CACD,MAAM,WAAW;GACtB;GAEA,SACE,MAAM,IAAI,UAAU;IAClB,MAAM;IACN,SAAS,4BAA4B,KAAK,KAAK;GACjD,CAAC;EAEL;CACF;AACF;;;;;;;AC/HA,MAAa,iBAAoC;CAC/C,MAAM,IAAI,UAAU,EAClB,MAAM,YACR,CAAC;AACH"}
|
package/dist/adapters/next.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_codes = require("../codes-HK4UsP07.cjs");
|
|
3
3
|
const require_getErrorShape = require("../getErrorShape-hncV8cPE.cjs");
|
|
4
4
|
const require_asyncGeneratorDelegate = require("../asyncGeneratorDelegate-Dj-8tGhf.cjs");
|
|
5
|
-
const require_node_http = require("../node-http-
|
|
5
|
+
const require_node_http = require("../node-http-X8RiQEuH.cjs");
|
|
6
6
|
//#region src/adapters/next.ts
|
|
7
7
|
function createNextApiHandler(opts) {
|
|
8
8
|
return async (req, res) => {
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as run } from "../codes-C9N0z0an.mjs";
|
|
2
2
|
import { n as _objectSpread2 } from "../getErrorShape-zlj81BiC.mjs";
|
|
3
3
|
import { v as TRPCError } from "../asyncGeneratorDelegate-FcEJT04i.mjs";
|
|
4
|
-
import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-
|
|
4
|
+
import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-ChhZEv1k.mjs";
|
|
5
5
|
//#region src/adapters/next.ts
|
|
6
6
|
function createNextApiHandler(opts) {
|
|
7
7
|
return async (req, res) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.mjs","names":[],"sources":["../../src/adapters/next.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 { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n// @trpc/server\nimport type { AnyRouter } from '../@trpc/server';\n// @trpc/server\nimport { TRPCError } from '../@trpc/server';\n//
|
|
1
|
+
{"version":3,"file":"next.mjs","names":[],"sources":["../../src/adapters/next.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 { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n// @trpc/server\nimport type { AnyRouter } from '../@trpc/server';\n// @trpc/server\nimport { TRPCError } from '../@trpc/server';\n// oxlint-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 CreateNextContextOptions = NodeHTTPCreateContextFnOptions<\n NextApiRequest,\n NextApiResponse\n>;\n\n/**\n * Preventing \"TypeScript where it's tough not to get \"The inferred type of 'xxxx' cannot be named without a reference to [...]\"\n */\nexport type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n\nexport function createNextApiHandler<TRouter extends AnyRouter>(\n opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest, NextApiResponse>,\n): NextApiHandler {\n return async (req, res) => {\n let path = '';\n\n await run(async () => {\n path = run(() => {\n if (typeof req.query['trpc'] === 'string') {\n return req.query['trpc'];\n }\n if (Array.isArray(req.query['trpc'])) {\n return req.query['trpc'].join('/');\n }\n throw new TRPCError({\n message:\n 'Query \"trpc\" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',\n code: 'INTERNAL_SERVER_ERROR',\n });\n });\n\n await nodeHTTPRequestHandler({\n ...opts,\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":";;;;;AAgCA,SAAgB,qBACd,MACgB;CAChB,OAAO,OAAO,KAAK,QAAQ;EACzB,IAAI,OAAO;EAEX,MAAM,IAAI,YAAY;GACpB,OAAO,UAAU;IACf,IAAI,OAAO,IAAI,MAAM,YAAY,UAC/B,OAAO,IAAI,MAAM;IAEnB,IAAI,MAAM,QAAQ,IAAI,MAAM,OAAO,GACjC,OAAO,IAAI,MAAM,OAAO,CAAC,KAAK,GAAG;IAEnC,MAAM,IAAI,UAAU;KAClB,SACE;KACF,MAAM;IACR,CAAC;GACH,CAAC;GAED,MAAM,uBAAA,eAAA,eAAA,CAAA,GACD,IAAA,GAAA,CAAA,GAAA;IACH;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_node_http = require("../../node-http-
|
|
2
|
+
const require_node_http = require("../../node-http-X8RiQEuH.cjs");
|
|
3
3
|
exports.createURL = require_node_http.createURL;
|
|
4
4
|
exports.incomingMessageToRequest = require_node_http.incomingMessageToRequest;
|
|
5
5
|
exports.internal_exceptionHandler = require_node_http.internal_exceptionHandler;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as incomingMessageToRequest, n as nodeHTTPRequestHandler, r as createURL, t as internal_exceptionHandler } from "../../node-http-
|
|
1
|
+
import { i as incomingMessageToRequest, n as nodeHTTPRequestHandler, r as createURL, t as internal_exceptionHandler } from "../../node-http-ChhZEv1k.mjs";
|
|
2
2
|
export { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
3
3
|
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_rolldown_runtime = require("../rolldown-runtime-CFW-PwTP.cjs");
|
|
3
3
|
const require_codes = require("../codes-HK4UsP07.cjs");
|
|
4
4
|
const require_getErrorShape = require("../getErrorShape-hncV8cPE.cjs");
|
|
5
|
-
const require_node_http = require("../node-http-
|
|
5
|
+
const require_node_http = require("../node-http-X8RiQEuH.cjs");
|
|
6
6
|
let http = require("http");
|
|
7
7
|
http = require_rolldown_runtime.__toESM(http, 1);
|
|
8
8
|
//#region src/adapters/standalone.ts
|
|
@@ -15,13 +15,19 @@ http = require_rolldown_runtime.__toESM(http, 1);
|
|
|
15
15
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
+
const trimSlashes = (path) => {
|
|
19
|
+
path = path.startsWith("/") ? path.slice(1) : path;
|
|
20
|
+
path = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
21
|
+
return path;
|
|
22
|
+
};
|
|
18
23
|
function createHandler(opts) {
|
|
19
24
|
var _opts$basePath;
|
|
20
|
-
const
|
|
25
|
+
const basePath = trimSlashes((_opts$basePath = opts.basePath) !== null && _opts$basePath !== void 0 ? _opts$basePath : "/");
|
|
21
26
|
return (req, res) => {
|
|
22
27
|
let path = "";
|
|
23
28
|
require_codes.run(async () => {
|
|
24
|
-
|
|
29
|
+
const url = require_node_http.createURL(req);
|
|
30
|
+
path = trimSlashes(trimSlashes(url.pathname).slice(basePath.length));
|
|
25
31
|
await require_node_http.nodeHTTPRequestHandler(require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, opts), {}, {
|
|
26
32
|
req,
|
|
27
33
|
res,
|
|
@@ -7,7 +7,6 @@ type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHT
|
|
|
7
7
|
/**
|
|
8
8
|
* The base path to handle requests for.
|
|
9
9
|
* This will be sliced from the beginning of the request path
|
|
10
|
-
* (Do not miss including the trailing slash)
|
|
11
10
|
* @default '/'
|
|
12
11
|
* @example '/trpc/'
|
|
13
12
|
* @example '/trpc/api/'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.cts","names":[],"sources":["../../src/adapters/standalone.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"standalone.d.cts","names":[],"sources":["../../src/adapters/standalone.ts"],"mappings":";;;;;KAqCK,yBACH,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,oBAChB,uBAAuB,SAAS,UAAU;;;;;;;;EAQ5C;;YAIU,yBAAyB,gBAAgB,aACnD,yBAAyB,SAAS,KAAK,iBAAiB,KAAK;YAEnD,2BAA2B,+BACrC,KAAK,iBACL,KAAK;;;;wBAyCS,kBAAkB,gBAAgB,WAChD,MAAM,yBAAyB,WAC9B,KAAK;wBAIQ,iBAAiB,gBAAgB,WAC/C,MAAM,yBAAyB,WAAQ,KAAA,cAAA,KAAA,wBAAA,KAAA;YAM7B,0BAA0B,gBAAgB,aACpD,yBACE,SACA,MAAM,oBACN,MAAM;YAGE,4BAA4B,+BACtC,MAAM,oBACN,MAAM;wBAGQ,mBAAmB,MAAM,0BAA0B,cAAU,KAAA,MAAA,oBAAA,KAAA,MAAA,oBAAA,MAAA"}
|
|
@@ -7,7 +7,6 @@ type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHT
|
|
|
7
7
|
/**
|
|
8
8
|
* The base path to handle requests for.
|
|
9
9
|
* This will be sliced from the beginning of the request path
|
|
10
|
-
* (Do not miss including the trailing slash)
|
|
11
10
|
* @default '/'
|
|
12
11
|
* @example '/trpc/'
|
|
13
12
|
* @example '/trpc/api/'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.mts","names":[],"sources":["../../src/adapters/standalone.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"standalone.d.mts","names":[],"sources":["../../src/adapters/standalone.ts"],"mappings":";;;;;KAqCK,yBACH,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,oBAChB,uBAAuB,SAAS,UAAU;;;;;;;;EAQ5C;;YAIU,yBAAyB,gBAAgB,aACnD,yBAAyB,SAAS,KAAK,iBAAiB,KAAK;YAEnD,2BAA2B,+BACrC,KAAK,iBACL,KAAK;;;;wBAyCS,kBAAkB,gBAAgB,WAChD,MAAM,yBAAyB,WAC9B,KAAK;wBAIQ,iBAAiB,gBAAgB,WAC/C,MAAM,yBAAyB,WAAQ,KAAA,cAAA,KAAA,wBAAA,KAAA;YAM7B,0BAA0B,gBAAgB,aACpD,yBACE,SACA,MAAM,oBACN,MAAM;YAGE,4BAA4B,+BACtC,MAAM,oBACN,MAAM;wBAGQ,mBAAmB,MAAM,0BAA0B,cAAU,KAAA,MAAA,oBAAA,KAAA,MAAA,oBAAA,MAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as run } from "../codes-C9N0z0an.mjs";
|
|
2
2
|
import { n as _objectSpread2 } from "../getErrorShape-zlj81BiC.mjs";
|
|
3
|
-
import { n as nodeHTTPRequestHandler, r as createURL, t as internal_exceptionHandler } from "../node-http-
|
|
3
|
+
import { n as nodeHTTPRequestHandler, r as createURL, t as internal_exceptionHandler } from "../node-http-ChhZEv1k.mjs";
|
|
4
4
|
import http from "http";
|
|
5
5
|
//#region src/adapters/standalone.ts
|
|
6
6
|
/**
|
|
@@ -12,13 +12,19 @@ import http from "http";
|
|
|
12
12
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
+
const trimSlashes = (path) => {
|
|
16
|
+
path = path.startsWith("/") ? path.slice(1) : path;
|
|
17
|
+
path = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
18
|
+
return path;
|
|
19
|
+
};
|
|
15
20
|
function createHandler(opts) {
|
|
16
21
|
var _opts$basePath;
|
|
17
|
-
const
|
|
22
|
+
const basePath = trimSlashes((_opts$basePath = opts.basePath) !== null && _opts$basePath !== void 0 ? _opts$basePath : "/");
|
|
18
23
|
return (req, res) => {
|
|
19
24
|
let path = "";
|
|
20
25
|
run(async () => {
|
|
21
|
-
|
|
26
|
+
const url = createURL(req);
|
|
27
|
+
path = trimSlashes(trimSlashes(url.pathname).slice(basePath.length));
|
|
22
28
|
await nodeHTTPRequestHandler(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
23
29
|
req,
|
|
24
30
|
res,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.mjs","names":[],"sources":["../../src/adapters/standalone.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 */\n\nimport http from 'http';\n// --- http2 ---\nimport type * as http2 from 'http2';\n// @trpc/server\nimport { type AnyRouter } from '../@trpc/server';\n//
|
|
1
|
+
{"version":3,"file":"standalone.mjs","names":[],"sources":["../../src/adapters/standalone.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 */\n\nimport http from 'http';\n// --- http2 ---\nimport type * as http2 from 'http2';\n// @trpc/server\nimport { type AnyRouter } from '../@trpc/server';\n// oxlint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n NodeHTTPRequest,\n NodeHTTPResponse,\n} from './node-http';\nimport {\n createURL,\n internal_exceptionHandler,\n nodeHTTPRequestHandler,\n} from './node-http';\n\n// same as in the fetch adapter\nconst trimSlashes = (path: string): string => {\n path = path.startsWith('/') ? path.slice(1) : path;\n path = path.endsWith('/') ? path.slice(0, -1) : path;\n\n return path;\n};\n\ntype StandaloneHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends NodeHTTPRequest,\n TResponse extends NodeHTTPResponse,\n> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {\n /**\n * The base path to handle requests for.\n * This will be sliced from the beginning of the request path\n * @default '/'\n * @example '/trpc/'\n * @example '/trpc/api/'\n */\n basePath?: string;\n};\n\n// --- http1 ---\nexport type CreateHTTPHandlerOptions<TRouter extends AnyRouter> =\n StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;\n\nexport type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<\n http.IncomingMessage,\n http.ServerResponse\n>;\n\nfunction createHandler<\n TRouter extends AnyRouter,\n TRequest extends NodeHTTPRequest,\n TResponse extends NodeHTTPResponse,\n>(\n opts: StandaloneHandlerOptions<TRouter, TRequest, TResponse>,\n): (req: TRequest, res: TResponse) => void {\n const basePath = trimSlashes(opts.basePath ?? '/');\n\n return (req, res) => {\n let path = '';\n\n run(async () => {\n const url = createURL(req);\n\n // get procedure(s) path and remove the slashes around it\n path = trimSlashes(trimSlashes(url.pathname).slice(basePath.length));\n\n await nodeHTTPRequestHandler({\n ...opts,\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\n/**\n * @internal\n */\nexport function createHTTPHandler<TRouter extends AnyRouter>(\n opts: CreateHTTPHandlerOptions<TRouter>,\n): http.RequestListener {\n return createHandler(opts);\n}\n\nexport function createHTTPServer<TRouter extends AnyRouter>(\n opts: CreateHTTPHandlerOptions<TRouter>,\n) {\n return http.createServer(createHTTPHandler(opts));\n}\n\n// --- http2 ---\nexport type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> =\n StandaloneHandlerOptions<\n TRouter,\n http2.Http2ServerRequest,\n http2.Http2ServerResponse\n >;\n\nexport type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<\n http2.Http2ServerRequest,\n http2.Http2ServerResponse\n>;\n\nexport function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>) {\n return createHandler(opts);\n}\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,eAAe,SAAyB;CAC5C,OAAO,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,CAAC,IAAI;CAC9C,OAAO,KAAK,SAAS,GAAG,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;CAEhD,OAAO;AACT;AA0BA,SAAS,cAKP,MACyC;;CACzC,MAAM,WAAW,aAAA,iBAAY,KAAK,cAAA,QAAA,mBAAA,KAAA,IAAA,iBAAY,GAAG;CAEjD,QAAQ,KAAK,QAAQ;EACnB,IAAI,OAAO;EAEX,IAAI,YAAY;GACd,MAAM,MAAM,UAAU,GAAG;GAGzB,OAAO,YAAY,YAAY,IAAI,QAAQ,CAAC,CAAC,MAAM,SAAS,MAAM,CAAC;GAEnE,MAAM,uBAAA,eAAA,eAAA,CAAA,GACD,IAAA,GAAA,CAAA,GAAA;IACH;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF;;;;AAKA,SAAgB,kBACd,MACsB;CACtB,OAAO,cAAc,IAAI;AAC3B;AAEA,SAAgB,iBACd,MACA;CACA,OAAO,KAAK,aAAa,kBAAkB,IAAI,CAAC;AAClD;AAeA,SAAgB,mBAAmB,MAA4C;CAC7E,OAAO,cAAc,IAAI;AAC3B"}
|
package/dist/adapters/ws.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ws = require("../ws-
|
|
2
|
+
const require_ws = require("../ws-7qWW7Uec.cjs");
|
|
3
3
|
exports.applyWSSHandler = require_ws.applyWSSHandler;
|
|
4
4
|
exports.getWSConnectionHandler = require_ws.getWSConnectionHandler;
|
|
5
5
|
exports.handleKeepAlive = require_ws.handleKeepAlive;
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as jsonEncoder, n as getWSConnectionHandler, r as handleKeepAlive, t as applyWSSHandler } from "../ws-
|
|
1
|
+
import { i as jsonEncoder, n as getWSConnectionHandler, r as handleKeepAlive, t as applyWSSHandler } from "../ws-BYfo-HED.mjs";
|
|
2
2
|
export { applyWSSHandler, getWSConnectionHandler, handleKeepAlive, jsonEncoder };
|
|
3
3
|
|