@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
package/dist/http.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { resolveHTTPResponse } from './@trpc-core-unstable-do-not-import-this-please';
|
|
3
|
-
export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPRequest, HTTPResponse, OnErrorFunction, ProcedureCall, ResolveHTTPRequestOptionsContextFn, ResponseChunk, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from './@trpc-core-unstable-do-not-import-this-please';
|
|
4
|
-
export { getBatchStreamFormatter } from './@trpc-core-unstable-do-not-import-this-please';
|
|
5
|
-
export type { BaseContentTypeHandler, BodyResult, } from './@trpc-core-unstable-do-not-import-this-please';
|
|
6
|
-
export { getJsonContentTypeInputs } from './@trpc-core-unstable-do-not-import-this-please';
|
|
1
|
+
export * from './@trpc/server/http';
|
|
7
2
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
package/dist/http.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
|
|
4
|
+
require('./unstable-core-do-not-import/rpc/codes.js');
|
|
5
|
+
require('./unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
7
|
+
var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
8
|
+
var contentType = require('./unstable-core-do-not-import/http/contentType.js');
|
|
4
9
|
|
|
5
|
-
var core = require('@trpc/core');
|
|
6
10
|
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, 'getHTTPStatusCode', {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return core.getHTTPStatusCode; }
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, 'getHTTPStatusCodeFromError', {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return core.getHTTPStatusCodeFromError; }
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(exports, 'getJsonContentTypeInputs', {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return core.getJsonContentTypeInputs; }
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, 'resolveHTTPResponse', {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return core.resolveHTTPResponse; }
|
|
28
|
-
});
|
|
12
|
+
exports.getHTTPStatusCode = getHTTPStatusCode.getHTTPStatusCode;
|
|
13
|
+
exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromError;
|
|
14
|
+
exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
|
|
15
|
+
exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
|
|
16
|
+
exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
|
package/dist/http.mjs
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
|
|
2
|
+
import './unstable-core-do-not-import/rpc/codes.mjs';
|
|
3
|
+
import './unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
5
|
+
export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
6
|
+
export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
export
|
|
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 './@trpc-core-unstable-do-not-import-this-please';
|
|
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 '@trpc/core';
|
|
55
|
-
export {
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated use `getTRPCErrorShape` instead
|
|
58
|
-
*/
|
|
59
|
-
getErrorShape,
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated use `callTRPCProcedure` instead
|
|
62
|
-
*/
|
|
63
|
-
callProcedure, } from '@trpc/core';
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated
|
|
66
|
-
* Use `Awaited<ReturnType<typeof myFunction>>` instead
|
|
67
|
-
*/
|
|
68
|
-
export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> = Awaited<ReturnType<TFunction>>;
|
|
1
|
+
export * from './@trpc/server';
|
|
69
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,48 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var getErrorShape = require('./unstable-core-do-not-import/error/getErrorShape.js');
|
|
4
|
+
var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
|
|
5
|
+
var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
|
|
6
|
+
var middleware = require('./unstable-core-do-not-import/middleware.js');
|
|
7
|
+
var router = require('./unstable-core-do-not-import/router.js');
|
|
8
|
+
var transformer = require('./unstable-core-do-not-import/transformer.js');
|
|
9
|
+
var createProxy = require('./unstable-core-do-not-import/createProxy.js');
|
|
10
|
+
require('./unstable-core-do-not-import/rpc/codes.js');
|
|
4
11
|
|
|
5
|
-
var core = require('@trpc/core');
|
|
6
12
|
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return core.callProcedure; }
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(exports, 'createTRPCFlatProxy', {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return core.createFlatProxy; }
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, 'experimental_standaloneMiddleware', {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return core.experimental_standaloneMiddleware; }
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, 'experimental_trpcMiddleware', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () { return core.experimental_standaloneMiddleware; }
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(exports, 'getErrorShape', {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () { return core.getErrorShape; }
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, 'getTRPCErrorFromUnknown', {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () { return core.getTRPCErrorFromUnknown; }
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(exports, 'initTRPC', {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () { return core.initTRPC; }
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(exports, 'transformTRPCResponse', {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () { return core.transformTRPCResponse; }
|
|
48
|
-
});
|
|
14
|
+
exports.getErrorShape = getErrorShape.getErrorShape;
|
|
15
|
+
exports.TRPCError = TRPCError.TRPCError;
|
|
16
|
+
exports.getTRPCErrorFromUnknown = TRPCError.getTRPCErrorFromUnknown;
|
|
17
|
+
exports.initTRPC = initTRPC.initTRPC;
|
|
18
|
+
exports.experimental_standaloneMiddleware = middleware.experimental_standaloneMiddleware;
|
|
19
|
+
exports.experimental_trpcMiddleware = middleware.experimental_standaloneMiddleware;
|
|
20
|
+
exports.callProcedure = router.callProcedure;
|
|
21
|
+
exports.callTRPCProcedure = router.callProcedure;
|
|
22
|
+
exports.transformTRPCResponse = transformer.transformTRPCResponse;
|
|
23
|
+
exports.createTRPCFlatProxy = createProxy.createFlatProxy;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
|
+
export { TRPCError, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
+
export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
|
|
4
|
+
export { experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware } from './unstable-core-do-not-import/middleware.mjs';
|
|
5
|
+
export { callProcedure, callProcedure as callTRPCProcedure } from './unstable-core-do-not-import/router.mjs';
|
|
6
|
+
export { transformTRPCResponse } from './unstable-core-do-not-import/transformer.mjs';
|
|
7
|
+
export { createFlatProxy as createTRPCFlatProxy } from './unstable-core-do-not-import/createProxy.mjs';
|
|
8
|
+
import './unstable-core-do-not-import/rpc/codes.mjs';
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var search = require('./search.js');
|
|
4
|
+
var utils = require('./utils.js');
|
|
5
|
+
|
|
6
|
+
const mergeArrays2 = Function.prototype.apply.bind(utils.mergeArrays, undefined);
|
|
7
|
+
const dash = utils.stringToArray('--');
|
|
8
|
+
const CRLF = utils.stringToArray('\r\n');
|
|
9
|
+
function parseContentDisposition(header) {
|
|
10
|
+
const parts = header.split(';').map(part => part.trim());
|
|
11
|
+
if (parts.shift() !== 'form-data') {
|
|
12
|
+
throw new Error('malformed content-disposition header: missing "form-data" in `' + JSON.stringify(parts) + '`');
|
|
13
|
+
}
|
|
14
|
+
const out = {};
|
|
15
|
+
for (const part of parts) {
|
|
16
|
+
const kv = part.split('=', 2);
|
|
17
|
+
if (kv.length !== 2) {
|
|
18
|
+
throw new Error('malformed content-disposition header: key-value pair not found - ' + part + ' in `' + header + '`');
|
|
19
|
+
}
|
|
20
|
+
const [name, value] = kv;
|
|
21
|
+
if (value[0] === '"' && value[value.length - 1] === '"') {
|
|
22
|
+
out[name] = value.slice(1, -1).replace(/\\"/g, '"');
|
|
23
|
+
} else if (value[0] !== '"' && value[value.length - 1] !== '"') {
|
|
24
|
+
out[name] = value;
|
|
25
|
+
} else if (value[0] === '"' && value[value.length - 1] !== '"' || value[0] !== '"' && value[value.length - 1] === '"') {
|
|
26
|
+
throw new Error('malformed content-disposition header: mismatched quotations in `' + header + '`');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!out.name) {
|
|
30
|
+
throw new Error('malformed content-disposition header: missing field name in `' + header + '`');
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
function parsePartHeaders(lines) {
|
|
35
|
+
const entries = [];
|
|
36
|
+
let disposition = false;
|
|
37
|
+
let line;
|
|
38
|
+
while (typeof (line = lines.shift()) !== 'undefined') {
|
|
39
|
+
const colon = line.indexOf(':');
|
|
40
|
+
if (colon === -1) {
|
|
41
|
+
throw new Error('malformed multipart-form header: missing colon');
|
|
42
|
+
}
|
|
43
|
+
const header = line.slice(0, colon).trim().toLowerCase();
|
|
44
|
+
const value = line.slice(colon + 1).trim();
|
|
45
|
+
switch (header) {
|
|
46
|
+
case 'content-disposition':
|
|
47
|
+
disposition = true;
|
|
48
|
+
entries.push(...Object.entries(parseContentDisposition(value)));
|
|
49
|
+
break;
|
|
50
|
+
case 'content-type':
|
|
51
|
+
entries.push([
|
|
52
|
+
'contentType',
|
|
53
|
+
value
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!disposition) {
|
|
58
|
+
throw new Error('malformed multipart-form header: missing content-disposition');
|
|
59
|
+
}
|
|
60
|
+
return Object.fromEntries(entries);
|
|
61
|
+
}
|
|
62
|
+
async function readHeaderLines(it, needle) {
|
|
63
|
+
let firstChunk = true;
|
|
64
|
+
let lastTokenWasMatch = false;
|
|
65
|
+
const headerLines = [[]];
|
|
66
|
+
const crlfSearch = new search.StreamSearch(CRLF);
|
|
67
|
+
for (;;) {
|
|
68
|
+
const result = await it.next();
|
|
69
|
+
if (result.done) {
|
|
70
|
+
throw new Error('malformed multipart-form data: unexpected end of stream');
|
|
71
|
+
}
|
|
72
|
+
if (firstChunk && result.value !== search.MATCH && utils.arraysEqual(result.value.slice(0, 2), dash)) {
|
|
73
|
+
return [
|
|
74
|
+
undefined,
|
|
75
|
+
new Uint8Array()
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
let chunk;
|
|
79
|
+
if (result.value !== search.MATCH) {
|
|
80
|
+
chunk = result.value;
|
|
81
|
+
} else if (!lastTokenWasMatch) {
|
|
82
|
+
chunk = needle;
|
|
83
|
+
} else {
|
|
84
|
+
throw new Error('malformed multipart-form data: unexpected boundary');
|
|
85
|
+
}
|
|
86
|
+
if (!chunk.length) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (firstChunk) {
|
|
90
|
+
firstChunk = false;
|
|
91
|
+
}
|
|
92
|
+
const tokens = crlfSearch.feed(chunk);
|
|
93
|
+
for (const [i, token] of tokens.entries()) {
|
|
94
|
+
const isMatch = token === search.MATCH;
|
|
95
|
+
if (!isMatch && !token.length) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (lastTokenWasMatch && isMatch) {
|
|
99
|
+
tokens.push(crlfSearch.end());
|
|
100
|
+
return [
|
|
101
|
+
headerLines.filter(chunks => chunks.length).map(mergeArrays2).map(utils.arrayToString),
|
|
102
|
+
utils.mergeArrays(...tokens.slice(i + 1).map(token => token === search.MATCH ? CRLF : token))
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
if (lastTokenWasMatch = isMatch) {
|
|
106
|
+
headerLines.push([]);
|
|
107
|
+
} else {
|
|
108
|
+
headerLines[headerLines.length - 1].push(token);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function* streamMultipart(body, boundary) {
|
|
114
|
+
const needle = utils.mergeArrays(dash, utils.stringToArray(boundary));
|
|
115
|
+
const it = new search.ReadableStreamSearch(needle, body)[Symbol.asyncIterator]();
|
|
116
|
+
for (;;) {
|
|
117
|
+
const result = await it.next();
|
|
118
|
+
if (result.done) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (result.value === search.MATCH) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const crlfSearch = new search.StreamSearch(CRLF);
|
|
126
|
+
for (;;) {
|
|
127
|
+
const [headerLines, tail] = await readHeaderLines(it, needle);
|
|
128
|
+
if (!headerLines) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
async function nextToken() {
|
|
132
|
+
const result = await it.next();
|
|
133
|
+
if (result.done) {
|
|
134
|
+
throw new Error('malformed multipart-form data: unexpected end of stream');
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
let trailingCRLF = false;
|
|
139
|
+
function feedChunk(chunk) {
|
|
140
|
+
const chunks = [];
|
|
141
|
+
for (const token of crlfSearch.feed(chunk)) {
|
|
142
|
+
if (trailingCRLF) {
|
|
143
|
+
chunks.push(CRLF);
|
|
144
|
+
}
|
|
145
|
+
if (!(trailingCRLF = token === search.MATCH)) {
|
|
146
|
+
chunks.push(token);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return utils.mergeArrays(...chunks);
|
|
150
|
+
}
|
|
151
|
+
let done = false;
|
|
152
|
+
async function nextChunk() {
|
|
153
|
+
const result = await nextToken();
|
|
154
|
+
let chunk;
|
|
155
|
+
if (result.value !== search.MATCH) {
|
|
156
|
+
chunk = result.value;
|
|
157
|
+
} else if (!trailingCRLF) {
|
|
158
|
+
chunk = CRLF;
|
|
159
|
+
} else {
|
|
160
|
+
done = true;
|
|
161
|
+
return { value: crlfSearch.end() };
|
|
162
|
+
}
|
|
163
|
+
return { value: feedChunk(chunk) };
|
|
164
|
+
}
|
|
165
|
+
const bufferedChunks = [{ value: feedChunk(tail) }];
|
|
166
|
+
yield {
|
|
167
|
+
...parsePartHeaders(headerLines),
|
|
168
|
+
data: {
|
|
169
|
+
[Symbol.asyncIterator]() {
|
|
170
|
+
return this;
|
|
171
|
+
},
|
|
172
|
+
async next() {
|
|
173
|
+
for (;;) {
|
|
174
|
+
const result = bufferedChunks.shift();
|
|
175
|
+
if (!result) {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
if (result.value.length > 0) {
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (;;) {
|
|
183
|
+
if (done) {
|
|
184
|
+
return {
|
|
185
|
+
done,
|
|
186
|
+
value: undefined
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const result = await nextChunk();
|
|
190
|
+
if (result.value.length > 0) {
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
while (!done) {
|
|
198
|
+
bufferedChunks.push(await nextChunk());
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
exports.streamMultipart = streamMultipart;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ReadableStreamSearch, MATCH, StreamSearch } from './search.mjs';
|
|
2
|
+
import { mergeArrays, stringToArray, arraysEqual, arrayToString } from './utils.mjs';
|
|
3
|
+
|
|
4
|
+
const mergeArrays2 = Function.prototype.apply.bind(mergeArrays, undefined);
|
|
5
|
+
const dash = stringToArray('--');
|
|
6
|
+
const CRLF = stringToArray('\r\n');
|
|
7
|
+
function parseContentDisposition(header) {
|
|
8
|
+
const parts = header.split(';').map(part => part.trim());
|
|
9
|
+
if (parts.shift() !== 'form-data') {
|
|
10
|
+
throw new Error('malformed content-disposition header: missing "form-data" in `' + JSON.stringify(parts) + '`');
|
|
11
|
+
}
|
|
12
|
+
const out = {};
|
|
13
|
+
for (const part of parts) {
|
|
14
|
+
const kv = part.split('=', 2);
|
|
15
|
+
if (kv.length !== 2) {
|
|
16
|
+
throw new Error('malformed content-disposition header: key-value pair not found - ' + part + ' in `' + header + '`');
|
|
17
|
+
}
|
|
18
|
+
const [name, value] = kv;
|
|
19
|
+
if (value[0] === '"' && value[value.length - 1] === '"') {
|
|
20
|
+
out[name] = value.slice(1, -1).replace(/\\"/g, '"');
|
|
21
|
+
} else if (value[0] !== '"' && value[value.length - 1] !== '"') {
|
|
22
|
+
out[name] = value;
|
|
23
|
+
} else if (value[0] === '"' && value[value.length - 1] !== '"' || value[0] !== '"' && value[value.length - 1] === '"') {
|
|
24
|
+
throw new Error('malformed content-disposition header: mismatched quotations in `' + header + '`');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!out.name) {
|
|
28
|
+
throw new Error('malformed content-disposition header: missing field name in `' + header + '`');
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
function parsePartHeaders(lines) {
|
|
33
|
+
const entries = [];
|
|
34
|
+
let disposition = false;
|
|
35
|
+
let line;
|
|
36
|
+
while (typeof (line = lines.shift()) !== 'undefined') {
|
|
37
|
+
const colon = line.indexOf(':');
|
|
38
|
+
if (colon === -1) {
|
|
39
|
+
throw new Error('malformed multipart-form header: missing colon');
|
|
40
|
+
}
|
|
41
|
+
const header = line.slice(0, colon).trim().toLowerCase();
|
|
42
|
+
const value = line.slice(colon + 1).trim();
|
|
43
|
+
switch (header) {
|
|
44
|
+
case 'content-disposition':
|
|
45
|
+
disposition = true;
|
|
46
|
+
entries.push(...Object.entries(parseContentDisposition(value)));
|
|
47
|
+
break;
|
|
48
|
+
case 'content-type':
|
|
49
|
+
entries.push([
|
|
50
|
+
'contentType',
|
|
51
|
+
value
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!disposition) {
|
|
56
|
+
throw new Error('malformed multipart-form header: missing content-disposition');
|
|
57
|
+
}
|
|
58
|
+
return Object.fromEntries(entries);
|
|
59
|
+
}
|
|
60
|
+
async function readHeaderLines(it, needle) {
|
|
61
|
+
let firstChunk = true;
|
|
62
|
+
let lastTokenWasMatch = false;
|
|
63
|
+
const headerLines = [[]];
|
|
64
|
+
const crlfSearch = new StreamSearch(CRLF);
|
|
65
|
+
for (;;) {
|
|
66
|
+
const result = await it.next();
|
|
67
|
+
if (result.done) {
|
|
68
|
+
throw new Error('malformed multipart-form data: unexpected end of stream');
|
|
69
|
+
}
|
|
70
|
+
if (firstChunk && result.value !== MATCH && arraysEqual(result.value.slice(0, 2), dash)) {
|
|
71
|
+
return [
|
|
72
|
+
undefined,
|
|
73
|
+
new Uint8Array()
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
let chunk;
|
|
77
|
+
if (result.value !== MATCH) {
|
|
78
|
+
chunk = result.value;
|
|
79
|
+
} else if (!lastTokenWasMatch) {
|
|
80
|
+
chunk = needle;
|
|
81
|
+
} else {
|
|
82
|
+
throw new Error('malformed multipart-form data: unexpected boundary');
|
|
83
|
+
}
|
|
84
|
+
if (!chunk.length) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (firstChunk) {
|
|
88
|
+
firstChunk = false;
|
|
89
|
+
}
|
|
90
|
+
const tokens = crlfSearch.feed(chunk);
|
|
91
|
+
for (const [i, token] of tokens.entries()) {
|
|
92
|
+
const isMatch = token === MATCH;
|
|
93
|
+
if (!isMatch && !token.length) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (lastTokenWasMatch && isMatch) {
|
|
97
|
+
tokens.push(crlfSearch.end());
|
|
98
|
+
return [
|
|
99
|
+
headerLines.filter(chunks => chunks.length).map(mergeArrays2).map(arrayToString),
|
|
100
|
+
mergeArrays(...tokens.slice(i + 1).map(token => token === MATCH ? CRLF : token))
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
if (lastTokenWasMatch = isMatch) {
|
|
104
|
+
headerLines.push([]);
|
|
105
|
+
} else {
|
|
106
|
+
headerLines[headerLines.length - 1].push(token);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function* streamMultipart(body, boundary) {
|
|
112
|
+
const needle = mergeArrays(dash, stringToArray(boundary));
|
|
113
|
+
const it = new ReadableStreamSearch(needle, body)[Symbol.asyncIterator]();
|
|
114
|
+
for (;;) {
|
|
115
|
+
const result = await it.next();
|
|
116
|
+
if (result.done) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (result.value === MATCH) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const crlfSearch = new StreamSearch(CRLF);
|
|
124
|
+
for (;;) {
|
|
125
|
+
const [headerLines, tail] = await readHeaderLines(it, needle);
|
|
126
|
+
if (!headerLines) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
async function nextToken() {
|
|
130
|
+
const result = await it.next();
|
|
131
|
+
if (result.done) {
|
|
132
|
+
throw new Error('malformed multipart-form data: unexpected end of stream');
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
let trailingCRLF = false;
|
|
137
|
+
function feedChunk(chunk) {
|
|
138
|
+
const chunks = [];
|
|
139
|
+
for (const token of crlfSearch.feed(chunk)) {
|
|
140
|
+
if (trailingCRLF) {
|
|
141
|
+
chunks.push(CRLF);
|
|
142
|
+
}
|
|
143
|
+
if (!(trailingCRLF = token === MATCH)) {
|
|
144
|
+
chunks.push(token);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return mergeArrays(...chunks);
|
|
148
|
+
}
|
|
149
|
+
let done = false;
|
|
150
|
+
async function nextChunk() {
|
|
151
|
+
const result = await nextToken();
|
|
152
|
+
let chunk;
|
|
153
|
+
if (result.value !== MATCH) {
|
|
154
|
+
chunk = result.value;
|
|
155
|
+
} else if (!trailingCRLF) {
|
|
156
|
+
chunk = CRLF;
|
|
157
|
+
} else {
|
|
158
|
+
done = true;
|
|
159
|
+
return { value: crlfSearch.end() };
|
|
160
|
+
}
|
|
161
|
+
return { value: feedChunk(chunk) };
|
|
162
|
+
}
|
|
163
|
+
const bufferedChunks = [{ value: feedChunk(tail) }];
|
|
164
|
+
yield {
|
|
165
|
+
...parsePartHeaders(headerLines),
|
|
166
|
+
data: {
|
|
167
|
+
[Symbol.asyncIterator]() {
|
|
168
|
+
return this;
|
|
169
|
+
},
|
|
170
|
+
async next() {
|
|
171
|
+
for (;;) {
|
|
172
|
+
const result = bufferedChunks.shift();
|
|
173
|
+
if (!result) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
if (result.value.length > 0) {
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (;;) {
|
|
181
|
+
if (done) {
|
|
182
|
+
return {
|
|
183
|
+
done,
|
|
184
|
+
value: undefined
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const result = await nextChunk();
|
|
188
|
+
if (result.value.length > 0) {
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
while (!done) {
|
|
196
|
+
bufferedChunks.push(await nextChunk());
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { streamMultipart };
|