@trpc/client 10.0.0-alpha.23 → 10.0.0-alpha.26

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 (74) hide show
  1. package/dist/TRPCClientError.d.ts +2 -2
  2. package/dist/TRPCClientError.d.ts.map +1 -1
  3. package/dist/createTRPCClient.d.ts +1 -2
  4. package/dist/createTRPCClient.d.ts.map +1 -1
  5. package/dist/httpUtils-089853f6.mjs +99 -0
  6. package/dist/httpUtils-a0169eef.js +106 -0
  7. package/dist/index.js +63 -1031
  8. package/dist/index.mjs +55 -1015
  9. package/dist/internals/TRPCClient.d.ts +4 -2
  10. package/dist/internals/TRPCClient.d.ts.map +1 -1
  11. package/dist/links/httpBatchLink.js +317 -0
  12. package/dist/links/httpBatchLink.mjs +313 -0
  13. package/dist/links/httpBatchLink.ts.js +1 -0
  14. package/dist/links/httpLink.js +44 -0
  15. package/dist/links/httpLink.mjs +40 -0
  16. package/dist/links/httpLink.ts.js +1 -0
  17. package/dist/links/loggerLink.js +107 -0
  18. package/dist/links/loggerLink.mjs +98 -0
  19. package/dist/links/loggerLink.ts.js +1 -0
  20. package/dist/links/splitLink.js +10 -0
  21. package/dist/links/splitLink.mjs +2 -0
  22. package/dist/links/splitLink.ts.js +1 -0
  23. package/dist/links/types.d.ts +1 -1
  24. package/dist/links/types.d.ts.map +1 -1
  25. package/dist/links/wsLink.d.ts +2 -2
  26. package/dist/links/wsLink.d.ts.map +1 -1
  27. package/dist/links/wsLink.js +19 -0
  28. package/dist/links/wsLink.mjs +10 -0
  29. package/dist/links/wsLink.ts.js +1 -0
  30. package/dist/splitLink-62ff9db0.mjs +49 -0
  31. package/dist/splitLink-8202386e.js +52 -0
  32. package/dist/wsLink-69f5adb8.js +451 -0
  33. package/dist/wsLink-9468a563.mjs +436 -0
  34. package/links/httpBatchLink/index.d.ts +1 -0
  35. package/links/httpBatchLink/index.js +1 -0
  36. package/links/httpLink/index.d.ts +1 -0
  37. package/links/httpLink/index.js +1 -0
  38. package/links/loggerLink/index.d.ts +1 -0
  39. package/links/loggerLink/index.js +1 -0
  40. package/links/splitLink/index.d.ts +1 -0
  41. package/links/splitLink/index.js +1 -0
  42. package/links/wsLink/index.d.ts +1 -0
  43. package/links/wsLink/index.js +1 -0
  44. package/package.json +31 -5
  45. package/src/TRPCClientError.ts +2 -2
  46. package/src/createTRPCClient.ts +1 -2
  47. package/src/internals/TRPCClient.ts +17 -0
  48. package/src/links/types.ts +1 -1
  49. package/src/links/wsLink.ts +2 -2
  50. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.d.ts +0 -1
  51. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.dev.js +0 -214
  52. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.js +0 -7
  53. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.prod.js +0 -214
  54. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.esm.js +0 -210
  55. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.d.ts +0 -1
  56. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.dev.js +0 -67
  57. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.js +0 -7
  58. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.prod.js +0 -67
  59. package/links/httpLink/dist/trpc-client-links-httpLink.esm.js +0 -63
  60. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.d.ts +0 -1
  61. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.dev.js +0 -89
  62. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.js +0 -7
  63. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.prod.js +0 -89
  64. package/links/loggerLink/dist/trpc-client-links-loggerLink.esm.js +0 -85
  65. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.d.ts +0 -1
  66. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.dev.js +0 -19
  67. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.js +0 -7
  68. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.prod.js +0 -19
  69. package/links/splitLink/dist/trpc-client-links-splitLink.esm.js +0 -15
  70. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.d.ts +0 -1
  71. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.dev.js +0 -397
  72. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.js +0 -7
  73. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.prod.js +0 -397
  74. package/links/wsLink/dist/trpc-client-links-wsLink.esm.js +0 -392
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-client-links-httpLink.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-client-links-httpLink.cjs.dev.js");
7
- }
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var TRPCClientError = require('../../../dist/TRPCClientError-e9bf96e9.cjs.prod.js');
6
- var transformRPCResponse = require('../../../dist/transformRPCResponse-e6daeb02.cjs.prod.js');
7
- require('@babel/runtime/helpers/objectSpread2');
8
- require('@babel/runtime/helpers/classCallCheck');
9
- require('@babel/runtime/helpers/createClass');
10
- require('@babel/runtime/helpers/assertThisInitialized');
11
- require('@babel/runtime/helpers/inherits');
12
- require('@babel/runtime/helpers/createSuper');
13
- require('@babel/runtime/helpers/wrapNativeSuper');
14
-
15
- function httpLink(opts) {
16
- var url = opts.url; // initialized config
17
-
18
- return function (runtime) {
19
- // initialized in app
20
- return function (_ref) {
21
- var op = _ref.op,
22
- prev = _ref.prev,
23
- onDestroy = _ref.onDestroy;
24
- var path = op.path,
25
- input = op.input,
26
- type = op.type;
27
-
28
- var _httpRequest = transformRPCResponse.httpRequest({
29
- runtime: runtime,
30
- type: type,
31
- input: input,
32
- url: url,
33
- path: path
34
- }),
35
- promise = _httpRequest.promise,
36
- cancel = _httpRequest.cancel;
37
-
38
- var isDone = false;
39
-
40
- var prevOnce = function prevOnce(result) {
41
- if (isDone) {
42
- return;
43
- }
44
-
45
- isDone = true;
46
- prev(result);
47
- };
48
-
49
- onDestroy(function () {
50
- prevOnce(TRPCClientError.TRPCClientError.from(new transformRPCResponse.TRPCAbortError(), {
51
- isDone: true
52
- }));
53
- cancel();
54
- });
55
- promise.then(function (envelope) {
56
- prevOnce(transformRPCResponse.transformRPCResponse({
57
- envelope: envelope,
58
- runtime: runtime
59
- }));
60
- }).catch(function (cause) {
61
- prevOnce(TRPCClientError.TRPCClientError.from(cause));
62
- });
63
- };
64
- };
65
- }
66
-
67
- exports.httpLink = httpLink;
@@ -1,63 +0,0 @@
1
- import { T as TRPCClientError } from '../../../dist/TRPCClientError-09b8a26b.esm.js';
2
- import { h as httpRequest, T as TRPCAbortError, t as transformRPCResponse } from '../../../dist/transformRPCResponse-3700ef8b.esm.js';
3
- import '@babel/runtime/helpers/objectSpread2';
4
- import '@babel/runtime/helpers/classCallCheck';
5
- import '@babel/runtime/helpers/createClass';
6
- import '@babel/runtime/helpers/assertThisInitialized';
7
- import '@babel/runtime/helpers/inherits';
8
- import '@babel/runtime/helpers/createSuper';
9
- import '@babel/runtime/helpers/wrapNativeSuper';
10
-
11
- function httpLink(opts) {
12
- var url = opts.url; // initialized config
13
-
14
- return function (runtime) {
15
- // initialized in app
16
- return function (_ref) {
17
- var op = _ref.op,
18
- prev = _ref.prev,
19
- onDestroy = _ref.onDestroy;
20
- var path = op.path,
21
- input = op.input,
22
- type = op.type;
23
-
24
- var _httpRequest = httpRequest({
25
- runtime: runtime,
26
- type: type,
27
- input: input,
28
- url: url,
29
- path: path
30
- }),
31
- promise = _httpRequest.promise,
32
- cancel = _httpRequest.cancel;
33
-
34
- var isDone = false;
35
-
36
- var prevOnce = function prevOnce(result) {
37
- if (isDone) {
38
- return;
39
- }
40
-
41
- isDone = true;
42
- prev(result);
43
- };
44
-
45
- onDestroy(function () {
46
- prevOnce(TRPCClientError.from(new TRPCAbortError(), {
47
- isDone: true
48
- }));
49
- cancel();
50
- });
51
- promise.then(function (envelope) {
52
- prevOnce(transformRPCResponse({
53
- envelope: envelope,
54
- runtime: runtime
55
- }));
56
- }).catch(function (cause) {
57
- prevOnce(TRPCClientError.from(cause));
58
- });
59
- };
60
- };
61
- }
62
-
63
- export { httpLink };
@@ -1 +0,0 @@
1
- export * from "../../../dist/declarations/src/links/loggerLink";
@@ -1,89 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
-
8
- var palette = {
9
- query: ['72e3ff', '3fb0d8'],
10
- mutation: ['c5a3fc', '904dfc'],
11
- subscription: ['ff49e1', 'd83fbe']
12
- };
13
-
14
- // maybe this should be moved to it's own package
15
- var defaultLogger = function defaultLogger() {
16
- var c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : console;
17
- return function (props) {
18
- var direction = props.direction,
19
- input = props.input,
20
- type = props.type,
21
- path = props.path,
22
- context = props.context,
23
- id = props.id;
24
-
25
- var _palette$type = _slicedToArray(palette[type], 2),
26
- light = _palette$type[0],
27
- dark = _palette$type[1];
28
-
29
- var css = "\n background-color: #".concat(direction === 'up' ? light : dark, "; \n color: ").concat(direction === 'up' ? 'black' : 'white', ";\n padding: 2px;\n ");
30
- var parts = ['%c', direction === 'up' ? '>>' : '<<', type, "#".concat(id), "%c".concat(path, "%c"), '%O'];
31
- var args = [css, "".concat(css, "; font-weight: bold;"), "".concat(css, "; font-weight: normal;")];
32
-
33
- if (props.direction === 'up') {
34
- args.push({
35
- input: input,
36
- context: context
37
- });
38
- } else {
39
- args.push({
40
- input: input,
41
- result: props.result,
42
- elapsedMs: props.elapsedMs,
43
- context: context
44
- });
45
- }
46
-
47
- var fn = props.direction === 'down' && props.result && props.result instanceof Error ? 'error' : 'log';
48
- c[fn].apply(null, [parts.join(' ')].concat(args));
49
- };
50
- };
51
-
52
- function loggerLink() {
53
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
- var _opts$enabled = opts.enabled,
55
- enabled = _opts$enabled === void 0 ? function () {
56
- return true;
57
- } : _opts$enabled;
58
- var _opts$logger = opts.logger,
59
- logger = _opts$logger === void 0 ? defaultLogger(opts.console) : _opts$logger;
60
- return function () {
61
- return function (_ref) {
62
- var op = _ref.op,
63
- next = _ref.next,
64
- prev = _ref.prev;
65
- // ->
66
- enabled(_objectSpread(_objectSpread({}, op), {}, {
67
- direction: 'up'
68
- })) && logger(_objectSpread(_objectSpread({}, op), {}, {
69
- direction: 'up'
70
- }));
71
- var requestStartTime = Date.now();
72
- next(op, function (result) {
73
- var elapsedMs = Date.now() - requestStartTime;
74
- enabled(_objectSpread(_objectSpread({}, op), {}, {
75
- direction: 'down',
76
- result: result
77
- })) && logger(_objectSpread(_objectSpread({}, op), {}, {
78
- direction: 'down',
79
- elapsedMs: elapsedMs,
80
- result: result
81
- })); // <-
82
-
83
- prev(result);
84
- });
85
- };
86
- };
87
- }
88
-
89
- exports.loggerLink = loggerLink;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-client-links-loggerLink.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-client-links-loggerLink.cjs.dev.js");
7
- }
@@ -1,89 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
-
8
- var palette = {
9
- query: ['72e3ff', '3fb0d8'],
10
- mutation: ['c5a3fc', '904dfc'],
11
- subscription: ['ff49e1', 'd83fbe']
12
- };
13
-
14
- // maybe this should be moved to it's own package
15
- var defaultLogger = function defaultLogger() {
16
- var c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : console;
17
- return function (props) {
18
- var direction = props.direction,
19
- input = props.input,
20
- type = props.type,
21
- path = props.path,
22
- context = props.context,
23
- id = props.id;
24
-
25
- var _palette$type = _slicedToArray(palette[type], 2),
26
- light = _palette$type[0],
27
- dark = _palette$type[1];
28
-
29
- var css = "\n background-color: #".concat(direction === 'up' ? light : dark, "; \n color: ").concat(direction === 'up' ? 'black' : 'white', ";\n padding: 2px;\n ");
30
- var parts = ['%c', direction === 'up' ? '>>' : '<<', type, "#".concat(id), "%c".concat(path, "%c"), '%O'];
31
- var args = [css, "".concat(css, "; font-weight: bold;"), "".concat(css, "; font-weight: normal;")];
32
-
33
- if (props.direction === 'up') {
34
- args.push({
35
- input: input,
36
- context: context
37
- });
38
- } else {
39
- args.push({
40
- input: input,
41
- result: props.result,
42
- elapsedMs: props.elapsedMs,
43
- context: context
44
- });
45
- }
46
-
47
- var fn = props.direction === 'down' && props.result && props.result instanceof Error ? 'error' : 'log';
48
- c[fn].apply(null, [parts.join(' ')].concat(args));
49
- };
50
- };
51
-
52
- function loggerLink() {
53
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
54
- var _opts$enabled = opts.enabled,
55
- enabled = _opts$enabled === void 0 ? function () {
56
- return true;
57
- } : _opts$enabled;
58
- var _opts$logger = opts.logger,
59
- logger = _opts$logger === void 0 ? defaultLogger(opts.console) : _opts$logger;
60
- return function () {
61
- return function (_ref) {
62
- var op = _ref.op,
63
- next = _ref.next,
64
- prev = _ref.prev;
65
- // ->
66
- enabled(_objectSpread(_objectSpread({}, op), {}, {
67
- direction: 'up'
68
- })) && logger(_objectSpread(_objectSpread({}, op), {}, {
69
- direction: 'up'
70
- }));
71
- var requestStartTime = Date.now();
72
- next(op, function (result) {
73
- var elapsedMs = Date.now() - requestStartTime;
74
- enabled(_objectSpread(_objectSpread({}, op), {}, {
75
- direction: 'down',
76
- result: result
77
- })) && logger(_objectSpread(_objectSpread({}, op), {}, {
78
- direction: 'down',
79
- elapsedMs: elapsedMs,
80
- result: result
81
- })); // <-
82
-
83
- prev(result);
84
- });
85
- };
86
- };
87
- }
88
-
89
- exports.loggerLink = loggerLink;
@@ -1,85 +0,0 @@
1
- import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
2
- import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
3
-
4
- var palette = {
5
- query: ['72e3ff', '3fb0d8'],
6
- mutation: ['c5a3fc', '904dfc'],
7
- subscription: ['ff49e1', 'd83fbe']
8
- };
9
-
10
- // maybe this should be moved to it's own package
11
- var defaultLogger = function defaultLogger() {
12
- var c = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : console;
13
- return function (props) {
14
- var direction = props.direction,
15
- input = props.input,
16
- type = props.type,
17
- path = props.path,
18
- context = props.context,
19
- id = props.id;
20
-
21
- var _palette$type = _slicedToArray(palette[type], 2),
22
- light = _palette$type[0],
23
- dark = _palette$type[1];
24
-
25
- var css = "\n background-color: #".concat(direction === 'up' ? light : dark, "; \n color: ").concat(direction === 'up' ? 'black' : 'white', ";\n padding: 2px;\n ");
26
- var parts = ['%c', direction === 'up' ? '>>' : '<<', type, "#".concat(id), "%c".concat(path, "%c"), '%O'];
27
- var args = [css, "".concat(css, "; font-weight: bold;"), "".concat(css, "; font-weight: normal;")];
28
-
29
- if (props.direction === 'up') {
30
- args.push({
31
- input: input,
32
- context: context
33
- });
34
- } else {
35
- args.push({
36
- input: input,
37
- result: props.result,
38
- elapsedMs: props.elapsedMs,
39
- context: context
40
- });
41
- }
42
-
43
- var fn = props.direction === 'down' && props.result && props.result instanceof Error ? 'error' : 'log';
44
- c[fn].apply(null, [parts.join(' ')].concat(args));
45
- };
46
- };
47
-
48
- function loggerLink() {
49
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
50
- var _opts$enabled = opts.enabled,
51
- enabled = _opts$enabled === void 0 ? function () {
52
- return true;
53
- } : _opts$enabled;
54
- var _opts$logger = opts.logger,
55
- logger = _opts$logger === void 0 ? defaultLogger(opts.console) : _opts$logger;
56
- return function () {
57
- return function (_ref) {
58
- var op = _ref.op,
59
- next = _ref.next,
60
- prev = _ref.prev;
61
- // ->
62
- enabled(_objectSpread(_objectSpread({}, op), {}, {
63
- direction: 'up'
64
- })) && logger(_objectSpread(_objectSpread({}, op), {}, {
65
- direction: 'up'
66
- }));
67
- var requestStartTime = Date.now();
68
- next(op, function (result) {
69
- var elapsedMs = Date.now() - requestStartTime;
70
- enabled(_objectSpread(_objectSpread({}, op), {}, {
71
- direction: 'down',
72
- result: result
73
- })) && logger(_objectSpread(_objectSpread({}, op), {}, {
74
- direction: 'down',
75
- elapsedMs: elapsedMs,
76
- result: result
77
- })); // <-
78
-
79
- prev(result);
80
- });
81
- };
82
- };
83
- }
84
-
85
- export { loggerLink };
@@ -1 +0,0 @@
1
- export * from "../../../dist/declarations/src/links/splitLink";
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function splitLink(opts) {
6
- return function (rt) {
7
- var links = 'left' in opts ? {
8
- true: opts.left,
9
- false: opts.right
10
- } : opts;
11
- var yes = links.true(rt);
12
- var no = links.false(rt);
13
- return function (props) {
14
- opts.condition(props.op) ? yes(props) : no(props);
15
- };
16
- };
17
- }
18
-
19
- exports.splitLink = splitLink;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-client-links-splitLink.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-client-links-splitLink.cjs.dev.js");
7
- }
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function splitLink(opts) {
6
- return function (rt) {
7
- var links = 'left' in opts ? {
8
- true: opts.left,
9
- false: opts.right
10
- } : opts;
11
- var yes = links.true(rt);
12
- var no = links.false(rt);
13
- return function (props) {
14
- opts.condition(props.op) ? yes(props) : no(props);
15
- };
16
- };
17
- }
18
-
19
- exports.splitLink = splitLink;
@@ -1,15 +0,0 @@
1
- function splitLink(opts) {
2
- return function (rt) {
3
- var links = 'left' in opts ? {
4
- true: opts.left,
5
- false: opts.right
6
- } : opts;
7
- var yes = links.true(rt);
8
- var no = links.false(rt);
9
- return function (props) {
10
- opts.condition(props.op) ? yes(props) : no(props);
11
- };
12
- };
13
- }
14
-
15
- export { splitLink };
@@ -1 +0,0 @@
1
- export * from "../../../dist/declarations/src/links/wsLink";