@trpc/server 10.0.0-proxy-beta.10 → 10.0.0-proxy-beta.12

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.
Files changed (36) hide show
  1. package/dist/adapters/aws-lambda/index.js +3 -3
  2. package/dist/adapters/aws-lambda/index.mjs +3 -3
  3. package/dist/adapters/express.js +3 -3
  4. package/dist/adapters/express.mjs +3 -3
  5. package/dist/adapters/fastify/index.js +2 -2
  6. package/dist/adapters/fastify/index.mjs +2 -2
  7. package/dist/adapters/fetch/index.js +2 -2
  8. package/dist/adapters/fetch/index.mjs +2 -2
  9. package/dist/adapters/next.js +3 -3
  10. package/dist/adapters/next.mjs +3 -3
  11. package/dist/adapters/node-http/index.js +3 -3
  12. package/dist/adapters/node-http/index.mjs +3 -3
  13. package/dist/adapters/standalone.js +3 -3
  14. package/dist/adapters/standalone.mjs +3 -3
  15. package/dist/core/middleware.d.ts +2 -1
  16. package/dist/core/middleware.d.ts.map +1 -1
  17. package/dist/index-5a6a2e91.mjs +48 -0
  18. package/dist/index-62d46c97.js +51 -0
  19. package/dist/index.js +3 -3
  20. package/dist/index.mjs +5 -5
  21. package/dist/{nodeHTTPRequestHandler-7b588236.js → nodeHTTPRequestHandler-831afd20.js} +1 -1
  22. package/dist/{nodeHTTPRequestHandler-4062f93e.mjs → nodeHTTPRequestHandler-f627eff7.mjs} +1 -1
  23. package/dist/{resolveHTTPResponse-3af47381.js → resolveHTTPResponse-190892ac.js} +2 -2
  24. package/dist/{resolveHTTPResponse-8b09a709.mjs → resolveHTTPResponse-75ea5653.mjs} +2 -2
  25. package/dist/{router-dabfef7f.mjs → router-133cf4a4.mjs} +1 -1
  26. package/dist/{router-9960eb02.js → router-3bad08e5.js} +1 -1
  27. package/dist/shared/createProxy/index.d.ts +6 -4
  28. package/dist/shared/createProxy/index.d.ts.map +1 -1
  29. package/dist/shared/index.js +3 -2
  30. package/dist/shared/index.mjs +1 -1
  31. package/package.json +6 -6
  32. package/src/core/middleware.ts +1 -2
  33. package/src/core/router.ts +2 -2
  34. package/src/shared/createProxy/index.ts +40 -33
  35. package/dist/index-354358bb.mjs +0 -39
  36. package/dist/index-b8627db5.js +0 -41
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('../../router-9960eb02.js');
5
+ require('../../router-3bad08e5.js');
6
6
  var TRPCError = require('../../TRPCError-fe9113e5.js');
7
- var resolveHTTPResponse = require('../../resolveHTTPResponse-3af47381.js');
7
+ var resolveHTTPResponse = require('../../resolveHTTPResponse-190892ac.js');
8
8
  require('../../codes-76c38a34.js');
9
- require('../../index-b8627db5.js');
9
+ require('../../index-62d46c97.js');
10
10
  require('../../transformTRPCResponse-11ac69cc.js');
11
11
 
12
12
  function isPayloadV1(event) {
@@ -1,8 +1,8 @@
1
- import '../../router-dabfef7f.mjs';
1
+ import '../../router-133cf4a4.mjs';
2
2
  import { T as TRPCError } from '../../TRPCError-281ac25a.mjs';
3
- import { r as resolveHTTPResponse } from '../../resolveHTTPResponse-8b09a709.mjs';
3
+ import { r as resolveHTTPResponse } from '../../resolveHTTPResponse-75ea5653.mjs';
4
4
  import '../../codes-7d21f749.mjs';
5
- import '../../index-354358bb.mjs';
5
+ import '../../index-5a6a2e91.mjs';
6
6
  import '../../transformTRPCResponse-c8138d5f.mjs';
7
7
 
8
8
  function isPayloadV1(event) {
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-7b588236.js');
6
- require('../resolveHTTPResponse-3af47381.js');
5
+ var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-831afd20.js');
6
+ require('../resolveHTTPResponse-190892ac.js');
7
7
  require('../TRPCError-fe9113e5.js');
8
8
  require('../codes-76c38a34.js');
9
- require('../index-b8627db5.js');
9
+ require('../index-62d46c97.js');
10
10
  require('../transformTRPCResponse-11ac69cc.js');
11
11
 
12
12
  function createExpressMiddleware(opts) {
@@ -1,8 +1,8 @@
1
- import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-4062f93e.mjs';
2
- import '../resolveHTTPResponse-8b09a709.mjs';
1
+ import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-f627eff7.mjs';
2
+ import '../resolveHTTPResponse-75ea5653.mjs';
3
3
  import '../TRPCError-281ac25a.mjs';
4
4
  import '../codes-7d21f749.mjs';
5
- import '../index-354358bb.mjs';
5
+ import '../index-5a6a2e91.mjs';
6
6
  import '../transformTRPCResponse-c8138d5f.mjs';
7
7
 
8
8
  function createExpressMiddleware(opts) {
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var resolveHTTPResponse = require('../../resolveHTTPResponse-3af47381.js');
5
+ var resolveHTTPResponse = require('../../resolveHTTPResponse-190892ac.js');
6
6
  var adapters_ws = require('../ws.js');
7
7
  require('../../TRPCError-fe9113e5.js');
8
8
  require('../../codes-76c38a34.js');
9
- require('../../index-b8627db5.js');
9
+ require('../../index-62d46c97.js');
10
10
  require('../../transformTRPCResponse-11ac69cc.js');
11
11
  require('../../observable-b651bf11.js');
12
12
 
@@ -1,8 +1,8 @@
1
- import { b as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-8b09a709.mjs';
1
+ import { b as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-75ea5653.mjs';
2
2
  import { applyWSSHandler } from '../ws.mjs';
3
3
  import '../../TRPCError-281ac25a.mjs';
4
4
  import '../../codes-7d21f749.mjs';
5
- import '../../index-354358bb.mjs';
5
+ import '../../index-5a6a2e91.mjs';
6
6
  import '../../transformTRPCResponse-c8138d5f.mjs';
7
7
  import '../../observable-e129ac9d.mjs';
8
8
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var resolveHTTPResponse = require('../../resolveHTTPResponse-3af47381.js');
5
+ var resolveHTTPResponse = require('../../resolveHTTPResponse-190892ac.js');
6
6
  require('../../TRPCError-fe9113e5.js');
7
7
  require('../../codes-76c38a34.js');
8
- require('../../index-b8627db5.js');
8
+ require('../../index-62d46c97.js');
9
9
  require('../../transformTRPCResponse-11ac69cc.js');
10
10
 
11
11
  resolveHTTPResponse.assertNotBrowser();
@@ -1,7 +1,7 @@
1
- import { b as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-8b09a709.mjs';
1
+ import { b as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-75ea5653.mjs';
2
2
  import '../../TRPCError-281ac25a.mjs';
3
3
  import '../../codes-7d21f749.mjs';
4
- import '../../index-354358bb.mjs';
4
+ import '../../index-5a6a2e91.mjs';
5
5
  import '../../transformTRPCResponse-c8138d5f.mjs';
6
6
 
7
7
  assertNotBrowser();
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var TRPCError = require('../TRPCError-fe9113e5.js');
6
- var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-7b588236.js');
7
- require('../resolveHTTPResponse-3af47381.js');
6
+ var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-831afd20.js');
7
+ require('../resolveHTTPResponse-190892ac.js');
8
8
  require('../codes-76c38a34.js');
9
- require('../index-b8627db5.js');
9
+ require('../index-62d46c97.js');
10
10
  require('../transformTRPCResponse-11ac69cc.js');
11
11
 
12
12
  /* eslint-disable @typescript-eslint/no-explicit-any */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1,8 +1,8 @@
1
1
  import { T as TRPCError } from '../TRPCError-281ac25a.mjs';
2
- import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-4062f93e.mjs';
3
- import '../resolveHTTPResponse-8b09a709.mjs';
2
+ import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-f627eff7.mjs';
3
+ import '../resolveHTTPResponse-75ea5653.mjs';
4
4
  import '../codes-7d21f749.mjs';
5
- import '../index-354358bb.mjs';
5
+ import '../index-5a6a2e91.mjs';
6
6
  import '../transformTRPCResponse-c8138d5f.mjs';
7
7
 
8
8
  /* eslint-disable @typescript-eslint/no-explicit-any */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nodeHTTPRequestHandler = require('../../nodeHTTPRequestHandler-7b588236.js');
6
- require('../../resolveHTTPResponse-3af47381.js');
5
+ var nodeHTTPRequestHandler = require('../../nodeHTTPRequestHandler-831afd20.js');
6
+ require('../../resolveHTTPResponse-190892ac.js');
7
7
  require('../../TRPCError-fe9113e5.js');
8
8
  require('../../codes-76c38a34.js');
9
- require('../../index-b8627db5.js');
9
+ require('../../index-62d46c97.js');
10
10
  require('../../transformTRPCResponse-11ac69cc.js');
11
11
 
12
12
 
@@ -1,6 +1,6 @@
1
- export { n as nodeHTTPRequestHandler } from '../../nodeHTTPRequestHandler-4062f93e.mjs';
2
- import '../../resolveHTTPResponse-8b09a709.mjs';
1
+ export { n as nodeHTTPRequestHandler } from '../../nodeHTTPRequestHandler-f627eff7.mjs';
2
+ import '../../resolveHTTPResponse-75ea5653.mjs';
3
3
  import '../../TRPCError-281ac25a.mjs';
4
4
  import '../../codes-7d21f749.mjs';
5
- import '../../index-354358bb.mjs';
5
+ import '../../index-5a6a2e91.mjs';
6
6
  import '../../transformTRPCResponse-c8138d5f.mjs';
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var http = require('node:http');
6
- var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-7b588236.js');
7
- require('../resolveHTTPResponse-3af47381.js');
6
+ var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-831afd20.js');
7
+ require('../resolveHTTPResponse-190892ac.js');
8
8
  require('../TRPCError-fe9113e5.js');
9
9
  require('../codes-76c38a34.js');
10
- require('../index-b8627db5.js');
10
+ require('../index-62d46c97.js');
11
11
  require('../transformTRPCResponse-11ac69cc.js');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -1,9 +1,9 @@
1
1
  import http from 'node:http';
2
- import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-4062f93e.mjs';
3
- import '../resolveHTTPResponse-8b09a709.mjs';
2
+ import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-f627eff7.mjs';
3
+ import '../resolveHTTPResponse-75ea5653.mjs';
4
4
  import '../TRPCError-281ac25a.mjs';
5
5
  import '../codes-7d21f749.mjs';
6
- import '../index-354358bb.mjs';
6
+ import '../index-5a6a2e91.mjs';
7
7
  import '../transformTRPCResponse-c8138d5f.mjs';
8
8
 
9
9
  function createHTTPHandler(opts) {
@@ -1,3 +1,4 @@
1
+ import { TRPCError } from '../error/TRPCError';
1
2
  import { RootConfig } from './internals/config';
2
3
  import { ParseFn } from './internals/getParseFn';
3
4
  import { ProcedureBuilderMiddleware } from './internals/procedureBuilder';
@@ -26,7 +27,7 @@ interface MiddlewareOKResult<_TParams extends ProcedureParams> extends Middlewar
26
27
  */
27
28
  interface MiddlewareErrorResult<_TParams extends ProcedureParams> extends MiddlewareResultBase {
28
29
  ok: false;
29
- error: Error;
30
+ error: TRPCError;
30
31
  }
31
32
  /**
32
33
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../../packages/server/src/core/middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC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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
+ return callback({
19
+ args,
20
+ path
21
+ });
22
+ }
23
+ });
24
+ return proxy;
25
+ }
26
+ /**
27
+ * Creates a proxy that calls the callback with the path and arguments
28
+ *
29
+ * @internal
30
+ */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
31
+ /**
32
+ * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
33
+ *
34
+ * @internal
35
+ */ const createFlatProxy = (callback)=>{
36
+ return new Proxy(noop, {
37
+ get (_obj, name) {
38
+ if (typeof name !== 'string' || name === 'then') {
39
+ // special case for if the proxy is accidentally treated
40
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
41
+ return undefined;
42
+ }
43
+ return callback(name);
44
+ }
45
+ });
46
+ };
47
+
48
+ export { createFlatProxy as a, createRecursiveProxy as c };
@@ -0,0 +1,51 @@
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
+ return callback({
21
+ args,
22
+ path
23
+ });
24
+ }
25
+ });
26
+ return proxy;
27
+ }
28
+ /**
29
+ * Creates a proxy that calls the callback with the path and arguments
30
+ *
31
+ * @internal
32
+ */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
33
+ /**
34
+ * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
35
+ *
36
+ * @internal
37
+ */ const createFlatProxy = (callback)=>{
38
+ return new Proxy(noop, {
39
+ get (_obj, name) {
40
+ if (typeof name !== 'string' || name === 'then') {
41
+ // special case for if the proxy is accidentally treated
42
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
43
+ return undefined;
44
+ }
45
+ return callback(name);
46
+ }
47
+ });
48
+ };
49
+
50
+ exports.createFlatProxy = createFlatProxy;
51
+ exports.createRecursiveProxy = createRecursiveProxy;
package/dist/index.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var resolveHTTPResponse = require('./resolveHTTPResponse-3af47381.js');
6
- var router = require('./router-9960eb02.js');
5
+ var resolveHTTPResponse = require('./resolveHTTPResponse-190892ac.js');
6
+ var router = require('./router-3bad08e5.js');
7
7
  var TRPCError = require('./TRPCError-fe9113e5.js');
8
8
  require('./codes-76c38a34.js');
9
- require('./index-b8627db5.js');
9
+ require('./index-62d46c97.js');
10
10
  require('./transformTRPCResponse-11ac69cc.js');
11
11
 
12
12
  function mergeRouters(...routerList) {
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { m as mergeWithoutOverrides, d as defaultFormatter, a as defaultTransformer, c as createRouterFactory, g as getDataTransformer } from './resolveHTTPResponse-8b09a709.mjs';
2
- export { b as assertNotBrowser, e as callProcedure, a as defaultTransformer, g as getDataTransformer, p as procedureTypes, r as resolveHTTPResponse } from './resolveHTTPResponse-8b09a709.mjs';
3
- import { c as createBuilder, a as createMiddlewareFactory } from './router-dabfef7f.mjs';
4
- export { b as createInputMiddleware, d as createOutputMiddleware, r as router } from './router-dabfef7f.mjs';
1
+ import { m as mergeWithoutOverrides, d as defaultFormatter, a as defaultTransformer, c as createRouterFactory, g as getDataTransformer } from './resolveHTTPResponse-75ea5653.mjs';
2
+ export { b as assertNotBrowser, e as callProcedure, a as defaultTransformer, g as getDataTransformer, p as procedureTypes, r as resolveHTTPResponse } from './resolveHTTPResponse-75ea5653.mjs';
3
+ import { c as createBuilder, a as createMiddlewareFactory } from './router-133cf4a4.mjs';
4
+ export { b as createInputMiddleware, d as createOutputMiddleware, r as router } from './router-133cf4a4.mjs';
5
5
  export { T as TRPCError } from './TRPCError-281ac25a.mjs';
6
6
  import './codes-7d21f749.mjs';
7
- import './index-354358bb.mjs';
7
+ import './index-5a6a2e91.mjs';
8
8
  import './transformTRPCResponse-c8138d5f.mjs';
9
9
 
10
10
  function mergeRouters(...routerList) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var resolveHTTPResponse = require('./resolveHTTPResponse-3af47381.js');
3
+ var resolveHTTPResponse = require('./resolveHTTPResponse-190892ac.js');
4
4
  var TRPCError = require('./TRPCError-fe9113e5.js');
5
5
 
6
6
  async function getPostBody({ req , maxBodySize }) {
@@ -1,4 +1,4 @@
1
- import { b as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-8b09a709.mjs';
1
+ import { b as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-75ea5653.mjs';
2
2
  import { T as TRPCError } from './TRPCError-281ac25a.mjs';
3
3
 
4
4
  async function getPostBody({ req , maxBodySize }) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  var TRPCError = require('./TRPCError-fe9113e5.js');
4
4
  var codes = require('./codes-76c38a34.js');
5
- var index = require('./index-b8627db5.js');
5
+ var index = require('./index-62d46c97.js');
6
6
  var transformTRPCResponse = require('./transformTRPCResponse-11ac69cc.js');
7
7
 
8
8
  /* istanbul ignore file */ function assertNotBrowser() {
@@ -188,7 +188,7 @@ const emptyRouter = {
188
188
  transformer: _def.transformer,
189
189
  errorFormatter: _def.errorFormatter,
190
190
  createCaller (ctx) {
191
- const proxy = index.createProxy(({ path , args })=>{
191
+ const proxy = index.createRecursiveProxy(({ path , args })=>{
192
192
  // interop mode
193
193
  if (path.length === 1 && procedureTypes.includes(path[0])) {
194
194
  return callProcedure({
@@ -1,6 +1,6 @@
1
1
  import { T as TRPCError, g as getTRPCErrorFromUnknown, a as getCauseFromUnknown } from './TRPCError-281ac25a.mjs';
2
2
  import { i as invert, T as TRPC_ERROR_CODES_BY_KEY } from './codes-7d21f749.mjs';
3
- import { c as createProxy } from './index-354358bb.mjs';
3
+ import { c as createRecursiveProxy } from './index-5a6a2e91.mjs';
4
4
  import { t as transformTRPCResponse } from './transformTRPCResponse-c8138d5f.mjs';
5
5
 
6
6
  /* istanbul ignore file */ function assertNotBrowser() {
@@ -186,7 +186,7 @@ const emptyRouter = {
186
186
  transformer: _def.transformer,
187
187
  errorFormatter: _def.errorFormatter,
188
188
  createCaller (ctx) {
189
- const proxy = createProxy(({ path , args })=>{
189
+ const proxy = createRecursiveProxy(({ path , args })=>{
190
190
  // interop mode
191
191
  if (path.length === 1 && procedureTypes.includes(path[0])) {
192
192
  return callProcedure({
@@ -1,4 +1,4 @@
1
- import { m as mergeWithoutOverrides, b as assertNotBrowser, c as createRouterFactory, d as defaultFormatter, f as getHTTPStatusCodeFromError, a as defaultTransformer } from './resolveHTTPResponse-8b09a709.mjs';
1
+ import { m as mergeWithoutOverrides, b as assertNotBrowser, c as createRouterFactory, d as defaultFormatter, f as getHTTPStatusCodeFromError, a as defaultTransformer } from './resolveHTTPResponse-75ea5653.mjs';
2
2
  import { T as TRPC_ERROR_CODES_BY_KEY } from './codes-7d21f749.mjs';
3
3
  import { T as TRPCError, a as getCauseFromUnknown, g as getTRPCErrorFromUnknown } from './TRPCError-281ac25a.mjs';
4
4
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var resolveHTTPResponse = require('./resolveHTTPResponse-3af47381.js');
3
+ var resolveHTTPResponse = require('./resolveHTTPResponse-190892ac.js');
4
4
  var codes = require('./codes-76c38a34.js');
5
5
  var TRPCError = require('./TRPCError-fe9113e5.js');
6
6
 
@@ -6,12 +6,14 @@ declare type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
6
6
  /**
7
7
  * Creates a proxy that calls the callback with the path and arguments
8
8
  *
9
- * @remarks
10
- * This has a special handling to manage if it's accidentally treated like
11
- * a PromiseLike.
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.
12
14
  *
13
15
  * @internal
14
16
  */
15
- export declare const createProxy: (callback: ProxyCallback) => unknown;
17
+ export declare const createFlatProxy: <TFaux>(callback: (path: keyof TFaux & string) => any) => TFaux;
16
18
  export {};
17
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/server/src/shared/createProxy/index.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AACD,aAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAoC7D;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,aAAc,aAAa,YACvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/server/src/shared/createProxy/index.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AACD,aAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AA2B7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,aAAc,aAAa,YAC5B,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,eAAe,oDACgB,GAAG,UAY9C,CAAC"}
@@ -2,8 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../index-b8627db5.js');
5
+ var index = require('../index-62d46c97.js');
6
6
 
7
7
 
8
8
 
9
- exports.createProxy = index.createProxy;
9
+ exports.createFlatProxy = index.createFlatProxy;
10
+ exports.createRecursiveProxy = index.createRecursiveProxy;
@@ -1 +1 @@
1
- export { c as createProxy } from '../index-354358bb.mjs';
1
+ export { a as createFlatProxy, c as createRecursiveProxy } from '../index-5a6a2e91.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "10.0.0-proxy-beta.10",
3
+ "version": "10.0.0-proxy-beta.12",
4
4
  "description": "tRPC Server",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -122,10 +122,10 @@
122
122
  "@testing-library/jest-dom": "^5.16.5",
123
123
  "@testing-library/react": "^13.4.0",
124
124
  "@testing-library/user-event": "^14.4.3",
125
- "@trpc/client": "10.0.0-proxy-beta.10",
126
- "@trpc/next": "10.0.0-proxy-beta.10",
127
- "@trpc/react": "10.0.0-proxy-beta.10",
128
- "@trpc/server": "10.0.0-proxy-beta.10",
125
+ "@trpc/client": "10.0.0-proxy-beta.12",
126
+ "@trpc/next": "10.0.0-proxy-beta.12",
127
+ "@trpc/react": "10.0.0-proxy-beta.12",
128
+ "@trpc/server": "10.0.0-proxy-beta.12",
129
129
  "@types/aws-lambda": "^8.10.97",
130
130
  "@types/express": "^4.17.12",
131
131
  "@types/hash-sum": "^1.0.0",
@@ -161,5 +161,5 @@
161
161
  "yup": "^0.32.8",
162
162
  "zod": "^3.0.0"
163
163
  },
164
- "gitHead": "f380ecc219d93521a645de690fde69fa2b8fc664"
164
+ "gitHead": "5b25e9483cdd7d3c58e0843232acef790eeaf425"
165
165
  }
@@ -34,8 +34,7 @@ interface MiddlewareOKResult<_TParams extends ProcedureParams>
34
34
  interface MiddlewareErrorResult<_TParams extends ProcedureParams>
35
35
  extends MiddlewareResultBase {
36
36
  ok: false;
37
- error: Error;
38
- // we could guarantee it's always of this type
37
+ error: TRPCError;
39
38
  }
40
39
 
41
40
  /**
@@ -6,7 +6,7 @@ import {
6
6
  } from '../error/formatter';
7
7
  import { getHTTPStatusCodeFromError } from '../http/internals/getHTTPStatusCode';
8
8
  import { TRPCErrorShape, TRPC_ERROR_CODES_BY_KEY } from '../rpc';
9
- import { createProxy } from '../shared';
9
+ import { createRecursiveProxy } from '../shared';
10
10
  import { CombinedDataTransformer, defaultTransformer } from '../transformer';
11
11
  import { RootConfig } from './internals/config';
12
12
  import { mergeWithoutOverrides } from './internals/mergeWithoutOverrides';
@@ -266,7 +266,7 @@ export function createRouterFactory<TConfig extends RootConfig>(
266
266
  transformer: _def.transformer,
267
267
  errorFormatter: _def.errorFormatter,
268
268
  createCaller(ctx) {
269
- const proxy = createProxy(({ path, args }) => {
269
+ const proxy = createRecursiveProxy(({ path, args }) => {
270
270
  // interop mode
271
271
  if (
272
272
  path.length === 1 &&
@@ -4,36 +4,27 @@ interface ProxyCallbackOptions {
4
4
  }
5
5
  type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
6
6
 
7
- function createProxyInner(callback: ProxyCallback, ...path: string[]) {
8
- const proxy: unknown = new Proxy(
9
- () => {
10
- // noop
11
- },
12
- {
13
- get(_obj, name) {
14
- if (name === 'then') {
15
- return undefined;
16
- }
17
- if (typeof name === 'string') {
18
- if (name === 'then') {
19
- // special case for if the proxy is accidentally treated
20
- // like a PromiseLike (like in `Promise.resolve(proxy)`)
21
- return undefined;
22
- }
23
- return createProxyInner(callback, ...path, name);
24
- }
7
+ const noop = () => {
8
+ // noop
9
+ };
25
10
 
26
- throw new Error('Not supported');
27
- },
28
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
- apply(_1, _2, args) {
30
- return callback({
31
- args,
32
- path,
33
- });
34
- },
11
+ function createInnerProxy(callback: ProxyCallback, path: string[]) {
12
+ const proxy: unknown = new Proxy(noop, {
13
+ get(_obj, key) {
14
+ if (typeof key !== 'string' || key === 'then') {
15
+ // special case for if the proxy is accidentally treated
16
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
17
+ return undefined;
18
+ }
19
+ return createInnerProxy(callback, [...path, key]);
20
+ },
21
+ apply(_1, _2, args) {
22
+ return callback({
23
+ args,
24
+ path,
25
+ });
35
26
  },
36
- );
27
+ });
37
28
 
38
29
  return proxy;
39
30
  }
@@ -41,11 +32,27 @@ function createProxyInner(callback: ProxyCallback, ...path: string[]) {
41
32
  /**
42
33
  * Creates a proxy that calls the callback with the path and arguments
43
34
  *
44
- * @remarks
45
- * This has a special handling to manage if it's accidentally treated like
46
- * a PromiseLike.
35
+ * @internal
36
+ */
37
+ export const createRecursiveProxy = (callback: ProxyCallback) =>
38
+ createInnerProxy(callback, []);
39
+
40
+ /**
41
+ * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
47
42
  *
48
43
  * @internal
49
44
  */
50
- export const createProxy = (callback: ProxyCallback) =>
51
- createProxyInner(callback);
45
+ export const createFlatProxy = <TFaux>(
46
+ callback: (path: keyof TFaux & string) => any,
47
+ ): TFaux => {
48
+ return new Proxy(noop, {
49
+ get(_obj, name) {
50
+ if (typeof name !== 'string' || name === 'then') {
51
+ // special case for if the proxy is accidentally treated
52
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
53
+ return undefined;
54
+ }
55
+ return callback(name as any);
56
+ },
57
+ }) as TFaux;
58
+ };
@@ -1,39 +0,0 @@
1
- function createProxyInner(callback, ...path) {
2
- const proxy = new Proxy(()=>{
3
- // noop
4
- }, {
5
- get (_obj, name) {
6
- if (name === 'then') {
7
- return undefined;
8
- }
9
- if (typeof name === 'string') {
10
- if (name === 'then') {
11
- // special case for if the proxy is accidentally treated
12
- // like a PromiseLike (like in `Promise.resolve(proxy)`)
13
- return undefined;
14
- }
15
- return createProxyInner(callback, ...path, name);
16
- }
17
- throw new Error('Not supported');
18
- },
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- apply (_1, _2, args) {
21
- return callback({
22
- args,
23
- path
24
- });
25
- }
26
- });
27
- return proxy;
28
- }
29
- /**
30
- * Creates a proxy that calls the callback with the path and arguments
31
- *
32
- * @remarks
33
- * This has a special handling to manage if it's accidentally treated like
34
- * a PromiseLike.
35
- *
36
- * @internal
37
- */ const createProxy = (callback)=>createProxyInner(callback);
38
-
39
- export { createProxy as c };
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- function createProxyInner(callback, ...path) {
4
- const proxy = new Proxy(()=>{
5
- // noop
6
- }, {
7
- get (_obj, name) {
8
- if (name === 'then') {
9
- return undefined;
10
- }
11
- if (typeof name === 'string') {
12
- if (name === 'then') {
13
- // special case for if the proxy is accidentally treated
14
- // like a PromiseLike (like in `Promise.resolve(proxy)`)
15
- return undefined;
16
- }
17
- return createProxyInner(callback, ...path, name);
18
- }
19
- throw new Error('Not supported');
20
- },
21
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
- apply (_1, _2, args) {
23
- return callback({
24
- args,
25
- path
26
- });
27
- }
28
- });
29
- return proxy;
30
- }
31
- /**
32
- * Creates a proxy that calls the callback with the path and arguments
33
- *
34
- * @remarks
35
- * This has a special handling to manage if it's accidentally treated like
36
- * a PromiseLike.
37
- *
38
- * @internal
39
- */ const createProxy = (callback)=>createProxyInner(callback);
40
-
41
- exports.createProxy = createProxy;