@trpc/client 11.0.0-rc.843 → 11.0.0
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/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/links/wsLink/index.d.ts +1 -0
- package/links/wsLink/index.js +1 -0
- 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
- package/dist/bundle-analysis.json +0 -431
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/links/wsLink';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/links/wsLink');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "11.0.0
|
|
3
|
+
"version": "11.0.0",
|
|
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
|
|
80
|
+
"@trpc/server": "11.0.0",
|
|
81
81
|
"typescript": ">=5.7.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@trpc/server": "11.0.0
|
|
84
|
+
"@trpc/server": "11.0.0",
|
|
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": "85841a1ae4679847fd29ad5454c1a584a2e206d2"
|
|
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
|
>(
|
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"bundleSize": 75612,
|
|
3
|
-
"bundleOrigSize": 94335,
|
|
4
|
-
"bundleReduction": 19.85,
|
|
5
|
-
"modules": [
|
|
6
|
-
{
|
|
7
|
-
"id": "/src/links/wsLink/wsClient/wsClient.ts",
|
|
8
|
-
"size": 12067,
|
|
9
|
-
"origSize": 12199,
|
|
10
|
-
"renderedExports": [
|
|
11
|
-
"WsClient"
|
|
12
|
-
],
|
|
13
|
-
"removedExports": [],
|
|
14
|
-
"dependents": [
|
|
15
|
-
"/src/links/wsLink/createWsClient.ts"
|
|
16
|
-
],
|
|
17
|
-
"percent": 15.96,
|
|
18
|
-
"reduction": 1.08
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"id": "/src/links/httpSubscriptionLink.ts",
|
|
22
|
-
"size": 7969,
|
|
23
|
-
"origSize": 7693,
|
|
24
|
-
"renderedExports": [
|
|
25
|
-
"unstable_httpSubscriptionLink"
|
|
26
|
-
],
|
|
27
|
-
"removedExports": [],
|
|
28
|
-
"dependents": [],
|
|
29
|
-
"percent": 10.54,
|
|
30
|
-
"reduction": 0
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"id": "/src/links/wsLink/wsClient/wsConnection.ts",
|
|
34
|
-
"size": 6174,
|
|
35
|
-
"origSize": 6492,
|
|
36
|
-
"renderedExports": [
|
|
37
|
-
"WsConnection",
|
|
38
|
-
"backwardCompatibility"
|
|
39
|
-
],
|
|
40
|
-
"removedExports": [],
|
|
41
|
-
"dependents": [
|
|
42
|
-
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
43
|
-
],
|
|
44
|
-
"percent": 8.17,
|
|
45
|
-
"reduction": 4.9
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"id": "/src/links/httpBatchStreamLink.ts",
|
|
49
|
-
"size": 6017,
|
|
50
|
-
"origSize": 6295,
|
|
51
|
-
"renderedExports": [
|
|
52
|
-
"unstable_httpBatchStreamLink"
|
|
53
|
-
],
|
|
54
|
-
"removedExports": [],
|
|
55
|
-
"dependents": [],
|
|
56
|
-
"percent": 7.96,
|
|
57
|
-
"reduction": 4.42
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"id": "/src/links/loggerLink.ts",
|
|
61
|
-
"size": 5596,
|
|
62
|
-
"origSize": 6946,
|
|
63
|
-
"renderedExports": [
|
|
64
|
-
"loggerLink"
|
|
65
|
-
],
|
|
66
|
-
"removedExports": [],
|
|
67
|
-
"dependents": [],
|
|
68
|
-
"percent": 7.4,
|
|
69
|
-
"reduction": 19.44
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"id": "/src/links/wsLink/wsClient/requestManager.ts",
|
|
73
|
-
"size": 4792,
|
|
74
|
-
"origSize": 5216,
|
|
75
|
-
"renderedExports": [
|
|
76
|
-
"RequestManager"
|
|
77
|
-
],
|
|
78
|
-
"removedExports": [],
|
|
79
|
-
"dependents": [
|
|
80
|
-
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
81
|
-
],
|
|
82
|
-
"percent": 6.34,
|
|
83
|
-
"reduction": 8.13
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"id": "/src/internals/dataLoader.ts",
|
|
87
|
-
"size": 4084,
|
|
88
|
-
"origSize": 4328,
|
|
89
|
-
"renderedExports": [
|
|
90
|
-
"dataLoader"
|
|
91
|
-
],
|
|
92
|
-
"removedExports": [],
|
|
93
|
-
"dependents": [
|
|
94
|
-
"/src/links/httpBatchLink.ts",
|
|
95
|
-
"/src/links/httpBatchStreamLink.ts"
|
|
96
|
-
],
|
|
97
|
-
"percent": 5.4,
|
|
98
|
-
"reduction": 5.64
|
|
99
|
-
},
|
|
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
|
-
{
|
|
113
|
-
"id": "/src/links/internals/httpUtils.ts",
|
|
114
|
-
"size": 3692,
|
|
115
|
-
"origSize": 5873,
|
|
116
|
-
"renderedExports": [
|
|
117
|
-
"resolveHTTPLinkOptions",
|
|
118
|
-
"getInput",
|
|
119
|
-
"getUrl",
|
|
120
|
-
"getBody",
|
|
121
|
-
"jsonHttpRequester",
|
|
122
|
-
"fetchHTTPResponse",
|
|
123
|
-
"httpRequest"
|
|
124
|
-
],
|
|
125
|
-
"removedExports": [],
|
|
126
|
-
"dependents": [
|
|
127
|
-
"/src/links/httpBatchLink.ts",
|
|
128
|
-
"/src/links/httpLink.ts",
|
|
129
|
-
"/src/links/httpBatchStreamLink.ts",
|
|
130
|
-
"/src/links/httpSubscriptionLink.ts"
|
|
131
|
-
],
|
|
132
|
-
"percent": 4.88,
|
|
133
|
-
"reduction": 37.14
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"id": "/src/links/httpLink.ts",
|
|
137
|
-
"size": 3292,
|
|
138
|
-
"origSize": 3765,
|
|
139
|
-
"renderedExports": [
|
|
140
|
-
"httpLink"
|
|
141
|
-
],
|
|
142
|
-
"removedExports": [],
|
|
143
|
-
"dependents": [],
|
|
144
|
-
"percent": 4.35,
|
|
145
|
-
"reduction": 12.56
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
149
|
-
"size": 3158,
|
|
150
|
-
"origSize": 4417,
|
|
151
|
-
"renderedExports": [
|
|
152
|
-
"TRPCUntypedClient"
|
|
153
|
-
],
|
|
154
|
-
"removedExports": [],
|
|
155
|
-
"dependents": [
|
|
156
|
-
"/src/createTRPCUntypedClient.ts",
|
|
157
|
-
"/src/createTRPCClient.ts"
|
|
158
|
-
],
|
|
159
|
-
"percent": 4.18,
|
|
160
|
-
"reduction": 28.5
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"id": "/src/TRPCClientError.ts",
|
|
164
|
-
"size": 2787,
|
|
165
|
-
"origSize": 3564,
|
|
166
|
-
"renderedExports": [
|
|
167
|
-
"TRPCClientError"
|
|
168
|
-
],
|
|
169
|
-
"removedExports": [],
|
|
170
|
-
"dependents": [
|
|
171
|
-
"/src/index.ts",
|
|
172
|
-
"/src/links/httpBatchLink.ts",
|
|
173
|
-
"/src/links/httpLink.ts",
|
|
174
|
-
"/src/links/httpBatchStreamLink.ts",
|
|
175
|
-
"/src/links/httpSubscriptionLink.ts",
|
|
176
|
-
"/src/internals/TRPCUntypedClient.ts",
|
|
177
|
-
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
178
|
-
],
|
|
179
|
-
"percent": 3.69,
|
|
180
|
-
"reduction": 21.8
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"id": "/src/links/wsLink/wsClient/utils.ts",
|
|
184
|
-
"size": 2781,
|
|
185
|
-
"origSize": 2794,
|
|
186
|
-
"renderedExports": [
|
|
187
|
-
"TRPCWebSocketClosedError",
|
|
188
|
-
"ResettableTimeout",
|
|
189
|
-
"withResolvers",
|
|
190
|
-
"prepareUrl",
|
|
191
|
-
"buildConnectionMessage"
|
|
192
|
-
],
|
|
193
|
-
"removedExports": [],
|
|
194
|
-
"dependents": [
|
|
195
|
-
"/src/links/wsLink/wsClient/wsClient.ts",
|
|
196
|
-
"/src/links/wsLink/wsClient/requestManager.ts",
|
|
197
|
-
"/src/links/wsLink/wsClient/wsConnection.ts"
|
|
198
|
-
],
|
|
199
|
-
"percent": 3.68,
|
|
200
|
-
"reduction": 0.47
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"id": "/src/links/retryLink.ts",
|
|
204
|
-
"size": 2194,
|
|
205
|
-
"origSize": 2702,
|
|
206
|
-
"renderedExports": [
|
|
207
|
-
"retryLink"
|
|
208
|
-
],
|
|
209
|
-
"removedExports": [],
|
|
210
|
-
"dependents": [],
|
|
211
|
-
"percent": 2.9,
|
|
212
|
-
"reduction": 18.8
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
"id": "/src/internals/signals.ts",
|
|
216
|
-
"size": 1188,
|
|
217
|
-
"origSize": 1236,
|
|
218
|
-
"renderedExports": [
|
|
219
|
-
"allAbortSignals",
|
|
220
|
-
"raceAbortSignals"
|
|
221
|
-
],
|
|
222
|
-
"removedExports": [],
|
|
223
|
-
"dependents": [
|
|
224
|
-
"/src/links/httpBatchLink.ts",
|
|
225
|
-
"/src/links/httpBatchStreamLink.ts",
|
|
226
|
-
"/src/links/httpSubscriptionLink.ts"
|
|
227
|
-
],
|
|
228
|
-
"percent": 1.57,
|
|
229
|
-
"reduction": 3.88
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"id": "/src/createTRPCClient.ts",
|
|
233
|
-
"size": 1170,
|
|
234
|
-
"origSize": 4737,
|
|
235
|
-
"renderedExports": [
|
|
236
|
-
"clientCallTypeToProcedureType",
|
|
237
|
-
"createTRPCClientProxy",
|
|
238
|
-
"createTRPCClient",
|
|
239
|
-
"getUntypedClient"
|
|
240
|
-
],
|
|
241
|
-
"removedExports": [],
|
|
242
|
-
"dependents": [
|
|
243
|
-
"/src/index.ts"
|
|
244
|
-
],
|
|
245
|
-
"percent": 1.55,
|
|
246
|
-
"reduction": 75.3
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
"id": "/src/links/wsLink/wsLink.ts",
|
|
250
|
-
"size": 939,
|
|
251
|
-
"origSize": 1600,
|
|
252
|
-
"renderedExports": [
|
|
253
|
-
"wsLink",
|
|
254
|
-
"createWSClient"
|
|
255
|
-
],
|
|
256
|
-
"removedExports": [],
|
|
257
|
-
"dependents": [],
|
|
258
|
-
"percent": 1.24,
|
|
259
|
-
"reduction": 41.31
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
"id": "/src/links/internals/createChain.ts",
|
|
263
|
-
"size": 690,
|
|
264
|
-
"origSize": 1026,
|
|
265
|
-
"renderedExports": [
|
|
266
|
-
"createChain"
|
|
267
|
-
],
|
|
268
|
-
"removedExports": [],
|
|
269
|
-
"dependents": [
|
|
270
|
-
"/src/links/splitLink.ts",
|
|
271
|
-
"/src/internals/TRPCUntypedClient.ts"
|
|
272
|
-
],
|
|
273
|
-
"percent": 0.91,
|
|
274
|
-
"reduction": 32.75
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
"id": "/src/links/splitLink.ts",
|
|
278
|
-
"size": 610,
|
|
279
|
-
"origSize": 1108,
|
|
280
|
-
"renderedExports": [
|
|
281
|
-
"splitLink"
|
|
282
|
-
],
|
|
283
|
-
"removedExports": [],
|
|
284
|
-
"dependents": [],
|
|
285
|
-
"percent": 0.81,
|
|
286
|
-
"reduction": 44.95
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
"id": "/src/internals/transformer.ts",
|
|
290
|
-
"size": 565,
|
|
291
|
-
"origSize": 1697,
|
|
292
|
-
"renderedExports": [
|
|
293
|
-
"getTransformer"
|
|
294
|
-
],
|
|
295
|
-
"removedExports": [],
|
|
296
|
-
"dependents": [
|
|
297
|
-
"/src/unstable-internals.ts"
|
|
298
|
-
],
|
|
299
|
-
"percent": 0.75,
|
|
300
|
-
"reduction": 66.71
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
"id": "/src/links/wsLink/wsClient/options.ts",
|
|
304
|
-
"size": 485,
|
|
305
|
-
"origSize": 2636,
|
|
306
|
-
"renderedExports": [
|
|
307
|
-
"lazyDefaults",
|
|
308
|
-
"keepAliveDefaults",
|
|
309
|
-
"exponentialBackoff"
|
|
310
|
-
],
|
|
311
|
-
"removedExports": [],
|
|
312
|
-
"dependents": [
|
|
313
|
-
"/src/links/wsLink/wsClient/wsClient.ts"
|
|
314
|
-
],
|
|
315
|
-
"percent": 0.64,
|
|
316
|
-
"reduction": 81.6
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
"id": "/src/getFetch.ts",
|
|
320
|
-
"size": 428,
|
|
321
|
-
"origSize": 644,
|
|
322
|
-
"renderedExports": [
|
|
323
|
-
"getFetch"
|
|
324
|
-
],
|
|
325
|
-
"removedExports": [],
|
|
326
|
-
"dependents": [
|
|
327
|
-
"/src/index.ts",
|
|
328
|
-
"/src/links/internals/httpUtils.ts"
|
|
329
|
-
],
|
|
330
|
-
"percent": 0.57,
|
|
331
|
-
"reduction": 33.54
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
"id": "/src/links/internals/contentTypes.ts",
|
|
335
|
-
"size": 330,
|
|
336
|
-
"origSize": 389,
|
|
337
|
-
"renderedExports": [
|
|
338
|
-
"isOctetType",
|
|
339
|
-
"isFormData",
|
|
340
|
-
"isNonJsonSerializable"
|
|
341
|
-
],
|
|
342
|
-
"removedExports": [],
|
|
343
|
-
"dependents": [],
|
|
344
|
-
"percent": 0.44,
|
|
345
|
-
"reduction": 15.17
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
"id": "/src/internals/inputWithTrackedEventId.ts",
|
|
349
|
-
"size": 254,
|
|
350
|
-
"origSize": 273,
|
|
351
|
-
"renderedExports": [
|
|
352
|
-
"inputWithTrackedEventId"
|
|
353
|
-
],
|
|
354
|
-
"removedExports": [],
|
|
355
|
-
"dependents": [
|
|
356
|
-
"/src/links/httpSubscriptionLink.ts",
|
|
357
|
-
"/src/links/retryLink.ts"
|
|
358
|
-
],
|
|
359
|
-
"percent": 0.34,
|
|
360
|
-
"reduction": 6.96
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
"id": "/src/links/internals/urlWithConnectionParams.ts",
|
|
364
|
-
"size": 240,
|
|
365
|
-
"origSize": 1016,
|
|
366
|
-
"renderedExports": [
|
|
367
|
-
"resultOf"
|
|
368
|
-
],
|
|
369
|
-
"removedExports": [],
|
|
370
|
-
"dependents": [
|
|
371
|
-
"/src/links/httpSubscriptionLink.ts",
|
|
372
|
-
"/src/links/wsLink/wsClient/utils.ts"
|
|
373
|
-
],
|
|
374
|
-
"percent": 0.32,
|
|
375
|
-
"reduction": 76.38
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
"id": "/src/createTRPCUntypedClient.ts",
|
|
379
|
-
"size": 100,
|
|
380
|
-
"origSize": 574,
|
|
381
|
-
"renderedExports": [
|
|
382
|
-
"createTRPCUntypedClient"
|
|
383
|
-
],
|
|
384
|
-
"removedExports": [],
|
|
385
|
-
"dependents": [
|
|
386
|
-
"/src/index.ts"
|
|
387
|
-
],
|
|
388
|
-
"percent": 0.13,
|
|
389
|
-
"reduction": 82.58
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
"id": "/src/links/wsLink/createWsClient.ts",
|
|
393
|
-
"size": 73,
|
|
394
|
-
"origSize": 315,
|
|
395
|
-
"renderedExports": [
|
|
396
|
-
"createWSClient"
|
|
397
|
-
],
|
|
398
|
-
"removedExports": [],
|
|
399
|
-
"dependents": [
|
|
400
|
-
"/src/links/wsLink/wsLink.ts"
|
|
401
|
-
],
|
|
402
|
-
"percent": 0.1,
|
|
403
|
-
"reduction": 76.83
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
"id": "/src/index.ts",
|
|
407
|
-
"size": 0,
|
|
408
|
-
"origSize": 540,
|
|
409
|
-
"renderedExports": [],
|
|
410
|
-
"removedExports": [],
|
|
411
|
-
"dependents": [],
|
|
412
|
-
"percent": 0,
|
|
413
|
-
"reduction": 100
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
"id": "/src/unstable-internals.ts",
|
|
417
|
-
"size": 0,
|
|
418
|
-
"origSize": 90,
|
|
419
|
-
"renderedExports": [],
|
|
420
|
-
"removedExports": [],
|
|
421
|
-
"dependents": [
|
|
422
|
-
"/src/links/wsLink/wsLink.ts",
|
|
423
|
-
"/src/links/httpSubscriptionLink.ts",
|
|
424
|
-
"/src/links/internals/httpUtils.ts"
|
|
425
|
-
],
|
|
426
|
-
"percent": 0,
|
|
427
|
-
"reduction": 100
|
|
428
|
-
}
|
|
429
|
-
],
|
|
430
|
-
"moduleCount": 29
|
|
431
|
-
}
|