@trpc/client 11.0.0-rc.840 → 11.0.0-rc.844
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/bundle-analysis.json +37 -37
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/links/HTTPBatchLinkOptions.d.ts +5 -0
- package/dist/links/HTTPBatchLinkOptions.d.ts.map +1 -1
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.js +5 -1
- package/dist/links/httpBatchLink.mjs +5 -1
- package/dist/links/httpBatchStreamLink.d.ts +1 -9
- package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
- package/dist/links/httpBatchStreamLink.js +2 -2
- package/dist/links/httpBatchStreamLink.mjs +2 -2
- package/dist/links/httpSubscriptionLink.d.ts +1 -1
- package/dist/links/httpSubscriptionLink.d.ts.map +1 -1
- package/dist/links/httpSubscriptionLink.js +2 -2
- package/dist/links/httpSubscriptionLink.mjs +2 -2
- package/package.json +4 -4
- package/src/links/HTTPBatchLinkOptions.ts +6 -0
- package/src/links/httpBatchLink.ts +5 -1
- package/src/links/httpBatchStreamLink.ts +2 -12
- package/src/links/httpSubscriptionLink.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 19.
|
|
2
|
+
"bundleSize": 75781,
|
|
3
|
+
"bundleOrigSize": 94156,
|
|
4
|
+
"bundleReduction": 19.52,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/links/wsLink/wsClient/wsClient.ts",
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/links/wsLink/createWsClient.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 15.
|
|
17
|
+
"percent": 15.92,
|
|
18
18
|
"reduction": 1.08
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"id": "/src/links/httpSubscriptionLink.ts",
|
|
22
|
-
"size":
|
|
23
|
-
"origSize":
|
|
22
|
+
"size": 7960,
|
|
23
|
+
"origSize": 7684,
|
|
24
24
|
"renderedExports": [
|
|
25
|
-
"
|
|
25
|
+
"httpSubscriptionLink"
|
|
26
26
|
],
|
|
27
27
|
"removedExports": [],
|
|
28
28
|
"dependents": [],
|
|
29
|
-
"percent": 10.
|
|
29
|
+
"percent": 10.5,
|
|
30
30
|
"reduction": 0
|
|
31
31
|
},
|
|
32
32
|
{
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"dependents": [
|
|
42
42
|
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
43
43
|
],
|
|
44
|
-
"percent": 8.
|
|
44
|
+
"percent": 8.15,
|
|
45
45
|
"reduction": 4.9
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"id": "/src/links/httpBatchStreamLink.ts",
|
|
49
|
-
"size":
|
|
50
|
-
"origSize":
|
|
49
|
+
"size": 6008,
|
|
50
|
+
"origSize": 5972,
|
|
51
51
|
"renderedExports": [
|
|
52
|
-
"
|
|
52
|
+
"httpBatchStreamLink"
|
|
53
53
|
],
|
|
54
54
|
"removedExports": [],
|
|
55
55
|
"dependents": [],
|
|
56
|
-
"percent": 7.
|
|
57
|
-
"reduction":
|
|
56
|
+
"percent": 7.93,
|
|
57
|
+
"reduction": 0
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"id": "/src/links/loggerLink.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
],
|
|
66
66
|
"removedExports": [],
|
|
67
67
|
"dependents": [],
|
|
68
|
-
"percent": 7.
|
|
68
|
+
"percent": 7.38,
|
|
69
69
|
"reduction": 19.44
|
|
70
70
|
},
|
|
71
71
|
{
|
|
@@ -79,9 +79,21 @@
|
|
|
79
79
|
"dependents": [
|
|
80
80
|
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
81
81
|
],
|
|
82
|
-
"percent": 6.
|
|
82
|
+
"percent": 6.32,
|
|
83
83
|
"reduction": 8.13
|
|
84
84
|
},
|
|
85
|
+
{
|
|
86
|
+
"id": "/src/links/httpBatchLink.ts",
|
|
87
|
+
"size": 4124,
|
|
88
|
+
"origSize": 4323,
|
|
89
|
+
"renderedExports": [
|
|
90
|
+
"httpBatchLink"
|
|
91
|
+
],
|
|
92
|
+
"removedExports": [],
|
|
93
|
+
"dependents": [],
|
|
94
|
+
"percent": 5.44,
|
|
95
|
+
"reduction": 4.6
|
|
96
|
+
},
|
|
85
97
|
{
|
|
86
98
|
"id": "/src/internals/dataLoader.ts",
|
|
87
99
|
"size": 4084,
|
|
@@ -94,21 +106,9 @@
|
|
|
94
106
|
"/src/links/httpBatchLink.ts",
|
|
95
107
|
"/src/links/httpBatchStreamLink.ts"
|
|
96
108
|
],
|
|
97
|
-
"percent": 5.
|
|
109
|
+
"percent": 5.39,
|
|
98
110
|
"reduction": 5.64
|
|
99
111
|
},
|
|
100
|
-
{
|
|
101
|
-
"id": "/src/links/httpBatchLink.ts",
|
|
102
|
-
"size": 3937,
|
|
103
|
-
"origSize": 4170,
|
|
104
|
-
"renderedExports": [
|
|
105
|
-
"httpBatchLink"
|
|
106
|
-
],
|
|
107
|
-
"removedExports": [],
|
|
108
|
-
"dependents": [],
|
|
109
|
-
"percent": 5.21,
|
|
110
|
-
"reduction": 5.59
|
|
111
|
-
},
|
|
112
112
|
{
|
|
113
113
|
"id": "/src/links/internals/httpUtils.ts",
|
|
114
114
|
"size": 3692,
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"/src/links/httpBatchStreamLink.ts",
|
|
130
130
|
"/src/links/httpSubscriptionLink.ts"
|
|
131
131
|
],
|
|
132
|
-
"percent": 4.
|
|
132
|
+
"percent": 4.87,
|
|
133
133
|
"reduction": 37.14
|
|
134
134
|
},
|
|
135
135
|
{
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
],
|
|
142
142
|
"removedExports": [],
|
|
143
143
|
"dependents": [],
|
|
144
|
-
"percent": 4.
|
|
144
|
+
"percent": 4.34,
|
|
145
145
|
"reduction": 12.56
|
|
146
146
|
},
|
|
147
147
|
{
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"/src/createTRPCUntypedClient.ts",
|
|
157
157
|
"/src/createTRPCClient.ts"
|
|
158
158
|
],
|
|
159
|
-
"percent": 4.
|
|
159
|
+
"percent": 4.17,
|
|
160
160
|
"reduction": 28.5
|
|
161
161
|
},
|
|
162
162
|
{
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"/src/internals/TRPCUntypedClient.ts",
|
|
177
177
|
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
178
178
|
],
|
|
179
|
-
"percent": 3.
|
|
179
|
+
"percent": 3.68,
|
|
180
180
|
"reduction": 21.8
|
|
181
181
|
},
|
|
182
182
|
{
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
"/src/links/wsLink/wsClient/requestManager.ts",
|
|
197
197
|
"/src/links/wsLink/wsClient/wsConnection.ts"
|
|
198
198
|
],
|
|
199
|
-
"percent": 3.
|
|
199
|
+
"percent": 3.67,
|
|
200
200
|
"reduction": 0.47
|
|
201
201
|
},
|
|
202
202
|
{
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
"dependents": [
|
|
243
243
|
"/src/index.ts"
|
|
244
244
|
],
|
|
245
|
-
"percent": 1.
|
|
245
|
+
"percent": 1.54,
|
|
246
246
|
"reduction": 75.3
|
|
247
247
|
},
|
|
248
248
|
{
|
|
@@ -282,7 +282,7 @@
|
|
|
282
282
|
],
|
|
283
283
|
"removedExports": [],
|
|
284
284
|
"dependents": [],
|
|
285
|
-
"percent": 0.
|
|
285
|
+
"percent": 0.8,
|
|
286
286
|
"reduction": 44.95
|
|
287
287
|
},
|
|
288
288
|
{
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
"/src/index.ts",
|
|
328
328
|
"/src/links/internals/httpUtils.ts"
|
|
329
329
|
],
|
|
330
|
-
"percent": 0.
|
|
330
|
+
"percent": 0.56,
|
|
331
331
|
"reduction": 33.54
|
|
332
332
|
},
|
|
333
333
|
{
|
package/dist/index.js
CHANGED
|
@@ -30,12 +30,12 @@ exports.isFormData = contentTypes.isFormData;
|
|
|
30
30
|
exports.isNonJsonSerializable = contentTypes.isNonJsonSerializable;
|
|
31
31
|
exports.isOctetType = contentTypes.isOctetType;
|
|
32
32
|
exports.httpBatchLink = httpBatchLink.httpBatchLink;
|
|
33
|
-
exports.
|
|
33
|
+
exports.httpBatchStreamLink = httpBatchStreamLink.httpBatchStreamLink;
|
|
34
34
|
exports.httpLink = httpLink.httpLink;
|
|
35
35
|
exports.loggerLink = loggerLink.loggerLink;
|
|
36
36
|
exports.splitLink = splitLink.splitLink;
|
|
37
37
|
exports.wsLink = wsLink.wsLink;
|
|
38
|
-
exports.
|
|
38
|
+
exports.httpSubscriptionLink = httpSubscriptionLink.httpSubscriptionLink;
|
|
39
39
|
exports.retryLink = retryLink.retryLink;
|
|
40
40
|
exports.TRPCUntypedClient = TRPCUntypedClient.TRPCUntypedClient;
|
|
41
41
|
exports.createWSClient = createWsClient.createWSClient;
|
package/dist/index.mjs
CHANGED
|
@@ -4,12 +4,12 @@ export { getFetch } from './getFetch.mjs';
|
|
|
4
4
|
export { TRPCClientError } from './TRPCClientError.mjs';
|
|
5
5
|
export { isFormData, isNonJsonSerializable, isOctetType } from './links/internals/contentTypes.mjs';
|
|
6
6
|
export { httpBatchLink } from './links/httpBatchLink.mjs';
|
|
7
|
-
export {
|
|
7
|
+
export { httpBatchStreamLink } from './links/httpBatchStreamLink.mjs';
|
|
8
8
|
export { httpLink } from './links/httpLink.mjs';
|
|
9
9
|
export { loggerLink } from './links/loggerLink.mjs';
|
|
10
10
|
export { splitLink } from './links/splitLink.mjs';
|
|
11
11
|
export { wsLink } from './links/wsLink/wsLink.mjs';
|
|
12
|
-
export {
|
|
12
|
+
export { httpSubscriptionLink } from './links/httpSubscriptionLink.mjs';
|
|
13
13
|
export { retryLink } from './links/retryLink.mjs';
|
|
14
14
|
export { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
|
|
15
15
|
export { createWSClient } from './links/wsLink/createWsClient.mjs';
|
|
@@ -11,5 +11,10 @@ export type HTTPBatchLinkOptions<TRoot extends AnyClientTypes> = HTTPLinkBaseOpt
|
|
|
11
11
|
headers?: HTTPHeaders | ((opts: {
|
|
12
12
|
opList: NonEmptyArray<Operation>;
|
|
13
13
|
}) => HTTPHeaders | Promise<HTTPHeaders>);
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of calls in a single batch request
|
|
16
|
+
* @default Infinity
|
|
17
|
+
*/
|
|
18
|
+
maxItems?: number;
|
|
14
19
|
};
|
|
15
20
|
//# sourceMappingURL=HTTPBatchLinkOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTTPBatchLinkOptions.d.ts","sourceRoot":"","sources":["../../src/links/HTTPBatchLinkOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,cAAc,IAC3D,mBAAmB,CAAC,KAAK,CAAC,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EACJ,WAAW,GACX,CAAC,CAAC,IAAI,EAAE;QACN,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;KAClC,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"HTTPBatchLinkOptions.d.ts","sourceRoot":"","sources":["../../src/links/HTTPBatchLinkOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,cAAc,IAC3D,mBAAmB,CAAC,KAAK,CAAC,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EACJ,WAAW,GACX,CAAC,CAAC,IAAI,EAAE;QACN,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;KAClC,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAE9C;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAQ7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAOnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAQ7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAOnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,CAsHnB"}
|
|
@@ -12,14 +12,18 @@ var httpUtils = require('./internals/httpUtils.js');
|
|
|
12
12
|
*/ function httpBatchLink(opts) {
|
|
13
13
|
const resolvedOpts = httpUtils.resolveHTTPLinkOptions(opts);
|
|
14
14
|
const maxURLLength = opts.maxURLLength ?? Infinity;
|
|
15
|
+
const maxItems = opts.maxItems ?? Infinity;
|
|
15
16
|
return ()=>{
|
|
16
17
|
const batchLoader = (type)=>{
|
|
17
18
|
return {
|
|
18
19
|
validate (batchOps) {
|
|
19
|
-
if (maxURLLength === Infinity) {
|
|
20
|
+
if (maxURLLength === Infinity && maxItems === Infinity) {
|
|
20
21
|
// escape hatch for quick calcs
|
|
21
22
|
return true;
|
|
22
23
|
}
|
|
24
|
+
if (batchOps.length > maxItems) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
23
27
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
24
28
|
const inputs = batchOps.map((op)=>op.input);
|
|
25
29
|
const url = httpUtils.getUrl({
|
|
@@ -10,14 +10,18 @@ import { resolveHTTPLinkOptions, jsonHttpRequester, getUrl } from './internals/h
|
|
|
10
10
|
*/ function httpBatchLink(opts) {
|
|
11
11
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
12
12
|
const maxURLLength = opts.maxURLLength ?? Infinity;
|
|
13
|
+
const maxItems = opts.maxItems ?? Infinity;
|
|
13
14
|
return ()=>{
|
|
14
15
|
const batchLoader = (type)=>{
|
|
15
16
|
return {
|
|
16
17
|
validate (batchOps) {
|
|
17
|
-
if (maxURLLength === Infinity) {
|
|
18
|
+
if (maxURLLength === Infinity && maxItems === Infinity) {
|
|
18
19
|
// escape hatch for quick calcs
|
|
19
20
|
return true;
|
|
20
21
|
}
|
|
22
|
+
if (batchOps.length > maxItems) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
21
25
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
22
26
|
const inputs = batchOps.map((op)=>op.input);
|
|
23
27
|
const url = getUrl({
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { AnyRouter } from '@trpc/server';
|
|
2
|
-
import type { AnyRootTypes } from '@trpc/server/unstable-core-do-not-import';
|
|
3
2
|
import type { HTTPBatchLinkOptions } from './HTTPBatchLinkOptions';
|
|
4
3
|
import type { TRPCLink } from './types';
|
|
5
|
-
export type HTTPBatchStreamLinkOptions<TRoot extends AnyRootTypes> = HTTPBatchLinkOptions<TRoot> & {
|
|
6
|
-
/**
|
|
7
|
-
* Maximum number of calls in a single batch request
|
|
8
|
-
* @default Infinity
|
|
9
|
-
*/
|
|
10
|
-
maxItems?: number;
|
|
11
|
-
};
|
|
12
4
|
/**
|
|
13
5
|
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
14
6
|
*/
|
|
15
|
-
export declare function
|
|
7
|
+
export declare function httpBatchStreamLink<TRouter extends AnyRouter>(opts: HTTPBatchLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
|
|
16
8
|
//# sourceMappingURL=httpBatchStreamLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpBatchStreamLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchStreamLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"httpBatchStreamLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchStreamLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAS7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,SAAS,EAC3D,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,CAgKnB"}
|
|
@@ -9,7 +9,7 @@ var httpUtils = require('./internals/httpUtils.js');
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
12
|
-
*/ function
|
|
12
|
+
*/ function httpBatchStreamLink(opts) {
|
|
13
13
|
const resolvedOpts = httpUtils.resolveHTTPLinkOptions(opts);
|
|
14
14
|
const maxURLLength = opts.maxURLLength ?? Infinity;
|
|
15
15
|
const maxItems = opts.maxItems ?? Infinity;
|
|
@@ -143,4 +143,4 @@ var httpUtils = require('./internals/httpUtils.js');
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
exports.
|
|
146
|
+
exports.httpBatchStreamLink = httpBatchStreamLink;
|
|
@@ -7,7 +7,7 @@ import { resolveHTTPLinkOptions, fetchHTTPResponse, getBody, getUrl } from './in
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
10
|
-
*/ function
|
|
10
|
+
*/ function httpBatchStreamLink(opts) {
|
|
11
11
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
12
12
|
const maxURLLength = opts.maxURLLength ?? Infinity;
|
|
13
13
|
const maxItems = opts.maxItems ?? Infinity;
|
|
@@ -141,4 +141,4 @@ import { resolveHTTPLinkOptions, fetchHTTPResponse, getBody, getUrl } from './in
|
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
export {
|
|
144
|
+
export { httpBatchStreamLink };
|
|
@@ -17,6 +17,6 @@ type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes, TEventSource exte
|
|
|
17
17
|
/**
|
|
18
18
|
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
|
19
19
|
*/
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function httpSubscriptionLink<TInferrable extends InferrableClientTypes, TEventSource extends EventSourceLike.AnyConstructor>(opts: HTTPSubscriptionLinkOptions<inferClientTypes<TInferrable>, TEventSource>): TRPCLink<TInferrable>;
|
|
21
21
|
export {};
|
|
22
22
|
//# sourceMappingURL=httpSubscriptionLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpSubscriptionLink.d.ts","sourceRoot":"","sources":["../../src/links/httpSubscriptionLink.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,0CAA0C,CAAC;AASlD,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBnD,KAAK,2BAA2B,CAC9B,KAAK,SAAS,cAAc,EAC5B,YAAY,SAAS,eAAe,CAAC,cAAc,GAAG,OAAO,WAAW,IACtE;IACF;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,kBAAkB,CAAC,EACf,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,GACxC,CAAC,CAAC,IAAI,EAAE;QACN,EAAE,EAAE,SAAS,CAAC;KACf,KACG,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,GACxC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC5D,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAC3B,8BAA8B,CAAC;AAajC;;GAEG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"httpSubscriptionLink.d.ts","sourceRoot":"","sources":["../../src/links/httpSubscriptionLink.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,0CAA0C,CAAC;AASlD,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBnD,KAAK,2BAA2B,CAC9B,KAAK,SAAS,cAAc,EAC5B,YAAY,SAAS,eAAe,CAAC,cAAc,GAAG,OAAO,WAAW,IACtE;IACF;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,kBAAkB,CAAC,EACf,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,GACxC,CAAC,CAAC,IAAI,EAAE;QACN,EAAE,EAAE,SAAS,CAAC;KACf,KACG,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,GACxC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC5D,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAC3B,8BAA8B,CAAC;AAajC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,SAAS,qBAAqB,EACzC,YAAY,SAAS,eAAe,CAAC,cAAc,EAEnD,IAAI,EAAE,2BAA2B,CAC/B,gBAAgB,CAAC,WAAW,CAAC,EAC7B,YAAY,CACb,GACA,QAAQ,CAAC,WAAW,CAAC,CAuKvB"}
|
|
@@ -30,7 +30,7 @@ async function urlWithConnectionParams(opts) {
|
|
|
30
30
|
];
|
|
31
31
|
/**
|
|
32
32
|
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
|
33
|
-
*/ function
|
|
33
|
+
*/ function httpSubscriptionLink(opts) {
|
|
34
34
|
const transformer$1 = transformer.getTransformer(opts.transformer);
|
|
35
35
|
return ()=>{
|
|
36
36
|
return ({ op })=>{
|
|
@@ -180,4 +180,4 @@ async function urlWithConnectionParams(opts) {
|
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
exports.
|
|
183
|
+
exports.httpSubscriptionLink = httpSubscriptionLink;
|
|
@@ -28,7 +28,7 @@ async function urlWithConnectionParams(opts) {
|
|
|
28
28
|
];
|
|
29
29
|
/**
|
|
30
30
|
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
|
31
|
-
*/ function
|
|
31
|
+
*/ function httpSubscriptionLink(opts) {
|
|
32
32
|
const transformer = getTransformer(opts.transformer);
|
|
33
33
|
return ()=>{
|
|
34
34
|
return ({ op })=>{
|
|
@@ -178,4 +178,4 @@ async function urlWithConnectionParams(opts) {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
export {
|
|
181
|
+
export { httpSubscriptionLink };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.844+0244dee81",
|
|
4
4
|
"description": "The tRPC client library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"!**/__tests__"
|
|
78
78
|
],
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@trpc/server": "11.0.0-rc.
|
|
80
|
+
"@trpc/server": "11.0.0-rc.844+0244dee81",
|
|
81
81
|
"typescript": ">=5.7.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@trpc/server": "11.0.0-rc.
|
|
84
|
+
"@trpc/server": "11.0.0-rc.844+0244dee81",
|
|
85
85
|
"@types/isomorphic-fetch": "^0.0.39",
|
|
86
86
|
"@types/node": "^22.13.5",
|
|
87
87
|
"dataloader": "^2.2.2",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"funding": [
|
|
102
102
|
"https://trpc.io/sponsor"
|
|
103
103
|
],
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "0244dee8108e808281041838d6c326dacb030bf2"
|
|
105
105
|
}
|
|
@@ -15,4 +15,10 @@ export type HTTPBatchLinkOptions<TRoot extends AnyClientTypes> =
|
|
|
15
15
|
| ((opts: {
|
|
16
16
|
opList: NonEmptyArray<Operation>;
|
|
17
17
|
}) => HTTPHeaders | Promise<HTTPHeaders>);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of calls in a single batch request
|
|
21
|
+
* @default Infinity
|
|
22
|
+
*/
|
|
23
|
+
maxItems?: number;
|
|
18
24
|
};
|
|
@@ -23,6 +23,7 @@ export function httpBatchLink<TRouter extends AnyRouter>(
|
|
|
23
23
|
): TRPCLink<TRouter> {
|
|
24
24
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
25
25
|
const maxURLLength = opts.maxURLLength ?? Infinity;
|
|
26
|
+
const maxItems = opts.maxItems ?? Infinity;
|
|
26
27
|
|
|
27
28
|
return () => {
|
|
28
29
|
const batchLoader = (
|
|
@@ -30,10 +31,13 @@ export function httpBatchLink<TRouter extends AnyRouter>(
|
|
|
30
31
|
): BatchLoader<Operation, HTTPResult> => {
|
|
31
32
|
return {
|
|
32
33
|
validate(batchOps) {
|
|
33
|
-
if (maxURLLength === Infinity) {
|
|
34
|
+
if (maxURLLength === Infinity && maxItems === Infinity) {
|
|
34
35
|
// escape hatch for quick calcs
|
|
35
36
|
return true;
|
|
36
37
|
}
|
|
38
|
+
if (batchOps.length > maxItems) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
37
41
|
const path = batchOps.map((op) => op.path).join(',');
|
|
38
42
|
const inputs = batchOps.map((op) => op.input);
|
|
39
43
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { AnyRouter, ProcedureType } from '@trpc/server';
|
|
2
2
|
import { observable } from '@trpc/server/observable';
|
|
3
3
|
import type { TRPCErrorShape, TRPCResponse } from '@trpc/server/rpc';
|
|
4
|
-
import type { AnyRootTypes } from '@trpc/server/unstable-core-do-not-import';
|
|
5
4
|
import { jsonlStreamConsumer } from '@trpc/server/unstable-core-do-not-import';
|
|
6
5
|
import type { BatchLoader } from '../internals/dataLoader';
|
|
7
6
|
import { dataLoader } from '../internals/dataLoader';
|
|
@@ -18,20 +17,11 @@ import {
|
|
|
18
17
|
} from './internals/httpUtils';
|
|
19
18
|
import type { Operation, TRPCLink } from './types';
|
|
20
19
|
|
|
21
|
-
export type HTTPBatchStreamLinkOptions<TRoot extends AnyRootTypes> =
|
|
22
|
-
HTTPBatchLinkOptions<TRoot> & {
|
|
23
|
-
/**
|
|
24
|
-
* Maximum number of calls in a single batch request
|
|
25
|
-
* @default Infinity
|
|
26
|
-
*/
|
|
27
|
-
maxItems?: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
20
|
/**
|
|
31
21
|
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
32
22
|
*/
|
|
33
|
-
export function
|
|
34
|
-
opts:
|
|
23
|
+
export function httpBatchStreamLink<TRouter extends AnyRouter>(
|
|
24
|
+
opts: HTTPBatchLinkOptions<TRouter['_def']['_config']['$types']>,
|
|
35
25
|
): TRPCLink<TRouter> {
|
|
36
26
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
37
27
|
const maxURLLength = opts.maxURLLength ?? Infinity;
|
|
@@ -77,7 +77,7 @@ const codes5xx: TRPC_ERROR_CODE_NUMBER[] = [
|
|
|
77
77
|
/**
|
|
78
78
|
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
|
79
79
|
*/
|
|
80
|
-
export function
|
|
80
|
+
export function httpSubscriptionLink<
|
|
81
81
|
TInferrable extends InferrableClientTypes,
|
|
82
82
|
TEventSource extends EventSourceLike.AnyConstructor,
|
|
83
83
|
>(
|