@trpc/client 11.0.0-rc.413 → 11.0.0-rc.419

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 (46) hide show
  1. package/dist/bundle-analysis.json +55 -40
  2. package/dist/createTRPCClient.d.ts.map +1 -1
  3. package/dist/createTRPCClient.js +9 -9
  4. package/dist/createTRPCClient.mjs +10 -10
  5. package/dist/index.js +2 -0
  6. package/dist/index.mjs +1 -0
  7. package/dist/internals/TRPCUntypedClient.d.ts +3 -1
  8. package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
  9. package/dist/internals/TRPCUntypedClient.js +3 -1
  10. package/dist/internals/TRPCUntypedClient.mjs +3 -1
  11. package/dist/internals/dataLoader.d.ts.map +1 -1
  12. package/dist/links/httpBatchLink.d.ts.map +1 -1
  13. package/dist/links/httpBatchLink.js +3 -2
  14. package/dist/links/httpBatchLink.mjs +3 -2
  15. package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
  16. package/dist/links/httpBatchStreamLink.js +5 -6
  17. package/dist/links/httpBatchStreamLink.mjs +5 -6
  18. package/dist/links/httpLink.d.ts +2 -2
  19. package/dist/links/httpLink.d.ts.map +1 -1
  20. package/dist/links/httpLink.js +3 -0
  21. package/dist/links/httpLink.mjs +3 -0
  22. package/dist/links/httpSubscriptionLink.d.ts +19 -0
  23. package/dist/links/httpSubscriptionLink.d.ts.map +1 -0
  24. package/dist/links/httpSubscriptionLink.js +87 -0
  25. package/dist/links/httpSubscriptionLink.mjs +85 -0
  26. package/dist/links/internals/contentTypes.d.ts +3 -3
  27. package/dist/links/internals/contentTypes.d.ts.map +1 -1
  28. package/dist/links/internals/httpUtils.d.ts +4 -4
  29. package/dist/links/internals/httpUtils.d.ts.map +1 -1
  30. package/dist/links/internals/httpUtils.js +6 -7
  31. package/dist/links/internals/httpUtils.mjs +6 -7
  32. package/dist/links/loggerLink.d.ts +0 -1
  33. package/dist/links/loggerLink.d.ts.map +1 -1
  34. package/dist/links/wsLink.d.ts +4 -4
  35. package/dist/links/wsLink.d.ts.map +1 -1
  36. package/dist/links.d.ts +1 -0
  37. package/dist/links.d.ts.map +1 -1
  38. package/package.json +4 -4
  39. package/src/createTRPCClient.ts +11 -8
  40. package/src/internals/TRPCUntypedClient.ts +4 -2
  41. package/src/links/httpBatchLink.ts +8 -5
  42. package/src/links/httpBatchStreamLink.ts +10 -7
  43. package/src/links/httpLink.ts +8 -2
  44. package/src/links/httpSubscriptionLink.ts +121 -0
  45. package/src/links/internals/httpUtils.ts +10 -11
  46. package/src/links.ts +1 -0
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 46976,
3
- "bundleOrigSize": 63519,
4
- "bundleReduction": 26.04,
2
+ "bundleSize": 50717,
3
+ "bundleOrigSize": 67665,
4
+ "bundleReduction": 25.05,
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.67,
16
+ "percent": 23.78,
17
17
  "reduction": 11.68
18
18
  },
19
19
  {
20
20
  "id": "/src/links/httpBatchStreamLink.ts",
21
- "size": 6153,
22
- "origSize": 6253,
21
+ "size": 6237,
22
+ "origSize": 6400,
23
23
  "renderedExports": [
24
24
  "unstable_httpBatchStreamLink"
25
25
  ],
26
26
  "removedExports": [],
27
27
  "dependents": [],
28
- "percent": 13.1,
29
- "reduction": 1.6
28
+ "percent": 12.3,
29
+ "reduction": 2.55
30
30
  },
31
31
  {
32
32
  "id": "/src/links/loggerLink.ts",
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "removedExports": [],
39
39
  "dependents": [],
40
- "percent": 11.62,
40
+ "percent": 10.76,
41
41
  "reduction": 18.48
42
42
  },
43
43
  {
@@ -52,25 +52,25 @@
52
52
  "/src/links/httpBatchLink.ts",
53
53
  "/src/links/httpBatchStreamLink.ts"
54
54
  ],
55
- "percent": 9.59,
55
+ "percent": 8.88,
56
56
  "reduction": 6.34
57
57
  },
58
58
  {
59
59
  "id": "/src/links/httpBatchLink.ts",
60
- "size": 3906,
61
- "origSize": 4074,
60
+ "size": 4030,
61
+ "origSize": 4173,
62
62
  "renderedExports": [
63
63
  "httpBatchLink"
64
64
  ],
65
65
  "removedExports": [],
66
66
  "dependents": [],
67
- "percent": 8.31,
68
- "reduction": 4.12
67
+ "percent": 7.95,
68
+ "reduction": 3.43
69
69
  },
70
70
  {
71
71
  "id": "/src/links/internals/httpUtils.ts",
72
- "size": 3469,
73
- "origSize": 5927,
72
+ "size": 3443,
73
+ "origSize": 5895,
74
74
  "renderedExports": [
75
75
  "resolveHTTPLinkOptions",
76
76
  "getInput",
@@ -84,27 +84,40 @@
84
84
  "dependents": [
85
85
  "/src/links/httpBatchLink.ts",
86
86
  "/src/links/httpLink.ts",
87
- "/src/links/httpBatchStreamLink.ts"
87
+ "/src/links/httpBatchStreamLink.ts",
88
+ "/src/links/httpSubscriptionLink.ts"
89
+ ],
90
+ "percent": 6.79,
91
+ "reduction": 41.59
92
+ },
93
+ {
94
+ "id": "/src/links/httpSubscriptionLink.ts",
95
+ "size": 3277,
96
+ "origSize": 3535,
97
+ "renderedExports": [
98
+ "unstable_httpSubscriptionLink"
88
99
  ],
89
- "percent": 7.38,
90
- "reduction": 41.47
100
+ "removedExports": [],
101
+ "dependents": [],
102
+ "percent": 6.46,
103
+ "reduction": 7.3
91
104
  },
92
105
  {
93
106
  "id": "/src/links/httpLink.ts",
94
- "size": 2939,
95
- "origSize": 3459,
107
+ "size": 3167,
108
+ "origSize": 3698,
96
109
  "renderedExports": [
97
110
  "httpLink"
98
111
  ],
99
112
  "removedExports": [],
100
113
  "dependents": [],
101
- "percent": 6.26,
102
- "reduction": 15.03
114
+ "percent": 6.24,
115
+ "reduction": 14.36
103
116
  },
104
117
  {
105
118
  "id": "/src/internals/TRPCUntypedClient.ts",
106
- "size": 2299,
107
- "origSize": 4207,
119
+ "size": 2372,
120
+ "origSize": 4306,
108
121
  "renderedExports": [
109
122
  "TRPCUntypedClient"
110
123
  ],
@@ -113,8 +126,8 @@
113
126
  "/src/createTRPCUntypedClient.ts",
114
127
  "/src/createTRPCClient.ts"
115
128
  ],
116
- "percent": 4.89,
117
- "reduction": 45.35
129
+ "percent": 4.68,
130
+ "reduction": 44.91
118
131
  },
119
132
  {
120
133
  "id": "/src/TRPCClientError.ts",
@@ -130,16 +143,17 @@
130
143
  "/src/links/httpLink.ts",
131
144
  "/src/links/wsLink.ts",
132
145
  "/src/links/httpBatchStreamLink.ts",
146
+ "/src/links/httpSubscriptionLink.ts",
133
147
  "/src/internals/TRPCUntypedClient.ts",
134
148
  "/src/links/internals/httpUtils.ts"
135
149
  ],
136
- "percent": 3.97,
150
+ "percent": 3.68,
137
151
  "reduction": 45.71
138
152
  },
139
153
  {
140
154
  "id": "/src/createTRPCClient.ts",
141
- "size": 1206,
142
- "origSize": 4369,
155
+ "size": 1187,
156
+ "origSize": 4428,
143
157
  "renderedExports": [
144
158
  "clientCallTypeToProcedureType",
145
159
  "createTRPCClientProxy",
@@ -150,8 +164,8 @@
150
164
  "dependents": [
151
165
  "/src/index.ts"
152
166
  ],
153
- "percent": 2.57,
154
- "reduction": 72.4
167
+ "percent": 2.34,
168
+ "reduction": 73.19
155
169
  },
156
170
  {
157
171
  "id": "/src/links/internals/createChain.ts",
@@ -165,7 +179,7 @@
165
179
  "/src/links/splitLink.ts",
166
180
  "/src/internals/TRPCUntypedClient.ts"
167
181
  ],
168
- "percent": 1.47,
182
+ "percent": 1.36,
169
183
  "reduction": 32.75
170
184
  },
171
185
  {
@@ -177,7 +191,7 @@
177
191
  ],
178
192
  "removedExports": [],
179
193
  "dependents": [],
180
- "percent": 1.3,
194
+ "percent": 1.2,
181
195
  "reduction": 44.95
182
196
  },
183
197
  {
@@ -191,7 +205,7 @@
191
205
  "dependents": [
192
206
  "/src/unstable-internals.ts"
193
207
  ],
194
- "percent": 1.2,
208
+ "percent": 1.11,
195
209
  "reduction": 66.75
196
210
  },
197
211
  {
@@ -206,7 +220,7 @@
206
220
  "/src/index.ts",
207
221
  "/src/links/internals/httpUtils.ts"
208
222
  ],
209
- "percent": 0.91,
223
+ "percent": 0.84,
210
224
  "reduction": 33.54
211
225
  },
212
226
  {
@@ -220,7 +234,7 @@
220
234
  "dependents": [
221
235
  "/src/links/internals/httpUtils.ts"
222
236
  ],
223
- "percent": 0.84,
237
+ "percent": 0.78,
224
238
  "reduction": 30.4
225
239
  },
226
240
  {
@@ -234,7 +248,7 @@
234
248
  ],
235
249
  "removedExports": [],
236
250
  "dependents": [],
237
- "percent": 0.7,
251
+ "percent": 0.65,
238
252
  "reduction": 15.17
239
253
  },
240
254
  {
@@ -248,7 +262,7 @@
248
262
  "dependents": [
249
263
  "/src/index.ts"
250
264
  ],
251
- "percent": 0.21,
265
+ "percent": 0.2,
252
266
  "reduction": 82.58
253
267
  },
254
268
  {
@@ -269,11 +283,12 @@
269
283
  "removedExports": [],
270
284
  "dependents": [
271
285
  "/src/links/wsLink.ts",
286
+ "/src/links/httpSubscriptionLink.ts",
272
287
  "/src/links/internals/httpUtils.ts"
273
288
  ],
274
289
  "percent": 0,
275
290
  "reduction": 100
276
291
  }
277
292
  ],
278
- "moduleCount": 19
293
+ "moduleCount": 20
279
294
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createTRPCClient.d.ts","sourceRoot":"","sources":["../src/createTRPCClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACb,MAAM,0CAA0C,CAAC;AAKlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,+BAA+B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,KACrB,aAEF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,SAAS,IACpD,iBAAiB,CAAC,OAAO,CAAC,SAAS,MAAM,MAAM,GAC3C,uBAAuB,GAAG,MAAM,MAAM,SAAS,KAAK,GAClD,iBAAiB,CAAC,OAAO,CAAC,GAC1B,iBAAiB,CAAC,uBAAuB,GAAG,MAAM,MAAM,CAAC,GAC3D,KAAK,CAAC;AAEZ;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACjC,gBAAgB,CAAC,OAAO,CAAC,CAoB3B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,GACrC,gBAAgB,CAAC,OAAO,CAAC,CAI3B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACjC,iBAAiB,CAAC,OAAO,CAAC,CAE5B"}
@@ -14,6 +14,14 @@ const clientCallTypeMap = {
14
14
  /**
15
15
  * @internal
16
16
  */ function createTRPCClientProxy(client) {
17
+ const proxy = unstableCoreDoNotImport.createRecursiveProxy(({ path , args })=>{
18
+ const pathCopy = [
19
+ ...path
20
+ ];
21
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
22
+ const fullPath = pathCopy.join('.');
23
+ return client[procedureType](fullPath, ...args);
24
+ });
17
25
  return unstableCoreDoNotImport.createFlatProxy((key)=>{
18
26
  if (client.hasOwnProperty(key)) {
19
27
  return client[key];
@@ -21,15 +29,7 @@ const clientCallTypeMap = {
21
29
  if (key === '__untypedClient') {
22
30
  return client;
23
31
  }
24
- return unstableCoreDoNotImport.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
- });
32
+ return proxy[key];
33
33
  });
34
34
  }
35
35
  function createTRPCClient(opts) {
@@ -1,4 +1,4 @@
1
- import { createFlatProxy, createRecursiveProxy } from '@trpc/server/unstable-core-do-not-import';
1
+ import { createRecursiveProxy, createFlatProxy } from '@trpc/server/unstable-core-do-not-import';
2
2
  import { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
3
3
 
4
4
  const clientCallTypeMap = {
@@ -12,6 +12,14 @@ const clientCallTypeMap = {
12
12
  /**
13
13
  * @internal
14
14
  */ function createTRPCClientProxy(client) {
15
+ const proxy = createRecursiveProxy(({ path , args })=>{
16
+ const pathCopy = [
17
+ ...path
18
+ ];
19
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
20
+ const fullPath = pathCopy.join('.');
21
+ return client[procedureType](fullPath, ...args);
22
+ });
15
23
  return createFlatProxy((key)=>{
16
24
  if (client.hasOwnProperty(key)) {
17
25
  return client[key];
@@ -19,15 +27,7 @@ const clientCallTypeMap = {
19
27
  if (key === '__untypedClient') {
20
28
  return client;
21
29
  }
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
- });
30
+ return proxy[key];
31
31
  });
32
32
  }
33
33
  function createTRPCClient(opts) {
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ var httpLink = require('./links/httpLink.js');
11
11
  var loggerLink = require('./links/loggerLink.js');
12
12
  var splitLink = require('./links/splitLink.js');
13
13
  var wsLink = require('./links/wsLink.js');
14
+ var httpSubscriptionLink = require('./links/httpSubscriptionLink.js');
14
15
  var TRPCUntypedClient = require('./internals/TRPCUntypedClient.js');
15
16
 
16
17
 
@@ -33,4 +34,5 @@ exports.loggerLink = loggerLink.loggerLink;
33
34
  exports.splitLink = splitLink.splitLink;
34
35
  exports.createWSClient = wsLink.createWSClient;
35
36
  exports.wsLink = wsLink.wsLink;
37
+ exports.unstable_httpSubscriptionLink = httpSubscriptionLink.unstable_httpSubscriptionLink;
36
38
  exports.TRPCUntypedClient = TRPCUntypedClient.TRPCUntypedClient;
package/dist/index.mjs CHANGED
@@ -9,4 +9,5 @@ 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 { createWSClient, wsLink } from './links/wsLink.mjs';
12
+ export { unstable_httpSubscriptionLink } from './links/httpSubscriptionLink.mjs';
12
13
  export { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
@@ -10,7 +10,9 @@ export interface TRPCRequestOptions {
10
10
  signal?: AbortSignal;
11
11
  }
12
12
  export interface TRPCSubscriptionObserver<TValue, TError> {
13
- onStarted: () => void;
13
+ onStarted: (opts: {
14
+ context: OperationContext | undefined;
15
+ }) => void;
14
16
  onData: (value: TValue) => void;
15
17
  onError: (err: TError) => void;
16
18
  onStopped: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"TRPCUntypedClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,SAAS,EACV,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EACjB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB,CAAC,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AS;IACtD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IACnD,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC;IASlD,OAAO,CAAC,QAAQ;IAuBhB,OAAO,CAAC,gBAAgB;IAyBjB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,kBAAkB;IAS9D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,kBAAkB;IASjE,YAAY,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,OAAO,CACX,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAC9D,GACC,kBAAkB,GACnB,cAAc;CA2BlB"}
@@ -59,7 +59,9 @@ class TRPCUntypedClient {
59
59
  return observable$.subscribe({
60
60
  next (envelope) {
61
61
  if (envelope.result.type === 'started') {
62
- opts.onStarted?.();
62
+ opts.onStarted?.({
63
+ context: envelope.context
64
+ });
63
65
  } else if (envelope.result.type === 'stopped') {
64
66
  opts.onStopped?.();
65
67
  } else {
@@ -57,7 +57,9 @@ class TRPCUntypedClient {
57
57
  return observable$.subscribe({
58
58
  next (envelope) {
59
59
  if (envelope.result.type === 'started') {
60
- opts.onStarted?.();
60
+ opts.onStarted?.({
61
+ context: envelope.context
62
+ });
61
63
  } else if (envelope.result.type === 'stopped') {
62
64
  opts.onStopped?.();
63
65
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../src/internals/dataLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAajE,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK;QACvB,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,EAAE,QAAQ,CAAC;KAClB,CAAC;CACH,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EACrC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;gBA0GnB,IAAI,KAAG,iBAAiB,MAAM,CAAC;EAsCnD"}
1
+ {"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../src/internals/dataLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAajE,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK;QACvB,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,EAAE,QAAQ,CAAC;KAClB,CAAC;CACH,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EACrC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;gBA0GnB,IAAI,KAAG,gBAAgB,CAAC,MAAM,CAAC;EAsCnD"}
@@ -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;AAO7D,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,CAmHnB"}
1
+ {"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAO7D,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"}
@@ -65,14 +65,15 @@ var httpUtils = require('./internals/httpUtils.js');
65
65
  };
66
66
  const query = dataLoader.dataLoader(batchLoader('query'));
67
67
  const mutation = dataLoader.dataLoader(batchLoader('mutation'));
68
- const subscription = dataLoader.dataLoader(batchLoader('subscription'));
69
68
  const loaders = {
70
69
  query,
71
- subscription,
72
70
  mutation
73
71
  };
74
72
  return ({ op })=>{
75
73
  return observable.observable((observer)=>{
74
+ /* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
75
+ throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
76
+ }
76
77
  const loader = loaders[op.type];
77
78
  const { promise , cancel } = loader.load(op);
78
79
  let _res = undefined;
@@ -63,14 +63,15 @@ import { resolveHTTPLinkOptions, getUrl, jsonHttpRequester } from './internals/h
63
63
  };
64
64
  const query = dataLoader(batchLoader('query'));
65
65
  const mutation = dataLoader(batchLoader('mutation'));
66
- const subscription = dataLoader(batchLoader('subscription'));
67
66
  const loaders = {
68
67
  query,
69
- subscription,
70
68
  mutation
71
69
  };
72
70
  return ({ op })=>{
73
71
  return observable((observer)=>{
72
+ /* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
73
+ throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
74
+ }
74
75
  const loader = loaders[op.type];
75
76
  const { promise , cancel } = loader.load(op);
76
77
  let _res = undefined;
@@ -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;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,CAkKnB"}
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,CAqKnB"}
@@ -60,10 +60,8 @@ var httpUtils = require('./internals/httpUtils.js');
60
60
  }, ac);
61
61
  return {
62
62
  promise: responsePromise.then(async (res)=>{
63
- if (!res.body) {
64
- throw new Error('Received response without body');
65
- }
66
63
  const [head] = await unstableCoreDoNotImport.jsonlStreamConsumer({
64
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67
65
  from: res.body,
68
66
  deserialize: resolvedOpts.transformer.output.deserialize,
69
67
  // onError: console.error,
@@ -75,7 +73,7 @@ var httpUtils = require('./internals/httpUtils.js');
75
73
  }
76
74
  });
77
75
  const promises = Object.keys(batchOps).map(async (key)=>{
78
- let json = await head[key];
76
+ let json = await Promise.resolve(head[key]);
79
77
  if ('result' in json) {
80
78
  /**
81
79
  * Not very pretty, but we need to unwrap nested data as promises
@@ -105,14 +103,15 @@ var httpUtils = require('./internals/httpUtils.js');
105
103
  };
106
104
  const query = dataLoader.dataLoader(batchLoader('query'));
107
105
  const mutation = dataLoader.dataLoader(batchLoader('mutation'));
108
- const subscription = dataLoader.dataLoader(batchLoader('subscription'));
109
106
  const loaders = {
110
107
  query,
111
- subscription,
112
108
  mutation
113
109
  };
114
110
  return ({ op })=>{
115
111
  return observable.observable((observer)=>{
112
+ /* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
113
+ throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
114
+ }
116
115
  const loader = loaders[op.type];
117
116
  const { promise , cancel } = loader.load(op);
118
117
  let _res = undefined;
@@ -58,10 +58,8 @@ import { resolveHTTPLinkOptions, getUrl, fetchHTTPResponse, getBody } from './in
58
58
  }, ac);
59
59
  return {
60
60
  promise: responsePromise.then(async (res)=>{
61
- if (!res.body) {
62
- throw new Error('Received response without body');
63
- }
64
61
  const [head] = await jsonlStreamConsumer({
62
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
65
63
  from: res.body,
66
64
  deserialize: resolvedOpts.transformer.output.deserialize,
67
65
  // onError: console.error,
@@ -73,7 +71,7 @@ import { resolveHTTPLinkOptions, getUrl, fetchHTTPResponse, getBody } from './in
73
71
  }
74
72
  });
75
73
  const promises = Object.keys(batchOps).map(async (key)=>{
76
- let json = await head[key];
74
+ let json = await Promise.resolve(head[key]);
77
75
  if ('result' in json) {
78
76
  /**
79
77
  * Not very pretty, but we need to unwrap nested data as promises
@@ -103,14 +101,15 @@ import { resolveHTTPLinkOptions, getUrl, fetchHTTPResponse, getBody } from './in
103
101
  };
104
102
  const query = dataLoader(batchLoader('query'));
105
103
  const mutation = dataLoader(batchLoader('mutation'));
106
- const subscription = dataLoader(batchLoader('subscription'));
107
104
  const loaders = {
108
105
  query,
109
- subscription,
110
106
  mutation
111
107
  };
112
108
  return ({ op })=>{
113
109
  return observable((observer)=>{
110
+ /* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
111
+ throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
112
+ }
114
113
  const loader = loaders[op.type];
115
114
  const { promise , cancel } = loader.load(op);
116
115
  let _res = undefined;
@@ -1,7 +1,7 @@
1
- import type { AnyRootTypes, AnyRouter } from '@trpc/server/unstable-core-do-not-import';
1
+ import type { AnyClientTypes, AnyRouter } from '@trpc/server/unstable-core-do-not-import';
2
2
  import type { HTTPLinkBaseOptions } from './internals/httpUtils';
3
3
  import { type HTTPHeaders, type Operation, type TRPCLink } from './types';
4
- export type HTTPLinkOptions<TRoot extends AnyRootTypes> = HTTPLinkBaseOptions<TRoot> & {
4
+ export type HTTPLinkOptions<TRoot extends AnyClientTypes> = HTTPLinkBaseOptions<TRoot> & {
5
5
  /**
6
6
  * Headers to be set on outgoing requests or a callback that of said headers
7
7
  * @link http://trpc.io/docs/client/headers
@@ -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,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"}
1
+ {"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,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,cAAc,IACtD,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,CA+DnB"}
@@ -41,6 +41,9 @@ const universalRequester = (opts)=>{
41
41
  return ({ op })=>{
42
42
  return observable.observable((observer)=>{
43
43
  const { path , input , type } = op;
44
+ /* istanbul ignore if -- @preserve */ if (type === 'subscription') {
45
+ throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
46
+ }
44
47
  const request = universalRequester({
45
48
  ...resolvedOpts,
46
49
  type,
@@ -39,6 +39,9 @@ const universalRequester = (opts)=>{
39
39
  return ({ op })=>{
40
40
  return observable((observer)=>{
41
41
  const { path , input , type } = op;
42
+ /* istanbul ignore if -- @preserve */ if (type === 'subscription') {
43
+ throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
44
+ }
42
45
  const request = universalRequester({
43
46
  ...resolvedOpts,
44
47
  type,
@@ -0,0 +1,19 @@
1
+ import type { AnyClientTypes, inferClientTypes, InferrableClientTypes, MaybePromise } from '@trpc/server/unstable-core-do-not-import';
2
+ import { type TransformerOptions } from '../unstable-internals';
3
+ import type { TRPCLink } from './types';
4
+ type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes> = {
5
+ /**
6
+ * The URL to connect to (can be a function that returns a URL)
7
+ */
8
+ url: string | (() => MaybePromise<string>);
9
+ /**
10
+ * EventSource options
11
+ */
12
+ eventSourceOptions?: EventSourceInit;
13
+ } & TransformerOptions<TRoot>;
14
+ /**
15
+ * @see https://trpc.io/docs/client/links/httpSubscriptionLink
16
+ */
17
+ export declare function unstable_httpSubscriptionLink<TInferrable extends InferrableClientTypes>(opts: HTTPSubscriptionLinkOptions<inferClientTypes<TInferrable>>): TRPCLink<TInferrable>;
18
+ export {};
19
+ //# sourceMappingURL=httpSubscriptionLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpSubscriptionLink.d.ts","sourceRoot":"","sources":["../../src/links/httpSubscriptionLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EAEb,MAAM,0CAA0C,CAAC;AAMlD,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,KAAK,2BAA2B,CAAC,KAAK,SAAS,cAAc,IAAI;IAC/D;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C;;OAEG;IACH,kBAAkB,CAAC,EAAE,eAAe,CAAC;CACtC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAS9B;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,SAAS,qBAAqB,EAEzC,IAAI,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,GAC/D,QAAQ,CAAC,WAAW,CAAC,CA8EvB"}