@trpc/client 10.0.0-alpha.12 → 10.0.0-alpha.13

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 (77) hide show
  1. package/dist/{httpUtils-1f9e4e3c.js → httpUtils-27640b42.js} +0 -0
  2. package/dist/{httpUtils-c09d7b79.mjs → httpUtils-b92552af.mjs} +0 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +138 -9
  6. package/dist/index.mjs +128 -6
  7. package/dist/links/httpBatchLink.d.ts +1 -1
  8. package/dist/links/httpBatchLink.d.ts.map +1 -1
  9. package/dist/links/httpBatchLink.js +1 -1
  10. package/dist/links/httpBatchLink.mjs +1 -1
  11. package/dist/links/httpLink.d.ts +1 -1
  12. package/dist/links/httpLink.d.ts.map +1 -1
  13. package/dist/links/httpLink.js +1 -1
  14. package/dist/links/httpLink.mjs +1 -1
  15. package/dist/links/index.d.ts +11 -0
  16. package/dist/links/index.d.ts.map +1 -0
  17. package/dist/links/{httpUtils.d.ts → internals/httpUtils.d.ts} +1 -1
  18. package/dist/links/internals/httpUtils.d.ts.map +1 -0
  19. package/dist/links/splitLink.js +3 -25
  20. package/dist/links/splitLink.mjs +2 -28
  21. package/dist/links/wsLink.js +11 -377
  22. package/dist/links/wsLink.mjs +9 -369
  23. package/dist/{createChain-e77be464.js → splitLink-8635d455.js} +25 -0
  24. package/dist/{createChain-480b6341.mjs → splitLink-a736378a.mjs} +25 -1
  25. package/dist/wsLink-a6a0f3a8.mjs +440 -0
  26. package/dist/wsLink-c9323097.js +455 -0
  27. package/package.json +4 -34
  28. package/src/index.ts +1 -1
  29. package/src/links/httpBatchLink.ts +5 -1
  30. package/src/links/httpLink.ts +1 -1
  31. package/src/links/index.ts +10 -0
  32. package/src/links/{httpUtils.ts → internals/httpUtils.ts} +1 -1
  33. package/dist/TRPCClientError-17b117e1.mjs +0 -81
  34. package/dist/TRPCClientError-ec6bd2ca.js +0 -94
  35. package/dist/links/httpUtils.d.ts.map +0 -1
  36. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.d.ts +0 -1
  37. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.dev.js +0 -214
  38. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.js +0 -7
  39. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.prod.js +0 -214
  40. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.esm.js +0 -210
  41. package/links/httpBatchLink/index.d.ts +0 -1
  42. package/links/httpBatchLink/index.js +0 -1
  43. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.d.ts +0 -1
  44. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.dev.js +0 -67
  45. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.js +0 -7
  46. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.prod.js +0 -67
  47. package/links/httpLink/dist/trpc-client-links-httpLink.esm.js +0 -63
  48. package/links/httpLink/index.d.ts +0 -1
  49. package/links/httpLink/index.js +0 -1
  50. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.d.ts +0 -1
  51. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.dev.js +0 -89
  52. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.js +0 -7
  53. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.prod.js +0 -89
  54. package/links/loggerLink/dist/trpc-client-links-loggerLink.esm.js +0 -85
  55. package/links/loggerLink/index.d.ts +0 -1
  56. package/links/loggerLink/index.js +0 -1
  57. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.d.ts +0 -1
  58. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.dev.js +0 -19
  59. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.js +0 -7
  60. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.prod.js +0 -19
  61. package/links/splitLink/dist/trpc-client-links-splitLink.esm.js +0 -15
  62. package/links/splitLink/index.d.ts +0 -1
  63. package/links/splitLink/index.js +0 -1
  64. package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.d.ts +0 -1
  65. package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.dev.js +0 -67
  66. package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.js +0 -7
  67. package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.prod.js +0 -67
  68. package/links/transformerLink/dist/trpc-client-links-transformerLink.esm.js +0 -63
  69. package/links/transformerLink/index.d.ts +0 -1
  70. package/links/transformerLink/index.js +0 -1
  71. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.d.ts +0 -1
  72. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.dev.js +0 -395
  73. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.js +0 -7
  74. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.prod.js +0 -395
  75. package/links/wsLink/dist/trpc-client-links-wsLink.esm.js +0 -390
  76. package/links/wsLink/index.d.ts +0 -1
  77. package/links/wsLink/index.js +0 -1
@@ -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/links/loggerLink';
@@ -1 +0,0 @@
1
- module.exports = require('../../dist/links/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/links/splitLink';
@@ -1 +0,0 @@
1
- module.exports = require('../../dist/links/splitLink');
@@ -1 +0,0 @@
1
- export * from "../../../dist/declarations/src/links/transformerLink";
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var observable = require('../../../dist/observable-9aad8c3e.cjs.dev.js');
7
-
8
- /**
9
- * @internal
10
- */
11
- function transformOperationResult(result, transformer) {
12
- if ('error' in result.data) {
13
- return _objectSpread(_objectSpread({}, result), {}, {
14
- data: _objectSpread(_objectSpread({}, result.data), {}, {
15
- error: transformer.deserialize(result.data.error)
16
- })
17
- });
18
- }
19
-
20
- if (result.data.result.type !== 'data') {
21
- return result;
22
- }
23
-
24
- return _objectSpread(_objectSpread({}, result), {}, {
25
- data: _objectSpread(_objectSpread({}, result.data), {}, {
26
- result: _objectSpread(_objectSpread({}, result.data.result), {}, {
27
- data: transformer.deserialize(result.data.result.data)
28
- })
29
- })
30
- });
31
- }
32
-
33
- function transformerLink(transformer) {
34
- var _transformer = transformer ? 'input' in transformer ? {
35
- serialize: transformer.input.serialize,
36
- deserialize: transformer.output.deserialize
37
- } : transformer : {
38
- serialize: function serialize(data) {
39
- return data;
40
- },
41
- deserialize: function deserialize(data) {
42
- return data;
43
- }
44
- };
45
-
46
- return function () {
47
- return function (props) {
48
- var input = _transformer.serialize(props.op.input);
49
-
50
- return observable.observable(function (observer) {
51
- var next$ = props.next(_objectSpread(_objectSpread({}, props.op), {}, {
52
- input: input
53
- })).subscribe({
54
- next: function next(value) {
55
- var transformed = transformOperationResult(value, _transformer);
56
- observer.next(transformed);
57
- },
58
- error: observer.error,
59
- complete: observer.complete
60
- });
61
- return next$;
62
- });
63
- };
64
- };
65
- }
66
-
67
- exports.transformerLink = transformerLink;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-client-links-transformerLink.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-client-links-transformerLink.cjs.dev.js");
7
- }
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var observable = require('../../../dist/observable-ccb54234.cjs.prod.js');
7
-
8
- /**
9
- * @internal
10
- */
11
- function transformOperationResult(result, transformer) {
12
- if ('error' in result.data) {
13
- return _objectSpread(_objectSpread({}, result), {}, {
14
- data: _objectSpread(_objectSpread({}, result.data), {}, {
15
- error: transformer.deserialize(result.data.error)
16
- })
17
- });
18
- }
19
-
20
- if (result.data.result.type !== 'data') {
21
- return result;
22
- }
23
-
24
- return _objectSpread(_objectSpread({}, result), {}, {
25
- data: _objectSpread(_objectSpread({}, result.data), {}, {
26
- result: _objectSpread(_objectSpread({}, result.data.result), {}, {
27
- data: transformer.deserialize(result.data.result.data)
28
- })
29
- })
30
- });
31
- }
32
-
33
- function transformerLink(transformer) {
34
- var _transformer = transformer ? 'input' in transformer ? {
35
- serialize: transformer.input.serialize,
36
- deserialize: transformer.output.deserialize
37
- } : transformer : {
38
- serialize: function serialize(data) {
39
- return data;
40
- },
41
- deserialize: function deserialize(data) {
42
- return data;
43
- }
44
- };
45
-
46
- return function () {
47
- return function (props) {
48
- var input = _transformer.serialize(props.op.input);
49
-
50
- return observable.observable(function (observer) {
51
- var next$ = props.next(_objectSpread(_objectSpread({}, props.op), {}, {
52
- input: input
53
- })).subscribe({
54
- next: function next(value) {
55
- var transformed = transformOperationResult(value, _transformer);
56
- observer.next(transformed);
57
- },
58
- error: observer.error,
59
- complete: observer.complete
60
- });
61
- return next$;
62
- });
63
- };
64
- };
65
- }
66
-
67
- exports.transformerLink = transformerLink;
@@ -1,63 +0,0 @@
1
- import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
2
- import { o as observable } from '../../../dist/observable-01534ea8.esm.js';
3
-
4
- /**
5
- * @internal
6
- */
7
- function transformOperationResult(result, transformer) {
8
- if ('error' in result.data) {
9
- return _objectSpread(_objectSpread({}, result), {}, {
10
- data: _objectSpread(_objectSpread({}, result.data), {}, {
11
- error: transformer.deserialize(result.data.error)
12
- })
13
- });
14
- }
15
-
16
- if (result.data.result.type !== 'data') {
17
- return result;
18
- }
19
-
20
- return _objectSpread(_objectSpread({}, result), {}, {
21
- data: _objectSpread(_objectSpread({}, result.data), {}, {
22
- result: _objectSpread(_objectSpread({}, result.data.result), {}, {
23
- data: transformer.deserialize(result.data.result.data)
24
- })
25
- })
26
- });
27
- }
28
-
29
- function transformerLink(transformer) {
30
- var _transformer = transformer ? 'input' in transformer ? {
31
- serialize: transformer.input.serialize,
32
- deserialize: transformer.output.deserialize
33
- } : transformer : {
34
- serialize: function serialize(data) {
35
- return data;
36
- },
37
- deserialize: function deserialize(data) {
38
- return data;
39
- }
40
- };
41
-
42
- return function () {
43
- return function (props) {
44
- var input = _transformer.serialize(props.op.input);
45
-
46
- return observable(function (observer) {
47
- var next$ = props.next(_objectSpread(_objectSpread({}, props.op), {}, {
48
- input: input
49
- })).subscribe({
50
- next: function next(value) {
51
- var transformed = transformOperationResult(value, _transformer);
52
- observer.next(transformed);
53
- },
54
- error: observer.error,
55
- complete: observer.complete
56
- });
57
- return next$;
58
- });
59
- };
60
- };
61
- }
62
-
63
- export { transformerLink };
@@ -1 +0,0 @@
1
- export * from '../../dist/links/transformerLink';
@@ -1 +0,0 @@
1
- module.exports = require('../../dist/links/transformerLink');
@@ -1 +0,0 @@
1
- export * from "../../../dist/declarations/src/links/wsLink";