@trpc/server 10.0.0-proxy-beta.11 → 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.
- package/dist/adapters/aws-lambda/index.js +3 -3
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/express.js +3 -3
- package/dist/adapters/express.mjs +3 -3
- package/dist/adapters/fastify/index.js +2 -2
- package/dist/adapters/fastify/index.mjs +2 -2
- package/dist/adapters/fetch/index.js +2 -2
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/next.js +3 -3
- package/dist/adapters/next.mjs +3 -3
- package/dist/adapters/node-http/index.js +3 -3
- package/dist/adapters/node-http/index.mjs +3 -3
- package/dist/adapters/standalone.js +3 -3
- package/dist/adapters/standalone.mjs +3 -3
- package/dist/index-5a6a2e91.mjs +48 -0
- package/dist/index-62d46c97.js +51 -0
- package/dist/index.js +3 -3
- package/dist/index.mjs +5 -5
- package/dist/{nodeHTTPRequestHandler-7b588236.js → nodeHTTPRequestHandler-831afd20.js} +1 -1
- package/dist/{nodeHTTPRequestHandler-4062f93e.mjs → nodeHTTPRequestHandler-f627eff7.mjs} +1 -1
- package/dist/{resolveHTTPResponse-3af47381.js → resolveHTTPResponse-190892ac.js} +2 -2
- package/dist/{resolveHTTPResponse-8b09a709.mjs → resolveHTTPResponse-75ea5653.mjs} +2 -2
- package/dist/{router-dabfef7f.mjs → router-133cf4a4.mjs} +1 -1
- package/dist/{router-9960eb02.js → router-3bad08e5.js} +1 -1
- package/dist/shared/createProxy/index.d.ts +6 -4
- package/dist/shared/createProxy/index.d.ts.map +1 -1
- package/dist/shared/index.js +3 -2
- package/dist/shared/index.mjs +1 -1
- package/package.json +6 -6
- package/src/core/router.ts +2 -2
- package/src/shared/createProxy/index.ts +40 -33
- package/dist/index-354358bb.mjs +0 -39
- 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-
|
|
5
|
+
require('../../router-3bad08e5.js');
|
|
6
6
|
var TRPCError = require('../../TRPCError-fe9113e5.js');
|
|
7
|
-
var resolveHTTPResponse = require('../../resolveHTTPResponse-
|
|
7
|
+
var resolveHTTPResponse = require('../../resolveHTTPResponse-190892ac.js');
|
|
8
8
|
require('../../codes-76c38a34.js');
|
|
9
|
-
require('../../index-
|
|
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-
|
|
1
|
+
import '../../router-133cf4a4.mjs';
|
|
2
2
|
import { T as TRPCError } from '../../TRPCError-281ac25a.mjs';
|
|
3
|
-
import { r as resolveHTTPResponse } from '../../resolveHTTPResponse-
|
|
3
|
+
import { r as resolveHTTPResponse } from '../../resolveHTTPResponse-75ea5653.mjs';
|
|
4
4
|
import '../../codes-7d21f749.mjs';
|
|
5
|
-
import '../../index-
|
|
5
|
+
import '../../index-5a6a2e91.mjs';
|
|
6
6
|
import '../../transformTRPCResponse-c8138d5f.mjs';
|
|
7
7
|
|
|
8
8
|
function isPayloadV1(event) {
|
package/dist/adapters/express.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-
|
|
6
|
-
require('../resolveHTTPResponse-
|
|
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-
|
|
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-
|
|
2
|
-
import '../resolveHTTPResponse-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
5
|
+
var resolveHTTPResponse = require('../../resolveHTTPResponse-190892ac.js');
|
|
6
6
|
require('../../TRPCError-fe9113e5.js');
|
|
7
7
|
require('../../codes-76c38a34.js');
|
|
8
|
-
require('../../index-
|
|
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-
|
|
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-
|
|
4
|
+
import '../../index-5a6a2e91.mjs';
|
|
5
5
|
import '../../transformTRPCResponse-c8138d5f.mjs';
|
|
6
6
|
|
|
7
7
|
assertNotBrowser();
|
package/dist/adapters/next.js
CHANGED
|
@@ -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-
|
|
7
|
-
require('../resolveHTTPResponse-
|
|
6
|
+
var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-831afd20.js');
|
|
7
|
+
require('../resolveHTTPResponse-190892ac.js');
|
|
8
8
|
require('../codes-76c38a34.js');
|
|
9
|
-
require('../index-
|
|
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
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { T as TRPCError } from '../TRPCError-281ac25a.mjs';
|
|
2
|
-
import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-
|
|
3
|
-
import '../resolveHTTPResponse-
|
|
2
|
+
import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-f627eff7.mjs';
|
|
3
|
+
import '../resolveHTTPResponse-75ea5653.mjs';
|
|
4
4
|
import '../codes-7d21f749.mjs';
|
|
5
|
-
import '../index-
|
|
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-
|
|
6
|
-
require('../../resolveHTTPResponse-
|
|
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-
|
|
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-
|
|
2
|
-
import '../../resolveHTTPResponse-
|
|
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-
|
|
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-
|
|
7
|
-
require('../resolveHTTPResponse-
|
|
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-
|
|
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-
|
|
3
|
-
import '../resolveHTTPResponse-
|
|
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-
|
|
6
|
+
import '../index-5a6a2e91.mjs';
|
|
7
7
|
import '../transformTRPCResponse-c8138d5f.mjs';
|
|
8
8
|
|
|
9
9
|
function createHTTPHandler(opts) {
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
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-
|
|
6
|
-
var router = require('./router-
|
|
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-
|
|
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-
|
|
2
|
-
export { b as assertNotBrowser, e as callProcedure, a as defaultTransformer, g as getDataTransformer, p as procedureTypes, r as resolveHTTPResponse } from './resolveHTTPResponse-
|
|
3
|
-
import { c as createBuilder, a as createMiddlewareFactory } from './router-
|
|
4
|
-
export { b as createInputMiddleware, d as createOutputMiddleware, r as router } from './router-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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.
|
|
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
|
|
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 =
|
|
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-
|
|
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
|
|
|
@@ -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
|
-
* @
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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;
|
|
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"}
|
package/dist/shared/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../index-
|
|
5
|
+
var index = require('../index-62d46c97.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports.
|
|
9
|
+
exports.createFlatProxy = index.createFlatProxy;
|
|
10
|
+
exports.createRecursiveProxy = index.createRecursiveProxy;
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { c as
|
|
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.
|
|
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.
|
|
126
|
-
"@trpc/next": "10.0.0-proxy-beta.
|
|
127
|
-
"@trpc/react": "10.0.0-proxy-beta.
|
|
128
|
-
"@trpc/server": "10.0.0-proxy-beta.
|
|
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": "
|
|
164
|
+
"gitHead": "5b25e9483cdd7d3c58e0843232acef790eeaf425"
|
|
165
165
|
}
|
package/src/core/router.ts
CHANGED
|
@@ -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 {
|
|
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 =
|
|
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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
* @
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
51
|
-
|
|
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
|
+
};
|
package/dist/index-354358bb.mjs
DELETED
|
@@ -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 };
|
package/dist/index-b8627db5.js
DELETED
|
@@ -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;
|