@trpc/client 10.0.0-alpha.45 → 10.0.0-alpha.46

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 (60) hide show
  1. package/dist/httpUtils-44781613.mjs +76 -0
  2. package/dist/httpUtils-801112a6.js +79 -0
  3. package/dist/index.js +226 -337
  4. package/dist/index.mjs +228 -333
  5. package/dist/internals/TRPCClient.d.ts +3 -1
  6. package/dist/internals/TRPCClient.d.ts.map +1 -1
  7. package/dist/internals/dataLoader.d.ts.map +1 -1
  8. package/dist/internals/fetchHelpers.d.ts.map +1 -1
  9. package/dist/internals/retryDelay.d.ts.map +1 -1
  10. package/dist/links/dedupeLink.d.ts.map +1 -1
  11. package/dist/links/httpBatchLink.d.ts.map +1 -1
  12. package/dist/links/httpBatchLink.js +182 -304
  13. package/dist/links/httpBatchLink.mjs +182 -304
  14. package/dist/links/httpLink.d.ts.map +1 -1
  15. package/dist/links/httpLink.js +30 -53
  16. package/dist/links/httpLink.mjs +30 -53
  17. package/dist/links/index.d.ts.map +1 -1
  18. package/dist/links/internals/createChain.d.ts.map +1 -1
  19. package/dist/links/internals/httpUtils.d.ts.map +1 -1
  20. package/dist/links/internals/transformResult.d.ts.map +1 -1
  21. package/dist/links/loggerLink.d.ts.map +1 -1
  22. package/dist/links/loggerLink.js +89 -94
  23. package/dist/links/loggerLink.mjs +89 -89
  24. package/dist/links/retryLink.d.ts.map +1 -1
  25. package/dist/links/splitLink.d.ts.map +1 -1
  26. package/dist/links/splitLink.js +1 -1
  27. package/dist/links/splitLink.mjs +1 -1
  28. package/dist/links/types.d.ts.map +1 -1
  29. package/dist/links/wsLink.d.ts.map +1 -1
  30. package/dist/links/wsLink.js +248 -379
  31. package/dist/links/wsLink.mjs +248 -368
  32. package/dist/splitLink-695ae288.js +48 -0
  33. package/dist/splitLink-ad44a55d.mjs +45 -0
  34. package/dist/transformResult-106791d7.mjs +62 -0
  35. package/dist/transformResult-e15ccdf6.js +65 -0
  36. package/links/httpBatchLink/index.d.ts +1 -1
  37. package/links/httpBatchLink/index.js +1 -1
  38. package/links/httpLink/index.d.ts +1 -1
  39. package/links/httpLink/index.js +1 -1
  40. package/links/loggerLink/index.d.ts +1 -1
  41. package/links/loggerLink/index.js +1 -1
  42. package/links/splitLink/index.d.ts +1 -1
  43. package/links/splitLink/index.js +1 -1
  44. package/links/wsLink/index.d.ts +1 -1
  45. package/links/wsLink/index.js +1 -1
  46. package/package.json +7 -11
  47. package/src/internals/TRPCClient.ts +10 -9
  48. package/src/links/wsLink.ts +1 -1
  49. package/dist/httpUtils-089853f6.mjs +0 -99
  50. package/dist/httpUtils-a0169eef.js +0 -106
  51. package/dist/index.ts.js +0 -1
  52. package/dist/links/httpBatchLink.ts.js +0 -1
  53. package/dist/links/httpLink.ts.js +0 -1
  54. package/dist/links/loggerLink.ts.js +0 -1
  55. package/dist/links/splitLink.ts.js +0 -1
  56. package/dist/links/wsLink.ts.js +0 -1
  57. package/dist/splitLink-0202cd7b.mjs +0 -54
  58. package/dist/splitLink-23c5ce5c.js +0 -57
  59. package/dist/transformResult-06bec648.mjs +0 -108
  60. package/dist/transformResult-3ccc74ea.js +0 -122
@@ -1,330 +1,208 @@
1
1
  import { observable } from '@trpc/server/observable';
2
- import { t as transformResult, T as TRPCClientError } from '../transformResult-06bec648.mjs';
3
- import { g as getUrl, h as httpRequest } from '../httpUtils-089853f6.mjs';
4
- import '@babel/runtime/helpers/defineProperty';
5
- import '@babel/runtime/helpers/classCallCheck';
6
- import '@babel/runtime/helpers/createClass';
7
- import '@babel/runtime/helpers/assertThisInitialized';
8
- import '@babel/runtime/helpers/inherits';
9
- import '@babel/runtime/helpers/possibleConstructorReturn';
10
- import '@babel/runtime/helpers/getPrototypeOf';
11
- import '@babel/runtime/helpers/wrapNativeSuper';
2
+ import { t as transformResult, T as TRPCClientError } from '../transformResult-106791d7.mjs';
3
+ import { g as getUrl, h as httpRequest } from '../httpUtils-44781613.mjs';
12
4
 
13
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
-
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
-
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
-
19
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
20
-
21
- /**
5
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
22
6
  * A function that should never be called unless we messed something up.
23
- */
24
- var throwFatalError = function throwFatalError() {
25
- throw new Error('Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new');
7
+ */ const throwFatalError = ()=>{
8
+ throw new Error('Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new');
26
9
  };
27
10
  /**
28
11
  * Dataloader that's very inspired by https://github.com/graphql/dataloader
29
12
  * Less configuration, no caching, and allows you to cancel requests
30
13
  * When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled
31
- */
32
-
33
-
34
- function dataLoader(batchLoader) {
35
- var pendingItems = null;
36
- var dispatchTimer = null;
37
-
38
- var destroyTimerAndPendingItems = function destroyTimerAndPendingItems() {
39
- clearTimeout(dispatchTimer);
40
- dispatchTimer = null;
41
- pendingItems = null;
42
- };
43
- /**
14
+ */ function dataLoader(batchLoader) {
15
+ let pendingItems = null;
16
+ let dispatchTimer = null;
17
+ const destroyTimerAndPendingItems = ()=>{
18
+ clearTimeout(dispatchTimer);
19
+ dispatchTimer = null;
20
+ pendingItems = null;
21
+ };
22
+ /**
44
23
  * Iterate through the items and split them into groups based on the `batchLoader`'s validate function
45
- */
46
-
47
-
48
- function groupItems(items) {
49
- var groupedItems = [[]];
50
- var index = 0;
51
-
52
- while (true) {
53
- var item = items[index];
54
-
55
- if (!item) {
56
- // we're done
57
- break;
58
- }
59
-
60
- var lastGroup = groupedItems[groupedItems.length - 1];
61
-
62
- if (item.aborted) {
63
- // Item was aborted before it was dispatched
64
- item.reject(new Error('Aborted'));
65
- index++;
66
- continue;
67
- }
68
-
69
- var isValid = batchLoader.validate(lastGroup.concat(item).map(function (it) {
70
- return it.key;
71
- }));
72
-
73
- if (isValid) {
74
- lastGroup.push(item);
75
- index++;
76
- continue;
77
- }
78
-
79
- if (lastGroup.length === 0) {
80
- item.reject(new Error('Input is too big for a single dispatch'));
81
- index++;
82
- continue;
83
- } // Create new group, next iteration will try to add the item to that
84
-
85
-
86
- groupedItems.push([]);
24
+ */ function groupItems(items) {
25
+ const groupedItems = [
26
+ []
27
+ ];
28
+ let index = 0;
29
+ while(true){
30
+ const item = items[index];
31
+ if (!item) {
32
+ break;
33
+ }
34
+ const lastGroup = groupedItems[groupedItems.length - 1];
35
+ if (item.aborted) {
36
+ // Item was aborted before it was dispatched
37
+ item.reject(new Error('Aborted'));
38
+ index++;
39
+ continue;
40
+ }
41
+ const isValid = batchLoader.validate(lastGroup.concat(item).map((it)=>it.key));
42
+ if (isValid) {
43
+ lastGroup.push(item);
44
+ index++;
45
+ continue;
46
+ }
47
+ if (lastGroup.length === 0) {
48
+ item.reject(new Error('Input is too big for a single dispatch'));
49
+ index++;
50
+ continue;
51
+ }
52
+ // Create new group, next iteration will try to add the item to that
53
+ groupedItems.push([]);
54
+ }
55
+ return groupedItems;
87
56
  }
88
-
89
- return groupedItems;
90
- }
91
-
92
- function dispatch() {
93
- var groupedItems = groupItems(pendingItems);
94
- destroyTimerAndPendingItems(); // Create batches for each group of items
95
-
96
- var _iterator = _createForOfIteratorHelper(groupedItems),
97
- _step;
98
-
99
- try {
100
- var _loop = function _loop() {
101
- var items = _step.value;
102
-
103
- if (!items.length) {
104
- return "continue";
57
+ function dispatch() {
58
+ const groupedItems = groupItems(pendingItems);
59
+ destroyTimerAndPendingItems();
60
+ // Create batches for each group of items
61
+ for (const items of groupedItems){
62
+ if (!items.length) {
63
+ continue;
64
+ }
65
+ const batch = {
66
+ items,
67
+ cancel: throwFatalError
68
+ };
69
+ for (const item of items){
70
+ item.batch = batch;
71
+ }
72
+ const { promise , cancel } = batchLoader.fetch(batch.items.map((_item)=>_item.key));
73
+ batch.cancel = cancel;
74
+ promise.then((result)=>{
75
+ for(let i = 0; i < result.length; i++){
76
+ const value = result[i];
77
+ const item = batch.items[i];
78
+ item.resolve(value);
79
+ item.batch = null;
80
+ }
81
+ }).catch((cause)=>{
82
+ for (const item of batch.items){
83
+ item.reject(cause);
84
+ item.batch = null;
85
+ }
86
+ });
105
87
  }
106
-
107
- var batch = {
108
- items: items,
109
- cancel: throwFatalError
88
+ }
89
+ function load(key) {
90
+ const item = {
91
+ aborted: false,
92
+ key,
93
+ batch: null,
94
+ resolve: throwFatalError,
95
+ reject: throwFatalError
110
96
  };
111
-
112
- var _iterator2 = _createForOfIteratorHelper(items),
113
- _step2;
114
-
115
- try {
116
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
117
- var item = _step2.value;
118
- item.batch = batch;
119
- }
120
- } catch (err) {
121
- _iterator2.e(err);
122
- } finally {
123
- _iterator2.f();
124
- }
125
-
126
- var _batchLoader$fetch = batchLoader.fetch(batch.items.map(function (_item) {
127
- return _item.key;
128
- })),
129
- promise = _batchLoader$fetch.promise,
130
- cancel = _batchLoader$fetch.cancel;
131
-
132
- batch.cancel = cancel;
133
- promise.then(function (result) {
134
- for (var i = 0; i < result.length; i++) {
135
- var _value = result[i];
136
- var item = batch.items[i];
137
- item.resolve(_value);
138
- item.batch = null;
139
- }
140
- }).catch(function (cause) {
141
- var _iterator3 = _createForOfIteratorHelper(batch.items),
142
- _step3;
143
-
144
- try {
145
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
146
- var item = _step3.value;
147
- item.reject(cause);
148
- item.batch = null;
97
+ const promise = new Promise((resolve, reject)=>{
98
+ item.reject = reject;
99
+ item.resolve = resolve;
100
+ if (!pendingItems) {
101
+ pendingItems = [];
149
102
  }
150
- } catch (err) {
151
- _iterator3.e(err);
152
- } finally {
153
- _iterator3.f();
154
- }
103
+ pendingItems.push(item);
155
104
  });
156
- };
157
-
158
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
159
- var _ret = _loop();
160
-
161
- if (_ret === "continue") continue;
162
- }
163
- } catch (err) {
164
- _iterator.e(err);
165
- } finally {
166
- _iterator.f();
167
- }
168
- }
169
-
170
- function load(key) {
171
- var item = {
172
- aborted: false,
173
- key: key,
174
- batch: null,
175
- resolve: throwFatalError,
176
- reject: throwFatalError
177
- };
178
- var promise = new Promise(function (resolve, reject) {
179
- item.reject = reject;
180
- item.resolve = resolve;
181
-
182
- if (!pendingItems) {
183
- pendingItems = [];
184
- }
185
-
186
- pendingItems.push(item);
187
- });
188
-
189
- if (!dispatchTimer) {
190
- dispatchTimer = setTimeout(dispatch);
105
+ if (!dispatchTimer) {
106
+ dispatchTimer = setTimeout(dispatch);
107
+ }
108
+ const cancel = ()=>{
109
+ item.aborted = true;
110
+ if (item.batch?.items.every((item)=>item.aborted)) {
111
+ // All items in the batch have been cancelled
112
+ item.batch.cancel();
113
+ item.batch = null;
114
+ }
115
+ };
116
+ return {
117
+ promise,
118
+ cancel
119
+ };
191
120
  }
192
-
193
- var cancel = function cancel() {
194
- var _item$batch;
195
-
196
- item.aborted = true;
197
-
198
- if ((_item$batch = item.batch) !== null && _item$batch !== void 0 && _item$batch.items.every(function (item) {
199
- return item.aborted;
200
- })) {
201
- // All items in the batch have been cancelled
202
- item.batch.cancel();
203
- item.batch = null;
204
- }
205
- };
206
-
207
121
  return {
208
- promise: promise,
209
- cancel: cancel
122
+ load
210
123
  };
211
- }
212
-
213
- return {
214
- load: load
215
- };
216
124
  }
217
125
 
218
126
  function httpBatchLink(opts) {
219
- // initialized config
220
- return function (runtime) {
221
- var maxURLLength = opts.maxURLLength || Infinity;
222
-
223
- var batchLoader = function batchLoader(type) {
224
- var validate = function validate(batchOps) {
225
- if (maxURLLength === Infinity) {
226
- // escape hatch for quick calcs
227
- return true;
228
- }
229
-
230
- var path = batchOps.map(function (op) {
231
- return op.path;
232
- }).join(',');
233
- var inputs = batchOps.map(function (op) {
234
- return op.input;
235
- });
236
- var url = getUrl({
237
- url: opts.url,
238
- runtime: runtime,
239
- type: type,
240
- path: path,
241
- inputs: inputs
242
- });
243
- return url.length <= maxURLLength;
244
- };
245
-
246
- var fetch = function fetch(batchOps) {
247
- var path = batchOps.map(function (op) {
248
- return op.path;
249
- }).join(',');
250
- var inputs = batchOps.map(function (op) {
251
- return op.input;
252
- });
253
-
254
- var _httpRequest = httpRequest({
255
- url: opts.url,
256
- runtime: runtime,
257
- type: type,
258
- path: path,
259
- inputs: inputs
260
- }),
261
- promise = _httpRequest.promise,
262
- cancel = _httpRequest.cancel;
263
-
264
- return {
265
- promise: promise.then(function (res) {
266
- var resJSON = Array.isArray(res.json) ? res.json : batchOps.map(function () {
267
- return res.json;
268
- });
269
- var result = resJSON.map(function (item) {
270
- return {
271
- meta: res.meta,
272
- json: item
273
- };
274
- });
275
- return result;
276
- }),
277
- cancel: cancel
127
+ // initialized config
128
+ return (runtime)=>{
129
+ const maxURLLength = opts.maxURLLength || Infinity;
130
+ const batchLoader = (type)=>{
131
+ const validate = (batchOps)=>{
132
+ if (maxURLLength === Infinity) {
133
+ // escape hatch for quick calcs
134
+ return true;
135
+ }
136
+ const path = batchOps.map((op)=>op.path).join(',');
137
+ const inputs = batchOps.map((op)=>op.input);
138
+ const url = getUrl({
139
+ url: opts.url,
140
+ runtime,
141
+ type,
142
+ path,
143
+ inputs
144
+ });
145
+ return url.length <= maxURLLength;
146
+ };
147
+ const fetch = (batchOps)=>{
148
+ const path = batchOps.map((op)=>op.path).join(',');
149
+ const inputs = batchOps.map((op)=>op.input);
150
+ const { promise , cancel } = httpRequest({
151
+ url: opts.url,
152
+ runtime,
153
+ type,
154
+ path,
155
+ inputs
156
+ });
157
+ return {
158
+ promise: promise.then((res)=>{
159
+ const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(()=>res.json);
160
+ const result = resJSON.map((item)=>({
161
+ meta: res.meta,
162
+ json: item
163
+ }));
164
+ return result;
165
+ }),
166
+ cancel
167
+ };
168
+ };
169
+ return {
170
+ validate,
171
+ fetch
172
+ };
278
173
  };
279
- };
280
-
281
- return {
282
- validate: validate,
283
- fetch: fetch
284
- };
285
- };
286
-
287
- var query = dataLoader(batchLoader('query'));
288
- var mutation = dataLoader(batchLoader('mutation'));
289
- var subscription = dataLoader(batchLoader('subscription'));
290
- var loaders = {
291
- query: query,
292
- subscription: subscription,
293
- mutation: mutation
294
- };
295
- return function (_ref) {
296
- var op = _ref.op;
297
- return observable(function (observer) {
298
- var loader = loaders[op.type];
299
-
300
- var _loader$load = loader.load(op),
301
- promise = _loader$load.promise,
302
- cancel = _loader$load.cancel;
303
-
304
- promise.then(function (res) {
305
- var transformed = transformResult(res.json, runtime);
306
-
307
- if (!transformed.ok) {
308
- observer.error(TRPCClientError.from(transformed.error, {
309
- meta: res.meta
310
- }));
311
- return;
312
- }
313
-
314
- observer.next({
315
- context: res.meta,
316
- result: transformed.result
317
- });
318
- observer.complete();
319
- }).catch(function (err) {
320
- return observer.error(err);
321
- });
322
- return function () {
323
- cancel();
174
+ const query = dataLoader(batchLoader('query'));
175
+ const mutation = dataLoader(batchLoader('mutation'));
176
+ const subscription = dataLoader(batchLoader('subscription'));
177
+ const loaders = {
178
+ query,
179
+ subscription,
180
+ mutation
181
+ };
182
+ return ({ op })=>{
183
+ return observable((observer)=>{
184
+ const loader = loaders[op.type];
185
+ const { promise , cancel } = loader.load(op);
186
+ promise.then((res)=>{
187
+ const transformed = transformResult(res.json, runtime);
188
+ if (!transformed.ok) {
189
+ observer.error(TRPCClientError.from(transformed.error, {
190
+ meta: res.meta
191
+ }));
192
+ return;
193
+ }
194
+ observer.next({
195
+ context: res.meta,
196
+ result: transformed.result
197
+ });
198
+ observer.complete();
199
+ }).catch((err)=>observer.error(err));
200
+ return ()=>{
201
+ cancel();
202
+ };
203
+ });
324
204
  };
325
- });
326
205
  };
327
- };
328
206
  }
329
207
 
330
208
  export { httpBatchLink };
@@ -1 +1 @@
1
- {"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,QAAQ,CAAC,OAAO,SAAS,SAAS,EAChD,IAAI,EAAE,eAAe,GACpB,QAAQ,CAAC,OAAO,CAAC,CAqCnB"}
1
+ {"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../../../packages/client/src/links/httpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,QAAQ,CAAC,OAAO,SAAS,SAAS,EAChD,IAAI,EAAE,eAAe,GACpB,QAAQ,CAAC,OAAO,CAAC,CAqCnB"}
@@ -3,61 +3,38 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
- var transformResult = require('../transformResult-3ccc74ea.js');
7
- var httpUtils = require('../httpUtils-a0169eef.js');
8
- require('@babel/runtime/helpers/defineProperty');
9
- require('@babel/runtime/helpers/classCallCheck');
10
- require('@babel/runtime/helpers/createClass');
11
- require('@babel/runtime/helpers/assertThisInitialized');
12
- require('@babel/runtime/helpers/inherits');
13
- require('@babel/runtime/helpers/possibleConstructorReturn');
14
- require('@babel/runtime/helpers/getPrototypeOf');
15
- require('@babel/runtime/helpers/wrapNativeSuper');
6
+ var transformResult = require('../transformResult-e15ccdf6.js');
7
+ var httpUtils = require('../httpUtils-801112a6.js');
16
8
 
17
9
  function httpLink(opts) {
18
- var url = opts.url;
19
- return function (runtime) {
20
- return function (_ref) {
21
- var op = _ref.op;
22
- return observable.observable(function (observer) {
23
- var path = op.path,
24
- input = op.input,
25
- type = op.type;
26
-
27
- var _httpRequest = httpUtils.httpRequest({
28
- url: url,
29
- runtime: runtime,
30
- type: type,
31
- path: path,
32
- input: input
33
- }),
34
- promise = _httpRequest.promise,
35
- cancel = _httpRequest.cancel;
36
-
37
- promise.then(function (res) {
38
- var transformed = transformResult.transformResult(res.json, runtime);
39
-
40
- if (!transformed.ok) {
41
- observer.error(transformResult.TRPCClientError.from(transformed.error, {
42
- meta: res.meta
43
- }));
44
- return;
45
- }
46
-
47
- observer.next({
48
- context: res.meta,
49
- result: transformed.result
50
- });
51
- observer.complete();
52
- }).catch(function (cause) {
53
- return transformResult.TRPCClientError.from(cause);
54
- });
55
- return function () {
56
- cancel();
57
- };
58
- });
59
- };
60
- };
10
+ const { url } = opts;
11
+ return (runtime)=>({ op })=>observable.observable((observer)=>{
12
+ const { path , input , type } = op;
13
+ const { promise , cancel } = httpUtils.httpRequest({
14
+ url,
15
+ runtime,
16
+ type,
17
+ path,
18
+ input
19
+ });
20
+ promise.then((res)=>{
21
+ const transformed = transformResult.transformResult(res.json, runtime);
22
+ if (!transformed.ok) {
23
+ observer.error(transformResult.TRPCClientError.from(transformed.error, {
24
+ meta: res.meta
25
+ }));
26
+ return;
27
+ }
28
+ observer.next({
29
+ context: res.meta,
30
+ result: transformed.result
31
+ });
32
+ observer.complete();
33
+ }).catch((cause)=>transformResult.TRPCClientError.from(cause));
34
+ return ()=>{
35
+ cancel();
36
+ };
37
+ });
61
38
  }
62
39
 
63
40
  exports.httpLink = httpLink;