@trpc/server 11.0.0-alpha-tmp-export-from-main.213 → 11.0.0-alpha-tmp-export-from-main-nuke-core.236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@trpc/server/http.d.ts +7 -0
- package/dist/@trpc/server/http.d.ts.map +1 -0
- package/dist/@trpc/server/index.d.ts +69 -0
- package/dist/@trpc/server/index.d.ts.map +1 -0
- package/dist/@trpc/server/rpc.d.ts +3 -0
- package/dist/@trpc/server/rpc.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +1 -2
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +20 -109
- package/dist/adapters/aws-lambda/index.mjs +5 -92
- package/dist/adapters/aws-lambda/utils.d.ts +2 -3
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/utils.js +101 -0
- package/dist/adapters/aws-lambda/utils.mjs +94 -0
- package/dist/adapters/express.d.ts +1 -2
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +1 -6
- package/dist/adapters/express.mjs +1 -4
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +84 -0
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +82 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -2
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +50 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +48 -0
- package/dist/adapters/fastify/index.js +4 -125
- package/dist/adapters/fastify/index.mjs +2 -125
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +120 -0
- package/dist/adapters/fetch/fetchRequestHandler.mjs +118 -0
- package/dist/adapters/fetch/index.js +2 -115
- package/dist/adapters/fetch/index.mjs +1 -116
- package/dist/adapters/fetch/types.d.ts +2 -3
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +1 -2
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +7 -9
- package/dist/adapters/next.mjs +5 -5
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.js +161 -0
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.mjs +157 -0
- package/dist/adapters/node-http/content-type/form-data/index.js +20 -646
- package/dist/adapters/node-http/content-type/form-data/index.mjs +9 -631
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.js +29 -0
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.mjs +27 -0
- package/dist/adapters/node-http/content-type/form-data/streamSlice.js +46 -0
- package/dist/adapters/node-http/content-type/form-data/streamSlice.mjs +44 -0
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.js +30 -0
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.mjs +26 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +44 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +42 -0
- package/dist/adapters/node-http/content-type/json/index.js +7 -43
- package/dist/adapters/node-http/content-type/json/index.mjs +5 -39
- package/dist/adapters/node-http/index.js +1 -6
- package/dist/adapters/node-http/index.mjs +1 -4
- package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
- package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
- package/dist/{contentType-72ed9df5.mjs → adapters/node-http/internals/contentType.mjs} +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/{nodeHTTPRequestHandler-55f05150.js → adapters/node-http/nodeHTTPRequestHandler.js} +8 -6
- package/dist/{nodeHTTPRequestHandler-2d5c8791.mjs → adapters/node-http/nodeHTTPRequestHandler.mjs} +6 -4
- package/dist/adapters/node-http/types.d.ts +3 -4
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -2
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +3 -11
- package/dist/adapters/standalone.mjs +3 -5
- package/dist/adapters/ws.d.ts +3 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +33 -28
- package/dist/adapters/ws.mjs +8 -1
- package/dist/bundle-analysis.json +757 -0
- package/dist/http.d.ts +1 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +11 -23
- package/dist/http.mjs +6 -1
- package/dist/index.d.ts +1 -68
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -43
- package/dist/index.mjs +8 -1
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.js +203 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.mjs +201 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.js +167 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/search.mjs +163 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.js +35 -0
- package/dist/node_modules/.pnpm/@web3-storage_multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/utils.mjs +30 -0
- package/dist/observable/index.d.ts +5 -0
- package/dist/observable/index.d.ts.map +1 -0
- package/dist/observable/index.js +13 -0
- package/dist/observable/index.mjs +2 -0
- package/dist/observable/observable.d.ts +13 -0
- package/dist/observable/observable.d.ts.map +1 -0
- package/dist/observable/observable.js +126 -0
- package/dist/observable/observable.mjs +122 -0
- package/dist/observable/operators.d.ts +8 -0
- package/dist/observable/operators.d.ts.map +1 -0
- package/dist/observable/operators.js +103 -0
- package/dist/observable/operators.mjs +99 -0
- package/dist/observable/types.d.ts +26 -0
- package/dist/observable/types.d.ts.map +1 -0
- package/dist/rpc.d.ts +1 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +6 -15
- package/dist/rpc.mjs +3 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +6 -11
- package/dist/shared.mjs +4 -1
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +6 -0
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts +19 -0
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/createProxy.js +52 -0
- package/dist/unstable-core-do-not-import/createProxy.mjs +49 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +13 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.js +67 -0
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +63 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +33 -0
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/formatter.js +7 -0
- package/dist/unstable-core-do-not-import/error/formatter.mjs +5 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +15 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +31 -0
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +29 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +24 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.js +32 -0
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.mjs +30 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +29 -0
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/contentType.js +54 -0
- package/dist/unstable-core-do-not-import/http/contentType.mjs +52 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +5 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +51 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +48 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts +7 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +51 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +295 -0
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +293 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts +96 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.d.ts +37 -0
- package/dist/unstable-core-do-not-import/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/index.js +48 -0
- package/dist/unstable-core-do-not-import/index.mjs +16 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +96 -0
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/initTRPC.js +95 -0
- package/dist/unstable-core-do-not-import/initTRPC.mjs +93 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts +105 -0
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/middleware.js +95 -0
- package/dist/unstable-core-do-not-import/middleware.mjs +89 -0
- package/dist/unstable-core-do-not-import/parser.d.ts +30 -0
- package/dist/unstable-core-do-not-import/parser.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/parser.js +37 -0
- package/dist/unstable-core-do-not-import/parser.mjs +35 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts +72 -0
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedure.js +9 -0
- package/dist/unstable-core-do-not-import/procedure.mjs +7 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +101 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.js +176 -0
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +173 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +75 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rootConfig.js +8 -0
- package/dist/unstable-core-do-not-import/rootConfig.mjs +6 -0
- package/dist/unstable-core-do-not-import/router.d.ts +85 -0
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/router.js +156 -0
- package/dist/unstable-core-do-not-import/router.mjs +151 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +51 -0
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/codes.js +38 -0
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +35 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +97 -0
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +5 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +59 -0
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +57 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts +62 -0
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts +107 -0
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/transformer.js +107 -0
- package/dist/unstable-core-do-not-import/transformer.mjs +102 -0
- package/dist/unstable-core-do-not-import/types.d.ts +98 -0
- package/dist/unstable-core-do-not-import/types.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.d.ts +27 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/utils.js +44 -0
- package/dist/unstable-core-do-not-import/utils.mjs +39 -0
- package/package.json +54 -126
- package/src/@trpc/server/http.ts +26 -0
- package/src/@trpc/server/index.ts +105 -0
- package/src/@trpc/server/rpc.ts +26 -0
- package/src/adapters/aws-lambda/index.ts +4 -5
- package/src/adapters/aws-lambda/utils.ts +3 -4
- package/src/adapters/express.ts +1 -3
- package/src/adapters/fastify/fastifyRequestHandler.ts +6 -4
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -2
- package/src/adapters/fetch/fetchRequestHandler.ts +6 -4
- package/src/adapters/fetch/types.ts +2 -3
- package/src/adapters/next.ts +2 -3
- package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
- package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
- package/src/adapters/node-http/content-type/json/index.ts +1 -1
- package/src/adapters/node-http/internals/contentType.ts +2 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +6 -4
- package/src/adapters/node-http/types.ts +4 -5
- package/src/adapters/standalone.ts +3 -3
- package/src/adapters/ws.ts +14 -13
- package/src/http.ts +1 -26
- package/src/index.ts +1 -105
- package/src/observable/index.ts +10 -0
- package/src/observable/observable.ts +158 -0
- package/src/observable/operators.ts +119 -0
- package/src/observable/types.ts +76 -0
- package/src/rpc.ts +1 -26
- package/src/shared.ts +1 -1
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +9 -0
- package/src/unstable-core-do-not-import/createProxy.ts +59 -0
- package/src/unstable-core-do-not-import/error/TRPCError.ts +82 -0
- package/src/unstable-core-do-not-import/error/formatter.ts +51 -0
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +36 -0
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +29 -0
- package/src/unstable-core-do-not-import/http/contentType.ts +99 -0
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +57 -0
- package/src/unstable-core-do-not-import/http/index.ts +23 -0
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +458 -0
- package/src/unstable-core-do-not-import/http/types.ts +111 -0
- package/src/unstable-core-do-not-import/index.ts +110 -0
- package/src/unstable-core-do-not-import/initTRPC.ts +206 -0
- package/src/unstable-core-do-not-import/middleware.ts +233 -0
- package/src/unstable-core-do-not-import/parser.ts +94 -0
- package/src/unstable-core-do-not-import/procedure.ts +108 -0
- package/src/unstable-core-do-not-import/procedureBuilder.ts +458 -0
- package/src/unstable-core-do-not-import/rootConfig.ts +90 -0
- package/src/unstable-core-do-not-import/router.ts +370 -0
- package/src/unstable-core-do-not-import/rpc/codes.ts +44 -0
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +136 -0
- package/src/unstable-core-do-not-import/rpc/index.ts +21 -0
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +85 -0
- package/src/unstable-core-do-not-import/serialize.ts +122 -0
- package/src/unstable-core-do-not-import/transformer.ts +202 -0
- package/src/unstable-core-do-not-import/types.ts +151 -0
- package/src/unstable-core-do-not-import/utils.ts +59 -0
- package/unstable-core-do-not-import/index.d.ts +1 -0
- package/unstable-core-do-not-import/index.js +1 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +0 -10
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +0 -1
- package/dist/@trpc-server/http.d.ts +0 -2
- package/dist/@trpc-server/http.d.ts.map +0 -1
- package/dist/contentType-24c44bba.js +0 -5
- package/dist/nodeHTTPRequestHandler-7691fc79.js +0 -105
- package/dist/observable.d.ts +0 -3
- package/dist/observable.d.ts.map +0 -1
- package/dist/observable.js +0 -32
- package/dist/observable.mjs +0 -1
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +0 -146
- package/src/@trpc-server/http.ts +0 -2
- package/src/observable.ts +0 -16
- /package/dist/{contentType-d9d22104.js → adapters/node-http/internals/contentType.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src/observable/operators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,QAAQ,EACR,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EACnD,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,GAC3D,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAoB7D;AAED,UAAU,WAAW;CAAG;AACxB,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAClC,KAAK,CAAC,EAAE,WAAW,GAClB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CA2D1C;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC1C,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CAqB1C"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function map(project) {
|
|
4
|
+
return (originalObserver)=>{
|
|
5
|
+
return {
|
|
6
|
+
subscribe (observer) {
|
|
7
|
+
let index = 0;
|
|
8
|
+
const subscription = originalObserver.subscribe({
|
|
9
|
+
next (value) {
|
|
10
|
+
observer.next?.(project(value, index++));
|
|
11
|
+
},
|
|
12
|
+
error (error) {
|
|
13
|
+
observer.error?.(error);
|
|
14
|
+
},
|
|
15
|
+
complete () {
|
|
16
|
+
observer.complete?.();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return subscription;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function share(_opts) {
|
|
25
|
+
return (originalObserver)=>{
|
|
26
|
+
let refCount = 0;
|
|
27
|
+
let subscription = null;
|
|
28
|
+
const observers = [];
|
|
29
|
+
function startIfNeeded() {
|
|
30
|
+
if (subscription) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
subscription = originalObserver.subscribe({
|
|
34
|
+
next (value) {
|
|
35
|
+
for (const observer of observers){
|
|
36
|
+
observer.next?.(value);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
error (error) {
|
|
40
|
+
for (const observer of observers){
|
|
41
|
+
observer.error?.(error);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
complete () {
|
|
45
|
+
for (const observer of observers){
|
|
46
|
+
observer.complete?.();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function resetIfNeeded() {
|
|
52
|
+
// "resetOnRefCountZero"
|
|
53
|
+
if (refCount === 0 && subscription) {
|
|
54
|
+
const _sub = subscription;
|
|
55
|
+
subscription = null;
|
|
56
|
+
_sub.unsubscribe();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
subscribe (observer) {
|
|
61
|
+
refCount++;
|
|
62
|
+
observers.push(observer);
|
|
63
|
+
startIfNeeded();
|
|
64
|
+
return {
|
|
65
|
+
unsubscribe () {
|
|
66
|
+
refCount--;
|
|
67
|
+
resetIfNeeded();
|
|
68
|
+
const index = observers.findIndex((v)=>v === observer);
|
|
69
|
+
if (index > -1) {
|
|
70
|
+
observers.splice(index, 1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function tap(observer) {
|
|
79
|
+
return (originalObserver)=>{
|
|
80
|
+
return {
|
|
81
|
+
subscribe (observer2) {
|
|
82
|
+
return originalObserver.subscribe({
|
|
83
|
+
next (v) {
|
|
84
|
+
observer.next?.(v);
|
|
85
|
+
observer2.next?.(v);
|
|
86
|
+
},
|
|
87
|
+
error (v) {
|
|
88
|
+
observer.error?.(v);
|
|
89
|
+
observer2.error?.(v);
|
|
90
|
+
},
|
|
91
|
+
complete () {
|
|
92
|
+
observer.complete?.();
|
|
93
|
+
observer2.complete?.();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
exports.map = map;
|
|
102
|
+
exports.share = share;
|
|
103
|
+
exports.tap = tap;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
function map(project) {
|
|
2
|
+
return (originalObserver)=>{
|
|
3
|
+
return {
|
|
4
|
+
subscribe (observer) {
|
|
5
|
+
let index = 0;
|
|
6
|
+
const subscription = originalObserver.subscribe({
|
|
7
|
+
next (value) {
|
|
8
|
+
observer.next?.(project(value, index++));
|
|
9
|
+
},
|
|
10
|
+
error (error) {
|
|
11
|
+
observer.error?.(error);
|
|
12
|
+
},
|
|
13
|
+
complete () {
|
|
14
|
+
observer.complete?.();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return subscription;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function share(_opts) {
|
|
23
|
+
return (originalObserver)=>{
|
|
24
|
+
let refCount = 0;
|
|
25
|
+
let subscription = null;
|
|
26
|
+
const observers = [];
|
|
27
|
+
function startIfNeeded() {
|
|
28
|
+
if (subscription) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
subscription = originalObserver.subscribe({
|
|
32
|
+
next (value) {
|
|
33
|
+
for (const observer of observers){
|
|
34
|
+
observer.next?.(value);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
error (error) {
|
|
38
|
+
for (const observer of observers){
|
|
39
|
+
observer.error?.(error);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
complete () {
|
|
43
|
+
for (const observer of observers){
|
|
44
|
+
observer.complete?.();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function resetIfNeeded() {
|
|
50
|
+
// "resetOnRefCountZero"
|
|
51
|
+
if (refCount === 0 && subscription) {
|
|
52
|
+
const _sub = subscription;
|
|
53
|
+
subscription = null;
|
|
54
|
+
_sub.unsubscribe();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
subscribe (observer) {
|
|
59
|
+
refCount++;
|
|
60
|
+
observers.push(observer);
|
|
61
|
+
startIfNeeded();
|
|
62
|
+
return {
|
|
63
|
+
unsubscribe () {
|
|
64
|
+
refCount--;
|
|
65
|
+
resetIfNeeded();
|
|
66
|
+
const index = observers.findIndex((v)=>v === observer);
|
|
67
|
+
if (index > -1) {
|
|
68
|
+
observers.splice(index, 1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function tap(observer) {
|
|
77
|
+
return (originalObserver)=>{
|
|
78
|
+
return {
|
|
79
|
+
subscribe (observer2) {
|
|
80
|
+
return originalObserver.subscribe({
|
|
81
|
+
next (v) {
|
|
82
|
+
observer.next?.(v);
|
|
83
|
+
observer2.next?.(v);
|
|
84
|
+
},
|
|
85
|
+
error (v) {
|
|
86
|
+
observer.error?.(v);
|
|
87
|
+
observer2.error?.(v);
|
|
88
|
+
},
|
|
89
|
+
complete () {
|
|
90
|
+
observer.complete?.();
|
|
91
|
+
observer2.complete?.();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { map, share, tap };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface Unsubscribable {
|
|
2
|
+
unsubscribe(): void;
|
|
3
|
+
}
|
|
4
|
+
export type UnsubscribeFn = () => void;
|
|
5
|
+
interface Subscribable<TValue, TError> {
|
|
6
|
+
subscribe(observer: Partial<Observer<TValue, TError>>): Unsubscribable;
|
|
7
|
+
}
|
|
8
|
+
export interface Observable<TValue, TError> extends Subscribable<TValue, TError> {
|
|
9
|
+
pipe(): Observable<TValue, TError>;
|
|
10
|
+
pipe<TValue1, TError1>(op1: OperatorFunction<TValue, TError, TValue1, TError1>): Observable<TValue1, TError1>;
|
|
11
|
+
pipe<TValue1, TError1, TValue2, TError2>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>): Observable<TValue2, TError2>;
|
|
12
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>): Observable<TValue2, TError2>;
|
|
13
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>): Observable<TValue2, TError2>;
|
|
14
|
+
pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4, TValue5, TError5>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>, op5: OperatorFunction<TValue4, TError4, TValue5, TError5>): Observable<TValue2, TError2>;
|
|
15
|
+
}
|
|
16
|
+
export interface Observer<TValue, TError> {
|
|
17
|
+
next: (value: TValue) => void;
|
|
18
|
+
error: (err: TError) => void;
|
|
19
|
+
complete: () => void;
|
|
20
|
+
}
|
|
21
|
+
export type TeardownLogic = Unsubscribable | UnsubscribeFn | void;
|
|
22
|
+
export type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
23
|
+
export type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
|
|
24
|
+
export type MonoTypeOperatorFunction<TValue, TError> = OperatorFunction<TValue, TError, TValue, TError>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/observable/types.ts"],"names":[],"mappings":"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"}
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER, parseTRPCMessage, } from './@trpc-core-unstable-do-not-import-this-please';
|
|
1
|
+
export * from './@trpc/server/rpc';
|
|
3
2
|
//# sourceMappingURL=rpc.d.ts.map
|
package/dist/rpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
package/dist/rpc.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var codes = require('./unstable-core-do-not-import/rpc/codes.js');
|
|
4
|
+
var parseTRPCMessage = require('./unstable-core-do-not-import/rpc/parseTRPCMessage.js');
|
|
5
|
+
require('./unstable-core-do-not-import/rootConfig.js');
|
|
4
6
|
|
|
5
|
-
var core = require('@trpc/core');
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
get: function () { return core.TRPC_ERROR_CODES_BY_KEY; }
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, 'TRPC_ERROR_CODES_BY_NUMBER', {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return core.TRPC_ERROR_CODES_BY_NUMBER; }
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, 'parseTRPCMessage', {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return core.parseTRPCMessage; }
|
|
20
|
-
});
|
|
9
|
+
exports.TRPC_ERROR_CODES_BY_KEY = codes.TRPC_ERROR_CODES_BY_KEY;
|
|
10
|
+
exports.TRPC_ERROR_CODES_BY_NUMBER = codes.TRPC_ERROR_CODES_BY_NUMBER;
|
|
11
|
+
exports.parseTRPCMessage = parseTRPCMessage.parseTRPCMessage;
|
package/dist/rpc.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER
|
|
1
|
+
export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER } from './unstable-core-do-not-import/rpc/codes.mjs';
|
|
2
|
+
export { parseTRPCMessage } from './unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
|
|
3
|
+
import './unstable-core-do-not-import/rootConfig.mjs';
|
package/dist/shared.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ getErrorShape,
|
|
|
22
22
|
/**
|
|
23
23
|
* @deprecated `import { createTRPCFlatProxy } from '@trpc/server'` instead
|
|
24
24
|
*/
|
|
25
|
-
createTRPCFlatProxy as createFlatProxy, } from '
|
|
25
|
+
createTRPCFlatProxy as createFlatProxy, } from './@trpc/server';
|
|
26
26
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO;AACL;;GAEG;AACH,KAAK,mBAAmB;AACxB;;GAEG;AACH,KAAK,oBAAoB;AACzB;;GAEG;AACH,KAAK,+BAA+B;AACpC;;GAEG;AACH,KAAK,kCAAkC;AACvC;;GAEG;AACH,aAAa;AACb;;GAEG;AACH,mBAAmB,IAAI,eAAe,GACvC,MAAM,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO;AACL;;GAEG;AACH,KAAK,mBAAmB;AACxB;;GAEG;AACH,KAAK,oBAAoB;AACzB;;GAEG;AACH,KAAK,+BAA+B;AACpC;;GAEG;AACH,KAAK,kCAAkC;AACvC;;GAEG;AACH,aAAa;AACb;;GAEG;AACH,mBAAmB,IAAI,eAAe,GACvC,MAAM,gBAAgB,CAAC"}
|
package/dist/shared.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var getErrorShape = require('./unstable-core-do-not-import/error/getErrorShape.js');
|
|
4
|
+
var createProxy = require('./unstable-core-do-not-import/createProxy.js');
|
|
5
|
+
require('./unstable-core-do-not-import/rootConfig.js');
|
|
6
|
+
require('./unstable-core-do-not-import/rpc/codes.js');
|
|
4
7
|
|
|
5
|
-
var core = require('@trpc/core');
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return core.createFlatProxy; }
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, 'getErrorShape', {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return core.getErrorShape; }
|
|
16
|
-
});
|
|
10
|
+
exports.getErrorShape = getErrorShape.getErrorShape;
|
|
11
|
+
exports.createFlatProxy = createProxy.createFlatProxy;
|
package/dist/shared.mjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
|
+
export { createFlatProxy } from './unstable-core-do-not-import/createProxy.mjs';
|
|
3
|
+
import './unstable-core-do-not-import/rootConfig.mjs';
|
|
4
|
+
import './unstable-core-do-not-import/rpc/codes.mjs';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AnyRootConfig } from './rootConfig';
|
|
2
|
+
import type { AnyRouter } from './router';
|
|
3
|
+
export type TRPCInferrable = AnyRouter | AnyRootConfig;
|
|
4
|
+
export type inferConfig<TInferrable extends TRPCInferrable> = TInferrable extends AnyRouter ? TInferrable['_def']['_config'] : TInferrable;
|
|
5
|
+
export type inferErrorShape<TInferrable extends TRPCInferrable> = inferConfig<TInferrable>['$types']['errorShape'];
|
|
6
|
+
//# sourceMappingURL=TRPCInferrable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TRPCInferrable.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/TRPCInferrable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;AACvD,MAAM,MAAM,WAAW,CAAC,WAAW,SAAS,cAAc,IACxD,WAAW,SAAS,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;AAE/E,MAAM,MAAM,eAAe,CAAC,WAAW,SAAS,cAAc,IAC5D,WAAW,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface ProxyCallbackOptions {
|
|
2
|
+
path: string[];
|
|
3
|
+
args: unknown[];
|
|
4
|
+
}
|
|
5
|
+
type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const createRecursiveProxy: (callback: ProxyCallback) => unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare const createFlatProxy: <TFaux>(callback: (path: string & keyof TFaux) => any) => TFaux;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=createProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AA4B7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,aAAc,aAAa,YAC5B,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,eAAe,oDACgB,GAAG,UAY9C,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const noop = ()=>{
|
|
4
|
+
// noop
|
|
5
|
+
};
|
|
6
|
+
function createInnerProxy(callback, path) {
|
|
7
|
+
const proxy = new Proxy(noop, {
|
|
8
|
+
get (_obj, key) {
|
|
9
|
+
if (typeof key !== 'string' || key === 'then') {
|
|
10
|
+
// special case for if the proxy is accidentally treated
|
|
11
|
+
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return createInnerProxy(callback, [
|
|
15
|
+
...path,
|
|
16
|
+
key
|
|
17
|
+
]);
|
|
18
|
+
},
|
|
19
|
+
apply (_1, _2, args) {
|
|
20
|
+
const isApply = path[path.length - 1] === 'apply';
|
|
21
|
+
return callback({
|
|
22
|
+
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
23
|
+
path: isApply ? path.slice(0, -1) : path
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return proxy;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
34
|
+
/**
|
|
35
|
+
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/ const createFlatProxy = (callback)=>{
|
|
39
|
+
return new Proxy(noop, {
|
|
40
|
+
get (_obj, name) {
|
|
41
|
+
if (typeof name !== 'string' || name === 'then') {
|
|
42
|
+
// special case for if the proxy is accidentally treated
|
|
43
|
+
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return callback(name);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.createFlatProxy = createFlatProxy;
|
|
52
|
+
exports.createRecursiveProxy = createRecursiveProxy;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const noop = ()=>{
|
|
2
|
+
// noop
|
|
3
|
+
};
|
|
4
|
+
function createInnerProxy(callback, path) {
|
|
5
|
+
const proxy = new Proxy(noop, {
|
|
6
|
+
get (_obj, key) {
|
|
7
|
+
if (typeof key !== 'string' || key === 'then') {
|
|
8
|
+
// special case for if the proxy is accidentally treated
|
|
9
|
+
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return createInnerProxy(callback, [
|
|
13
|
+
...path,
|
|
14
|
+
key
|
|
15
|
+
]);
|
|
16
|
+
},
|
|
17
|
+
apply (_1, _2, args) {
|
|
18
|
+
const isApply = path[path.length - 1] === 'apply';
|
|
19
|
+
return callback({
|
|
20
|
+
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
21
|
+
path: isApply ? path.slice(0, -1) : path
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return proxy;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
32
|
+
/**
|
|
33
|
+
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/ const createFlatProxy = (callback)=>{
|
|
37
|
+
return new Proxy(noop, {
|
|
38
|
+
get (_obj, name) {
|
|
39
|
+
if (typeof name !== 'string' || name === 'then') {
|
|
40
|
+
// special case for if the proxy is accidentally treated
|
|
41
|
+
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return callback(name);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { createFlatProxy, createRecursiveProxy };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TRPC_ERROR_CODE_KEY } from '../rpc/codes';
|
|
2
|
+
export declare function getCauseFromUnknown(cause: unknown): Error | undefined;
|
|
3
|
+
export declare function getTRPCErrorFromUnknown(cause: unknown): TRPCError;
|
|
4
|
+
export declare class TRPCError extends Error {
|
|
5
|
+
readonly cause?: Error;
|
|
6
|
+
readonly code: "INTERNAL_SERVER_ERROR" | "PARSE_ERROR" | "BAD_REQUEST" | "NOT_IMPLEMENTED" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
|
|
7
|
+
constructor(opts: {
|
|
8
|
+
message?: string;
|
|
9
|
+
code: TRPC_ERROR_CODE_KEY;
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=TRPCError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TRPCError.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/TRPCError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMxD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAyBrE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAoBjE;AAED,qBAAa,SAAU,SAAQ,KAAK;IAGlC,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,SAAgB,IAAI,qSAAC;gBAET,IAAI,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,mBAAmB,CAAC;QAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAgBF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../utils.js');
|
|
4
|
+
|
|
5
|
+
class UnknownCauseError extends Error {
|
|
6
|
+
}
|
|
7
|
+
function getCauseFromUnknown(cause) {
|
|
8
|
+
if (cause instanceof Error) {
|
|
9
|
+
return cause;
|
|
10
|
+
}
|
|
11
|
+
const type = typeof cause;
|
|
12
|
+
if (type === 'undefined' || type === 'function' || cause === null) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
// Primitive types just get wrapped in an error
|
|
16
|
+
if (type !== 'object') {
|
|
17
|
+
return new Error(String(cause));
|
|
18
|
+
}
|
|
19
|
+
// If it's an object, we'll create a synthetic error
|
|
20
|
+
if (utils.isObject(cause)) {
|
|
21
|
+
const err = new UnknownCauseError();
|
|
22
|
+
for(const key in cause){
|
|
23
|
+
err[key] = cause[key];
|
|
24
|
+
}
|
|
25
|
+
return err;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
function getTRPCErrorFromUnknown(cause) {
|
|
30
|
+
if (cause instanceof TRPCError) {
|
|
31
|
+
return cause;
|
|
32
|
+
}
|
|
33
|
+
if (cause instanceof Error && cause.name === 'TRPCError') {
|
|
34
|
+
// https://github.com/trpc/trpc/pull/4848
|
|
35
|
+
return cause;
|
|
36
|
+
}
|
|
37
|
+
const trpcError = new TRPCError({
|
|
38
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
39
|
+
cause
|
|
40
|
+
});
|
|
41
|
+
// Inherit stack from error
|
|
42
|
+
if (cause instanceof Error && cause.stack) {
|
|
43
|
+
trpcError.stack = cause.stack;
|
|
44
|
+
}
|
|
45
|
+
return trpcError;
|
|
46
|
+
}
|
|
47
|
+
class TRPCError extends Error {
|
|
48
|
+
constructor(opts){
|
|
49
|
+
const cause = getCauseFromUnknown(opts.cause);
|
|
50
|
+
const message = opts.message ?? cause?.message ?? opts.code;
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
52
|
+
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
53
|
+
super(message, {
|
|
54
|
+
cause
|
|
55
|
+
});
|
|
56
|
+
this.code = opts.code;
|
|
57
|
+
this.name = 'TRPCError';
|
|
58
|
+
if (!this.cause) {
|
|
59
|
+
// < ES2022 / < Node 16.9.0 compatability
|
|
60
|
+
this.cause = cause;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.TRPCError = TRPCError;
|
|
66
|
+
exports.getCauseFromUnknown = getCauseFromUnknown;
|
|
67
|
+
exports.getTRPCErrorFromUnknown = getTRPCErrorFromUnknown;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isObject } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
class UnknownCauseError extends Error {
|
|
4
|
+
}
|
|
5
|
+
function getCauseFromUnknown(cause) {
|
|
6
|
+
if (cause instanceof Error) {
|
|
7
|
+
return cause;
|
|
8
|
+
}
|
|
9
|
+
const type = typeof cause;
|
|
10
|
+
if (type === 'undefined' || type === 'function' || cause === null) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
// Primitive types just get wrapped in an error
|
|
14
|
+
if (type !== 'object') {
|
|
15
|
+
return new Error(String(cause));
|
|
16
|
+
}
|
|
17
|
+
// If it's an object, we'll create a synthetic error
|
|
18
|
+
if (isObject(cause)) {
|
|
19
|
+
const err = new UnknownCauseError();
|
|
20
|
+
for(const key in cause){
|
|
21
|
+
err[key] = cause[key];
|
|
22
|
+
}
|
|
23
|
+
return err;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
function getTRPCErrorFromUnknown(cause) {
|
|
28
|
+
if (cause instanceof TRPCError) {
|
|
29
|
+
return cause;
|
|
30
|
+
}
|
|
31
|
+
if (cause instanceof Error && cause.name === 'TRPCError') {
|
|
32
|
+
// https://github.com/trpc/trpc/pull/4848
|
|
33
|
+
return cause;
|
|
34
|
+
}
|
|
35
|
+
const trpcError = new TRPCError({
|
|
36
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
37
|
+
cause
|
|
38
|
+
});
|
|
39
|
+
// Inherit stack from error
|
|
40
|
+
if (cause instanceof Error && cause.stack) {
|
|
41
|
+
trpcError.stack = cause.stack;
|
|
42
|
+
}
|
|
43
|
+
return trpcError;
|
|
44
|
+
}
|
|
45
|
+
class TRPCError extends Error {
|
|
46
|
+
constructor(opts){
|
|
47
|
+
const cause = getCauseFromUnknown(opts.cause);
|
|
48
|
+
const message = opts.message ?? cause?.message ?? opts.code;
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
+
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
51
|
+
super(message, {
|
|
52
|
+
cause
|
|
53
|
+
});
|
|
54
|
+
this.code = opts.code;
|
|
55
|
+
this.name = 'TRPCError';
|
|
56
|
+
if (!this.cause) {
|
|
57
|
+
// < ES2022 / < Node 16.9.0 compatability
|
|
58
|
+
this.cause = cause;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { TRPCError, getCauseFromUnknown, getTRPCErrorFromUnknown };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ProcedureType } from '../procedure';
|
|
2
|
+
import type { TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER, TRPCErrorShape } from '../rpc';
|
|
3
|
+
import type { TRPCError } from './TRPCError';
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export type ErrorFormatter<TContext, TShape extends TRPCErrorShape<number>> = (args: {
|
|
8
|
+
error: TRPCError;
|
|
9
|
+
type: ProcedureType | 'unknown';
|
|
10
|
+
path: string | undefined;
|
|
11
|
+
input: unknown;
|
|
12
|
+
ctx: TContext | undefined;
|
|
13
|
+
shape: DefaultErrorShape;
|
|
14
|
+
}) => TShape;
|
|
15
|
+
export type ErrorFormatterShape<TType> = TType extends ErrorFormatter<any, infer TShape> ? TShape : DefaultErrorShape;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export type DefaultErrorData = {
|
|
20
|
+
code: TRPC_ERROR_CODE_KEY;
|
|
21
|
+
httpStatus: number;
|
|
22
|
+
path?: string;
|
|
23
|
+
stack?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export interface DefaultErrorShape extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER, DefaultErrorData> {
|
|
29
|
+
message: string;
|
|
30
|
+
code: TRPC_ERROR_CODE_NUMBER;
|
|
31
|
+
}
|
|
32
|
+
export declare const defaultFormatter: ErrorFormatter<any, any>;
|
|
33
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACf,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,cAAc,CACxB,QAAQ,EACR,MAAM,SAAS,cAAc,CAAC,MAAM,CAAC,IACnC,CAAC,IAAI,EAAE;IACT,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,iBAAiB,CAAC;CAC1B,KAAK,MAAM,CAAC;AAEb,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI,KAAK,SAAS,cAAc,CACnE,GAAG,EACH,MAAM,MAAM,CACb,GACG,MAAM,GACN,iBAAiB,CAAC;AACtB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBACf,SAAQ,cAAc,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAErD,CAAC"}
|