@trpc/server 11.3.1 → 11.3.2-canary.4
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/adapters/aws-lambda/package.json +1 -0
- package/adapters/express/package.json +1 -0
- package/adapters/fastify/package.json +1 -0
- package/adapters/fetch/package.json +1 -0
- package/adapters/next/package.json +1 -0
- package/adapters/next-app-dir/package.json +1 -0
- package/adapters/node-http/package.json +1 -0
- package/adapters/standalone/package.json +1 -0
- package/adapters/ws/package.json +1 -0
- package/dist/adapters/aws-lambda/index.cjs +255 -0
- package/dist/adapters/aws-lambda/index.d.cts +31 -0
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.mts +31 -0
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -0
- package/dist/adapters/aws-lambda/index.mjs +248 -57
- package/dist/adapters/aws-lambda/index.mjs.map +1 -0
- package/dist/adapters/express.cjs +34 -0
- package/dist/adapters/express.d.cts +15 -0
- package/dist/adapters/express.d.cts.map +1 -0
- package/dist/adapters/express.d.mts +15 -0
- package/dist/adapters/express.d.mts.map +1 -0
- package/dist/adapters/express.mjs +30 -32
- package/dist/adapters/express.mjs.map +1 -0
- package/dist/adapters/fastify/index.cjs +75 -0
- package/dist/adapters/fastify/index.d.cts +29 -0
- package/dist/adapters/fastify/index.d.cts.map +1 -0
- package/dist/adapters/fastify/index.d.mts +29 -0
- package/dist/adapters/fastify/index.d.mts.map +1 -0
- package/dist/adapters/fastify/index.mjs +75 -2
- package/dist/adapters/fastify/index.mjs.map +1 -0
- package/dist/adapters/fetch/index.cjs +58 -0
- package/dist/adapters/fetch/index.d.cts +30 -0
- package/dist/adapters/fetch/index.d.cts.map +1 -0
- package/dist/adapters/fetch/index.d.mts +30 -0
- package/dist/adapters/fetch/index.d.mts.map +1 -0
- package/dist/adapters/fetch/index.mjs +59 -1
- package/dist/adapters/fetch/index.mjs.map +1 -0
- package/dist/adapters/next-app-dir.cjs +3050 -0
- package/dist/adapters/next-app-dir.d.cts +58 -0
- package/dist/adapters/next-app-dir.d.cts.map +1 -0
- package/dist/adapters/next-app-dir.d.mts +58 -0
- package/dist/adapters/next-app-dir.d.mts.map +1 -0
- package/dist/adapters/next-app-dir.mjs +3048 -4
- package/dist/adapters/next-app-dir.mjs.map +1 -0
- package/dist/adapters/next.cjs +41 -0
- package/dist/adapters/next.d.cts +19 -0
- package/dist/adapters/next.d.cts.map +1 -0
- package/dist/adapters/next.d.mts +19 -0
- package/dist/adapters/next.d.mts.map +1 -0
- package/dist/adapters/next.mjs +37 -44
- package/dist/adapters/next.mjs.map +1 -0
- package/dist/adapters/node-http/index.cjs +15 -0
- package/dist/adapters/node-http/index.d.cts +5 -0
- package/dist/adapters/node-http/index.d.mts +5 -0
- package/dist/adapters/node-http/index.mjs +12 -2
- package/dist/adapters/standalone.cjs +52 -0
- package/dist/adapters/standalone.d.cts +33 -0
- package/dist/adapters/standalone.d.cts.map +1 -0
- package/dist/adapters/standalone.d.mts +33 -0
- package/dist/adapters/standalone.d.mts.map +1 -0
- package/dist/adapters/standalone.mjs +40 -34
- package/dist/adapters/standalone.mjs.map +1 -0
- package/dist/adapters/ws.cjs +17 -0
- package/dist/adapters/ws.d.cts +61 -0
- package/dist/adapters/ws.d.cts.map +1 -0
- package/dist/adapters/ws.d.mts +61 -0
- package/dist/adapters/ws.d.mts.map +1 -0
- package/dist/adapters/ws.mjs +14 -539
- package/dist/contentTypeParsers-SN4WL9ze.mjs +13 -0
- package/dist/contentTypeParsers-SN4WL9ze.mjs.map +1 -0
- package/dist/contentTypeParsers-iAFF_pJG.cjs +18 -0
- package/dist/getErrorShape-CsikfkAc.cjs +201 -0
- package/dist/getErrorShape-DyYil4aT.mjs +149 -0
- package/dist/getErrorShape-DyYil4aT.mjs.map +1 -0
- package/dist/http-CWyjOa1l.mjs +0 -0
- package/dist/http-DXy3XyhL.cjs +0 -0
- package/dist/http.cjs +14 -0
- package/dist/http.d.cts +3 -0
- package/dist/http.d.mts +3 -0
- package/dist/http.mjs +9 -8
- package/dist/index.cjs +22 -0
- package/dist/index.d-BiUz7kM_.d.cts +65 -0
- package/dist/index.d-BiUz7kM_.d.cts.map +1 -0
- package/dist/index.d-ChWYhXbd.d.cts +99 -0
- package/dist/index.d-ChWYhXbd.d.cts.map +1 -0
- package/dist/index.d-CvZXeEyR.d.cts +11 -0
- package/dist/index.d-CvZXeEyR.d.cts.map +1 -0
- package/dist/index.d-D4qZxQJh.d.mts +65 -0
- package/dist/index.d-D4qZxQJh.d.mts.map +1 -0
- package/dist/index.d-Ocy_AnXj.d.mts +99 -0
- package/dist/index.d-Ocy_AnXj.d.mts.map +1 -0
- package/dist/index.d-vq_QHko2.d.mts +11 -0
- package/dist/index.d-vq_QHko2.d.mts.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +6 -13
- package/dist/initTRPC-COaJMShh.mjs +339 -0
- package/dist/initTRPC-COaJMShh.mjs.map +1 -0
- package/dist/initTRPC-DjEpHmY2.cjs +397 -0
- package/dist/node-http-BPR68yI4.cjs +243 -0
- package/dist/node-http-BUQnHuGI.mjs +221 -0
- package/dist/node-http-BUQnHuGI.mjs.map +1 -0
- package/dist/observable/index.cjs +13 -0
- package/dist/observable/index.d.cts +2 -0
- package/dist/observable/index.d.mts +2 -0
- package/dist/observable/index.mjs +4 -3
- package/dist/observable-B1orLHHI.mjs +155 -0
- package/dist/observable-B1orLHHI.mjs.map +1 -0
- package/dist/observable-BwdrSFZU.cjs +178 -0
- package/dist/observable-C6qq2Ydk.cjs +180 -0
- package/dist/observable-CFXA_tyK.mjs +146 -0
- package/dist/observable-CFXA_tyK.mjs.map +1 -0
- package/dist/parseTRPCMessage-ByQWigsq.cjs +73 -0
- package/dist/parseTRPCMessage-CNyYMSRB.mjs +63 -0
- package/dist/parseTRPCMessage-CNyYMSRB.mjs.map +1 -0
- package/dist/resolveResponse-B2CuaT_1.cjs +2042 -0
- package/dist/resolveResponse-DPbYgJDD.mjs +1912 -0
- package/dist/resolveResponse-DPbYgJDD.mjs.map +1 -0
- package/dist/rpc.cjs +6 -0
- package/dist/rpc.d.cts +3 -0
- package/dist/rpc.d.mts +3 -0
- package/dist/rpc.mjs +4 -5
- package/dist/shared.cjs +5 -0
- package/dist/shared.d.cts +4 -0
- package/dist/shared.d.mts +4 -0
- package/dist/shared.mjs +4 -6
- package/dist/tracked-Dl9sBZxY.cjs +483 -0
- package/dist/tracked-GEWPoL0C.mjs +383 -0
- package/dist/tracked-GEWPoL0C.mjs.map +1 -0
- package/dist/unstable-core-do-not-import-D89CaGtL.mjs +29 -0
- package/dist/unstable-core-do-not-import-D89CaGtL.mjs.map +1 -0
- package/dist/unstable-core-do-not-import-DFQys1IC.cjs +34 -0
- package/dist/unstable-core-do-not-import.cjs +83 -0
- package/dist/unstable-core-do-not-import.d-CSxj_rbP.d.cts +1974 -0
- package/dist/unstable-core-do-not-import.d-CSxj_rbP.d.cts.map +1 -0
- package/dist/unstable-core-do-not-import.d-ptrxwuSa.d.mts +1974 -0
- package/dist/unstable-core-do-not-import.d-ptrxwuSa.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.d.cts +3 -0
- package/dist/unstable-core-do-not-import.d.mts +3 -0
- package/dist/unstable-core-do-not-import.mjs +11 -30
- package/dist/utils-BHZJcBRv.mjs +137 -0
- package/dist/utils-BHZJcBRv.mjs.map +1 -0
- package/dist/utils-DVO6HZiR.cjs +220 -0
- package/dist/ws-C2nEUNk_.cjs +425 -0
- package/dist/ws-eIVIMTrw.mjs +409 -0
- package/dist/ws-eIVIMTrw.mjs.map +1 -0
- package/http/package.json +1 -0
- package/observable/package.json +1 -0
- package/package.json +131 -55
- package/rpc/package.json +1 -0
- package/shared/package.json +1 -0
- package/src/@trpc/server/index.ts +24 -0
- package/src/unstable-core-do-not-import/http/contentType.ts +5 -4
- package/src/unstable-core-do-not-import/initTRPC.ts +79 -4
- package/src/unstable-core-do-not-import/router.ts +36 -12
- package/src/unstable-core-do-not-import/utils.ts +3 -2
- package/unstable-core-do-not-import/package.json +1 -0
- package/adapters/aws-lambda/index.d.ts +0 -1
- package/adapters/aws-lambda/index.js +0 -1
- package/adapters/express/index.d.ts +0 -1
- package/adapters/express/index.js +0 -1
- package/adapters/fastify/index.d.ts +0 -1
- package/adapters/fastify/index.js +0 -1
- package/adapters/fetch/index.d.ts +0 -1
- package/adapters/fetch/index.js +0 -1
- package/adapters/next/index.d.ts +0 -1
- package/adapters/next/index.js +0 -1
- package/adapters/next-app-dir/index.d.ts +0 -1
- package/adapters/next-app-dir/index.js +0 -1
- package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
- package/adapters/node-http/content-type/form-data/index.js +0 -1
- package/adapters/node-http/content-type/json/index.d.ts +0 -1
- package/adapters/node-http/content-type/json/index.js +0 -1
- package/adapters/node-http/index.d.ts +0 -1
- package/adapters/node-http/index.js +0 -1
- package/adapters/standalone/index.d.ts +0 -1
- package/adapters/standalone/index.js +0 -1
- package/adapters/ws/index.d.ts +0 -1
- package/adapters/ws/index.js +0 -1
- package/dist/@trpc/server/http.d.ts +0 -8
- package/dist/@trpc/server/http.d.ts.map +0 -1
- package/dist/@trpc/server/index.d.ts +0 -65
- package/dist/@trpc/server/index.d.ts.map +0 -1
- package/dist/@trpc/server/rpc.d.ts +0 -3
- package/dist/@trpc/server/rpc.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts +0 -15
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/getPlanner.js +0 -179
- package/dist/adapters/aws-lambda/getPlanner.mjs +0 -177
- package/dist/adapters/aws-lambda/index.d.ts +0 -23
- package/dist/adapters/aws-lambda/index.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/index.js +0 -67
- package/dist/adapters/express.d.ts +0 -15
- package/dist/adapters/express.d.ts.map +0 -1
- package/dist/adapters/express.js +0 -39
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +0 -22
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +0 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +0 -49
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +0 -47
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +0 -21
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +0 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +0 -56
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +0 -54
- package/dist/adapters/fastify/index.d.ts +0 -3
- package/dist/adapters/fastify/index.d.ts.map +0 -1
- package/dist/adapters/fastify/index.js +0 -9
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +0 -13
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +0 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +0 -77
- package/dist/adapters/fetch/fetchRequestHandler.mjs +0 -75
- package/dist/adapters/fetch/index.d.ts +0 -3
- package/dist/adapters/fetch/index.d.ts.map +0 -1
- package/dist/adapters/fetch/index.js +0 -7
- package/dist/adapters/fetch/types.d.ts +0 -27
- package/dist/adapters/fetch/types.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts +0 -25
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +0 -94
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +0 -92
- package/dist/adapters/next-app-dir/notFound.d.ts +0 -7
- package/dist/adapters/next-app-dir/notFound.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/notFound.js +0 -18
- package/dist/adapters/next-app-dir/notFound.mjs +0 -16
- package/dist/adapters/next-app-dir/redirect.d.ts +0 -18
- package/dist/adapters/next-app-dir/redirect.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/redirect.js +0 -49
- package/dist/adapters/next-app-dir/redirect.mjs +0 -46
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts +0 -6
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +0 -70
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +0 -49
- package/dist/adapters/next-app-dir.d.ts +0 -7
- package/dist/adapters/next-app-dir.d.ts.map +0 -1
- package/dist/adapters/next-app-dir.js +0 -13
- package/dist/adapters/next.d.ts +0 -19
- package/dist/adapters/next.d.ts.map +0 -1
- package/dist/adapters/next.js +0 -51
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +0 -12
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +0 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +0 -123
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +0 -120
- package/dist/adapters/node-http/index.d.ts +0 -4
- package/dist/adapters/node-http/index.d.ts.map +0 -1
- package/dist/adapters/node-http/index.js +0 -11
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +0 -20
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +0 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +0 -96
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +0 -93
- package/dist/adapters/node-http/types.d.ts +0 -81
- package/dist/adapters/node-http/types.d.ts.map +0 -1
- package/dist/adapters/node-http/writeResponse.d.ts +0 -18
- package/dist/adapters/node-http/writeResponse.d.ts.map +0 -1
- package/dist/adapters/node-http/writeResponse.js +0 -83
- package/dist/adapters/node-http/writeResponse.mjs +0 -80
- package/dist/adapters/standalone.d.ts +0 -36
- package/dist/adapters/standalone.d.ts.map +0 -1
- package/dist/adapters/standalone.js +0 -49
- package/dist/adapters/ws.d.ts +0 -54
- package/dist/adapters/ws.d.ts.map +0 -1
- package/dist/adapters/ws.js +0 -544
- package/dist/http.d.ts +0 -2
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -19
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -35
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.2_rollup@4.34.8_tslib@2.8.1_typescript@5.8.2/node_modules/tslib/tslib.es6.js +0 -73
- package/dist/observable/behaviorSubject.d.ts +0 -15
- package/dist/observable/behaviorSubject.d.ts.map +0 -1
- package/dist/observable/behaviorSubject.js +0 -40
- package/dist/observable/behaviorSubject.mjs +0 -38
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -18
- package/dist/observable/observable.d.ts +0 -12
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/observable.js +0 -180
- package/dist/observable/observable.mjs +0 -175
- package/dist/observable/operators.d.ts +0 -10
- package/dist/observable/operators.d.ts.map +0 -1
- package/dist/observable/operators.js +0 -134
- package/dist/observable/operators.mjs +0 -128
- package/dist/observable/types.d.ts +0 -26
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/rpc.d.ts +0 -2
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js +0 -13
- package/dist/shared.d.ts +0 -26
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -13
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts +0 -17
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts +0 -36
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts +0 -69
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.js +0 -76
- package/dist/unstable-core-do-not-import/createProxy.mjs +0 -73
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +0 -76
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +0 -72
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -38
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +0 -7
- package/dist/unstable-core-do-not-import/error/formatter.mjs +0 -5
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +0 -31
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +0 -29
- package/dist/unstable-core-do-not-import/http/abortError.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/abortError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/abortError.js +0 -13
- package/dist/unstable-core-do-not-import/http/abortError.mjs +0 -10
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -13
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +0 -229
- package/dist/unstable-core-do-not-import/http/contentType.mjs +0 -227
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts +0 -14
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.js +0 -14
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +0 -12
- package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts +0 -2
- package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/formDataToObject.js +0 -40
- package/dist/unstable-core-do-not-import/http/formDataToObject.mjs +0 -38
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -10
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +0 -85
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +0 -78
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts +0 -4
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.js +0 -42
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.mjs +0 -39
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts +0 -15
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +0 -572
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +0 -570
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -138
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -94
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.js +0 -82
- package/dist/unstable-core-do-not-import/initTRPC.mjs +0 -80
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -107
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.js +0 -96
- package/dist/unstable-core-do-not-import/middleware.mjs +0 -90
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -44
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.js +0 -54
- package/dist/unstable-core-do-not-import/parser.mjs +0 -52
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -77
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.js +0 -9
- package/dist/unstable-core-do-not-import/procedure.mjs +0 -7
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -161
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -201
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +0 -199
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -98
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.js +0 -8
- package/dist/unstable-core-do-not-import/rootConfig.mjs +0 -6
- package/dist/unstable-core-do-not-import/router.d.ts +0 -98
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.js +0 -285
- package/dist/unstable-core-do-not-import/router.mjs +0 -278
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -45
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.js +0 -69
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +0 -65
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -109
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +0 -63
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +0 -61
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +0 -119
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +0 -607
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +0 -603
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +0 -108
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +0 -373
- package/dist/unstable-core-do-not-import/stream/sse.mjs +0 -369
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts +0 -31
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts +0 -31
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/tracked.js +0 -29
- package/dist/unstable-core-do-not-import/stream/tracked.mjs +0 -25
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +0 -174
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +0 -170
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts +0 -7
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.js +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.mjs +0 -15
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/disposable.js +0 -46
- package/dist/unstable-core-do-not-import/stream/utils/disposable.mjs +0 -43
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.js +0 -241
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.mjs +0 -239
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts +0 -8
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.js +0 -25
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.mjs +0 -23
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts +0 -5
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.js +0 -26
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.mjs +0 -23
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts +0 -7
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/withPing.js +0 -130
- package/dist/unstable-core-do-not-import/stream/utils/withPing.mjs +0 -127
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -99
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.js +0 -106
- package/dist/unstable-core-do-not-import/transformer.mjs +0 -101
- package/dist/unstable-core-do-not-import/types.d.ts +0 -127
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -42
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.js +0 -96
- package/dist/unstable-core-do-not-import/utils.mjs +0 -83
- package/dist/unstable-core-do-not-import.d.ts +0 -47
- package/dist/unstable-core-do-not-import.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import.js +0 -109
- package/dist/vendor/cookie-es/set-cookie/split.d.ts +0 -18
- package/dist/vendor/cookie-es/set-cookie/split.d.ts.map +0 -1
- package/dist/vendor/cookie-es/set-cookie/split.js +0 -79
- package/dist/vendor/cookie-es/set-cookie/split.mjs +0 -77
- package/dist/vendor/standard-schema-v1/error.d.ts +0 -13
- package/dist/vendor/standard-schema-v1/error.d.ts.map +0 -1
- package/dist/vendor/standard-schema-v1/error.js +0 -28
- package/dist/vendor/standard-schema-v1/error.mjs +0 -26
- package/dist/vendor/standard-schema-v1/spec.d.ts +0 -60
- package/dist/vendor/standard-schema-v1/spec.d.ts.map +0 -1
- package/dist/vendor/unpromise/index.d.ts +0 -3
- package/dist/vendor/unpromise/index.d.ts.map +0 -1
- package/dist/vendor/unpromise/types.d.ts +0 -28
- package/dist/vendor/unpromise/types.d.ts.map +0 -1
- package/dist/vendor/unpromise/unpromise.d.ts +0 -121
- package/dist/vendor/unpromise/unpromise.d.ts.map +0 -1
- package/dist/vendor/unpromise/unpromise.js +0 -292
- package/dist/vendor/unpromise/unpromise.mjs +0 -289
- package/http/index.d.ts +0 -1
- package/http/index.js +0 -1
- package/observable/index.d.ts +0 -1
- package/observable/index.js +0 -1
- package/rpc/index.d.ts +0 -1
- package/rpc/index.js +0 -1
- package/shared/index.d.ts +0 -1
- package/shared/index.js +0 -1
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from '../error/TRPCError.mjs';
|
|
2
|
-
import { getProcedureAtPath } from '../router.mjs';
|
|
3
|
-
import { isObject, unsetMarker } from '../utils.mjs';
|
|
4
|
-
import { parseConnectionParamsFromString } from './parseConnectionParams.mjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Memoize a function that takes no arguments
|
|
8
|
-
* @internal
|
|
9
|
-
*/ function memo(fn) {
|
|
10
|
-
let promise = null;
|
|
11
|
-
let value = unsetMarker;
|
|
12
|
-
return {
|
|
13
|
-
/**
|
|
14
|
-
* Lazily read the value
|
|
15
|
-
*/ read: async ()=>{
|
|
16
|
-
if (value !== unsetMarker) {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
// dedupes promises and catches errors
|
|
20
|
-
promise ?? (promise = fn().catch((cause)=>{
|
|
21
|
-
if (cause instanceof TRPCError) {
|
|
22
|
-
throw cause;
|
|
23
|
-
}
|
|
24
|
-
throw new TRPCError({
|
|
25
|
-
code: 'BAD_REQUEST',
|
|
26
|
-
message: cause instanceof Error ? cause.message : 'Invalid input',
|
|
27
|
-
cause
|
|
28
|
-
});
|
|
29
|
-
}));
|
|
30
|
-
value = await promise;
|
|
31
|
-
promise = null;
|
|
32
|
-
return value;
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* Get an already stored result
|
|
36
|
-
*/ result: ()=>{
|
|
37
|
-
return value !== unsetMarker ? value : undefined;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const jsonContentTypeHandler = {
|
|
42
|
-
isMatch (req) {
|
|
43
|
-
return !!req.headers.get('content-type')?.startsWith('application/json');
|
|
44
|
-
},
|
|
45
|
-
async parse (opts) {
|
|
46
|
-
const { req } = opts;
|
|
47
|
-
const isBatchCall = opts.searchParams.get('batch') === '1';
|
|
48
|
-
const paths = isBatchCall ? opts.path.split(',') : [
|
|
49
|
-
opts.path
|
|
50
|
-
];
|
|
51
|
-
const getInputs = memo(async ()=>{
|
|
52
|
-
let inputs = undefined;
|
|
53
|
-
if (req.method === 'GET') {
|
|
54
|
-
const queryInput = opts.searchParams.get('input');
|
|
55
|
-
if (queryInput) {
|
|
56
|
-
inputs = JSON.parse(queryInput);
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
inputs = await req.json();
|
|
60
|
-
}
|
|
61
|
-
if (inputs === undefined) {
|
|
62
|
-
return {};
|
|
63
|
-
}
|
|
64
|
-
if (!isBatchCall) {
|
|
65
|
-
return {
|
|
66
|
-
0: opts.router._def._config.transformer.input.deserialize(inputs)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (!isObject(inputs)) {
|
|
70
|
-
throw new TRPCError({
|
|
71
|
-
code: 'BAD_REQUEST',
|
|
72
|
-
message: '"input" needs to be an object when doing a batch call'
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const acc = {};
|
|
76
|
-
for (const index of paths.keys()){
|
|
77
|
-
const input = inputs[index];
|
|
78
|
-
if (input !== undefined) {
|
|
79
|
-
acc[index] = opts.router._def._config.transformer.input.deserialize(input);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return acc;
|
|
83
|
-
});
|
|
84
|
-
const calls = await Promise.all(paths.map(async (path, index)=>{
|
|
85
|
-
const procedure = await getProcedureAtPath(opts.router, path);
|
|
86
|
-
return {
|
|
87
|
-
path,
|
|
88
|
-
procedure,
|
|
89
|
-
getRawInput: async ()=>{
|
|
90
|
-
const inputs = await getInputs.read();
|
|
91
|
-
let input = inputs[index];
|
|
92
|
-
if (procedure?._def.type === 'subscription') {
|
|
93
|
-
const lastEventId = opts.headers.get('last-event-id') ?? opts.searchParams.get('lastEventId') ?? opts.searchParams.get('Last-Event-Id');
|
|
94
|
-
if (lastEventId) {
|
|
95
|
-
if (isObject(input)) {
|
|
96
|
-
input = {
|
|
97
|
-
...input,
|
|
98
|
-
lastEventId: lastEventId
|
|
99
|
-
};
|
|
100
|
-
} else {
|
|
101
|
-
input ?? (input = {
|
|
102
|
-
lastEventId: lastEventId
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return input;
|
|
108
|
-
},
|
|
109
|
-
result: ()=>{
|
|
110
|
-
return getInputs.result()?.[index];
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}));
|
|
114
|
-
const types = new Set(calls.map((call)=>call.procedure?._def.type).filter(Boolean));
|
|
115
|
-
/* istanbul ignore if -- @preserve */ if (types.size > 1) {
|
|
116
|
-
throw new TRPCError({
|
|
117
|
-
code: 'BAD_REQUEST',
|
|
118
|
-
message: `Cannot mix procedure types in call: ${Array.from(types).join(', ')}`
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
const type = types.values().next().value ?? 'unknown';
|
|
122
|
-
const connectionParamsStr = opts.searchParams.get('connectionParams');
|
|
123
|
-
const info = {
|
|
124
|
-
isBatchCall,
|
|
125
|
-
accept: req.headers.get('trpc-accept'),
|
|
126
|
-
calls,
|
|
127
|
-
type,
|
|
128
|
-
connectionParams: connectionParamsStr === null ? null : parseConnectionParamsFromString(connectionParamsStr),
|
|
129
|
-
signal: req.signal,
|
|
130
|
-
url: opts.url
|
|
131
|
-
};
|
|
132
|
-
return info;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
const formDataContentTypeHandler = {
|
|
136
|
-
isMatch (req) {
|
|
137
|
-
return !!req.headers.get('content-type')?.startsWith('multipart/form-data');
|
|
138
|
-
},
|
|
139
|
-
async parse (opts) {
|
|
140
|
-
const { req } = opts;
|
|
141
|
-
if (req.method !== 'POST') {
|
|
142
|
-
throw new TRPCError({
|
|
143
|
-
code: 'METHOD_NOT_SUPPORTED',
|
|
144
|
-
message: 'Only POST requests are supported for multipart/form-data requests'
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
const getInputs = memo(async ()=>{
|
|
148
|
-
const fd = await req.formData();
|
|
149
|
-
return fd;
|
|
150
|
-
});
|
|
151
|
-
const procedure = await getProcedureAtPath(opts.router, opts.path);
|
|
152
|
-
return {
|
|
153
|
-
accept: null,
|
|
154
|
-
calls: [
|
|
155
|
-
{
|
|
156
|
-
path: opts.path,
|
|
157
|
-
getRawInput: getInputs.read,
|
|
158
|
-
result: getInputs.result,
|
|
159
|
-
procedure
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
isBatchCall: false,
|
|
163
|
-
type: 'mutation',
|
|
164
|
-
connectionParams: null,
|
|
165
|
-
signal: req.signal,
|
|
166
|
-
url: opts.url
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const octetStreamContentTypeHandler = {
|
|
171
|
-
isMatch (req) {
|
|
172
|
-
return !!req.headers.get('content-type')?.startsWith('application/octet-stream');
|
|
173
|
-
},
|
|
174
|
-
async parse (opts) {
|
|
175
|
-
const { req } = opts;
|
|
176
|
-
if (req.method !== 'POST') {
|
|
177
|
-
throw new TRPCError({
|
|
178
|
-
code: 'METHOD_NOT_SUPPORTED',
|
|
179
|
-
message: 'Only POST requests are supported for application/octet-stream requests'
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
const getInputs = memo(async ()=>{
|
|
183
|
-
return req.body;
|
|
184
|
-
});
|
|
185
|
-
return {
|
|
186
|
-
calls: [
|
|
187
|
-
{
|
|
188
|
-
path: opts.path,
|
|
189
|
-
getRawInput: getInputs.read,
|
|
190
|
-
result: getInputs.result,
|
|
191
|
-
procedure: await getProcedureAtPath(opts.router, opts.path)
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
isBatchCall: false,
|
|
195
|
-
accept: null,
|
|
196
|
-
type: 'mutation',
|
|
197
|
-
connectionParams: null,
|
|
198
|
-
signal: req.signal,
|
|
199
|
-
url: opts.url
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
const handlers = [
|
|
204
|
-
jsonContentTypeHandler,
|
|
205
|
-
formDataContentTypeHandler,
|
|
206
|
-
octetStreamContentTypeHandler
|
|
207
|
-
];
|
|
208
|
-
function getContentTypeHandler(req) {
|
|
209
|
-
const handler = handlers.find((handler)=>handler.isMatch(req));
|
|
210
|
-
if (handler) {
|
|
211
|
-
return handler;
|
|
212
|
-
}
|
|
213
|
-
if (!handler && req.method === 'GET') {
|
|
214
|
-
// fallback to JSON for get requests so GET-requests can be opened in browser easily
|
|
215
|
-
return jsonContentTypeHandler;
|
|
216
|
-
}
|
|
217
|
-
throw new TRPCError({
|
|
218
|
-
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
219
|
-
message: req.headers.has('content-type') ? `Unsupported content-type "${req.headers.get('content-type')}` : 'Missing content-type header'
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
async function getRequestInfo(opts) {
|
|
223
|
-
const handler = getContentTypeHandler(opts.req);
|
|
224
|
-
return await handler.parse(opts);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export { getRequestInfo };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ParserZodEsque } from '../parser';
|
|
2
|
-
type UtilityParser<TInput, TOutput> = ParserZodEsque<TInput, TOutput> & {
|
|
3
|
-
parse: (input: unknown) => TOutput;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* File is only available from Node19+ but it always extends Blob so we can use that as a type until we eventually drop Node18
|
|
7
|
-
*/
|
|
8
|
-
interface FileLike extends Blob {
|
|
9
|
-
readonly name: string;
|
|
10
|
-
}
|
|
11
|
-
type OctetInput = Blob | Uint8Array | FileLike;
|
|
12
|
-
export declare const octetInputParser: UtilityParser<OctetInput, ReadableStream>;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=contentTypeParsers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contentTypeParsers.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentTypeParsers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,KAAK,aAAa,CAAC,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CACpC,CAAC;AAIF;;GAEG;AACH,UAAU,QAAS,SAAQ,IAAI;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,KAAK,UAAU,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC;AAC/C,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,UAAU,EAAE,cAAc,CAYtE,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const octetInputParser = {
|
|
4
|
-
_input: null,
|
|
5
|
-
_output: null,
|
|
6
|
-
parse (input) {
|
|
7
|
-
if (input instanceof ReadableStream) {
|
|
8
|
-
return input;
|
|
9
|
-
}
|
|
10
|
-
throw new Error(`Parsed input was expected to be a ReadableStream but was: ${typeof input}`);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
exports.octetInputParser = octetInputParser;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const octetInputParser = {
|
|
2
|
-
_input: null,
|
|
3
|
-
_output: null,
|
|
4
|
-
parse (input) {
|
|
5
|
-
if (input instanceof ReadableStream) {
|
|
6
|
-
return input;
|
|
7
|
-
}
|
|
8
|
-
throw new Error(`Parsed input was expected to be a ReadableStream but was: ${typeof input}`);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { octetInputParser };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formDataToObject.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/formDataToObject.ts"],"names":[],"mappings":"AAkCA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,2BASlD"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */ const isNumberString = (str)=>/^\d+$/.test(str);
|
|
4
|
-
function set(obj, path, value) {
|
|
5
|
-
if (path.length > 1) {
|
|
6
|
-
const newPath = [
|
|
7
|
-
...path
|
|
8
|
-
];
|
|
9
|
-
const key = newPath.shift();
|
|
10
|
-
const nextKey = newPath[0];
|
|
11
|
-
if (!obj[key]) {
|
|
12
|
-
obj[key] = isNumberString(nextKey) ? [] : {};
|
|
13
|
-
} else if (Array.isArray(obj[key]) && !isNumberString(nextKey)) {
|
|
14
|
-
obj[key] = Object.fromEntries(Object.entries(obj[key]));
|
|
15
|
-
}
|
|
16
|
-
set(obj[key], newPath, value);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const p = path[0];
|
|
20
|
-
if (obj[p] === undefined) {
|
|
21
|
-
obj[p] = value;
|
|
22
|
-
} else if (Array.isArray(obj[p])) {
|
|
23
|
-
obj[p].push(value);
|
|
24
|
-
} else {
|
|
25
|
-
obj[p] = [
|
|
26
|
-
obj[p],
|
|
27
|
-
value
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function formDataToObject(formData) {
|
|
32
|
-
const obj = {};
|
|
33
|
-
for (const [key, value] of formData.entries()){
|
|
34
|
-
const parts = key.split(/[\.\[\]]/).filter(Boolean);
|
|
35
|
-
set(obj, parts, value);
|
|
36
|
-
}
|
|
37
|
-
return obj;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.formDataToObject = formDataToObject;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */ const isNumberString = (str)=>/^\d+$/.test(str);
|
|
2
|
-
function set(obj, path, value) {
|
|
3
|
-
if (path.length > 1) {
|
|
4
|
-
const newPath = [
|
|
5
|
-
...path
|
|
6
|
-
];
|
|
7
|
-
const key = newPath.shift();
|
|
8
|
-
const nextKey = newPath[0];
|
|
9
|
-
if (!obj[key]) {
|
|
10
|
-
obj[key] = isNumberString(nextKey) ? [] : {};
|
|
11
|
-
} else if (Array.isArray(obj[key]) && !isNumberString(nextKey)) {
|
|
12
|
-
obj[key] = Object.fromEntries(Object.entries(obj[key]));
|
|
13
|
-
}
|
|
14
|
-
set(obj[key], newPath, value);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const p = path[0];
|
|
18
|
-
if (obj[p] === undefined) {
|
|
19
|
-
obj[p] = value;
|
|
20
|
-
} else if (Array.isArray(obj[p])) {
|
|
21
|
-
obj[p].push(value);
|
|
22
|
-
} else {
|
|
23
|
-
obj[p] = [
|
|
24
|
-
obj[p],
|
|
25
|
-
value
|
|
26
|
-
];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function formDataToObject(formData) {
|
|
30
|
-
const obj = {};
|
|
31
|
-
for (const [key, value] of formData.entries()){
|
|
32
|
-
const parts = key.split(/[\.\[\]]/).filter(Boolean);
|
|
33
|
-
set(obj, parts, value);
|
|
34
|
-
}
|
|
35
|
-
return obj;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { formDataToObject };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TRPCError } from '../error/TRPCError';
|
|
2
|
-
import type { TRPC_ERROR_CODES_BY_KEY, TRPCResponse } from '../rpc';
|
|
3
|
-
import type { InvertKeyValue, ValueOf } from '../types';
|
|
4
|
-
export declare const JSONRPC2_TO_HTTP_CODE: Record<keyof typeof TRPC_ERROR_CODES_BY_KEY, number>;
|
|
5
|
-
export declare const HTTP_CODE_TO_JSONRPC2: InvertKeyValue<typeof JSONRPC2_TO_HTTP_CODE>;
|
|
6
|
-
export declare function getStatusCodeFromKey(code: keyof typeof TRPC_ERROR_CODES_BY_KEY): number;
|
|
7
|
-
export declare function getStatusKeyFromCode(code: keyof typeof HTTP_CODE_TO_JSONRPC2): ValueOf<typeof HTTP_CODE_TO_JSONRPC2>;
|
|
8
|
-
export declare function getHTTPStatusCode(json: TRPCResponse | TRPCResponse[]): number;
|
|
9
|
-
export declare function getHTTPStatusCodeFromError(error: TRPCError): number;
|
|
10
|
-
//# sourceMappingURL=getHTTPStatusCode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getHTTPStatusCode.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,MAAM,OAAO,uBAAuB,EACpC,MAAM,CAsBP,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAChD,OAAO,qBAAqB,CAqBpB,CAAC;AAEX,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,OAAO,uBAAuB,UAG3C;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,OAAO,qBAAqB,GACvC,OAAO,CAAC,OAAO,qBAAqB,CAAC,CAEvC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,UAuBpE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,UAE1D"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var codes = require('../rpc/codes.js');
|
|
4
|
-
var utils = require('../utils.js');
|
|
5
|
-
|
|
6
|
-
const JSONRPC2_TO_HTTP_CODE = {
|
|
7
|
-
PARSE_ERROR: 400,
|
|
8
|
-
BAD_REQUEST: 400,
|
|
9
|
-
UNAUTHORIZED: 401,
|
|
10
|
-
PAYMENT_REQUIRED: 402,
|
|
11
|
-
FORBIDDEN: 403,
|
|
12
|
-
NOT_FOUND: 404,
|
|
13
|
-
METHOD_NOT_SUPPORTED: 405,
|
|
14
|
-
TIMEOUT: 408,
|
|
15
|
-
CONFLICT: 409,
|
|
16
|
-
PRECONDITION_FAILED: 412,
|
|
17
|
-
PAYLOAD_TOO_LARGE: 413,
|
|
18
|
-
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
19
|
-
UNPROCESSABLE_CONTENT: 422,
|
|
20
|
-
TOO_MANY_REQUESTS: 429,
|
|
21
|
-
CLIENT_CLOSED_REQUEST: 499,
|
|
22
|
-
INTERNAL_SERVER_ERROR: 500,
|
|
23
|
-
NOT_IMPLEMENTED: 501,
|
|
24
|
-
BAD_GATEWAY: 502,
|
|
25
|
-
SERVICE_UNAVAILABLE: 503,
|
|
26
|
-
GATEWAY_TIMEOUT: 504
|
|
27
|
-
};
|
|
28
|
-
const HTTP_CODE_TO_JSONRPC2 = {
|
|
29
|
-
400: 'BAD_REQUEST',
|
|
30
|
-
401: 'UNAUTHORIZED',
|
|
31
|
-
402: 'PAYMENT_REQUIRED',
|
|
32
|
-
403: 'FORBIDDEN',
|
|
33
|
-
404: 'NOT_FOUND',
|
|
34
|
-
405: 'METHOD_NOT_SUPPORTED',
|
|
35
|
-
408: 'TIMEOUT',
|
|
36
|
-
409: 'CONFLICT',
|
|
37
|
-
412: 'PRECONDITION_FAILED',
|
|
38
|
-
413: 'PAYLOAD_TOO_LARGE',
|
|
39
|
-
415: 'UNSUPPORTED_MEDIA_TYPE',
|
|
40
|
-
422: 'UNPROCESSABLE_CONTENT',
|
|
41
|
-
429: 'TOO_MANY_REQUESTS',
|
|
42
|
-
499: 'CLIENT_CLOSED_REQUEST',
|
|
43
|
-
500: 'INTERNAL_SERVER_ERROR',
|
|
44
|
-
501: 'NOT_IMPLEMENTED',
|
|
45
|
-
502: 'BAD_GATEWAY',
|
|
46
|
-
503: 'SERVICE_UNAVAILABLE',
|
|
47
|
-
504: 'GATEWAY_TIMEOUT'
|
|
48
|
-
};
|
|
49
|
-
function getStatusCodeFromKey(code) {
|
|
50
|
-
return JSONRPC2_TO_HTTP_CODE[code] ?? 500;
|
|
51
|
-
}
|
|
52
|
-
function getStatusKeyFromCode(code) {
|
|
53
|
-
return HTTP_CODE_TO_JSONRPC2[code] ?? 'INTERNAL_SERVER_ERROR';
|
|
54
|
-
}
|
|
55
|
-
function getHTTPStatusCode(json) {
|
|
56
|
-
const arr = Array.isArray(json) ? json : [
|
|
57
|
-
json
|
|
58
|
-
];
|
|
59
|
-
const httpStatuses = new Set(arr.map((res)=>{
|
|
60
|
-
if ('error' in res && utils.isObject(res.error.data)) {
|
|
61
|
-
if (typeof res.error.data?.['httpStatus'] === 'number') {
|
|
62
|
-
return res.error.data['httpStatus'];
|
|
63
|
-
}
|
|
64
|
-
const code = codes.TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
65
|
-
return getStatusCodeFromKey(code);
|
|
66
|
-
}
|
|
67
|
-
return 200;
|
|
68
|
-
}));
|
|
69
|
-
if (httpStatuses.size !== 1) {
|
|
70
|
-
return 207;
|
|
71
|
-
}
|
|
72
|
-
const httpStatus = httpStatuses.values().next().value;
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
74
|
-
return httpStatus;
|
|
75
|
-
}
|
|
76
|
-
function getHTTPStatusCodeFromError(error) {
|
|
77
|
-
return getStatusCodeFromKey(error.code);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
exports.HTTP_CODE_TO_JSONRPC2 = HTTP_CODE_TO_JSONRPC2;
|
|
81
|
-
exports.JSONRPC2_TO_HTTP_CODE = JSONRPC2_TO_HTTP_CODE;
|
|
82
|
-
exports.getHTTPStatusCode = getHTTPStatusCode;
|
|
83
|
-
exports.getHTTPStatusCodeFromError = getHTTPStatusCodeFromError;
|
|
84
|
-
exports.getStatusCodeFromKey = getStatusCodeFromKey;
|
|
85
|
-
exports.getStatusKeyFromCode = getStatusKeyFromCode;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { TRPC_ERROR_CODES_BY_NUMBER } from '../rpc/codes.mjs';
|
|
2
|
-
import { isObject } from '../utils.mjs';
|
|
3
|
-
|
|
4
|
-
const JSONRPC2_TO_HTTP_CODE = {
|
|
5
|
-
PARSE_ERROR: 400,
|
|
6
|
-
BAD_REQUEST: 400,
|
|
7
|
-
UNAUTHORIZED: 401,
|
|
8
|
-
PAYMENT_REQUIRED: 402,
|
|
9
|
-
FORBIDDEN: 403,
|
|
10
|
-
NOT_FOUND: 404,
|
|
11
|
-
METHOD_NOT_SUPPORTED: 405,
|
|
12
|
-
TIMEOUT: 408,
|
|
13
|
-
CONFLICT: 409,
|
|
14
|
-
PRECONDITION_FAILED: 412,
|
|
15
|
-
PAYLOAD_TOO_LARGE: 413,
|
|
16
|
-
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
17
|
-
UNPROCESSABLE_CONTENT: 422,
|
|
18
|
-
TOO_MANY_REQUESTS: 429,
|
|
19
|
-
CLIENT_CLOSED_REQUEST: 499,
|
|
20
|
-
INTERNAL_SERVER_ERROR: 500,
|
|
21
|
-
NOT_IMPLEMENTED: 501,
|
|
22
|
-
BAD_GATEWAY: 502,
|
|
23
|
-
SERVICE_UNAVAILABLE: 503,
|
|
24
|
-
GATEWAY_TIMEOUT: 504
|
|
25
|
-
};
|
|
26
|
-
const HTTP_CODE_TO_JSONRPC2 = {
|
|
27
|
-
400: 'BAD_REQUEST',
|
|
28
|
-
401: 'UNAUTHORIZED',
|
|
29
|
-
402: 'PAYMENT_REQUIRED',
|
|
30
|
-
403: 'FORBIDDEN',
|
|
31
|
-
404: 'NOT_FOUND',
|
|
32
|
-
405: 'METHOD_NOT_SUPPORTED',
|
|
33
|
-
408: 'TIMEOUT',
|
|
34
|
-
409: 'CONFLICT',
|
|
35
|
-
412: 'PRECONDITION_FAILED',
|
|
36
|
-
413: 'PAYLOAD_TOO_LARGE',
|
|
37
|
-
415: 'UNSUPPORTED_MEDIA_TYPE',
|
|
38
|
-
422: 'UNPROCESSABLE_CONTENT',
|
|
39
|
-
429: 'TOO_MANY_REQUESTS',
|
|
40
|
-
499: 'CLIENT_CLOSED_REQUEST',
|
|
41
|
-
500: 'INTERNAL_SERVER_ERROR',
|
|
42
|
-
501: 'NOT_IMPLEMENTED',
|
|
43
|
-
502: 'BAD_GATEWAY',
|
|
44
|
-
503: 'SERVICE_UNAVAILABLE',
|
|
45
|
-
504: 'GATEWAY_TIMEOUT'
|
|
46
|
-
};
|
|
47
|
-
function getStatusCodeFromKey(code) {
|
|
48
|
-
return JSONRPC2_TO_HTTP_CODE[code] ?? 500;
|
|
49
|
-
}
|
|
50
|
-
function getStatusKeyFromCode(code) {
|
|
51
|
-
return HTTP_CODE_TO_JSONRPC2[code] ?? 'INTERNAL_SERVER_ERROR';
|
|
52
|
-
}
|
|
53
|
-
function getHTTPStatusCode(json) {
|
|
54
|
-
const arr = Array.isArray(json) ? json : [
|
|
55
|
-
json
|
|
56
|
-
];
|
|
57
|
-
const httpStatuses = new Set(arr.map((res)=>{
|
|
58
|
-
if ('error' in res && isObject(res.error.data)) {
|
|
59
|
-
if (typeof res.error.data?.['httpStatus'] === 'number') {
|
|
60
|
-
return res.error.data['httpStatus'];
|
|
61
|
-
}
|
|
62
|
-
const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
63
|
-
return getStatusCodeFromKey(code);
|
|
64
|
-
}
|
|
65
|
-
return 200;
|
|
66
|
-
}));
|
|
67
|
-
if (httpStatuses.size !== 1) {
|
|
68
|
-
return 207;
|
|
69
|
-
}
|
|
70
|
-
const httpStatus = httpStatuses.values().next().value;
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
-
return httpStatus;
|
|
73
|
-
}
|
|
74
|
-
function getHTTPStatusCodeFromError(error) {
|
|
75
|
-
return getStatusCodeFromKey(error.code);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { HTTP_CODE_TO_JSONRPC2, JSONRPC2_TO_HTTP_CODE, getHTTPStatusCode, getHTTPStatusCodeFromError, getStatusCodeFromKey, getStatusKeyFromCode };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TRPCRequestInfo } from './types';
|
|
2
|
-
export declare function parseConnectionParamsFromUnknown(parsed: unknown): TRPCRequestInfo['connectionParams'];
|
|
3
|
-
export declare function parseConnectionParamsFromString(str: string): TRPCRequestInfo['connectionParams'];
|
|
4
|
-
//# sourceMappingURL=parseConnectionParams.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseConnectionParams.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/parseConnectionParams.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,OAAO,GACd,eAAe,CAAC,kBAAkB,CAAC,CA2BrC;AACD,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,GACV,eAAe,CAAC,kBAAkB,CAAC,CAYrC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var TRPCError = require('../error/TRPCError.js');
|
|
4
|
-
var utils = require('../utils.js');
|
|
5
|
-
|
|
6
|
-
function parseConnectionParamsFromUnknown(parsed) {
|
|
7
|
-
try {
|
|
8
|
-
if (parsed === null) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
if (!utils.isObject(parsed)) {
|
|
12
|
-
throw new Error('Expected object');
|
|
13
|
-
}
|
|
14
|
-
const nonStringValues = Object.entries(parsed).filter(([_key, value])=>typeof value !== 'string');
|
|
15
|
-
if (nonStringValues.length > 0) {
|
|
16
|
-
throw new Error(`Expected connectionParams to be string values. Got ${nonStringValues.map(([key, value])=>`${key}: ${typeof value}`).join(', ')}`);
|
|
17
|
-
}
|
|
18
|
-
return parsed;
|
|
19
|
-
} catch (cause) {
|
|
20
|
-
throw new TRPCError.TRPCError({
|
|
21
|
-
code: 'PARSE_ERROR',
|
|
22
|
-
message: 'Invalid connection params shape',
|
|
23
|
-
cause
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function parseConnectionParamsFromString(str) {
|
|
28
|
-
let parsed;
|
|
29
|
-
try {
|
|
30
|
-
parsed = JSON.parse(str);
|
|
31
|
-
} catch (cause) {
|
|
32
|
-
throw new TRPCError.TRPCError({
|
|
33
|
-
code: 'PARSE_ERROR',
|
|
34
|
-
message: 'Not JSON-parsable query params',
|
|
35
|
-
cause
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return parseConnectionParamsFromUnknown(parsed);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.parseConnectionParamsFromString = parseConnectionParamsFromString;
|
|
42
|
-
exports.parseConnectionParamsFromUnknown = parseConnectionParamsFromUnknown;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from '../error/TRPCError.mjs';
|
|
2
|
-
import { isObject } from '../utils.mjs';
|
|
3
|
-
|
|
4
|
-
function parseConnectionParamsFromUnknown(parsed) {
|
|
5
|
-
try {
|
|
6
|
-
if (parsed === null) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
if (!isObject(parsed)) {
|
|
10
|
-
throw new Error('Expected object');
|
|
11
|
-
}
|
|
12
|
-
const nonStringValues = Object.entries(parsed).filter(([_key, value])=>typeof value !== 'string');
|
|
13
|
-
if (nonStringValues.length > 0) {
|
|
14
|
-
throw new Error(`Expected connectionParams to be string values. Got ${nonStringValues.map(([key, value])=>`${key}: ${typeof value}`).join(', ')}`);
|
|
15
|
-
}
|
|
16
|
-
return parsed;
|
|
17
|
-
} catch (cause) {
|
|
18
|
-
throw new TRPCError({
|
|
19
|
-
code: 'PARSE_ERROR',
|
|
20
|
-
message: 'Invalid connection params shape',
|
|
21
|
-
cause
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function parseConnectionParamsFromString(str) {
|
|
26
|
-
let parsed;
|
|
27
|
-
try {
|
|
28
|
-
parsed = JSON.parse(str);
|
|
29
|
-
} catch (cause) {
|
|
30
|
-
throw new TRPCError({
|
|
31
|
-
code: 'PARSE_ERROR',
|
|
32
|
-
message: 'Not JSON-parsable query params',
|
|
33
|
-
cause
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return parseConnectionParamsFromUnknown(parsed);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TRPCError } from '../error/TRPCError';
|
|
2
|
-
import { type AnyRouter } from '../router';
|
|
3
|
-
import type { HTTPBaseHandlerOptions, ResolveHTTPRequestOptionsContextFn } from './types';
|
|
4
|
-
interface ResolveHTTPRequestOptions<TRouter extends AnyRouter> extends HTTPBaseHandlerOptions<TRouter, Request> {
|
|
5
|
-
createContext: ResolveHTTPRequestOptionsContextFn<TRouter>;
|
|
6
|
-
req: Request;
|
|
7
|
-
path: string;
|
|
8
|
-
/**
|
|
9
|
-
* If the request had an issue before reaching the handler
|
|
10
|
-
*/
|
|
11
|
-
error: TRPCError | null;
|
|
12
|
-
}
|
|
13
|
-
export declare function resolveResponse<TRouter extends AnyRouter>(opts: ResolveHTTPRequestOptions<TRouter>): Promise<Response>;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=resolveResponse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA+BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AA2ID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAqfnB"}
|