@trpc/client 10.0.0-alpha.16 → 10.0.0-alpha.19
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/TRPCClientError.d.ts +0 -8
- package/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/index.js +582 -586
- package/dist/index.mjs +581 -585
- package/dist/internals/TRPCClient.d.ts +1 -9
- package/dist/internals/TRPCClient.d.ts.map +1 -1
- package/dist/links/dedupeLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.d.ts +1 -1
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpLink.d.ts +1 -1
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/dist/links/splitLink.d.ts +1 -1
- package/dist/links/splitLink.d.ts.map +1 -1
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.d.ts +1 -11
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.dev.js +214 -0
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.js +6 -15
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.prod.js +214 -0
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.esm.js +210 -0
- package/links/httpLink/dist/trpc-client-links-httpLink.cjs.d.ts +1 -11
- package/links/httpLink/dist/trpc-client-links-httpLink.cjs.dev.js +67 -0
- package/links/httpLink/dist/trpc-client-links-httpLink.cjs.js +6 -15
- package/links/httpLink/dist/trpc-client-links-httpLink.cjs.prod.js +67 -0
- package/links/httpLink/dist/trpc-client-links-httpLink.esm.js +63 -0
- package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.d.ts +1 -11
- package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.dev.js +89 -0
- package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.js +6 -15
- package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.prod.js +89 -0
- package/links/loggerLink/dist/trpc-client-links-loggerLink.esm.js +85 -0
- package/links/splitLink/dist/trpc-client-links-splitLink.cjs.d.ts +1 -11
- package/links/splitLink/dist/trpc-client-links-splitLink.cjs.dev.js +19 -0
- package/links/splitLink/dist/trpc-client-links-splitLink.cjs.js +6 -15
- package/links/splitLink/dist/trpc-client-links-splitLink.cjs.prod.js +19 -0
- package/links/splitLink/dist/trpc-client-links-splitLink.esm.js +15 -0
- package/links/wsLink/dist/trpc-client-links-wsLink.cjs.d.ts +1 -11
- package/links/wsLink/dist/trpc-client-links-wsLink.cjs.dev.js +395 -0
- package/links/wsLink/dist/trpc-client-links-wsLink.cjs.js +6 -15
- package/links/wsLink/dist/trpc-client-links-wsLink.cjs.prod.js +395 -0
- package/links/wsLink/dist/trpc-client-links-wsLink.esm.js +390 -0
- package/observable/dist/trpc-client-rx.cjs.d.ts +1 -0
- package/observable/dist/trpc-client-rx.cjs.dev.js +9 -0
- package/observable/dist/trpc-client-rx.cjs.js +7 -0
- package/observable/dist/trpc-client-rx.cjs.prod.js +9 -0
- package/observable/dist/trpc-client-rx.esm.js +1 -0
- package/observable/index.d.ts +1 -0
- package/observable/index.js +1 -0
- package/package.json +9 -44
- package/src/TRPCClientError.ts +2 -10
- package/src/internals/TRPCClient.ts +7 -12
- package/src/links/dedupeLink.test.ts +1 -1
- package/src/links/dedupeLink.ts +1 -2
- package/src/links/httpBatchLink.ts +2 -2
- package/src/links/httpLink.ts +2 -2
- package/src/links/internals/createChain.test.ts +1 -1
- package/src/links/loggerLink.ts +1 -2
- package/src/links/splitLink.test.ts +2 -2
- package/src/links/splitLink.ts +2 -2
- package/src/observable/observable.test.ts +1 -3
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
|
2
2
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
3
3
|
import { o as observable, s as share, t as tap } from './tap-4bc60fb0.mjs';
|
|
4
4
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
6
|
import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
|
|
6
7
|
import _inherits from '@babel/runtime/helpers/inherits';
|
|
7
8
|
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
|
|
8
9
|
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
9
10
|
import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper';
|
|
10
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
11
11
|
|
|
12
12
|
function getWindow() {
|
|
13
13
|
if (typeof window !== 'undefined') {
|
|
@@ -35,6 +35,59 @@ function getFetch(f) {
|
|
|
35
35
|
throw new Error('No fetch implementation found');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
function dedupeLink() {
|
|
39
|
+
// initialized config
|
|
40
|
+
return function () {
|
|
41
|
+
// initialized in app
|
|
42
|
+
var pending = {};
|
|
43
|
+
return function (_ref) {
|
|
44
|
+
var op = _ref.op,
|
|
45
|
+
next = _ref.next;
|
|
46
|
+
|
|
47
|
+
// initialized for request
|
|
48
|
+
if (op.type !== 'query') {
|
|
49
|
+
// pass through
|
|
50
|
+
return next(op);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var key = JSON.stringify([op.path, op.input]);
|
|
54
|
+
|
|
55
|
+
if (pending[key]) {
|
|
56
|
+
// console.log('hooking into pending', { op });
|
|
57
|
+
return observable(function (observer) {
|
|
58
|
+
return pending[key].subscribe(observer);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var shared$ = observable(function (observer) {
|
|
63
|
+
function reset() {
|
|
64
|
+
delete pending[key];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var subscription = next(op).subscribe({
|
|
68
|
+
next: function next(v) {
|
|
69
|
+
observer.next(v);
|
|
70
|
+
},
|
|
71
|
+
error: function error(e) {
|
|
72
|
+
reset();
|
|
73
|
+
observer.error(e);
|
|
74
|
+
},
|
|
75
|
+
complete: function complete() {
|
|
76
|
+
reset();
|
|
77
|
+
observer.complete();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return function () {
|
|
81
|
+
reset();
|
|
82
|
+
subscription.unsubscribe();
|
|
83
|
+
};
|
|
84
|
+
}).pipe(share());
|
|
85
|
+
pending[key] = shared$;
|
|
86
|
+
return shared$;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
38
91
|
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; } } }; }
|
|
39
92
|
|
|
40
93
|
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); }
|
|
@@ -309,6 +362,196 @@ function httpBatchLink(opts) {
|
|
|
309
362
|
};
|
|
310
363
|
}
|
|
311
364
|
|
|
365
|
+
function httpLink(opts) {
|
|
366
|
+
var url = opts.url;
|
|
367
|
+
return function (runtime) {
|
|
368
|
+
return function (_ref) {
|
|
369
|
+
var op = _ref.op;
|
|
370
|
+
return observable(function (observer) {
|
|
371
|
+
var path = op.path,
|
|
372
|
+
input = op.input,
|
|
373
|
+
type = op.type;
|
|
374
|
+
|
|
375
|
+
var _httpRequest = httpRequest({
|
|
376
|
+
runtime: runtime,
|
|
377
|
+
path: path,
|
|
378
|
+
input: input,
|
|
379
|
+
type: type,
|
|
380
|
+
url: url
|
|
381
|
+
}),
|
|
382
|
+
promise = _httpRequest.promise,
|
|
383
|
+
cancel = _httpRequest.cancel;
|
|
384
|
+
|
|
385
|
+
promise.then(function (res) {
|
|
386
|
+
observer.next({
|
|
387
|
+
context: res.meta,
|
|
388
|
+
data: res.json
|
|
389
|
+
});
|
|
390
|
+
observer.complete();
|
|
391
|
+
}).catch(observer.error);
|
|
392
|
+
return function () {
|
|
393
|
+
cancel();
|
|
394
|
+
};
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
401
|
+
|
|
402
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
403
|
+
var palette = {
|
|
404
|
+
query: ['72e3ff', '3fb0d8'],
|
|
405
|
+
mutation: ['c5a3fc', '904dfc'],
|
|
406
|
+
subscription: ['ff49e1', 'd83fbe']
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
// maybe this should be moved to it's own package
|
|
410
|
+
var defaultLogger = function defaultLogger() {
|
|
411
|
+
var c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : console;
|
|
412
|
+
return function (props) {
|
|
413
|
+
var direction = props.direction,
|
|
414
|
+
input = props.input,
|
|
415
|
+
type = props.type,
|
|
416
|
+
path = props.path,
|
|
417
|
+
context = props.context,
|
|
418
|
+
id = props.id;
|
|
419
|
+
|
|
420
|
+
var _palette$type = _slicedToArray(palette[type], 2),
|
|
421
|
+
light = _palette$type[0],
|
|
422
|
+
dark = _palette$type[1];
|
|
423
|
+
|
|
424
|
+
var css = "\n background-color: #".concat(direction === 'up' ? light : dark, "; \n color: ").concat(direction === 'up' ? 'black' : 'white', ";\n padding: 2px;\n ");
|
|
425
|
+
var parts = ['%c', direction === 'up' ? '>>' : '<<', type, "#".concat(id), "%c".concat(path, "%c"), '%O'];
|
|
426
|
+
var args = [css, "".concat(css, "; font-weight: bold;"), "".concat(css, "; font-weight: normal;")];
|
|
427
|
+
|
|
428
|
+
if (props.direction === 'up') {
|
|
429
|
+
args.push({
|
|
430
|
+
input: input,
|
|
431
|
+
context: context
|
|
432
|
+
});
|
|
433
|
+
} else {
|
|
434
|
+
args.push({
|
|
435
|
+
input: input,
|
|
436
|
+
result: props.result,
|
|
437
|
+
elapsedMs: props.elapsedMs,
|
|
438
|
+
context: context
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
var fn = props.direction === 'down' && props.result && (props.result instanceof Error || 'error' in props.result.data) ? 'error' : 'log';
|
|
443
|
+
c[fn].apply(null, [parts.join(' ')].concat(args));
|
|
444
|
+
};
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
function loggerLink() {
|
|
448
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
449
|
+
var _opts$enabled = opts.enabled,
|
|
450
|
+
enabled = _opts$enabled === void 0 ? function () {
|
|
451
|
+
return true;
|
|
452
|
+
} : _opts$enabled;
|
|
453
|
+
var _opts$logger = opts.logger,
|
|
454
|
+
logger = _opts$logger === void 0 ? defaultLogger(opts.console) : _opts$logger;
|
|
455
|
+
return function () {
|
|
456
|
+
return function (_ref) {
|
|
457
|
+
var op = _ref.op,
|
|
458
|
+
next = _ref.next;
|
|
459
|
+
return observable(function (observer) {
|
|
460
|
+
// ->
|
|
461
|
+
enabled(_objectSpread$2(_objectSpread$2({}, op), {}, {
|
|
462
|
+
direction: 'up'
|
|
463
|
+
})) && logger(_objectSpread$2(_objectSpread$2({}, op), {}, {
|
|
464
|
+
direction: 'up'
|
|
465
|
+
}));
|
|
466
|
+
var requestStartTime = Date.now();
|
|
467
|
+
|
|
468
|
+
function logResult(result) {
|
|
469
|
+
var elapsedMs = Date.now() - requestStartTime;
|
|
470
|
+
enabled(_objectSpread$2(_objectSpread$2({}, op), {}, {
|
|
471
|
+
direction: 'down',
|
|
472
|
+
result: result
|
|
473
|
+
})) && logger(_objectSpread$2(_objectSpread$2({}, op), {}, {
|
|
474
|
+
direction: 'down',
|
|
475
|
+
elapsedMs: elapsedMs,
|
|
476
|
+
result: result
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return next(op).pipe(tap({
|
|
481
|
+
next: function next(result) {
|
|
482
|
+
logResult(result);
|
|
483
|
+
},
|
|
484
|
+
error: function error(result) {
|
|
485
|
+
logResult(result);
|
|
486
|
+
}
|
|
487
|
+
})).subscribe(observer);
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function retryLink(opts) {
|
|
494
|
+
// initialized config
|
|
495
|
+
return function () {
|
|
496
|
+
// initialized in app
|
|
497
|
+
return function (_ref) {
|
|
498
|
+
var op = _ref.op,
|
|
499
|
+
next = _ref.next;
|
|
500
|
+
// initialized for request
|
|
501
|
+
return observable(function (observer) {
|
|
502
|
+
var next$ = null;
|
|
503
|
+
var attempts = 0;
|
|
504
|
+
var isDone = false;
|
|
505
|
+
|
|
506
|
+
function attempt() {
|
|
507
|
+
var _next$;
|
|
508
|
+
|
|
509
|
+
attempts++;
|
|
510
|
+
(_next$ = next$) === null || _next$ === void 0 ? void 0 : _next$.unsubscribe();
|
|
511
|
+
next$ = next(op).subscribe({
|
|
512
|
+
error: function error(_error) {
|
|
513
|
+
if (attempts >= opts.attempts) {
|
|
514
|
+
observer.error(_error);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
attempt();
|
|
519
|
+
},
|
|
520
|
+
next: function next(result) {
|
|
521
|
+
if ('result' in result.data) {
|
|
522
|
+
isDone = true;
|
|
523
|
+
observer.next(result);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (attempts >= opts.attempts) {
|
|
528
|
+
isDone = true;
|
|
529
|
+
observer.next(result);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
attempt();
|
|
534
|
+
},
|
|
535
|
+
complete: function complete() {
|
|
536
|
+
if (isDone) {
|
|
537
|
+
observer.complete();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
attempt();
|
|
544
|
+
return function () {
|
|
545
|
+
var _next$2;
|
|
546
|
+
|
|
547
|
+
isDone = true;
|
|
548
|
+
(_next$2 = next$) === null || _next$2 === void 0 ? void 0 : _next$2.unsubscribe();
|
|
549
|
+
};
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
|
|
312
555
|
/** @internal */
|
|
313
556
|
function createChain(opts) {
|
|
314
557
|
return observable(function (observer) {
|
|
@@ -331,576 +574,9 @@ function createChain(opts) {
|
|
|
331
574
|
});
|
|
332
575
|
}
|
|
333
576
|
|
|
334
|
-
function
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
339
|
-
|
|
340
|
-
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
341
|
-
|
|
342
|
-
var TRPCClientError = /*#__PURE__*/function (_Error) {
|
|
343
|
-
_inherits(TRPCClientError, _Error);
|
|
344
|
-
|
|
345
|
-
var _super = /*#__PURE__*/_createSuper$2(TRPCClientError);
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* @deprecated use `cause`
|
|
349
|
-
*/
|
|
350
|
-
function TRPCClientError(message, opts) {
|
|
351
|
-
var _opts$cause, _opts$result, _opts$result2;
|
|
352
|
-
|
|
353
|
-
var _this;
|
|
354
|
-
|
|
355
|
-
_classCallCheck(this, TRPCClientError);
|
|
356
|
-
|
|
357
|
-
var cause = (_opts$cause = opts === null || opts === void 0 ? void 0 : opts.cause) !== null && _opts$cause !== void 0 ? _opts$cause : opts === null || opts === void 0 ? void 0 : opts.originalError; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
358
|
-
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
359
|
-
|
|
360
|
-
_this = _super.call(this, message, {
|
|
361
|
-
cause: cause
|
|
362
|
-
});
|
|
363
|
-
_this.originalError = void 0;
|
|
364
|
-
_this.cause = void 0;
|
|
365
|
-
_this.shape = void 0;
|
|
366
|
-
_this.data = void 0;
|
|
367
|
-
_this.meta = void 0;
|
|
368
|
-
_this.meta = opts === null || opts === void 0 ? void 0 : opts.meta;
|
|
369
|
-
_this.cause = _this.originalError = cause;
|
|
370
|
-
_this.shape = opts === null || opts === void 0 ? void 0 : (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error;
|
|
371
|
-
_this.data = opts === null || opts === void 0 ? void 0 : (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data;
|
|
372
|
-
_this.name = 'TRPCClientError';
|
|
373
|
-
Object.setPrototypeOf(_assertThisInitialized(_this), TRPCClientError.prototype);
|
|
374
|
-
return _this;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
_createClass(TRPCClientError, null, [{
|
|
378
|
-
key: "from",
|
|
379
|
-
value: function from(cause) {
|
|
380
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
381
|
-
|
|
382
|
-
if (!(cause instanceof Error)) {
|
|
383
|
-
var _message;
|
|
384
|
-
|
|
385
|
-
return new TRPCClientError((_message = cause.error.message) !== null && _message !== void 0 ? _message : '', _objectSpread$2(_objectSpread$2({}, opts), {}, {
|
|
386
|
-
cause: null,
|
|
387
|
-
result: cause
|
|
388
|
-
}));
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
if (cause.name === 'TRPCClientError') {
|
|
392
|
-
return cause;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return new TRPCClientError(cause.message, _objectSpread$2(_objectSpread$2({}, opts), {}, {
|
|
396
|
-
cause: cause,
|
|
397
|
-
result: null
|
|
398
|
-
}));
|
|
399
|
-
}
|
|
400
|
-
}]);
|
|
401
|
-
|
|
402
|
-
return TRPCClientError;
|
|
403
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
404
|
-
|
|
405
|
-
/** @internal */
|
|
406
|
-
function transformOperationResult$1(result) {
|
|
407
|
-
var context = result.context;
|
|
408
|
-
|
|
409
|
-
if ('error' in result.data) {
|
|
410
|
-
var error = TRPCClientError.from(result.data);
|
|
411
|
-
return {
|
|
412
|
-
ok: false,
|
|
413
|
-
error: error,
|
|
414
|
-
context: context
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
var data = result.data.result.data;
|
|
419
|
-
return {
|
|
420
|
-
ok: true,
|
|
421
|
-
data: data,
|
|
422
|
-
context: context
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
427
|
-
|
|
428
|
-
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
429
|
-
|
|
430
|
-
var ObservableAbortError = /*#__PURE__*/function (_Error) {
|
|
431
|
-
_inherits(ObservableAbortError, _Error);
|
|
432
|
-
|
|
433
|
-
var _super = /*#__PURE__*/_createSuper$1(ObservableAbortError);
|
|
434
|
-
|
|
435
|
-
function ObservableAbortError(message) {
|
|
436
|
-
var _this;
|
|
437
|
-
|
|
438
|
-
_classCallCheck(this, ObservableAbortError);
|
|
439
|
-
|
|
440
|
-
_this = _super.call(this, message);
|
|
441
|
-
_this.name = 'ObservableAbortError';
|
|
442
|
-
Object.setPrototypeOf(_assertThisInitialized(_this), ObservableAbortError.prototype);
|
|
443
|
-
return _this;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
return _createClass(ObservableAbortError);
|
|
447
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
448
|
-
/** @internal */
|
|
449
|
-
|
|
450
|
-
function observableToPromise(observable) {
|
|
451
|
-
var abort;
|
|
452
|
-
var promise = new Promise(function (resolve, reject) {
|
|
453
|
-
var isDone = false;
|
|
454
|
-
|
|
455
|
-
function onDone() {
|
|
456
|
-
if (isDone) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
isDone = true;
|
|
461
|
-
reject(new ObservableAbortError('This operation was cancelled.'));
|
|
462
|
-
obs$.unsubscribe();
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
var obs$ = observable.subscribe({
|
|
466
|
-
next: function next(data) {
|
|
467
|
-
isDone = true;
|
|
468
|
-
resolve(data);
|
|
469
|
-
onDone();
|
|
470
|
-
},
|
|
471
|
-
error: function error(data) {
|
|
472
|
-
isDone = true;
|
|
473
|
-
reject(data);
|
|
474
|
-
onDone();
|
|
475
|
-
},
|
|
476
|
-
complete: function complete() {
|
|
477
|
-
isDone = true;
|
|
478
|
-
onDone();
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
abort = onDone;
|
|
482
|
-
});
|
|
483
|
-
return {
|
|
484
|
-
promise: promise,
|
|
485
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
486
|
-
abort: abort
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
var idCounter = 0;
|
|
491
|
-
|
|
492
|
-
function getRequestId() {
|
|
493
|
-
return ++idCounter;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
var TRPCClient = /*#__PURE__*/function () {
|
|
497
|
-
function TRPCClient(opts) {
|
|
498
|
-
var _this = this;
|
|
499
|
-
|
|
500
|
-
_classCallCheck(this, TRPCClient);
|
|
501
|
-
|
|
502
|
-
this.links = void 0;
|
|
503
|
-
this.runtime = void 0;
|
|
504
|
-
|
|
505
|
-
var _fetch = getFetch(opts === null || opts === void 0 ? void 0 : opts.fetch);
|
|
506
|
-
|
|
507
|
-
var AC = getAbortController(opts === null || opts === void 0 ? void 0 : opts.AbortController);
|
|
508
|
-
|
|
509
|
-
function getHeadersFn() {
|
|
510
|
-
if (opts.headers) {
|
|
511
|
-
var headers = opts.headers;
|
|
512
|
-
return typeof headers === 'function' ? headers : function () {
|
|
513
|
-
return headers;
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
return function () {
|
|
518
|
-
return {};
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
this.runtime = {
|
|
523
|
-
AbortController: AC,
|
|
524
|
-
fetch: _fetch,
|
|
525
|
-
headers: getHeadersFn()
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
if ('links' in opts) {
|
|
529
|
-
this.links = opts.links.map(function (link) {
|
|
530
|
-
return link(_this.runtime);
|
|
531
|
-
});
|
|
532
|
-
} else {
|
|
533
|
-
this.links = [httpBatchLink({
|
|
534
|
-
url: opts.url
|
|
535
|
-
})(this.runtime)];
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
_createClass(TRPCClient, [{
|
|
540
|
-
key: "$request",
|
|
541
|
-
value: function $request(_ref) {
|
|
542
|
-
var type = _ref.type,
|
|
543
|
-
input = _ref.input,
|
|
544
|
-
path = _ref.path,
|
|
545
|
-
_ref$context = _ref.context,
|
|
546
|
-
context = _ref$context === void 0 ? {} : _ref$context;
|
|
547
|
-
var chain$ = createChain({
|
|
548
|
-
links: this.links,
|
|
549
|
-
op: {
|
|
550
|
-
id: getRequestId(),
|
|
551
|
-
type: type,
|
|
552
|
-
path: path,
|
|
553
|
-
input: input,
|
|
554
|
-
context: context
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
return chain$.pipe(share());
|
|
558
|
-
}
|
|
559
|
-
}, {
|
|
560
|
-
key: "requestAsPromise",
|
|
561
|
-
value: function requestAsPromise(opts) {
|
|
562
|
-
var req$ = this.$request(opts);
|
|
563
|
-
|
|
564
|
-
var _observableToPromise = observableToPromise(req$),
|
|
565
|
-
promise = _observableToPromise.promise,
|
|
566
|
-
abort = _observableToPromise.abort;
|
|
567
|
-
|
|
568
|
-
var cancellablePromise = new Promise(function (resolve, reject) {
|
|
569
|
-
promise.then(function (result) {
|
|
570
|
-
var transformed = transformOperationResult$1(result);
|
|
571
|
-
|
|
572
|
-
if (transformed.ok) {
|
|
573
|
-
resolve(transformed.data);
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
reject(transformed.error);
|
|
578
|
-
}).catch(function (err) {
|
|
579
|
-
reject(TRPCClientError.from(err));
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
cancellablePromise.cancel = abort;
|
|
583
|
-
return cancellablePromise;
|
|
584
|
-
}
|
|
585
|
-
}, {
|
|
586
|
-
key: "query",
|
|
587
|
-
value: function query(path) {
|
|
588
|
-
var _ref2;
|
|
589
|
-
|
|
590
|
-
var context = (_ref2 = arguments.length <= 2 ? undefined : arguments[2]) === null || _ref2 === void 0 ? void 0 : _ref2.context;
|
|
591
|
-
return this.requestAsPromise({
|
|
592
|
-
type: 'query',
|
|
593
|
-
path: path,
|
|
594
|
-
input: arguments.length <= 1 ? undefined : arguments[1],
|
|
595
|
-
context: context
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
}, {
|
|
599
|
-
key: "mutation",
|
|
600
|
-
value: function mutation(path) {
|
|
601
|
-
var _ref3;
|
|
602
|
-
|
|
603
|
-
var context = (_ref3 = arguments.length <= 2 ? undefined : arguments[2]) === null || _ref3 === void 0 ? void 0 : _ref3.context;
|
|
604
|
-
return this.requestAsPromise({
|
|
605
|
-
type: 'mutation',
|
|
606
|
-
path: path,
|
|
607
|
-
input: arguments.length <= 1 ? undefined : arguments[1],
|
|
608
|
-
context: context
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
}, {
|
|
612
|
-
key: "subscription",
|
|
613
|
-
value: function subscription(path, input, opts) {
|
|
614
|
-
var observable$ = this.$request({
|
|
615
|
-
type: 'subscription',
|
|
616
|
-
path: path,
|
|
617
|
-
input: input,
|
|
618
|
-
context: opts.context
|
|
619
|
-
});
|
|
620
|
-
return observable$.subscribe({
|
|
621
|
-
next: function next(result) {
|
|
622
|
-
var _opts$next;
|
|
623
|
-
|
|
624
|
-
if ('error' in result.data) {
|
|
625
|
-
var _opts$error;
|
|
626
|
-
|
|
627
|
-
var err = TRPCClientError.from(result.data, {
|
|
628
|
-
meta: result.context
|
|
629
|
-
});
|
|
630
|
-
(_opts$error = opts.error) === null || _opts$error === void 0 ? void 0 : _opts$error.call(opts, err);
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
(_opts$next = opts.next) === null || _opts$next === void 0 ? void 0 : _opts$next.call(opts, result.data.result);
|
|
635
|
-
},
|
|
636
|
-
error: function error(err) {
|
|
637
|
-
var _opts$error2;
|
|
638
|
-
|
|
639
|
-
(_opts$error2 = opts.error) === null || _opts$error2 === void 0 ? void 0 : _opts$error2.call(opts, err);
|
|
640
|
-
},
|
|
641
|
-
complete: function complete() {
|
|
642
|
-
var _opts$complete;
|
|
643
|
-
|
|
644
|
-
(_opts$complete = opts.complete) === null || _opts$complete === void 0 ? void 0 : _opts$complete.call(opts);
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
}]);
|
|
649
|
-
|
|
650
|
-
return TRPCClient;
|
|
651
|
-
}();
|
|
652
|
-
|
|
653
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
654
|
-
function createTRPCClient(opts) {
|
|
655
|
-
return new TRPCClient(opts);
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
function dedupeLink() {
|
|
659
|
-
// initialized config
|
|
660
|
-
return function () {
|
|
661
|
-
// initialized in app
|
|
662
|
-
var pending = {};
|
|
663
|
-
return function (_ref) {
|
|
664
|
-
var op = _ref.op,
|
|
665
|
-
next = _ref.next;
|
|
666
|
-
|
|
667
|
-
// initialized for request
|
|
668
|
-
if (op.type !== 'query') {
|
|
669
|
-
// pass through
|
|
670
|
-
return next(op);
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
var key = JSON.stringify([op.path, op.input]);
|
|
674
|
-
|
|
675
|
-
if (pending[key]) {
|
|
676
|
-
// console.log('hooking into pending', { op });
|
|
677
|
-
return observable(function (observer) {
|
|
678
|
-
return pending[key].subscribe(observer);
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
var shared$ = observable(function (observer) {
|
|
683
|
-
function reset() {
|
|
684
|
-
delete pending[key];
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
var subscription = next(op).subscribe({
|
|
688
|
-
next: function next(v) {
|
|
689
|
-
observer.next(v);
|
|
690
|
-
},
|
|
691
|
-
error: function error(e) {
|
|
692
|
-
reset();
|
|
693
|
-
observer.error(e);
|
|
694
|
-
},
|
|
695
|
-
complete: function complete() {
|
|
696
|
-
reset();
|
|
697
|
-
observer.complete();
|
|
698
|
-
}
|
|
699
|
-
});
|
|
700
|
-
return function () {
|
|
701
|
-
reset();
|
|
702
|
-
subscription.unsubscribe();
|
|
703
|
-
};
|
|
704
|
-
}).pipe(share());
|
|
705
|
-
pending[key] = shared$;
|
|
706
|
-
return shared$;
|
|
707
|
-
};
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
function httpLink(opts) {
|
|
712
|
-
var url = opts.url;
|
|
713
|
-
return function (runtime) {
|
|
714
|
-
return function (_ref) {
|
|
715
|
-
var op = _ref.op;
|
|
716
|
-
return observable(function (observer) {
|
|
717
|
-
var path = op.path,
|
|
718
|
-
input = op.input,
|
|
719
|
-
type = op.type;
|
|
720
|
-
|
|
721
|
-
var _httpRequest = httpRequest({
|
|
722
|
-
runtime: runtime,
|
|
723
|
-
path: path,
|
|
724
|
-
input: input,
|
|
725
|
-
type: type,
|
|
726
|
-
url: url
|
|
727
|
-
}),
|
|
728
|
-
promise = _httpRequest.promise,
|
|
729
|
-
cancel = _httpRequest.cancel;
|
|
730
|
-
|
|
731
|
-
promise.then(function (res) {
|
|
732
|
-
observer.next({
|
|
733
|
-
context: res.meta,
|
|
734
|
-
data: res.json
|
|
735
|
-
});
|
|
736
|
-
observer.complete();
|
|
737
|
-
}).catch(observer.error);
|
|
738
|
-
return function () {
|
|
739
|
-
cancel();
|
|
740
|
-
};
|
|
741
|
-
});
|
|
742
|
-
};
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
747
|
-
|
|
748
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
749
|
-
var palette = {
|
|
750
|
-
query: ['72e3ff', '3fb0d8'],
|
|
751
|
-
mutation: ['c5a3fc', '904dfc'],
|
|
752
|
-
subscription: ['ff49e1', 'd83fbe']
|
|
753
|
-
};
|
|
754
|
-
|
|
755
|
-
// maybe this should be moved to it's own package
|
|
756
|
-
var defaultLogger = function defaultLogger() {
|
|
757
|
-
var c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : console;
|
|
758
|
-
return function (props) {
|
|
759
|
-
var direction = props.direction,
|
|
760
|
-
input = props.input,
|
|
761
|
-
type = props.type,
|
|
762
|
-
path = props.path,
|
|
763
|
-
context = props.context,
|
|
764
|
-
id = props.id;
|
|
765
|
-
|
|
766
|
-
var _palette$type = _slicedToArray(palette[type], 2),
|
|
767
|
-
light = _palette$type[0],
|
|
768
|
-
dark = _palette$type[1];
|
|
769
|
-
|
|
770
|
-
var css = "\n background-color: #".concat(direction === 'up' ? light : dark, "; \n color: ").concat(direction === 'up' ? 'black' : 'white', ";\n padding: 2px;\n ");
|
|
771
|
-
var parts = ['%c', direction === 'up' ? '>>' : '<<', type, "#".concat(id), "%c".concat(path, "%c"), '%O'];
|
|
772
|
-
var args = [css, "".concat(css, "; font-weight: bold;"), "".concat(css, "; font-weight: normal;")];
|
|
773
|
-
|
|
774
|
-
if (props.direction === 'up') {
|
|
775
|
-
args.push({
|
|
776
|
-
input: input,
|
|
777
|
-
context: context
|
|
778
|
-
});
|
|
779
|
-
} else {
|
|
780
|
-
args.push({
|
|
781
|
-
input: input,
|
|
782
|
-
result: props.result,
|
|
783
|
-
elapsedMs: props.elapsedMs,
|
|
784
|
-
context: context
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
var fn = props.direction === 'down' && props.result && (props.result instanceof Error || 'error' in props.result.data) ? 'error' : 'log';
|
|
789
|
-
c[fn].apply(null, [parts.join(' ')].concat(args));
|
|
790
|
-
};
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
function loggerLink() {
|
|
794
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
795
|
-
var _opts$enabled = opts.enabled,
|
|
796
|
-
enabled = _opts$enabled === void 0 ? function () {
|
|
797
|
-
return true;
|
|
798
|
-
} : _opts$enabled;
|
|
799
|
-
var _opts$logger = opts.logger,
|
|
800
|
-
logger = _opts$logger === void 0 ? defaultLogger(opts.console) : _opts$logger;
|
|
801
|
-
return function () {
|
|
802
|
-
return function (_ref) {
|
|
803
|
-
var op = _ref.op,
|
|
804
|
-
next = _ref.next;
|
|
805
|
-
return observable(function (observer) {
|
|
806
|
-
// ->
|
|
807
|
-
enabled(_objectSpread$1(_objectSpread$1({}, op), {}, {
|
|
808
|
-
direction: 'up'
|
|
809
|
-
})) && logger(_objectSpread$1(_objectSpread$1({}, op), {}, {
|
|
810
|
-
direction: 'up'
|
|
811
|
-
}));
|
|
812
|
-
var requestStartTime = Date.now();
|
|
813
|
-
|
|
814
|
-
function logResult(result) {
|
|
815
|
-
var elapsedMs = Date.now() - requestStartTime;
|
|
816
|
-
enabled(_objectSpread$1(_objectSpread$1({}, op), {}, {
|
|
817
|
-
direction: 'down',
|
|
818
|
-
result: result
|
|
819
|
-
})) && logger(_objectSpread$1(_objectSpread$1({}, op), {}, {
|
|
820
|
-
direction: 'down',
|
|
821
|
-
elapsedMs: elapsedMs,
|
|
822
|
-
result: result
|
|
823
|
-
}));
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
return next(op).pipe(tap({
|
|
827
|
-
next: function next(result) {
|
|
828
|
-
logResult(result);
|
|
829
|
-
},
|
|
830
|
-
error: function error(result) {
|
|
831
|
-
logResult(result);
|
|
832
|
-
}
|
|
833
|
-
})).subscribe(observer);
|
|
834
|
-
});
|
|
835
|
-
};
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
function retryLink(opts) {
|
|
840
|
-
// initialized config
|
|
841
|
-
return function () {
|
|
842
|
-
// initialized in app
|
|
843
|
-
return function (_ref) {
|
|
844
|
-
var op = _ref.op,
|
|
845
|
-
next = _ref.next;
|
|
846
|
-
// initialized for request
|
|
847
|
-
return observable(function (observer) {
|
|
848
|
-
var next$ = null;
|
|
849
|
-
var attempts = 0;
|
|
850
|
-
var isDone = false;
|
|
851
|
-
|
|
852
|
-
function attempt() {
|
|
853
|
-
var _next$;
|
|
854
|
-
|
|
855
|
-
attempts++;
|
|
856
|
-
(_next$ = next$) === null || _next$ === void 0 ? void 0 : _next$.unsubscribe();
|
|
857
|
-
next$ = next(op).subscribe({
|
|
858
|
-
error: function error(_error) {
|
|
859
|
-
if (attempts >= opts.attempts) {
|
|
860
|
-
observer.error(_error);
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
attempt();
|
|
865
|
-
},
|
|
866
|
-
next: function next(result) {
|
|
867
|
-
if ('result' in result.data) {
|
|
868
|
-
isDone = true;
|
|
869
|
-
observer.next(result);
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
if (attempts >= opts.attempts) {
|
|
874
|
-
isDone = true;
|
|
875
|
-
observer.next(result);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
attempt();
|
|
880
|
-
},
|
|
881
|
-
complete: function complete() {
|
|
882
|
-
if (isDone) {
|
|
883
|
-
observer.complete();
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
attempt();
|
|
890
|
-
return function () {
|
|
891
|
-
var _next$2;
|
|
892
|
-
|
|
893
|
-
isDone = true;
|
|
894
|
-
(_next$2 = next$) === null || _next$2 === void 0 ? void 0 : _next$2.unsubscribe();
|
|
895
|
-
};
|
|
896
|
-
});
|
|
897
|
-
};
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
function asArray(value) {
|
|
902
|
-
return Array.isArray(value) ? value : [value];
|
|
903
|
-
}
|
|
577
|
+
function asArray(value) {
|
|
578
|
+
return Array.isArray(value) ? value : [value];
|
|
579
|
+
}
|
|
904
580
|
|
|
905
581
|
function splitLink(opts) {
|
|
906
582
|
return function (rt) {
|
|
@@ -922,17 +598,17 @@ function splitLink(opts) {
|
|
|
922
598
|
};
|
|
923
599
|
}
|
|
924
600
|
|
|
925
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
601
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
926
602
|
|
|
927
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
603
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
928
604
|
|
|
929
605
|
/**
|
|
930
606
|
* @internal
|
|
931
607
|
*/
|
|
932
|
-
function transformOperationResult(result, transformer) {
|
|
608
|
+
function transformOperationResult$1(result, transformer) {
|
|
933
609
|
if ('error' in result.data) {
|
|
934
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
935
|
-
data: _objectSpread(_objectSpread({}, result.data), {}, {
|
|
610
|
+
return _objectSpread$1(_objectSpread$1({}, result), {}, {
|
|
611
|
+
data: _objectSpread$1(_objectSpread$1({}, result.data), {}, {
|
|
936
612
|
error: transformer.deserialize(result.data.error)
|
|
937
613
|
})
|
|
938
614
|
});
|
|
@@ -942,9 +618,9 @@ function transformOperationResult(result, transformer) {
|
|
|
942
618
|
return result;
|
|
943
619
|
}
|
|
944
620
|
|
|
945
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
946
|
-
data: _objectSpread(_objectSpread({}, result.data), {}, {
|
|
947
|
-
result: _objectSpread(_objectSpread({}, result.data.result), {}, {
|
|
621
|
+
return _objectSpread$1(_objectSpread$1({}, result), {}, {
|
|
622
|
+
data: _objectSpread$1(_objectSpread$1({}, result.data), {}, {
|
|
623
|
+
result: _objectSpread$1(_objectSpread$1({}, result.data.result), {}, {
|
|
948
624
|
data: transformer.deserialize(result.data.result.data)
|
|
949
625
|
})
|
|
950
626
|
})
|
|
@@ -969,11 +645,11 @@ function transformerLink(transformer) {
|
|
|
969
645
|
var input = _transformer.serialize(props.op.input);
|
|
970
646
|
|
|
971
647
|
return observable(function (observer) {
|
|
972
|
-
var subscription = props.next(_objectSpread(_objectSpread({}, props.op), {}, {
|
|
648
|
+
var subscription = props.next(_objectSpread$1(_objectSpread$1({}, props.op), {}, {
|
|
973
649
|
input: input
|
|
974
650
|
})).subscribe({
|
|
975
651
|
next: function next(value) {
|
|
976
|
-
var transformed = transformOperationResult(value, _transformer);
|
|
652
|
+
var transformed = transformOperationResult$1(value, _transformer);
|
|
977
653
|
observer.next(transformed);
|
|
978
654
|
},
|
|
979
655
|
error: function error(err) {
|
|
@@ -994,9 +670,76 @@ var retryDelay = function retryDelay(attemptIndex) {
|
|
|
994
670
|
return attemptIndex === 0 ? 0 : Math.min(1000 * Math.pow(2, attemptIndex), 30000);
|
|
995
671
|
};
|
|
996
672
|
|
|
997
|
-
function
|
|
673
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
674
|
+
|
|
675
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
676
|
+
|
|
677
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
678
|
+
|
|
679
|
+
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
680
|
+
|
|
681
|
+
var TRPCClientError = /*#__PURE__*/function (_Error) {
|
|
682
|
+
_inherits(TRPCClientError, _Error);
|
|
683
|
+
|
|
684
|
+
var _super = /*#__PURE__*/_createSuper$2(TRPCClientError);
|
|
685
|
+
|
|
686
|
+
function TRPCClientError(message, opts) {
|
|
687
|
+
var _opts$result, _opts$result2;
|
|
688
|
+
|
|
689
|
+
var _this;
|
|
690
|
+
|
|
691
|
+
_classCallCheck(this, TRPCClientError);
|
|
692
|
+
|
|
693
|
+
var cause = opts === null || opts === void 0 ? void 0 : opts.cause; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
694
|
+
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
695
|
+
|
|
696
|
+
_this = _super.call(this, message, {
|
|
697
|
+
cause: cause
|
|
698
|
+
});
|
|
699
|
+
_this.cause = void 0;
|
|
700
|
+
_this.shape = void 0;
|
|
701
|
+
_this.data = void 0;
|
|
702
|
+
_this.meta = void 0;
|
|
703
|
+
_this.meta = opts === null || opts === void 0 ? void 0 : opts.meta;
|
|
704
|
+
_this.cause = cause;
|
|
705
|
+
_this.shape = opts === null || opts === void 0 ? void 0 : (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error;
|
|
706
|
+
_this.data = opts === null || opts === void 0 ? void 0 : (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data;
|
|
707
|
+
_this.name = 'TRPCClientError';
|
|
708
|
+
Object.setPrototypeOf(_assertThisInitialized(_this), TRPCClientError.prototype);
|
|
709
|
+
return _this;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
_createClass(TRPCClientError, null, [{
|
|
713
|
+
key: "from",
|
|
714
|
+
value: function from(cause) {
|
|
715
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
716
|
+
|
|
717
|
+
if (!(cause instanceof Error)) {
|
|
718
|
+
var _message;
|
|
719
|
+
|
|
720
|
+
return new TRPCClientError((_message = cause.error.message) !== null && _message !== void 0 ? _message : '', _objectSpread(_objectSpread({}, opts), {}, {
|
|
721
|
+
cause: null,
|
|
722
|
+
result: cause
|
|
723
|
+
}));
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (cause.name === 'TRPCClientError') {
|
|
727
|
+
return cause;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
return new TRPCClientError(cause.message, _objectSpread(_objectSpread({}, opts), {}, {
|
|
731
|
+
cause: cause,
|
|
732
|
+
result: null
|
|
733
|
+
}));
|
|
734
|
+
}
|
|
735
|
+
}]);
|
|
736
|
+
|
|
737
|
+
return TRPCClientError;
|
|
738
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
739
|
+
|
|
740
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
998
741
|
|
|
999
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
742
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1000
743
|
function createWSClient(opts) {
|
|
1001
744
|
var url = opts.url,
|
|
1002
745
|
_opts$WebSocket = opts.WebSocket,
|
|
@@ -1260,7 +1003,7 @@ function createWSClient(opts) {
|
|
|
1260
1003
|
var TRPCWebSocketClosedError = /*#__PURE__*/function (_Error) {
|
|
1261
1004
|
_inherits(TRPCWebSocketClosedError, _Error);
|
|
1262
1005
|
|
|
1263
|
-
var _super = /*#__PURE__*/_createSuper(TRPCWebSocketClosedError);
|
|
1006
|
+
var _super = /*#__PURE__*/_createSuper$1(TRPCWebSocketClosedError);
|
|
1264
1007
|
|
|
1265
1008
|
function TRPCWebSocketClosedError(message) {
|
|
1266
1009
|
var _this;
|
|
@@ -1279,7 +1022,7 @@ var TRPCWebSocketClosedError = /*#__PURE__*/function (_Error) {
|
|
|
1279
1022
|
var TRPCSubscriptionEndedError = /*#__PURE__*/function (_Error2) {
|
|
1280
1023
|
_inherits(TRPCSubscriptionEndedError, _Error2);
|
|
1281
1024
|
|
|
1282
|
-
var _super2 = /*#__PURE__*/_createSuper(TRPCSubscriptionEndedError);
|
|
1025
|
+
var _super2 = /*#__PURE__*/_createSuper$1(TRPCSubscriptionEndedError);
|
|
1283
1026
|
|
|
1284
1027
|
function TRPCSubscriptionEndedError(message) {
|
|
1285
1028
|
var _this2;
|
|
@@ -1347,4 +1090,257 @@ function wsLink(opts) {
|
|
|
1347
1090
|
};
|
|
1348
1091
|
}
|
|
1349
1092
|
|
|
1093
|
+
/** @internal */
|
|
1094
|
+
function transformOperationResult(result) {
|
|
1095
|
+
var context = result.context;
|
|
1096
|
+
|
|
1097
|
+
if ('error' in result.data) {
|
|
1098
|
+
var error = TRPCClientError.from(result.data);
|
|
1099
|
+
return {
|
|
1100
|
+
ok: false,
|
|
1101
|
+
error: error,
|
|
1102
|
+
context: context
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
var data = result.data.result.data;
|
|
1107
|
+
return {
|
|
1108
|
+
ok: true,
|
|
1109
|
+
data: data,
|
|
1110
|
+
context: context
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
1115
|
+
|
|
1116
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1117
|
+
|
|
1118
|
+
var ObservableAbortError = /*#__PURE__*/function (_Error) {
|
|
1119
|
+
_inherits(ObservableAbortError, _Error);
|
|
1120
|
+
|
|
1121
|
+
var _super = /*#__PURE__*/_createSuper(ObservableAbortError);
|
|
1122
|
+
|
|
1123
|
+
function ObservableAbortError(message) {
|
|
1124
|
+
var _this;
|
|
1125
|
+
|
|
1126
|
+
_classCallCheck(this, ObservableAbortError);
|
|
1127
|
+
|
|
1128
|
+
_this = _super.call(this, message);
|
|
1129
|
+
_this.name = 'ObservableAbortError';
|
|
1130
|
+
Object.setPrototypeOf(_assertThisInitialized(_this), ObservableAbortError.prototype);
|
|
1131
|
+
return _this;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
return _createClass(ObservableAbortError);
|
|
1135
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1136
|
+
/** @internal */
|
|
1137
|
+
|
|
1138
|
+
function observableToPromise(observable) {
|
|
1139
|
+
var abort;
|
|
1140
|
+
var promise = new Promise(function (resolve, reject) {
|
|
1141
|
+
var isDone = false;
|
|
1142
|
+
|
|
1143
|
+
function onDone() {
|
|
1144
|
+
if (isDone) {
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
isDone = true;
|
|
1149
|
+
reject(new ObservableAbortError('This operation was cancelled.'));
|
|
1150
|
+
obs$.unsubscribe();
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
var obs$ = observable.subscribe({
|
|
1154
|
+
next: function next(data) {
|
|
1155
|
+
isDone = true;
|
|
1156
|
+
resolve(data);
|
|
1157
|
+
onDone();
|
|
1158
|
+
},
|
|
1159
|
+
error: function error(data) {
|
|
1160
|
+
isDone = true;
|
|
1161
|
+
reject(data);
|
|
1162
|
+
onDone();
|
|
1163
|
+
},
|
|
1164
|
+
complete: function complete() {
|
|
1165
|
+
isDone = true;
|
|
1166
|
+
onDone();
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
abort = onDone;
|
|
1170
|
+
});
|
|
1171
|
+
return {
|
|
1172
|
+
promise: promise,
|
|
1173
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1174
|
+
abort: abort
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
var idCounter = 0;
|
|
1179
|
+
|
|
1180
|
+
function getRequestId() {
|
|
1181
|
+
return ++idCounter;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
var TRPCClient = /*#__PURE__*/function () {
|
|
1185
|
+
function TRPCClient(opts) {
|
|
1186
|
+
var _this = this;
|
|
1187
|
+
|
|
1188
|
+
_classCallCheck(this, TRPCClient);
|
|
1189
|
+
|
|
1190
|
+
this.links = void 0;
|
|
1191
|
+
this.runtime = void 0;
|
|
1192
|
+
|
|
1193
|
+
var _fetch = getFetch(opts === null || opts === void 0 ? void 0 : opts.fetch);
|
|
1194
|
+
|
|
1195
|
+
var AC = getAbortController(opts === null || opts === void 0 ? void 0 : opts.AbortController);
|
|
1196
|
+
|
|
1197
|
+
function getHeadersFn() {
|
|
1198
|
+
if (opts.headers) {
|
|
1199
|
+
var headers = opts.headers;
|
|
1200
|
+
return typeof headers === 'function' ? headers : function () {
|
|
1201
|
+
return headers;
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
return function () {
|
|
1206
|
+
return {};
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
this.runtime = {
|
|
1211
|
+
AbortController: AC,
|
|
1212
|
+
fetch: _fetch,
|
|
1213
|
+
headers: getHeadersFn()
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
if ('links' in opts) {
|
|
1217
|
+
this.links = opts.links.map(function (link) {
|
|
1218
|
+
return link(_this.runtime);
|
|
1219
|
+
});
|
|
1220
|
+
} else {
|
|
1221
|
+
this.links = [httpBatchLink({
|
|
1222
|
+
url: opts.url
|
|
1223
|
+
})(this.runtime)];
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
_createClass(TRPCClient, [{
|
|
1228
|
+
key: "$request",
|
|
1229
|
+
value: function $request(_ref) {
|
|
1230
|
+
var type = _ref.type,
|
|
1231
|
+
input = _ref.input,
|
|
1232
|
+
path = _ref.path,
|
|
1233
|
+
_ref$context = _ref.context,
|
|
1234
|
+
context = _ref$context === void 0 ? {} : _ref$context;
|
|
1235
|
+
var chain$ = createChain({
|
|
1236
|
+
links: this.links,
|
|
1237
|
+
op: {
|
|
1238
|
+
id: getRequestId(),
|
|
1239
|
+
type: type,
|
|
1240
|
+
path: path,
|
|
1241
|
+
input: input,
|
|
1242
|
+
context: context
|
|
1243
|
+
}
|
|
1244
|
+
});
|
|
1245
|
+
return chain$.pipe(share());
|
|
1246
|
+
}
|
|
1247
|
+
}, {
|
|
1248
|
+
key: "requestAsPromise",
|
|
1249
|
+
value: function requestAsPromise(opts) {
|
|
1250
|
+
var req$ = this.$request(opts);
|
|
1251
|
+
|
|
1252
|
+
var _observableToPromise = observableToPromise(req$),
|
|
1253
|
+
promise = _observableToPromise.promise,
|
|
1254
|
+
abort = _observableToPromise.abort;
|
|
1255
|
+
|
|
1256
|
+
var cancellablePromise = new Promise(function (resolve, reject) {
|
|
1257
|
+
promise.then(function (result) {
|
|
1258
|
+
var transformed = transformOperationResult(result);
|
|
1259
|
+
|
|
1260
|
+
if (transformed.ok) {
|
|
1261
|
+
resolve(transformed.data);
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
reject(transformed.error);
|
|
1266
|
+
}).catch(function (err) {
|
|
1267
|
+
reject(TRPCClientError.from(err));
|
|
1268
|
+
});
|
|
1269
|
+
});
|
|
1270
|
+
cancellablePromise.cancel = abort;
|
|
1271
|
+
return cancellablePromise;
|
|
1272
|
+
}
|
|
1273
|
+
}, {
|
|
1274
|
+
key: "query",
|
|
1275
|
+
value: function query(path) {
|
|
1276
|
+
var _ref2;
|
|
1277
|
+
|
|
1278
|
+
var context = (_ref2 = arguments.length <= 2 ? undefined : arguments[2]) === null || _ref2 === void 0 ? void 0 : _ref2.context;
|
|
1279
|
+
return this.requestAsPromise({
|
|
1280
|
+
type: 'query',
|
|
1281
|
+
path: path,
|
|
1282
|
+
input: arguments.length <= 1 ? undefined : arguments[1],
|
|
1283
|
+
context: context
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
}, {
|
|
1287
|
+
key: "mutation",
|
|
1288
|
+
value: function mutation(path) {
|
|
1289
|
+
var _ref3;
|
|
1290
|
+
|
|
1291
|
+
var context = (_ref3 = arguments.length <= 2 ? undefined : arguments[2]) === null || _ref3 === void 0 ? void 0 : _ref3.context;
|
|
1292
|
+
return this.requestAsPromise({
|
|
1293
|
+
type: 'mutation',
|
|
1294
|
+
path: path,
|
|
1295
|
+
input: arguments.length <= 1 ? undefined : arguments[1],
|
|
1296
|
+
context: context
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
}, {
|
|
1300
|
+
key: "subscription",
|
|
1301
|
+
value: function subscription(path, input, opts) {
|
|
1302
|
+
var observable$ = this.$request({
|
|
1303
|
+
type: 'subscription',
|
|
1304
|
+
path: path,
|
|
1305
|
+
input: input,
|
|
1306
|
+
context: opts.context
|
|
1307
|
+
});
|
|
1308
|
+
return observable$.subscribe({
|
|
1309
|
+
next: function next(result) {
|
|
1310
|
+
var _opts$next;
|
|
1311
|
+
|
|
1312
|
+
if ('error' in result.data) {
|
|
1313
|
+
var _opts$error;
|
|
1314
|
+
|
|
1315
|
+
var err = TRPCClientError.from(result.data, {
|
|
1316
|
+
meta: result.context
|
|
1317
|
+
});
|
|
1318
|
+
(_opts$error = opts.error) === null || _opts$error === void 0 ? void 0 : _opts$error.call(opts, err);
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
(_opts$next = opts.next) === null || _opts$next === void 0 ? void 0 : _opts$next.call(opts, result.data.result);
|
|
1323
|
+
},
|
|
1324
|
+
error: function error(err) {
|
|
1325
|
+
var _opts$error2;
|
|
1326
|
+
|
|
1327
|
+
(_opts$error2 = opts.error) === null || _opts$error2 === void 0 ? void 0 : _opts$error2.call(opts, err);
|
|
1328
|
+
},
|
|
1329
|
+
complete: function complete() {
|
|
1330
|
+
var _opts$complete;
|
|
1331
|
+
|
|
1332
|
+
(_opts$complete = opts.complete) === null || _opts$complete === void 0 ? void 0 : _opts$complete.call(opts);
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
}]);
|
|
1337
|
+
|
|
1338
|
+
return TRPCClient;
|
|
1339
|
+
}();
|
|
1340
|
+
|
|
1341
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1342
|
+
function createTRPCClient(opts) {
|
|
1343
|
+
return new TRPCClient(opts);
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1350
1346
|
export { TRPCClientError, createTRPCClient, createWSClient, dedupeLink, getFetch, httpBatchLink, httpLink, loggerLink, retryLink, splitLink, transformerLink, wsLink };
|