@trpc/client 11.0.0-rc.370 → 11.0.0-rc.374

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.
Files changed (47) hide show
  1. package/dist/bundle-analysis.json +60 -106
  2. package/dist/index.js +0 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/internals/dataLoader.d.ts +3 -4
  5. package/dist/internals/dataLoader.d.ts.map +1 -1
  6. package/dist/internals/dataLoader.js +14 -13
  7. package/dist/internals/dataLoader.mjs +14 -13
  8. package/dist/links/httpBatchLink.d.ts +6 -1
  9. package/dist/links/httpBatchLink.d.ts.map +1 -1
  10. package/dist/links/httpBatchLink.js +95 -30
  11. package/dist/links/httpBatchLink.mjs +96 -31
  12. package/dist/links/httpBatchStreamLink.d.ts +9 -6
  13. package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
  14. package/dist/links/httpBatchStreamLink.js +132 -34
  15. package/dist/links/httpBatchStreamLink.mjs +132 -34
  16. package/dist/links/httpLink.d.ts +4 -7
  17. package/dist/links/httpLink.d.ts.map +1 -1
  18. package/dist/links/httpLink.js +72 -46
  19. package/dist/links/httpLink.mjs +74 -47
  20. package/dist/links/internals/httpUtils.d.ts +2 -4
  21. package/dist/links/internals/httpUtils.d.ts.map +1 -1
  22. package/dist/links/internals/httpUtils.js +4 -32
  23. package/dist/links/internals/httpUtils.mjs +4 -32
  24. package/package.json +4 -4
  25. package/src/internals/dataLoader.ts +21 -19
  26. package/src/links/httpBatchLink.ts +132 -46
  27. package/src/links/httpBatchStreamLink.ts +173 -48
  28. package/src/links/httpLink.ts +100 -60
  29. package/src/links/internals/httpUtils.ts +5 -41
  30. package/dist/links/internals/createHTTPBatchLink.d.ts +0 -20
  31. package/dist/links/internals/createHTTPBatchLink.d.ts.map +0 -1
  32. package/dist/links/internals/createHTTPBatchLink.js +0 -85
  33. package/dist/links/internals/createHTTPBatchLink.mjs +0 -83
  34. package/dist/links/internals/getTextDecoder.d.ts +0 -3
  35. package/dist/links/internals/getTextDecoder.d.ts.map +0 -1
  36. package/dist/links/internals/getTextDecoder.js +0 -16
  37. package/dist/links/internals/getTextDecoder.mjs +0 -14
  38. package/dist/links/internals/parseJSONStream.d.ts +0 -39
  39. package/dist/links/internals/parseJSONStream.d.ts.map +0 -1
  40. package/dist/links/internals/parseJSONStream.js +0 -118
  41. package/dist/links/internals/parseJSONStream.mjs +0 -115
  42. package/dist/links/internals/streamingUtils.d.ts +0 -7
  43. package/dist/links/internals/streamingUtils.d.ts.map +0 -1
  44. package/src/links/internals/createHTTPBatchLink.ts +0 -133
  45. package/src/links/internals/getTextDecoder.ts +0 -19
  46. package/src/links/internals/parseJSONStream.ts +0 -166
  47. package/src/links/internals/streamingUtils.ts +0 -6
@@ -1,39 +1,104 @@
1
- import { createHTTPBatchLink } from './internals/createHTTPBatchLink.mjs';
2
- import { jsonHttpRequester } from './internals/httpUtils.mjs';
1
+ import { observable } from '@trpc/server/observable';
2
+ import { transformResult } from '@trpc/server/unstable-core-do-not-import';
3
+ import { dataLoader } from '../internals/dataLoader.mjs';
4
+ import { TRPCClientError } from '../TRPCClientError.mjs';
5
+ import { resolveHTTPLinkOptions, getUrl, jsonHttpRequester } from './internals/httpUtils.mjs';
3
6
 
4
- const batchRequester = (requesterOpts)=>{
5
- return (batchOps)=>{
6
- const path = batchOps.map((op)=>op.path).join(',');
7
- const inputs = batchOps.map((op)=>op.input);
8
- const { promise , cancel } = jsonHttpRequester({
9
- ...requesterOpts,
10
- path,
11
- inputs,
12
- headers () {
13
- if (!requesterOpts.opts.headers) {
14
- return {};
15
- }
16
- if (typeof requesterOpts.opts.headers === 'function') {
17
- return requesterOpts.opts.headers({
18
- opList: batchOps
7
+ /**
8
+ * @see https://trpc.io/docs/client/links/httpBatchLink
9
+ */ function httpBatchLink(opts) {
10
+ const resolvedOpts = resolveHTTPLinkOptions(opts);
11
+ const maxURLLength = opts.maxURLLength ?? Infinity;
12
+ return ()=>{
13
+ const batchLoader = (type)=>{
14
+ return {
15
+ validate (batchOps) {
16
+ if (maxURLLength === Infinity) {
17
+ // escape hatch for quick calcs
18
+ return true;
19
+ }
20
+ const path = batchOps.map((op)=>op.path).join(',');
21
+ const inputs = batchOps.map((op)=>op.input);
22
+ const url = getUrl({
23
+ ...resolvedOpts,
24
+ type,
25
+ path,
26
+ inputs
27
+ });
28
+ return url.length <= maxURLLength;
29
+ },
30
+ fetch (batchOps) {
31
+ const path = batchOps.map((op)=>op.path).join(',');
32
+ const inputs = batchOps.map((op)=>op.input);
33
+ const requester = jsonHttpRequester({
34
+ ...resolvedOpts,
35
+ path,
36
+ inputs,
37
+ type,
38
+ headers () {
39
+ if (!opts.headers) {
40
+ return {};
41
+ }
42
+ if (typeof opts.headers === 'function') {
43
+ return opts.headers({
44
+ opList: batchOps
45
+ });
46
+ }
47
+ return opts.headers;
48
+ }
19
49
  });
50
+ return {
51
+ cancel: requester.cancel,
52
+ promise: requester.promise.then((res)=>{
53
+ const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(()=>res.json);
54
+ const result = resJSON.map((item)=>({
55
+ meta: res.meta,
56
+ json: item
57
+ }));
58
+ return result;
59
+ })
60
+ };
20
61
  }
21
- return requesterOpts.opts.headers;
22
- }
23
- });
24
- return {
25
- promise: promise.then((res)=>{
26
- const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(()=>res.json);
27
- const result = resJSON.map((item)=>({
28
- meta: res.meta,
29
- json: item
62
+ };
63
+ };
64
+ const query = dataLoader(batchLoader('query'));
65
+ const mutation = dataLoader(batchLoader('mutation'));
66
+ const subscription = dataLoader(batchLoader('subscription'));
67
+ const loaders = {
68
+ query,
69
+ subscription,
70
+ mutation
71
+ };
72
+ return ({ op })=>{
73
+ return observable((observer)=>{
74
+ const loader = loaders[op.type];
75
+ const { promise , cancel } = loader.load(op);
76
+ let _res = undefined;
77
+ promise.then((res)=>{
78
+ _res = res;
79
+ const transformed = transformResult(res.json, resolvedOpts.transformer.output);
80
+ if (!transformed.ok) {
81
+ observer.error(TRPCClientError.from(transformed.error, {
82
+ meta: res.meta
83
+ }));
84
+ return;
85
+ }
86
+ observer.next({
87
+ context: res.meta,
88
+ result: transformed.result
89
+ });
90
+ observer.complete();
91
+ }).catch((err)=>{
92
+ observer.error(TRPCClientError.from(err, {
93
+ meta: _res?.meta
30
94
  }));
31
- return result;
32
- }),
33
- cancel
95
+ });
96
+ return ()=>{
97
+ cancel();
98
+ };
99
+ });
34
100
  };
35
101
  };
36
- };
37
- const httpBatchLink = createHTTPBatchLink(batchRequester);
102
+ }
38
103
 
39
104
  export { httpBatchLink };
@@ -1,13 +1,16 @@
1
+ import type { AnyRouter } from '@trpc/server';
1
2
  import type { AnyRootTypes } from '@trpc/server/unstable-core-do-not-import';
2
3
  import type { HTTPBatchLinkOptions } from './HTTPBatchLinkOptions';
3
- import type { TextDecoderEsque } from './internals/streamingUtils';
4
+ import type { TRPCLink } from './types';
4
5
  export type HTTPBatchStreamLinkOptions<TRoot extends AnyRootTypes> = HTTPBatchLinkOptions<TRoot> & {
5
6
  /**
6
- * Will default to the webAPI `TextDecoder`,
7
- * but you can use this option if your client
8
- * runtime doesn't provide it.
7
+ * Maximum number of calls in a single batch request
8
+ * @default Infinity
9
9
  */
10
- textDecoder?: TextDecoderEsque;
10
+ maxItems?: number;
11
11
  };
12
- export declare const unstable_httpBatchStreamLink: <TRouter extends import("@trpc/server/unstable-core-do-not-import").AnyRouter>(opts: HTTPBatchLinkOptions<import("@trpc/server/unstable-core-do-not-import").inferClientTypes<TRouter>>) => import("./types").TRPCLink<TRouter>;
12
+ /**
13
+ * @see https://trpc.io/docs/client/links/httpBatchStreamLink
14
+ */
15
+ export declare function unstable_httpBatchStreamLink<TRouter extends AnyRouter>(opts: HTTPBatchStreamLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
13
16
  //# 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,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAKnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,YAAY,IAC/D,oBAAoB,CAAC,KAAK,CAAC,GAAG;IAC5B;;;;OAIG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,CAAC;AA6CJ,eAAO,MAAM,4BAA4B,iOACH,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;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAM7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,YAAY,IAC/D,oBAAoB,CAAC,KAAK,CAAC,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,SAAS,SAAS,EACpE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GACrE,QAAQ,CAAC,OAAO,CAAC,CA4JnB"}
@@ -1,43 +1,141 @@
1
1
  'use strict';
2
2
 
3
- var createHTTPBatchLink = require('./internals/createHTTPBatchLink.js');
4
- var getTextDecoder = require('./internals/getTextDecoder.js');
5
- var parseJSONStream = require('./internals/parseJSONStream.js');
3
+ var observable = require('@trpc/server/observable');
4
+ var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
5
+ var dataLoader = require('../internals/dataLoader.js');
6
+ var TRPCClientError = require('../TRPCClientError.js');
7
+ var httpUtils = require('./internals/httpUtils.js');
6
8
 
7
- const streamRequester = (requesterOpts)=>{
8
- const textDecoder = getTextDecoder.getTextDecoder(requesterOpts.opts.textDecoder);
9
- return (batchOps, unitResolver)=>{
10
- const path = batchOps.map((op)=>op.path).join(',');
11
- const inputs = batchOps.map((op)=>op.input);
12
- const { cancel , promise } = parseJSONStream.streamingJsonHttpRequester({
13
- ...requesterOpts,
14
- textDecoder,
15
- path,
16
- inputs,
17
- headers () {
18
- if (!requesterOpts.opts.headers) {
19
- return {};
20
- }
21
- if (typeof requesterOpts.opts.headers === 'function') {
22
- return requesterOpts.opts.headers({
23
- opList: batchOps
9
+ /**
10
+ * @see https://trpc.io/docs/client/links/httpBatchStreamLink
11
+ */ function unstable_httpBatchStreamLink(opts) {
12
+ const resolvedOpts = httpUtils.resolveHTTPLinkOptions(opts);
13
+ const maxURLLength = opts.maxURLLength ?? Infinity;
14
+ const maxItems = opts.maxItems ?? Infinity;
15
+ return ()=>{
16
+ const batchLoader = (type)=>{
17
+ return {
18
+ validate (batchOps) {
19
+ if (maxURLLength === Infinity && maxItems === Infinity) {
20
+ // escape hatch for quick calcs
21
+ return true;
22
+ }
23
+ if (batchOps.length > maxItems) {
24
+ return false;
25
+ }
26
+ const path = batchOps.map((op)=>op.path).join(',');
27
+ const inputs = batchOps.map((op)=>op.input);
28
+ const url = httpUtils.getUrl({
29
+ ...resolvedOpts,
30
+ type,
31
+ path,
32
+ inputs
24
33
  });
34
+ return url.length <= maxURLLength;
35
+ },
36
+ fetch (batchOps) {
37
+ const path = batchOps.map((op)=>op.path).join(',');
38
+ const inputs = batchOps.map((op)=>op.input);
39
+ const ac = resolvedOpts.AbortController ? new resolvedOpts.AbortController() : null;
40
+ const responsePromise = httpUtils.fetchHTTPResponse({
41
+ ...resolvedOpts,
42
+ type,
43
+ contentTypeHeader: 'application/json',
44
+ trpcAcceptHeader: 'application/jsonl',
45
+ getUrl: httpUtils.getUrl,
46
+ getBody: httpUtils.getBody,
47
+ inputs,
48
+ path,
49
+ headers () {
50
+ if (!opts.headers) {
51
+ return {};
52
+ }
53
+ if (typeof opts.headers === 'function') {
54
+ return opts.headers({
55
+ opList: batchOps
56
+ });
57
+ }
58
+ return opts.headers;
59
+ }
60
+ }, ac);
61
+ return {
62
+ promise: responsePromise.then(async (res)=>{
63
+ if (!res.body) {
64
+ throw new Error('Received response without body');
65
+ }
66
+ const [head] = await unstableCoreDoNotImport.jsonlStreamConsumer({
67
+ from: res.body,
68
+ deserialize: resolvedOpts.transformer.output.deserialize
69
+ });
70
+ const promises = Object.keys(batchOps).map(async (key)=>{
71
+ let json = await head[key];
72
+ if ('result' in json) {
73
+ /**
74
+ * Not very pretty, but we need to unwrap nested data as promises
75
+ * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
76
+ */ const result = await Promise.resolve(json.result);
77
+ json = {
78
+ result: {
79
+ data: await Promise.resolve(result.data)
80
+ }
81
+ };
82
+ }
83
+ return {
84
+ json,
85
+ meta: {
86
+ response: res
87
+ }
88
+ };
89
+ });
90
+ return promises;
91
+ }),
92
+ cancel () {
93
+ ac?.abort();
94
+ }
95
+ };
25
96
  }
26
- return requesterOpts.opts.headers;
27
- }
28
- }, (index, res)=>{
29
- unitResolver(index, res);
30
- });
31
- return {
32
- /**
33
- * return an empty array because the batchLoader expects an array of results
34
- * but we've already called the `unitResolver` for each of them, there's
35
- * nothing left to do here.
36
- */ promise: promise.then(()=>[]),
37
- cancel
97
+ };
98
+ };
99
+ const query = dataLoader.dataLoader(batchLoader('query'));
100
+ const mutation = dataLoader.dataLoader(batchLoader('mutation'));
101
+ const subscription = dataLoader.dataLoader(batchLoader('subscription'));
102
+ const loaders = {
103
+ query,
104
+ subscription,
105
+ mutation
106
+ };
107
+ return ({ op })=>{
108
+ return observable.observable((observer)=>{
109
+ const loader = loaders[op.type];
110
+ const { promise , cancel } = loader.load(op);
111
+ let _res = undefined;
112
+ promise.then((res)=>{
113
+ _res = res;
114
+ if ('error' in res.json) {
115
+ observer.error(TRPCClientError.TRPCClientError.from(res.json, {
116
+ meta: res.meta
117
+ }));
118
+ return;
119
+ } else if ('result' in res.json) {
120
+ observer.next({
121
+ context: res.meta,
122
+ result: res.json.result
123
+ });
124
+ observer.complete();
125
+ return;
126
+ }
127
+ observer.complete();
128
+ }).catch((err)=>{
129
+ observer.error(TRPCClientError.TRPCClientError.from(err, {
130
+ meta: _res?.meta
131
+ }));
132
+ });
133
+ return ()=>{
134
+ cancel();
135
+ };
136
+ });
38
137
  };
39
138
  };
40
- };
41
- const unstable_httpBatchStreamLink = createHTTPBatchLink.createHTTPBatchLink(streamRequester);
139
+ }
42
140
 
43
141
  exports.unstable_httpBatchStreamLink = unstable_httpBatchStreamLink;
@@ -1,41 +1,139 @@
1
- import { createHTTPBatchLink } from './internals/createHTTPBatchLink.mjs';
2
- import { getTextDecoder } from './internals/getTextDecoder.mjs';
3
- import { streamingJsonHttpRequester } from './internals/parseJSONStream.mjs';
1
+ import { observable } from '@trpc/server/observable';
2
+ import { jsonlStreamConsumer } from '@trpc/server/unstable-core-do-not-import';
3
+ import { dataLoader } from '../internals/dataLoader.mjs';
4
+ import { TRPCClientError } from '../TRPCClientError.mjs';
5
+ import { resolveHTTPLinkOptions, getUrl, fetchHTTPResponse, getBody } from './internals/httpUtils.mjs';
4
6
 
5
- const streamRequester = (requesterOpts)=>{
6
- const textDecoder = getTextDecoder(requesterOpts.opts.textDecoder);
7
- return (batchOps, unitResolver)=>{
8
- const path = batchOps.map((op)=>op.path).join(',');
9
- const inputs = batchOps.map((op)=>op.input);
10
- const { cancel , promise } = streamingJsonHttpRequester({
11
- ...requesterOpts,
12
- textDecoder,
13
- path,
14
- inputs,
15
- headers () {
16
- if (!requesterOpts.opts.headers) {
17
- return {};
18
- }
19
- if (typeof requesterOpts.opts.headers === 'function') {
20
- return requesterOpts.opts.headers({
21
- opList: batchOps
7
+ /**
8
+ * @see https://trpc.io/docs/client/links/httpBatchStreamLink
9
+ */ function unstable_httpBatchStreamLink(opts) {
10
+ const resolvedOpts = resolveHTTPLinkOptions(opts);
11
+ const maxURLLength = opts.maxURLLength ?? Infinity;
12
+ const maxItems = opts.maxItems ?? Infinity;
13
+ return ()=>{
14
+ const batchLoader = (type)=>{
15
+ return {
16
+ validate (batchOps) {
17
+ if (maxURLLength === Infinity && maxItems === Infinity) {
18
+ // escape hatch for quick calcs
19
+ return true;
20
+ }
21
+ if (batchOps.length > maxItems) {
22
+ return false;
23
+ }
24
+ const path = batchOps.map((op)=>op.path).join(',');
25
+ const inputs = batchOps.map((op)=>op.input);
26
+ const url = getUrl({
27
+ ...resolvedOpts,
28
+ type,
29
+ path,
30
+ inputs
22
31
  });
32
+ return url.length <= maxURLLength;
33
+ },
34
+ fetch (batchOps) {
35
+ const path = batchOps.map((op)=>op.path).join(',');
36
+ const inputs = batchOps.map((op)=>op.input);
37
+ const ac = resolvedOpts.AbortController ? new resolvedOpts.AbortController() : null;
38
+ const responsePromise = fetchHTTPResponse({
39
+ ...resolvedOpts,
40
+ type,
41
+ contentTypeHeader: 'application/json',
42
+ trpcAcceptHeader: 'application/jsonl',
43
+ getUrl,
44
+ getBody,
45
+ inputs,
46
+ path,
47
+ headers () {
48
+ if (!opts.headers) {
49
+ return {};
50
+ }
51
+ if (typeof opts.headers === 'function') {
52
+ return opts.headers({
53
+ opList: batchOps
54
+ });
55
+ }
56
+ return opts.headers;
57
+ }
58
+ }, ac);
59
+ return {
60
+ promise: responsePromise.then(async (res)=>{
61
+ if (!res.body) {
62
+ throw new Error('Received response without body');
63
+ }
64
+ const [head] = await jsonlStreamConsumer({
65
+ from: res.body,
66
+ deserialize: resolvedOpts.transformer.output.deserialize
67
+ });
68
+ const promises = Object.keys(batchOps).map(async (key)=>{
69
+ let json = await head[key];
70
+ if ('result' in json) {
71
+ /**
72
+ * Not very pretty, but we need to unwrap nested data as promises
73
+ * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
74
+ */ const result = await Promise.resolve(json.result);
75
+ json = {
76
+ result: {
77
+ data: await Promise.resolve(result.data)
78
+ }
79
+ };
80
+ }
81
+ return {
82
+ json,
83
+ meta: {
84
+ response: res
85
+ }
86
+ };
87
+ });
88
+ return promises;
89
+ }),
90
+ cancel () {
91
+ ac?.abort();
92
+ }
93
+ };
23
94
  }
24
- return requesterOpts.opts.headers;
25
- }
26
- }, (index, res)=>{
27
- unitResolver(index, res);
28
- });
29
- return {
30
- /**
31
- * return an empty array because the batchLoader expects an array of results
32
- * but we've already called the `unitResolver` for each of them, there's
33
- * nothing left to do here.
34
- */ promise: promise.then(()=>[]),
35
- cancel
95
+ };
96
+ };
97
+ const query = dataLoader(batchLoader('query'));
98
+ const mutation = dataLoader(batchLoader('mutation'));
99
+ const subscription = dataLoader(batchLoader('subscription'));
100
+ const loaders = {
101
+ query,
102
+ subscription,
103
+ mutation
104
+ };
105
+ return ({ op })=>{
106
+ return observable((observer)=>{
107
+ const loader = loaders[op.type];
108
+ const { promise , cancel } = loader.load(op);
109
+ let _res = undefined;
110
+ promise.then((res)=>{
111
+ _res = res;
112
+ if ('error' in res.json) {
113
+ observer.error(TRPCClientError.from(res.json, {
114
+ meta: res.meta
115
+ }));
116
+ return;
117
+ } else if ('result' in res.json) {
118
+ observer.next({
119
+ context: res.meta,
120
+ result: res.json.result
121
+ });
122
+ observer.complete();
123
+ return;
124
+ }
125
+ observer.complete();
126
+ }).catch((err)=>{
127
+ observer.error(TRPCClientError.from(err, {
128
+ meta: _res?.meta
129
+ }));
130
+ });
131
+ return ()=>{
132
+ cancel();
133
+ };
134
+ });
36
135
  };
37
136
  };
38
- };
39
- const unstable_httpBatchStreamLink = createHTTPBatchLink(streamRequester);
137
+ }
40
138
 
41
139
  export { unstable_httpBatchStreamLink };
@@ -1,6 +1,6 @@
1
1
  import type { AnyRootTypes, AnyRouter } from '@trpc/server/unstable-core-do-not-import';
2
- import type { HTTPLinkBaseOptions, Requester } from './internals/httpUtils';
3
- import type { HTTPHeaders, Operation, TRPCLink } from './types';
2
+ import type { HTTPLinkBaseOptions } from './internals/httpUtils';
3
+ import { type HTTPHeaders, type Operation, type TRPCLink } from './types';
4
4
  export type HTTPLinkOptions<TRoot extends AnyRootTypes> = HTTPLinkBaseOptions<TRoot> & {
5
5
  /**
6
6
  * Headers to be set on outgoing requests or a callback that of said headers
@@ -10,11 +10,8 @@ export type HTTPLinkOptions<TRoot extends AnyRootTypes> = HTTPLinkBaseOptions<TR
10
10
  op: Operation;
11
11
  }) => HTTPHeaders | Promise<HTTPHeaders>);
12
12
  };
13
- export declare function httpLinkFactory(factoryOpts: {
14
- requester: Requester;
15
- }): <TRouter extends AnyRouter>(opts: HTTPLinkOptions<TRouter['_def']['_config']['$types']>) => TRPCLink<TRouter>;
16
13
  /**
17
- * @link https://trpc.io/docs/v11/client/links/httpLink
14
+ * @link https://trpc.io/docs/client/links/httpLink
18
15
  */
19
- export declare const httpLink: <TRouter extends AnyRouter>(opts: HTTPLinkOptions<TRouter['_def']['_config']['$types']>) => TRPCLink<TRouter>;
16
+ export declare function httpLink<TRouter extends AnyRouter = AnyRouter>(opts: HTTPLinkOptions<TRouter['_def']['_config']['$types']>): TRPCLink<TRouter>;
20
17
  //# sourceMappingURL=httpLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACV,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,mBAAmB,EAEnB,SAAS,EACV,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,YAAY,IACpD,mBAAmB,CAAC,KAAK,CAAC,GAAG;IAC3B;;;OAGG;IACH,OAAO,CAAC,EACJ,WAAW,GACX,CAAC,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;CACvE,CAAC;AAEJ,wBAAgB,eAAe,CAAC,WAAW,EAAE;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,qCAE3D,gBAAgB,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAC1D,SAAS,OAAO,CAAC,CAwDrB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,oCA9DX,gBAAgB,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAC1D,SAAS,OAAO,CA6DqD,CAAC"}
1
+ {"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACV,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,QAAQ,EACd,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,YAAY,IACpD,mBAAmB,CAAC,KAAK,CAAC,GAAG;IAC3B;;;OAGG;IACH,OAAO,CAAC,EACJ,WAAW,GACX,CAAC,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;CACvE,CAAC;AAmCJ;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EAC5D,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC1D,QAAQ,CAAC,OAAO,CAAC,CAyDnB"}