@trpc/server 10.0.0-alpha.32 → 10.0.0-alpha.35
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/shared/createProxy/index.d.ts +12 -0
- package/dist/shared/createProxy/index.d.ts.map +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +35 -0
- package/dist/shared/index.mjs +31 -0
- package/dist/shared/index.ts.js +1 -0
- package/package.json +8 -2
- package/shared/index.d.ts +1 -0
- package/shared/index.js +1 -0
- package/src/shared/createProxy/index.ts +38 -0
- package/src/shared/index.ts +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface ProxyCallbackOptions {
|
|
2
|
+
path: string[];
|
|
3
|
+
args: unknown[];
|
|
4
|
+
}
|
|
5
|
+
declare type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const createProxy: (callback: ProxyCallback) => unknown;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../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;AA4B7D;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAc,aAAa,YACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function createProxyInner(callback, ...path) {
|
|
6
|
+
const proxy = new Proxy(() => {// noop
|
|
7
|
+
}, {
|
|
8
|
+
get(_obj, name) {
|
|
9
|
+
if (typeof name === 'string') {
|
|
10
|
+
return createProxyInner(callback, ...path, name);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
throw new Error('Not supported');
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
+
apply(_1, _2, args) {
|
|
18
|
+
return callback({
|
|
19
|
+
args,
|
|
20
|
+
path
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
return proxy;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const createProxy = callback => createProxyInner(callback);
|
|
34
|
+
|
|
35
|
+
exports.createProxy = createProxy;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function createProxyInner(callback, ...path) {
|
|
2
|
+
const proxy = new Proxy(() => {// noop
|
|
3
|
+
}, {
|
|
4
|
+
get(_obj, name) {
|
|
5
|
+
if (typeof name === 'string') {
|
|
6
|
+
return createProxyInner(callback, ...path, name);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
throw new Error('Not supported');
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
apply(_1, _2, args) {
|
|
14
|
+
return callback({
|
|
15
|
+
args,
|
|
16
|
+
path
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
});
|
|
21
|
+
return proxy;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const createProxy = callback => createProxyInner(callback);
|
|
30
|
+
|
|
31
|
+
export { createProxy };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.35",
|
|
4
4
|
"description": "tRPC Server",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -88,6 +88,11 @@
|
|
|
88
88
|
"import": "./dist/subscription.mjs",
|
|
89
89
|
"require": "./dist/subscription.js",
|
|
90
90
|
"default": "./dist/subscription.js"
|
|
91
|
+
},
|
|
92
|
+
"./shared": {
|
|
93
|
+
"import": "./dist/shared/index.mjs",
|
|
94
|
+
"require": "./dist/shared/index.js",
|
|
95
|
+
"default": "./dist/shared/index.js"
|
|
91
96
|
}
|
|
92
97
|
},
|
|
93
98
|
"files": [
|
|
@@ -96,6 +101,7 @@
|
|
|
96
101
|
"adapters",
|
|
97
102
|
"rpc",
|
|
98
103
|
"observable",
|
|
104
|
+
"shared",
|
|
99
105
|
"src"
|
|
100
106
|
],
|
|
101
107
|
"publishConfig": {
|
|
@@ -133,5 +139,5 @@
|
|
|
133
139
|
"dependencies": {
|
|
134
140
|
"tslib": "^2.1.0"
|
|
135
141
|
},
|
|
136
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "4295407b073ffa1359f1d16315d6a95af25fd496"
|
|
137
143
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/shared';
|
package/shared/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/shared/index');
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface ProxyCallbackOptions {
|
|
2
|
+
path: string[];
|
|
3
|
+
args: unknown[];
|
|
4
|
+
}
|
|
5
|
+
type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
|
|
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 (typeof name === 'string') {
|
|
15
|
+
return createProxyInner(callback, ...path, name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
throw new Error('Not supported');
|
|
19
|
+
},
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
+
apply(_1, _2, args) {
|
|
22
|
+
return callback({
|
|
23
|
+
args,
|
|
24
|
+
path,
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return proxy;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a proxy that calls the callback with the path and arguments
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export const createProxy = (callback: ProxyCallback) =>
|
|
38
|
+
createProxyInner(callback);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createProxy';
|