@trpc/client 11.0.0-next-beta.206 → 11.0.0-next-beta.208
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/{TRPCClientError-3414c3d5.mjs → TRPCClientError.mjs} +1 -1
- package/dist/bundle-analysis.json +61 -61
- package/dist/createTRPCClient.js +50 -0
- package/dist/createTRPCClient.mjs +45 -0
- package/dist/createTRPCUntypedClient.js +10 -0
- package/dist/createTRPCUntypedClient.mjs +7 -0
- package/dist/getFetch.js +17 -0
- package/dist/getFetch.mjs +15 -0
- package/dist/index.js +32 -368
- package/dist/index.mjs +9 -352
- package/dist/internals/TRPCUntypedClient.js +113 -0
- package/dist/internals/TRPCUntypedClient.mjs +111 -0
- package/dist/{httpBatchLink-0ee76b31.mjs → internals/dataLoader.js} +2 -117
- package/dist/{httpBatchLink-6c1c898e.js → internals/dataLoader.mjs} +1 -121
- package/dist/internals/getAbortController.js +18 -0
- package/dist/internals/getAbortController.mjs +16 -0
- package/dist/links/httpBatchLink.js +37 -9
- package/dist/links/httpBatchLink.mjs +39 -5
- package/dist/links/httpBatchStreamLink.js +43 -0
- package/dist/links/httpBatchStreamLink.mjs +41 -0
- package/dist/links/httpFormDataLink.js +31 -0
- package/dist/links/httpFormDataLink.mjs +29 -0
- package/dist/links/httpLink.js +2 -4
- package/dist/links/httpLink.mjs +2 -2
- package/dist/{splitLink-18238436.js → links/internals/createChain.js} +0 -22
- package/dist/{splitLink-13989f7f.mjs → links/internals/createChain.mjs} +1 -22
- package/dist/links/internals/createHTTPBatchLink.js +86 -0
- package/dist/links/internals/createHTTPBatchLink.mjs +84 -0
- package/dist/links/internals/getTextDecoder.js +18 -0
- package/dist/links/internals/getTextDecoder.mjs +16 -0
- package/dist/{httpUtils-60af4c3d.js → links/internals/httpUtils.js} +5 -33
- package/dist/{httpUtils-82ae6a64.mjs → links/internals/httpUtils.mjs} +4 -31
- package/dist/links/internals/parseJSONStream.js +118 -0
- package/dist/links/internals/parseJSONStream.mjs +115 -0
- package/dist/links/loggerLink.js +4 -2
- package/dist/links/loggerLink.mjs +4 -0
- package/dist/links/splitLink.js +23 -6
- package/dist/links/splitLink.mjs +25 -2
- package/dist/links/wsLink.js +1 -3
- package/dist/links/wsLink.mjs +1 -1
- package/package.json +4 -4
- package/dist/TRPCClientError-27d80214.js +0 -61
- package/dist/httpBatchLink-bc1c3273.js +0 -247
- package/dist/httpUtils-49fa3edc.js +0 -151
- package/dist/splitLink-bd4bf809.js +0 -41
- /package/dist/{TRPCClientError-67aefe1c.js → TRPCClientError.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
2
|
+
"bundleSize": 46723,
|
|
3
3
|
"bundleOrigSize": 64199,
|
|
4
|
-
"bundleReduction": 27.
|
|
4
|
+
"bundleReduction": 27.22,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/links/wsLink.ts",
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
],
|
|
14
14
|
"removedExports": [],
|
|
15
15
|
"dependents": [],
|
|
16
|
-
"percent": 25.
|
|
16
|
+
"percent": 25.63,
|
|
17
17
|
"reduction": 10.37
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"id": "/src/links/loggerLink.ts",
|
|
21
|
-
"size":
|
|
21
|
+
"size": 5545,
|
|
22
22
|
"origSize": 6464,
|
|
23
23
|
"renderedExports": [
|
|
24
24
|
"loggerLink"
|
|
25
25
|
],
|
|
26
26
|
"removedExports": [],
|
|
27
27
|
"dependents": [],
|
|
28
|
-
"percent": 11.
|
|
29
|
-
"reduction":
|
|
28
|
+
"percent": 11.87,
|
|
29
|
+
"reduction": 14.22
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"id": "/src/internals/dataLoader.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependents": [
|
|
40
40
|
"/src/links/internals/createHTTPBatchLink.ts"
|
|
41
41
|
],
|
|
42
|
-
"percent": 9.
|
|
42
|
+
"percent": 9.44,
|
|
43
43
|
"reduction": 7.49
|
|
44
44
|
},
|
|
45
45
|
{
|
|
@@ -54,27 +54,12 @@
|
|
|
54
54
|
"dependents": [
|
|
55
55
|
"/src/links/httpBatchStreamLink.ts"
|
|
56
56
|
],
|
|
57
|
-
"percent": 8.
|
|
57
|
+
"percent": 8.58,
|
|
58
58
|
"reduction": 19.33
|
|
59
59
|
},
|
|
60
|
-
{
|
|
61
|
-
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
62
|
-
"size": 3250,
|
|
63
|
-
"origSize": 6188,
|
|
64
|
-
"renderedExports": [
|
|
65
|
-
"TRPCUntypedClient"
|
|
66
|
-
],
|
|
67
|
-
"removedExports": [],
|
|
68
|
-
"dependents": [
|
|
69
|
-
"/src/createTRPCUntypedClient.ts",
|
|
70
|
-
"/src/createTRPCClient.ts"
|
|
71
|
-
],
|
|
72
|
-
"percent": 7.02,
|
|
73
|
-
"reduction": 47.48
|
|
74
|
-
},
|
|
75
60
|
{
|
|
76
61
|
"id": "/src/links/internals/httpUtils.ts",
|
|
77
|
-
"size":
|
|
62
|
+
"size": 3271,
|
|
78
63
|
"origSize": 5299,
|
|
79
64
|
"renderedExports": [
|
|
80
65
|
"resolveHTTPLinkOptions",
|
|
@@ -86,29 +71,44 @@
|
|
|
86
71
|
],
|
|
87
72
|
"removedExports": [],
|
|
88
73
|
"dependents": [
|
|
89
|
-
"/src/links/internals/parseJSONStream.ts",
|
|
90
|
-
"/src/links/httpFormDataLink.ts",
|
|
91
74
|
"/src/links/httpLink.ts",
|
|
75
|
+
"/src/links/httpBatchLink.ts",
|
|
76
|
+
"/src/links/httpFormDataLink.ts",
|
|
92
77
|
"/src/links/internals/createHTTPBatchLink.ts",
|
|
93
|
-
"/src/links/
|
|
78
|
+
"/src/links/internals/parseJSONStream.ts"
|
|
79
|
+
],
|
|
80
|
+
"percent": 7,
|
|
81
|
+
"reduction": 38.27
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
85
|
+
"size": 3246,
|
|
86
|
+
"origSize": 6188,
|
|
87
|
+
"renderedExports": [
|
|
88
|
+
"TRPCUntypedClient"
|
|
94
89
|
],
|
|
95
|
-
"
|
|
96
|
-
"
|
|
90
|
+
"removedExports": [],
|
|
91
|
+
"dependents": [
|
|
92
|
+
"/src/createTRPCUntypedClient.ts",
|
|
93
|
+
"/src/createTRPCClient.ts"
|
|
94
|
+
],
|
|
95
|
+
"percent": 6.95,
|
|
96
|
+
"reduction": 47.54
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"id": "/src/links/internals/createHTTPBatchLink.ts",
|
|
100
|
-
"size":
|
|
100
|
+
"size": 2946,
|
|
101
101
|
"origSize": 3577,
|
|
102
102
|
"renderedExports": [
|
|
103
103
|
"createHTTPBatchLink"
|
|
104
104
|
],
|
|
105
105
|
"removedExports": [],
|
|
106
106
|
"dependents": [
|
|
107
|
-
"/src/links/
|
|
108
|
-
"/src/links/
|
|
107
|
+
"/src/links/httpBatchLink.ts",
|
|
108
|
+
"/src/links/httpBatchStreamLink.ts"
|
|
109
109
|
],
|
|
110
|
-
"percent": 6.
|
|
111
|
-
"reduction":
|
|
110
|
+
"percent": 6.31,
|
|
111
|
+
"reduction": 17.64
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"id": "/src/links/httpLink.ts",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"dependents": [
|
|
123
123
|
"/src/links/httpFormDataLink.ts"
|
|
124
124
|
],
|
|
125
|
-
"percent": 4.
|
|
125
|
+
"percent": 4.66,
|
|
126
126
|
"reduction": 16.39
|
|
127
127
|
},
|
|
128
128
|
{
|
|
@@ -134,43 +134,43 @@
|
|
|
134
134
|
],
|
|
135
135
|
"removedExports": [],
|
|
136
136
|
"dependents": [
|
|
137
|
-
"/src/internals/TRPCUntypedClient.ts",
|
|
138
137
|
"/src/index.ts",
|
|
139
138
|
"/src/links/httpLink.ts",
|
|
140
139
|
"/src/links/wsLink.ts",
|
|
140
|
+
"/src/internals/TRPCUntypedClient.ts",
|
|
141
141
|
"/src/links/internals/httpUtils.ts",
|
|
142
142
|
"/src/links/internals/createHTTPBatchLink.ts"
|
|
143
143
|
],
|
|
144
|
-
"percent": 3.
|
|
144
|
+
"percent": 3.87,
|
|
145
145
|
"reduction": 44.58
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"id": "/src/links/httpBatchStreamLink.ts",
|
|
149
|
-
"size":
|
|
149
|
+
"size": 1340,
|
|
150
150
|
"origSize": 2041,
|
|
151
151
|
"renderedExports": [
|
|
152
152
|
"unstable_httpBatchStreamLink"
|
|
153
153
|
],
|
|
154
154
|
"removedExports": [],
|
|
155
155
|
"dependents": [],
|
|
156
|
-
"percent": 2.
|
|
157
|
-
"reduction": 35
|
|
156
|
+
"percent": 2.87,
|
|
157
|
+
"reduction": 34.35
|
|
158
158
|
},
|
|
159
159
|
{
|
|
160
160
|
"id": "/src/links/httpBatchLink.ts",
|
|
161
|
-
"size":
|
|
161
|
+
"size": 1205,
|
|
162
162
|
"origSize": 1430,
|
|
163
163
|
"renderedExports": [
|
|
164
164
|
"httpBatchLink"
|
|
165
165
|
],
|
|
166
166
|
"removedExports": [],
|
|
167
167
|
"dependents": [],
|
|
168
|
-
"percent": 2.
|
|
169
|
-
"reduction":
|
|
168
|
+
"percent": 2.58,
|
|
169
|
+
"reduction": 15.73
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
"id": "/src/createTRPCClient.ts",
|
|
173
|
-
"size":
|
|
173
|
+
"size": 1168,
|
|
174
174
|
"origSize": 4356,
|
|
175
175
|
"renderedExports": [
|
|
176
176
|
"clientCallTypeToProcedureType",
|
|
@@ -182,20 +182,20 @@
|
|
|
182
182
|
"dependents": [
|
|
183
183
|
"/src/index.ts"
|
|
184
184
|
],
|
|
185
|
-
"percent": 2.
|
|
186
|
-
"reduction": 73.
|
|
185
|
+
"percent": 2.5,
|
|
186
|
+
"reduction": 73.19
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
"id": "/src/links/httpFormDataLink.ts",
|
|
190
|
-
"size":
|
|
190
|
+
"size": 703,
|
|
191
191
|
"origSize": 772,
|
|
192
192
|
"renderedExports": [
|
|
193
193
|
"experimental_formDataLink"
|
|
194
194
|
],
|
|
195
195
|
"removedExports": [],
|
|
196
196
|
"dependents": [],
|
|
197
|
-
"percent": 1.
|
|
198
|
-
"reduction": 8.
|
|
197
|
+
"percent": 1.5,
|
|
198
|
+
"reduction": 8.94
|
|
199
199
|
},
|
|
200
200
|
{
|
|
201
201
|
"id": "/src/links/internals/createChain.ts",
|
|
@@ -206,23 +206,23 @@
|
|
|
206
206
|
],
|
|
207
207
|
"removedExports": [],
|
|
208
208
|
"dependents": [
|
|
209
|
-
"/src/
|
|
210
|
-
"/src/
|
|
209
|
+
"/src/links/splitLink.ts",
|
|
210
|
+
"/src/internals/TRPCUntypedClient.ts"
|
|
211
211
|
],
|
|
212
|
-
"percent": 1.
|
|
212
|
+
"percent": 1.48,
|
|
213
213
|
"reduction": 30.58
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
216
|
"id": "/src/links/splitLink.ts",
|
|
217
|
-
"size":
|
|
217
|
+
"size": 610,
|
|
218
218
|
"origSize": 1076,
|
|
219
219
|
"renderedExports": [
|
|
220
220
|
"splitLink"
|
|
221
221
|
],
|
|
222
222
|
"removedExports": [],
|
|
223
223
|
"dependents": [],
|
|
224
|
-
"percent": 1.
|
|
225
|
-
"reduction":
|
|
224
|
+
"percent": 1.31,
|
|
225
|
+
"reduction": 43.31
|
|
226
226
|
},
|
|
227
227
|
{
|
|
228
228
|
"id": "/src/links/internals/getTextDecoder.ts",
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
"dependents": [
|
|
236
236
|
"/src/links/httpBatchStreamLink.ts"
|
|
237
237
|
],
|
|
238
|
-
"percent": 1.
|
|
238
|
+
"percent": 1.18,
|
|
239
239
|
"reduction": 12.78
|
|
240
240
|
},
|
|
241
241
|
{
|
|
@@ -249,7 +249,7 @@
|
|
|
249
249
|
"dependents": [
|
|
250
250
|
"/src/links/internals/httpUtils.ts"
|
|
251
251
|
],
|
|
252
|
-
"percent": 1.
|
|
252
|
+
"percent": 1.16,
|
|
253
253
|
"reduction": 20.29
|
|
254
254
|
},
|
|
255
255
|
{
|
|
@@ -264,12 +264,12 @@
|
|
|
264
264
|
"/src/index.ts",
|
|
265
265
|
"/src/links/internals/httpUtils.ts"
|
|
266
266
|
],
|
|
267
|
-
"percent": 0.
|
|
267
|
+
"percent": 0.92,
|
|
268
268
|
"reduction": 33.54
|
|
269
269
|
},
|
|
270
270
|
{
|
|
271
271
|
"id": "/src/createTRPCUntypedClient.ts",
|
|
272
|
-
"size":
|
|
272
|
+
"size": 100,
|
|
273
273
|
"origSize": 544,
|
|
274
274
|
"renderedExports": [
|
|
275
275
|
"createTRPCUntypedClient"
|
|
@@ -278,8 +278,8 @@
|
|
|
278
278
|
"dependents": [
|
|
279
279
|
"/src/index.ts"
|
|
280
280
|
],
|
|
281
|
-
"percent": 0.
|
|
282
|
-
"reduction":
|
|
281
|
+
"percent": 0.21,
|
|
282
|
+
"reduction": 81.62
|
|
283
283
|
},
|
|
284
284
|
{
|
|
285
285
|
"id": "/src/index.ts",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@trpc/core');
|
|
4
|
+
var TRPCUntypedClient = require('./internals/TRPCUntypedClient.js');
|
|
5
|
+
|
|
6
|
+
const clientCallTypeMap = {
|
|
7
|
+
query: 'query',
|
|
8
|
+
mutate: 'mutation',
|
|
9
|
+
subscribe: 'subscription'
|
|
10
|
+
};
|
|
11
|
+
/** @internal */ const clientCallTypeToProcedureType = (clientCallType)=>{
|
|
12
|
+
return clientCallTypeMap[clientCallType];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/ function createTRPCClientProxy(client) {
|
|
17
|
+
return core.createFlatProxy((key)=>{
|
|
18
|
+
if (client.hasOwnProperty(key)) {
|
|
19
|
+
return client[key];
|
|
20
|
+
}
|
|
21
|
+
if (key === '__untypedClient') {
|
|
22
|
+
return client;
|
|
23
|
+
}
|
|
24
|
+
return core.createRecursiveProxy(({ path , args })=>{
|
|
25
|
+
const pathCopy = [
|
|
26
|
+
key,
|
|
27
|
+
...path
|
|
28
|
+
];
|
|
29
|
+
const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
|
|
30
|
+
const fullPath = pathCopy.join('.');
|
|
31
|
+
return client[procedureType](fullPath, ...args);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function createTRPCClient(opts) {
|
|
36
|
+
const client = new TRPCUntypedClient.TRPCUntypedClient(opts);
|
|
37
|
+
const proxy = createTRPCClientProxy(client);
|
|
38
|
+
return proxy;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get an untyped client from a proxy client
|
|
42
|
+
* @internal
|
|
43
|
+
*/ function getUntypedClient(client) {
|
|
44
|
+
return client.__untypedClient;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.clientCallTypeToProcedureType = clientCallTypeToProcedureType;
|
|
48
|
+
exports.createTRPCClient = createTRPCClient;
|
|
49
|
+
exports.createTRPCClientProxy = createTRPCClientProxy;
|
|
50
|
+
exports.getUntypedClient = getUntypedClient;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createFlatProxy, createRecursiveProxy } from '@trpc/core';
|
|
2
|
+
import { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
|
|
3
|
+
|
|
4
|
+
const clientCallTypeMap = {
|
|
5
|
+
query: 'query',
|
|
6
|
+
mutate: 'mutation',
|
|
7
|
+
subscribe: 'subscription'
|
|
8
|
+
};
|
|
9
|
+
/** @internal */ const clientCallTypeToProcedureType = (clientCallType)=>{
|
|
10
|
+
return clientCallTypeMap[clientCallType];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/ function createTRPCClientProxy(client) {
|
|
15
|
+
return createFlatProxy((key)=>{
|
|
16
|
+
if (client.hasOwnProperty(key)) {
|
|
17
|
+
return client[key];
|
|
18
|
+
}
|
|
19
|
+
if (key === '__untypedClient') {
|
|
20
|
+
return client;
|
|
21
|
+
}
|
|
22
|
+
return createRecursiveProxy(({ path , args })=>{
|
|
23
|
+
const pathCopy = [
|
|
24
|
+
key,
|
|
25
|
+
...path
|
|
26
|
+
];
|
|
27
|
+
const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
|
|
28
|
+
const fullPath = pathCopy.join('.');
|
|
29
|
+
return client[procedureType](fullPath, ...args);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function createTRPCClient(opts) {
|
|
34
|
+
const client = new TRPCUntypedClient(opts);
|
|
35
|
+
const proxy = createTRPCClientProxy(client);
|
|
36
|
+
return proxy;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get an untyped client from a proxy client
|
|
40
|
+
* @internal
|
|
41
|
+
*/ function getUntypedClient(client) {
|
|
42
|
+
return client.__untypedClient;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, getUntypedClient };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var TRPCUntypedClient = require('./internals/TRPCUntypedClient.js');
|
|
4
|
+
|
|
5
|
+
function createTRPCUntypedClient(opts) {
|
|
6
|
+
return new TRPCUntypedClient.TRPCUntypedClient(opts);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
exports.TRPCUntypedClient = TRPCUntypedClient.TRPCUntypedClient;
|
|
10
|
+
exports.createTRPCUntypedClient = createTRPCUntypedClient;
|
package/dist/getFetch.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const isFunction = (fn)=>typeof fn === 'function';
|
|
4
|
+
function getFetch(customFetchImpl) {
|
|
5
|
+
if (customFetchImpl) {
|
|
6
|
+
return customFetchImpl;
|
|
7
|
+
}
|
|
8
|
+
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
9
|
+
return window.fetch;
|
|
10
|
+
}
|
|
11
|
+
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
12
|
+
return globalThis.fetch;
|
|
13
|
+
}
|
|
14
|
+
throw new Error('No fetch implementation found');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.getFetch = getFetch;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const isFunction = (fn)=>typeof fn === 'function';
|
|
2
|
+
function getFetch(customFetchImpl) {
|
|
3
|
+
if (customFetchImpl) {
|
|
4
|
+
return customFetchImpl;
|
|
5
|
+
}
|
|
6
|
+
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
7
|
+
return window.fetch;
|
|
8
|
+
}
|
|
9
|
+
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
10
|
+
return globalThis.fetch;
|
|
11
|
+
}
|
|
12
|
+
throw new Error('No fetch implementation found');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { getFetch };
|