@trpc/server 11.0.0-alpha-tmp-export-from-main.213 → 11.0.0-alpha-tmp-export-from-main-nuke-core.236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@trpc/server/http.d.ts +7 -0
- package/dist/@trpc/server/http.d.ts.map +1 -0
- package/dist/@trpc/server/index.d.ts +69 -0
- package/dist/@trpc/server/index.d.ts.map +1 -0
- package/dist/@trpc/server/rpc.d.ts +3 -0
- package/dist/@trpc/server/rpc.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +1 -2
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +20 -109
- package/dist/adapters/aws-lambda/index.mjs +5 -92
- package/dist/adapters/aws-lambda/utils.d.ts +2 -3
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/utils.js +101 -0
- package/dist/adapters/aws-lambda/utils.mjs +94 -0
- package/dist/adapters/express.d.ts +1 -2
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +1 -6
- package/dist/adapters/express.mjs +1 -4
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +84 -0
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +82 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -2
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +50 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +48 -0
- package/dist/adapters/fastify/index.js +4 -125
- package/dist/adapters/fastify/index.mjs +2 -125
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +120 -0
- package/dist/adapters/fetch/fetchRequestHandler.mjs +118 -0
- package/dist/adapters/fetch/index.js +2 -115
- package/dist/adapters/fetch/index.mjs +1 -116
- package/dist/adapters/fetch/types.d.ts +2 -3
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +1 -2
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +7 -9
- package/dist/adapters/next.mjs +5 -5
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.js +161 -0
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.mjs +157 -0
- package/dist/adapters/node-http/content-type/form-data/index.js +20 -646
- package/dist/adapters/node-http/content-type/form-data/index.mjs +9 -631
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.js +29 -0
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.mjs +27 -0
- package/dist/adapters/node-http/content-type/form-data/streamSlice.js +46 -0
- package/dist/adapters/node-http/content-type/form-data/streamSlice.mjs +44 -0
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.js +30 -0
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.mjs +26 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +44 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +42 -0
- package/dist/adapters/node-http/content-type/json/index.js +7 -43
- package/dist/adapters/node-http/content-type/json/index.mjs +5 -39
- package/dist/adapters/node-http/index.js +1 -6
- package/dist/adapters/node-http/index.mjs +1 -4
- package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
- package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
- package/dist/{contentType-72ed9df5.mjs → adapters/node-http/internals/contentType.mjs} +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/{nodeHTTPRequestHandler-55f05150.js → adapters/node-http/nodeHTTPRequestHandler.js} +8 -6
- package/dist/{nodeHTTPRequestHandler-2d5c8791.mjs → adapters/node-http/nodeHTTPRequestHandler.mjs} +6 -4
- package/dist/adapters/node-http/types.d.ts +3 -4
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -2
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +3 -11
- package/dist/adapters/standalone.mjs +3 -5
- package/dist/adapters/ws.d.ts +3 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +33 -28
- package/dist/adapters/ws.mjs +8 -1
- package/dist/bundle-analysis.json +757 -0
- package/dist/http.d.ts +1 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +11 -23
- package/dist/http.mjs +6 -1
- package/dist/index.d.ts +1 -68
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -43
- package/dist/index.mjs +8 -1
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.js +203 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.mjs +201 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.js +167 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.mjs +163 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.js +35 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.mjs +30 -0
- package/dist/observable/index.d.ts +5 -0
- package/dist/observable/index.d.ts.map +1 -0
- package/dist/observable/index.js +13 -0
- package/dist/observable/index.mjs +2 -0
- package/dist/observable/observable.d.ts +13 -0
- package/dist/observable/observable.d.ts.map +1 -0
- package/dist/observable/observable.js +126 -0
- package/dist/observable/observable.mjs +122 -0
- package/dist/observable/operators.d.ts +8 -0
- package/dist/observable/operators.d.ts.map +1 -0
- package/dist/observable/operators.js +103 -0
- package/dist/observable/operators.mjs +99 -0
- package/dist/observable/types.d.ts +26 -0
- package/dist/observable/types.d.ts.map +1 -0
- package/dist/rpc.d.ts +1 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +6 -15
- package/dist/rpc.mjs +3 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +6 -11
- package/dist/shared.mjs +4 -1
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +6 -0
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts +19 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.js +52 -0
- package/dist/unstable-core-do-not-import/createProxy.mjs +49 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +13 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.js +67 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +63 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +33 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/formatter.js +7 -0
- package/dist/unstable-core-do-not-import/error/formatter.mjs +5 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +15 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +31 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +29 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +24 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.js +32 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.mjs +30 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +29 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/contentType.js +54 -0
- package/dist/unstable-core-do-not-import/http/contentType.mjs +52 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +5 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +51 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +48 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts +7 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +51 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +295 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +293 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts +96 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.d.ts +37 -0
- package/dist/unstable-core-do-not-import/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.js +48 -0
- package/dist/unstable-core-do-not-import/index.mjs +16 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +96 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/initTRPC.js +95 -0
- package/dist/unstable-core-do-not-import/initTRPC.mjs +93 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts +105 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/middleware.js +95 -0
- package/dist/unstable-core-do-not-import/middleware.mjs +89 -0
- package/dist/unstable-core-do-not-import/parser.d.ts +30 -0
- package/dist/unstable-core-do-not-import/parser.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/parser.js +37 -0
- package/dist/unstable-core-do-not-import/parser.mjs +35 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts +72 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedure.js +9 -0
- package/dist/unstable-core-do-not-import/procedure.mjs +7 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +101 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.js +176 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +173 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +75 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rootConfig.js +8 -0
- package/dist/unstable-core-do-not-import/rootConfig.mjs +6 -0
- package/dist/unstable-core-do-not-import/router.d.ts +85 -0
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/router.js +156 -0
- package/dist/unstable-core-do-not-import/router.mjs +151 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +51 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/codes.js +38 -0
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +35 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +97 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +59 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +57 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts +62 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts +107 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.js +107 -0
- package/dist/unstable-core-do-not-import/transformer.mjs +102 -0
- package/dist/unstable-core-do-not-import/types.d.ts +98 -0
- package/dist/unstable-core-do-not-import/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.d.ts +27 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.js +44 -0
- package/dist/unstable-core-do-not-import/utils.mjs +39 -0
- package/package.json +54 -126
- package/src/@trpc/server/http.ts +26 -0
- package/src/@trpc/server/index.ts +105 -0
- package/src/@trpc/server/rpc.ts +26 -0
- package/src/adapters/aws-lambda/index.ts +4 -5
- package/src/adapters/aws-lambda/utils.ts +3 -4
- package/src/adapters/express.ts +1 -3
- package/src/adapters/fastify/fastifyRequestHandler.ts +6 -4
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -2
- package/src/adapters/fetch/fetchRequestHandler.ts +6 -4
- package/src/adapters/fetch/types.ts +2 -3
- package/src/adapters/next.ts +2 -3
- package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
- package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
- package/src/adapters/node-http/content-type/json/index.ts +1 -1
- package/src/adapters/node-http/internals/contentType.ts +2 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +6 -4
- package/src/adapters/node-http/types.ts +4 -5
- package/src/adapters/standalone.ts +3 -3
- package/src/adapters/ws.ts +14 -13
- package/src/http.ts +1 -26
- package/src/index.ts +1 -105
- package/src/observable/index.ts +10 -0
- package/src/observable/observable.ts +158 -0
- package/src/observable/operators.ts +119 -0
- package/src/observable/types.ts +76 -0
- package/src/rpc.ts +1 -26
- package/src/shared.ts +1 -1
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +9 -0
- package/src/unstable-core-do-not-import/createProxy.ts +59 -0
- package/src/unstable-core-do-not-import/error/TRPCError.ts +82 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +51 -0
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +36 -0
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +29 -0
- package/src/unstable-core-do-not-import/http/contentType.ts +99 -0
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +57 -0
- package/src/unstable-core-do-not-import/http/index.ts +23 -0
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +458 -0
- package/src/unstable-core-do-not-import/http/types.ts +111 -0
- package/src/unstable-core-do-not-import/index.ts +110 -0
- package/src/unstable-core-do-not-import/initTRPC.ts +206 -0
- package/src/unstable-core-do-not-import/middleware.ts +233 -0
- package/src/unstable-core-do-not-import/parser.ts +94 -0
- package/src/unstable-core-do-not-import/procedure.ts +108 -0
- package/src/unstable-core-do-not-import/procedureBuilder.ts +458 -0
- package/src/unstable-core-do-not-import/rootConfig.ts +90 -0
- package/src/unstable-core-do-not-import/router.ts +370 -0
- package/src/unstable-core-do-not-import/rpc/codes.ts +44 -0
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +136 -0
- package/src/unstable-core-do-not-import/rpc/index.ts +21 -0
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +85 -0
- package/src/unstable-core-do-not-import/serialize.ts +122 -0
- package/src/unstable-core-do-not-import/transformer.ts +202 -0
- package/src/unstable-core-do-not-import/types.ts +151 -0
- package/src/unstable-core-do-not-import/utils.ts +59 -0
- package/unstable-core-do-not-import/index.d.ts +1 -0
- package/unstable-core-do-not-import/index.js +1 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +0 -10
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +0 -1
- package/dist/@trpc-server/http.d.ts +0 -2
- package/dist/@trpc-server/http.d.ts.map +0 -1
- package/dist/contentType-24c44bba.js +0 -5
- package/dist/nodeHTTPRequestHandler-7691fc79.js +0 -105
- package/dist/observable.d.ts +0 -3
- package/dist/observable.d.ts.map +0 -1
- package/dist/observable.js +0 -32
- package/dist/observable.mjs +0 -1
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +0 -146
- package/src/@trpc-server/http.ts +0 -2
- package/src/observable.ts +0 -16
- /package/dist/{contentType-d9d22104.js → adapters/node-http/internals/contentType.js} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getHTTPStatusCode, getHTTPStatusCodeFromError, } from '../../unstable-core-do-not-import';
|
|
2
|
+
export { resolveHTTPResponse } from '../../unstable-core-do-not-import';
|
|
3
|
+
export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPRequest, HTTPResponse, OnErrorFunction, ProcedureCall, ResolveHTTPRequestOptionsContextFn, ResponseChunk, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from '../../unstable-core-do-not-import';
|
|
4
|
+
export { getBatchStreamFormatter } from '../../unstable-core-do-not-import';
|
|
5
|
+
export type { BaseContentTypeHandler, BodyResult, } from '../../unstable-core-do-not-import';
|
|
6
|
+
export { getJsonContentTypeInputs } from '../../unstable-core-do-not-import';
|
|
7
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,YAAY,EACV,sBAAsB,EACtB,UAAU,GACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export { TRPCError,
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated use `experimental_trpcMiddleware` instead
|
|
4
|
+
*/
|
|
5
|
+
experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, initTRPC, callProcedure as callTRPCProcedure, getTRPCErrorFromUnknown, transformTRPCResponse, createFlatProxy as createTRPCFlatProxy, type inferProcedureInput, type inferProcedureOutput, type inferRouterError, type inferRouterInputs, type inferRouterOutputs, type inferRouterContext, type inferTransformedProcedureOutput, type inferTransformedSubscriptionOutput, type AnyProcedure as AnyTRPCProcedure, type AnyRouter as AnyTRPCRouter, type AnyMiddlewareFunction as AnyTRPCMiddlewareFunction, type CombinedDataTransformer as TRPCCombinedDataTransformer, type ProcedureType as TRPCProcedureType, type AnyMutationProcedure as AnyTRPCMutationProcedure, type AnyQueryProcedure as AnyTRPCQueryProcedure, type ProcedureRouterRecord as TRPCProcedureRouterRecord, type ProcedureArgs as TRPCProcedureArgs, type AnySubscriptionProcedure as AnyTRPCSubscriptionProcedure, } from '../../unstable-core-do-not-import';
|
|
6
|
+
export type {
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated use `AnyTRPCProcedure` instead
|
|
9
|
+
*/
|
|
10
|
+
AnyProcedure,
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated use `AnyTRPCRouter` instead
|
|
13
|
+
*/
|
|
14
|
+
AnyRouter,
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use `AnyTRPCMiddlewareFunction` instead
|
|
17
|
+
*/
|
|
18
|
+
AnyMiddlewareFunction,
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated use `TRPCCombinedDataTransformer` instead
|
|
21
|
+
*/
|
|
22
|
+
CombinedDataTransformer,
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated This is a utility type will be removed in v12
|
|
25
|
+
*/
|
|
26
|
+
Dict,
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated This is a utility type will be removed in v12
|
|
29
|
+
*/
|
|
30
|
+
DeepPartial,
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated use `TRPCProcedureType` instead
|
|
33
|
+
*/
|
|
34
|
+
ProcedureType,
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use `AnyTRPCMutationProcedure` instead
|
|
37
|
+
*/
|
|
38
|
+
AnyMutationProcedure,
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated use `AnyTRPCQueryProcedure` instead
|
|
41
|
+
*/
|
|
42
|
+
AnyQueryProcedure,
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated use `TRPCProcedureRouterRecord` instead
|
|
45
|
+
*/
|
|
46
|
+
ProcedureRouterRecord,
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated use `TRPCProcedureArgs` instead
|
|
49
|
+
*/
|
|
50
|
+
ProcedureArgs,
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated use `AnyTRPCSubscriptionProcedure` instead
|
|
53
|
+
*/
|
|
54
|
+
AnySubscriptionProcedure, } from '../../unstable-core-do-not-import';
|
|
55
|
+
export {
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated use `getTRPCErrorShape` instead
|
|
58
|
+
*/
|
|
59
|
+
getErrorShape,
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated use `callTRPCProcedure` instead
|
|
62
|
+
*/
|
|
63
|
+
callProcedure, } from '../../unstable-core-do-not-import';
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated
|
|
66
|
+
* Use `Awaited<ReturnType<typeof myFunction>>` instead
|
|
67
|
+
*/
|
|
68
|
+
export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> = Awaited<ReturnType<TFunction>>;
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS;AACT;;GAEG;AACH,iCAAiC,EACjC,iCAAiC,IAAI,2BAA2B,EAChE,QAAQ,EAER,aAAa,IAAI,iBAAiB,EAClC,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,IAAI,mBAAmB,EACtC,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,YAAY,IAAI,gBAAgB,EACrC,KAAK,SAAS,IAAI,aAAa,EAC/B,KAAK,qBAAqB,IAAI,yBAAyB,EACvD,KAAK,uBAAuB,IAAI,2BAA2B,EAC3D,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,oBAAoB,IAAI,wBAAwB,EACrD,KAAK,iBAAiB,IAAI,qBAAqB,EAC/C,KAAK,qBAAqB,IAAI,yBAAyB,EACvD,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,wBAAwB,IAAI,4BAA4B,GAC9D,MAAM,mCAAmC,CAAC;AAE3C,YAAY;AACV;;GAEG;AACH,YAAY;AACZ;;GAEG;AACH,SAAS;AACT;;GAEG;AACH,qBAAqB;AACrB;;GAEG;AACH,uBAAuB;AAEvB;;GAEG;AACH,IAAI;AAEJ;;GAEG;AACH,WAAW;AACX;;GAEG;AACH,aAAa;AACb;;GAEG;AACH,oBAAoB;AAEpB;;GAEG;AACH,iBAAiB;AACjB;;GAEG;AACH,qBAAqB;AACrB;;GAEG;AACH,aAAa;AACb;;GAEG;AACH,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAE3C,OAAO;AACL;;GAEG;AACH,aAAa;AAEb;;GAEG;AACH,aAAa,GACd,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACxE,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { JSONRPC2, TRPCClientIncomingMessage, TRPCClientIncomingRequest, TRPCClientOutgoingMessage, TRPCClientOutgoingRequest, TRPCErrorResponse, TRPCErrorShape, TRPCReconnectNotification, TRPCRequest, TRPCRequestMessage, TRPCResponse, TRPCResponseMessage, TRPCResult, TRPCResultMessage, TRPCSubscriptionStopNotification, TRPCSuccessResponse, TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER, } from '../../unstable-core-do-not-import';
|
|
2
|
+
export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER, parseTRPCMessage, } from '../../unstable-core-do-not-import';
|
|
3
|
+
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/rpc.ts"],"names":[],"mappings":"AACA,YAAY,EACV,QAAQ,EACR,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 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`
|
|
3
3
|
*
|
|
4
|
-
* Do **not** import from `@trpc/core`
|
|
5
4
|
* @example
|
|
6
5
|
* ```ts
|
|
7
6
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
* ```
|
|
10
9
|
*/
|
|
11
10
|
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context as APIGWContext } from 'aws-lambda';
|
|
12
|
-
import type { AnyRouter } from '
|
|
11
|
+
import type { AnyRouter } from '../../@trpc/server';
|
|
13
12
|
import type { APIGatewayEvent, AWSLambdaOptions } from './utils';
|
|
14
13
|
export * from './utils';
|
|
15
14
|
/** 1:1 mapping of v1 or v2 input events, deduces which is which.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EACjC,OAAO,IAAI,YAAY,EACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AASpD,OAAO,KAAK,EACV,eAAe,EAEf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAUjB,cAAc,SAAS,CAAC;AAqDxB;;IAEI;AACJ,KAAK,gBAAgB,CAAC,KAAK,IAAI,KAAK,SAAS,oBAAoB,GAC7D,qBAAqB,GACrB,KAAK,SAAS,sBAAsB,GACpC,iCAAiC,GACjC,KAAK,CAAC;AACV,wBAAgB,uBAAuB,CACrC,OAAO,SAAS,SAAS,EACzB,MAAM,SAAS,eAAe,EAC9B,OAAO,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAExC,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,GACtC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,CA4B5D"}
|
|
@@ -1,103 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* 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`
|
|
9
|
-
*
|
|
10
|
-
* Do **not** import from `@trpc/core`
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
14
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
15
|
-
* ```
|
|
16
|
-
*/ // @trpc/server
|
|
17
|
-
function isPayloadV1(event) {
|
|
18
|
-
return determinePayloadFormat(event) == '1.0';
|
|
19
|
-
}
|
|
20
|
-
function isPayloadV2(event) {
|
|
21
|
-
return determinePayloadFormat(event) == '2.0';
|
|
22
|
-
}
|
|
23
|
-
function determinePayloadFormat(event) {
|
|
24
|
-
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
|
|
25
|
-
// According to AWS support, version is is extracted from the version property in the event.
|
|
26
|
-
// If there is no version property, then the version is implied as 1.0
|
|
27
|
-
const unknownEvent = event;
|
|
28
|
-
if (typeof unknownEvent.version === 'undefined') {
|
|
29
|
-
return '1.0';
|
|
30
|
-
} else {
|
|
31
|
-
if ([
|
|
32
|
-
'1.0',
|
|
33
|
-
'2.0'
|
|
34
|
-
].includes(unknownEvent.version)) {
|
|
35
|
-
return unknownEvent.version;
|
|
36
|
-
} else {
|
|
37
|
-
return 'custom';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function getHTTPMethod(event) {
|
|
42
|
-
if (isPayloadV1(event)) {
|
|
43
|
-
return event.httpMethod;
|
|
44
|
-
}
|
|
45
|
-
if (isPayloadV2(event)) {
|
|
46
|
-
return event.requestContext.http.method;
|
|
47
|
-
}
|
|
48
|
-
throw new core.TRPCError({
|
|
49
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
50
|
-
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function getPath(event) {
|
|
54
|
-
if (isPayloadV1(event)) {
|
|
55
|
-
if (!event.pathParameters) {
|
|
56
|
-
// Then this event was not triggered by a resource denoted with {proxy+}
|
|
57
|
-
return event.path.split('/').pop() ?? '';
|
|
58
|
-
}
|
|
59
|
-
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
60
|
-
for (const match of matches){
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
|
-
const group = match[1];
|
|
63
|
-
if (group.includes('+') && event.pathParameters) {
|
|
64
|
-
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return event.path.slice(1);
|
|
68
|
-
}
|
|
69
|
-
if (isPayloadV2(event)) {
|
|
70
|
-
const matches1 = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
71
|
-
for (const match1 of matches1){
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
73
|
-
const group1 = match1[1];
|
|
74
|
-
if (group1.includes('+') && event.pathParameters) {
|
|
75
|
-
return event.pathParameters[group1.replace('+', '')] ?? '';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return event.rawPath.slice(1);
|
|
79
|
-
}
|
|
80
|
-
throw new core.TRPCError({
|
|
81
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
82
|
-
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function transformHeaders(headers) {
|
|
86
|
-
const obj = {};
|
|
87
|
-
for (const [key, value] of Object.entries(headers)){
|
|
88
|
-
if (typeof value === 'undefined') {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
obj[key] = Array.isArray(value) ? value.join(',') : value;
|
|
92
|
-
}
|
|
93
|
-
return obj;
|
|
94
|
-
}
|
|
95
|
-
const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = 'Custom payload format version not handled by this adapter. Please use either 1.0 or 2.0. More information here' + 'https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html';
|
|
3
|
+
require('../../unstable-core-do-not-import/rpc/codes.js');
|
|
4
|
+
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
7
|
+
var utils = require('./utils.js');
|
|
96
8
|
|
|
97
9
|
/**
|
|
98
10
|
* 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`
|
|
99
11
|
*
|
|
100
|
-
* Do **not** import from `@trpc/core`
|
|
101
12
|
* @example
|
|
102
13
|
* ```ts
|
|
103
14
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
@@ -118,38 +29,38 @@ function lambdaEventToHTTPRequest(event) {
|
|
|
118
29
|
body = event.body;
|
|
119
30
|
}
|
|
120
31
|
return {
|
|
121
|
-
method: getHTTPMethod(event),
|
|
32
|
+
method: utils.getHTTPMethod(event),
|
|
122
33
|
query: query,
|
|
123
34
|
headers: event.headers,
|
|
124
35
|
body: body
|
|
125
36
|
};
|
|
126
37
|
}
|
|
127
38
|
function tRPCOutputToAPIGatewayOutput(event, response) {
|
|
128
|
-
if (isPayloadV1(event)) {
|
|
39
|
+
if (utils.isPayloadV1(event)) {
|
|
129
40
|
const resp = {
|
|
130
41
|
statusCode: response.status,
|
|
131
42
|
body: response.body ?? '',
|
|
132
|
-
headers: transformHeaders(response.headers ?? {})
|
|
43
|
+
headers: utils.transformHeaders(response.headers ?? {})
|
|
133
44
|
};
|
|
134
45
|
return resp;
|
|
135
|
-
} else if (isPayloadV2(event)) {
|
|
46
|
+
} else if (utils.isPayloadV2(event)) {
|
|
136
47
|
const resp1 = {
|
|
137
48
|
statusCode: response.status,
|
|
138
49
|
body: response.body ?? undefined,
|
|
139
|
-
headers: transformHeaders(response.headers ?? {})
|
|
50
|
+
headers: utils.transformHeaders(response.headers ?? {})
|
|
140
51
|
};
|
|
141
52
|
return resp1;
|
|
142
53
|
} else {
|
|
143
|
-
throw new
|
|
54
|
+
throw new TRPCError.TRPCError({
|
|
144
55
|
code: 'INTERNAL_SERVER_ERROR',
|
|
145
|
-
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
56
|
+
message: utils.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
146
57
|
});
|
|
147
58
|
}
|
|
148
59
|
}
|
|
149
60
|
function awsLambdaRequestHandler(opts) {
|
|
150
61
|
return async (event, context)=>{
|
|
151
62
|
const req = lambdaEventToHTTPRequest(event);
|
|
152
|
-
const path = getPath(event);
|
|
63
|
+
const path = utils.getPath(event);
|
|
153
64
|
const createContext = async (innerOpts)=>{
|
|
154
65
|
return await opts.createContext?.({
|
|
155
66
|
event,
|
|
@@ -157,7 +68,7 @@ function awsLambdaRequestHandler(opts) {
|
|
|
157
68
|
...innerOpts
|
|
158
69
|
});
|
|
159
70
|
};
|
|
160
|
-
const response = await
|
|
71
|
+
const response = await resolveHTTPResponse.resolveHTTPResponse({
|
|
161
72
|
router: opts.router,
|
|
162
73
|
batching: opts.batching,
|
|
163
74
|
responseMeta: opts?.responseMeta,
|
|
@@ -176,10 +87,10 @@ function awsLambdaRequestHandler(opts) {
|
|
|
176
87
|
};
|
|
177
88
|
}
|
|
178
89
|
|
|
179
|
-
exports.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE;
|
|
90
|
+
exports.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = utils.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE;
|
|
91
|
+
exports.getHTTPMethod = utils.getHTTPMethod;
|
|
92
|
+
exports.getPath = utils.getPath;
|
|
93
|
+
exports.isPayloadV1 = utils.isPayloadV1;
|
|
94
|
+
exports.isPayloadV2 = utils.isPayloadV2;
|
|
95
|
+
exports.transformHeaders = utils.transformHeaders;
|
|
180
96
|
exports.awsLambdaRequestHandler = awsLambdaRequestHandler;
|
|
181
|
-
exports.getHTTPMethod = getHTTPMethod;
|
|
182
|
-
exports.getPath = getPath;
|
|
183
|
-
exports.isPayloadV1 = isPayloadV1;
|
|
184
|
-
exports.isPayloadV2 = isPayloadV2;
|
|
185
|
-
exports.transformHeaders = transformHeaders;
|
|
@@ -1,99 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../unstable-core-do-not-import/rpc/codes.mjs';
|
|
2
|
+
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
5
|
+
import { getPath, getHTTPMethod, isPayloadV1, transformHeaders, isPayloadV2, UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE } from './utils.mjs';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* 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`
|
|
5
9
|
*
|
|
6
|
-
* Do **not** import from `@trpc/core`
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
10
|
-
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
11
|
-
* ```
|
|
12
|
-
*/ // @trpc/server
|
|
13
|
-
function isPayloadV1(event) {
|
|
14
|
-
return determinePayloadFormat(event) == '1.0';
|
|
15
|
-
}
|
|
16
|
-
function isPayloadV2(event) {
|
|
17
|
-
return determinePayloadFormat(event) == '2.0';
|
|
18
|
-
}
|
|
19
|
-
function determinePayloadFormat(event) {
|
|
20
|
-
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
|
|
21
|
-
// According to AWS support, version is is extracted from the version property in the event.
|
|
22
|
-
// If there is no version property, then the version is implied as 1.0
|
|
23
|
-
const unknownEvent = event;
|
|
24
|
-
if (typeof unknownEvent.version === 'undefined') {
|
|
25
|
-
return '1.0';
|
|
26
|
-
} else {
|
|
27
|
-
if ([
|
|
28
|
-
'1.0',
|
|
29
|
-
'2.0'
|
|
30
|
-
].includes(unknownEvent.version)) {
|
|
31
|
-
return unknownEvent.version;
|
|
32
|
-
} else {
|
|
33
|
-
return 'custom';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function getHTTPMethod(event) {
|
|
38
|
-
if (isPayloadV1(event)) {
|
|
39
|
-
return event.httpMethod;
|
|
40
|
-
}
|
|
41
|
-
if (isPayloadV2(event)) {
|
|
42
|
-
return event.requestContext.http.method;
|
|
43
|
-
}
|
|
44
|
-
throw new TRPCError({
|
|
45
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
46
|
-
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function getPath(event) {
|
|
50
|
-
if (isPayloadV1(event)) {
|
|
51
|
-
if (!event.pathParameters) {
|
|
52
|
-
// Then this event was not triggered by a resource denoted with {proxy+}
|
|
53
|
-
return event.path.split('/').pop() ?? '';
|
|
54
|
-
}
|
|
55
|
-
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
56
|
-
for (const match of matches){
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
58
|
-
const group = match[1];
|
|
59
|
-
if (group.includes('+') && event.pathParameters) {
|
|
60
|
-
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return event.path.slice(1);
|
|
64
|
-
}
|
|
65
|
-
if (isPayloadV2(event)) {
|
|
66
|
-
const matches1 = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
67
|
-
for (const match1 of matches1){
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
|
-
const group1 = match1[1];
|
|
70
|
-
if (group1.includes('+') && event.pathParameters) {
|
|
71
|
-
return event.pathParameters[group1.replace('+', '')] ?? '';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return event.rawPath.slice(1);
|
|
75
|
-
}
|
|
76
|
-
throw new TRPCError({
|
|
77
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
78
|
-
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function transformHeaders(headers) {
|
|
82
|
-
const obj = {};
|
|
83
|
-
for (const [key, value] of Object.entries(headers)){
|
|
84
|
-
if (typeof value === 'undefined') {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
obj[key] = Array.isArray(value) ? value.join(',') : value;
|
|
88
|
-
}
|
|
89
|
-
return obj;
|
|
90
|
-
}
|
|
91
|
-
const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = 'Custom payload format version not handled by this adapter. Please use either 1.0 or 2.0. More information here' + 'https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html';
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 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`
|
|
95
|
-
*
|
|
96
|
-
* Do **not** import from `@trpc/core`
|
|
97
10
|
* @example
|
|
98
11
|
* ```ts
|
|
99
12
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 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`
|
|
3
3
|
*
|
|
4
|
-
* Do **not** import from `@trpc/core`
|
|
5
4
|
* @example
|
|
6
5
|
* ```ts
|
|
7
6
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
@@ -9,8 +8,8 @@
|
|
|
9
8
|
* ```
|
|
10
9
|
*/
|
|
11
10
|
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2, Context as APIGWContext } from 'aws-lambda';
|
|
12
|
-
import type { AnyRouter, inferRouterContext } from '
|
|
13
|
-
import type { HTTPHeaders, OnErrorFunction, ResponseMetaFn, TRPCRequestInfo } from '
|
|
11
|
+
import type { AnyRouter, inferRouterContext } from '../../@trpc/server';
|
|
12
|
+
import type { HTTPHeaders, OnErrorFunction, ResponseMetaFn, TRPCRequestInfo } from '../../@trpc/server/http';
|
|
14
13
|
export type APIGatewayEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
15
14
|
export type APIGatewayResult = APIGatewayProxyResult | APIGatewayProxyStructuredResultV2;
|
|
16
15
|
export type CreateAWSLambdaContextOptions<TEvent extends APIGatewayEvent> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/utils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EACjC,OAAO,IAAI,YAAY,EACxB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxE,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAC5E,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,iCAAiC,CAAC;AAEtC,MAAM,MAAM,6BAA6B,CAAC,MAAM,SAAS,eAAe,IAAI;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,wBAAwB,CAClC,OAAO,SAAS,SAAS,EACzB,MAAM,SAAS,eAAe,IAC5B,CAAC,EACH,KAAK,EACL,OAAO,EACP,IAAI,GACL,EAAE,6BAA6B,CAAC,MAAM,CAAC,KACpC,kBAAkB,CAAC,OAAO,CAAC,GAC3B,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEzC,MAAM,MAAM,gBAAgB,CAC1B,OAAO,SAAS,SAAS,EACzB,MAAM,SAAS,eAAe,IAE5B;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;CACxC,GAAG,CACA;IACE;;QAEI;IACJ,aAAa,EAAE,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CAC1D,GACD;IACE;;QAEI;IACJ,aAAa,CAAC,EAAE,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CAC3D,CACJ,CAAC;AAEN,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,GACrB,KAAK,IAAI,oBAAoB,CAE/B;AACD,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,GACrB,KAAK,IAAI,sBAAsB,CAEjC;AAoBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,UAWnD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,eAAe,UA+B7C;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,GACnB,gBAAgB,CAAC,SAAS,CAAC,CAU7B;AAED,MAAM,MAAM,+BAA+B,GAAG,KAAK,GAAG,KAAK,CAAC;AAC5D,MAAM,MAAM,8BAA8B,GACtC,+BAA+B,GAC/B,QAAQ,CAAC;AAEb,eAAO,MAAM,4CAA4C,QAEiD,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../unstable-core-do-not-import/rpc/codes.js');
|
|
4
|
+
var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 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`
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
13
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
14
|
+
* ```
|
|
15
|
+
*/ // @trpc/server
|
|
16
|
+
function isPayloadV1(event) {
|
|
17
|
+
return determinePayloadFormat(event) == '1.0';
|
|
18
|
+
}
|
|
19
|
+
function isPayloadV2(event) {
|
|
20
|
+
return determinePayloadFormat(event) == '2.0';
|
|
21
|
+
}
|
|
22
|
+
function determinePayloadFormat(event) {
|
|
23
|
+
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
|
|
24
|
+
// According to AWS support, version is is extracted from the version property in the event.
|
|
25
|
+
// If there is no version property, then the version is implied as 1.0
|
|
26
|
+
const unknownEvent = event;
|
|
27
|
+
if (typeof unknownEvent.version === 'undefined') {
|
|
28
|
+
return '1.0';
|
|
29
|
+
} else {
|
|
30
|
+
if ([
|
|
31
|
+
'1.0',
|
|
32
|
+
'2.0'
|
|
33
|
+
].includes(unknownEvent.version)) {
|
|
34
|
+
return unknownEvent.version;
|
|
35
|
+
} else {
|
|
36
|
+
return 'custom';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function getHTTPMethod(event) {
|
|
41
|
+
if (isPayloadV1(event)) {
|
|
42
|
+
return event.httpMethod;
|
|
43
|
+
}
|
|
44
|
+
if (isPayloadV2(event)) {
|
|
45
|
+
return event.requestContext.http.method;
|
|
46
|
+
}
|
|
47
|
+
throw new TRPCError.TRPCError({
|
|
48
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
49
|
+
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function getPath(event) {
|
|
53
|
+
if (isPayloadV1(event)) {
|
|
54
|
+
if (!event.pathParameters) {
|
|
55
|
+
// Then this event was not triggered by a resource denoted with {proxy+}
|
|
56
|
+
return event.path.split('/').pop() ?? '';
|
|
57
|
+
}
|
|
58
|
+
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
59
|
+
for (const match of matches){
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
|
+
const group = match[1];
|
|
62
|
+
if (group.includes('+') && event.pathParameters) {
|
|
63
|
+
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return event.path.slice(1);
|
|
67
|
+
}
|
|
68
|
+
if (isPayloadV2(event)) {
|
|
69
|
+
const matches1 = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
70
|
+
for (const match1 of matches1){
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
const group1 = match1[1];
|
|
73
|
+
if (group1.includes('+') && event.pathParameters) {
|
|
74
|
+
return event.pathParameters[group1.replace('+', '')] ?? '';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return event.rawPath.slice(1);
|
|
78
|
+
}
|
|
79
|
+
throw new TRPCError.TRPCError({
|
|
80
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
81
|
+
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function transformHeaders(headers) {
|
|
85
|
+
const obj = {};
|
|
86
|
+
for (const [key, value] of Object.entries(headers)){
|
|
87
|
+
if (typeof value === 'undefined') {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
obj[key] = Array.isArray(value) ? value.join(',') : value;
|
|
91
|
+
}
|
|
92
|
+
return obj;
|
|
93
|
+
}
|
|
94
|
+
const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = 'Custom payload format version not handled by this adapter. Please use either 1.0 or 2.0. More information here' + 'https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html';
|
|
95
|
+
|
|
96
|
+
exports.UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE;
|
|
97
|
+
exports.getHTTPMethod = getHTTPMethod;
|
|
98
|
+
exports.getPath = getPath;
|
|
99
|
+
exports.isPayloadV1 = isPayloadV1;
|
|
100
|
+
exports.isPayloadV2 = isPayloadV2;
|
|
101
|
+
exports.transformHeaders = transformHeaders;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import '../../unstable-core-do-not-import/rpc/codes.mjs';
|
|
2
|
+
import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 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`
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
11
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
12
|
+
* ```
|
|
13
|
+
*/ // @trpc/server
|
|
14
|
+
function isPayloadV1(event) {
|
|
15
|
+
return determinePayloadFormat(event) == '1.0';
|
|
16
|
+
}
|
|
17
|
+
function isPayloadV2(event) {
|
|
18
|
+
return determinePayloadFormat(event) == '2.0';
|
|
19
|
+
}
|
|
20
|
+
function determinePayloadFormat(event) {
|
|
21
|
+
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
|
|
22
|
+
// According to AWS support, version is is extracted from the version property in the event.
|
|
23
|
+
// If there is no version property, then the version is implied as 1.0
|
|
24
|
+
const unknownEvent = event;
|
|
25
|
+
if (typeof unknownEvent.version === 'undefined') {
|
|
26
|
+
return '1.0';
|
|
27
|
+
} else {
|
|
28
|
+
if ([
|
|
29
|
+
'1.0',
|
|
30
|
+
'2.0'
|
|
31
|
+
].includes(unknownEvent.version)) {
|
|
32
|
+
return unknownEvent.version;
|
|
33
|
+
} else {
|
|
34
|
+
return 'custom';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getHTTPMethod(event) {
|
|
39
|
+
if (isPayloadV1(event)) {
|
|
40
|
+
return event.httpMethod;
|
|
41
|
+
}
|
|
42
|
+
if (isPayloadV2(event)) {
|
|
43
|
+
return event.requestContext.http.method;
|
|
44
|
+
}
|
|
45
|
+
throw new TRPCError({
|
|
46
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
47
|
+
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function getPath(event) {
|
|
51
|
+
if (isPayloadV1(event)) {
|
|
52
|
+
if (!event.pathParameters) {
|
|
53
|
+
// Then this event was not triggered by a resource denoted with {proxy+}
|
|
54
|
+
return event.path.split('/').pop() ?? '';
|
|
55
|
+
}
|
|
56
|
+
const matches = event.resource.matchAll(/\{(.*?)\}/g);
|
|
57
|
+
for (const match of matches){
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
+
const group = match[1];
|
|
60
|
+
if (group.includes('+') && event.pathParameters) {
|
|
61
|
+
return event.pathParameters[group.replace('+', '')] ?? '';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return event.path.slice(1);
|
|
65
|
+
}
|
|
66
|
+
if (isPayloadV2(event)) {
|
|
67
|
+
const matches1 = event.routeKey.matchAll(/\{(.*?)\}/g);
|
|
68
|
+
for (const match1 of matches1){
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
70
|
+
const group1 = match1[1];
|
|
71
|
+
if (group1.includes('+') && event.pathParameters) {
|
|
72
|
+
return event.pathParameters[group1.replace('+', '')] ?? '';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return event.rawPath.slice(1);
|
|
76
|
+
}
|
|
77
|
+
throw new TRPCError({
|
|
78
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
79
|
+
message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function transformHeaders(headers) {
|
|
83
|
+
const obj = {};
|
|
84
|
+
for (const [key, value] of Object.entries(headers)){
|
|
85
|
+
if (typeof value === 'undefined') {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
obj[key] = Array.isArray(value) ? value.join(',') : value;
|
|
89
|
+
}
|
|
90
|
+
return obj;
|
|
91
|
+
}
|
|
92
|
+
const UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE = 'Custom payload format version not handled by this adapter. Please use either 1.0 or 2.0. More information here' + 'https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html';
|
|
93
|
+
|
|
94
|
+
export { UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE, getHTTPMethod, getPath, isPayloadV1, isPayloadV2, transformHeaders };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 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`
|
|
3
3
|
*
|
|
4
|
-
* Do **not** import from `@trpc/core`
|
|
5
4
|
* @example
|
|
6
5
|
* ```ts
|
|
7
6
|
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
* ```
|
|
10
9
|
*/
|
|
11
10
|
import type * as express from 'express';
|
|
12
|
-
import type { AnyRouter } from '
|
|
11
|
+
import type { AnyRouter } from '../@trpc/server';
|
|
13
12
|
import type { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from './node-http';
|
|
14
13
|
export type CreateExpressContextOptions = NodeHTTPCreateContextFnOptions<express.Request, express.Response>;
|
|
15
14
|
export declare function createExpressMiddleware<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, express.Request, express.Response>): express.Handler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/adapters/express.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,QAAQ,CACjB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAC/D,IAAI,EAAE,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,GACvE,OAAO,CAAC,OAAO,CAgBjB"}
|