@trpc/client 10.0.0-alpha.17 → 10.0.0-alpha.18
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/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/package.json +9 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var TRPCClientError = require('../../../dist/TRPCClientError-bfee2bf5.cjs.dev.js');
|
|
6
|
+
var transformRPCResponse = require('../../../dist/transformRPCResponse-57e80136.cjs.dev.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,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
// this file might look strange and you might be wondering what it's for
|
|
3
|
-
// it's lets you import your source files by importing this entrypoint
|
|
4
|
-
// as you would import it if it was built with preconstruct build
|
|
5
|
-
// this file is slightly different to some others though
|
|
6
|
-
// it has a require hook which compiles your code with Babel
|
|
7
|
-
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
-
// but you can still require this module and it'll be compiled
|
|
1
|
+
'use strict';
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
unregister();
|
|
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
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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-739c13d0.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;
|
|
@@ -0,0 +1,63 @@
|
|
|
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-f7f8b0e1.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,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
-
|
|
4
|
-
// curious why you need to?
|
|
5
|
-
// this file exists so that you can import from the entrypoint normally
|
|
6
|
-
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
-
// which means we need to re-export all of the modules from your source file
|
|
8
|
-
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
-
// to check for a default export and re-export it if it exists
|
|
10
|
-
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
-
export * from "../../../src/links/loggerLink";
|
|
1
|
+
export * from "../../../dist/declarations/src/links/loggerLink";
|
|
@@ -0,0 +1,89 @@
|
|
|
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,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
// this file might look strange and you might be wondering what it's for
|
|
3
|
-
// it's lets you import your source files by importing this entrypoint
|
|
4
|
-
// as you would import it if it was built with preconstruct build
|
|
5
|
-
// this file is slightly different to some others though
|
|
6
|
-
// it has a require hook which compiles your code with Babel
|
|
7
|
-
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
-
// but you can still require this module and it'll be compiled
|
|
1
|
+
'use strict';
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
unregister();
|
|
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
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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;
|
|
@@ -0,0 +1,85 @@
|
|
|
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,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
-
|
|
4
|
-
// curious why you need to?
|
|
5
|
-
// this file exists so that you can import from the entrypoint normally
|
|
6
|
-
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
-
// which means we need to re-export all of the modules from your source file
|
|
8
|
-
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
-
// to check for a default export and re-export it if it exists
|
|
10
|
-
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
-
export * from "../../../src/links/splitLink";
|
|
1
|
+
export * from "../../../dist/declarations/src/links/splitLink";
|
|
@@ -0,0 +1,19 @@
|
|
|
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,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
// this file might look strange and you might be wondering what it's for
|
|
3
|
-
// it's lets you import your source files by importing this entrypoint
|
|
4
|
-
// as you would import it if it was built with preconstruct build
|
|
5
|
-
// this file is slightly different to some others though
|
|
6
|
-
// it has a require hook which compiles your code with Babel
|
|
7
|
-
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
-
// but you can still require this module and it'll be compiled
|
|
1
|
+
'use strict';
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
unregister();
|
|
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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
|
|
3
|
-
|
|
4
|
-
// curious why you need to?
|
|
5
|
-
// this file exists so that you can import from the entrypoint normally
|
|
6
|
-
// except that it points to your source file and you don't need to run build constantly
|
|
7
|
-
// which means we need to re-export all of the modules from your source file
|
|
8
|
-
// and since export * doesn't include default exports, we need to read your source file
|
|
9
|
-
// to check for a default export and re-export it if it exists
|
|
10
|
-
// it's not ideal, but it works pretty well ¯\_(ツ)_/¯
|
|
11
|
-
export * from "../../../src/links/wsLink";
|
|
1
|
+
export * from "../../../dist/declarations/src/links/wsLink";
|