@trpc/client 11.1.3-alpha-tmp-issues-6785.34 → 11.1.3-alpha-tmp-tsdown.24
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.mts +32 -0
- package/dist/TRPCClientError.d.mts.map +1 -0
- package/dist/TRPCClientError.d.ts +28 -25
- package/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/TRPCClientError.js +48 -72
- package/dist/TRPCClientError.mjs +48 -71
- package/dist/TRPCClientError.mjs.map +1 -0
- package/dist/_virtual/rolldown_runtime.js +39 -0
- package/dist/_virtual/rolldown_runtime.mjs +27 -0
- package/dist/createTRPCClient.d.mts +69 -0
- package/dist/createTRPCClient.d.mts.map +1 -0
- package/dist/createTRPCClient.d.ts +34 -34
- package/dist/createTRPCClient.d.ts.map +1 -1
- package/dist/createTRPCClient.js +34 -34
- package/dist/createTRPCClient.mjs +33 -31
- package/dist/createTRPCClient.mjs.map +1 -0
- package/dist/createTRPCUntypedClient.d.mts +8 -0
- package/dist/createTRPCUntypedClient.d.mts.map +1 -0
- package/dist/createTRPCUntypedClient.d.ts +7 -6
- package/dist/createTRPCUntypedClient.d.ts.map +1 -1
- package/dist/createTRPCUntypedClient.js +5 -6
- package/dist/createTRPCUntypedClient.mjs +6 -3
- package/dist/createTRPCUntypedClient.mjs.map +1 -0
- package/dist/getFetch.d.mts +9 -0
- package/dist/getFetch.d.mts.map +1 -0
- package/dist/getFetch.d.ts +8 -2
- package/dist/getFetch.d.ts.map +1 -1
- package/dist/getFetch.js +8 -13
- package/dist/getFetch.mjs +8 -11
- package/dist/getFetch.mjs.map +1 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.d.ts +21 -16
- package/dist/index.js +42 -42
- package/dist/index.mjs +19 -15
- package/dist/internals/TRPCUntypedClient.d.mts +45 -0
- package/dist/internals/TRPCUntypedClient.d.mts.map +1 -0
- package/dist/internals/TRPCUntypedClient.d.ts +39 -33
- package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
- package/dist/internals/TRPCUntypedClient.js +94 -113
- package/dist/internals/TRPCUntypedClient.mjs +93 -110
- package/dist/internals/TRPCUntypedClient.mjs.map +1 -0
- package/dist/internals/dataLoader.js +101 -112
- package/dist/internals/dataLoader.mjs +101 -110
- package/dist/internals/dataLoader.mjs.map +1 -0
- package/dist/internals/inputWithTrackedEventId.js +9 -12
- package/dist/internals/inputWithTrackedEventId.mjs +9 -10
- package/dist/internals/inputWithTrackedEventId.mjs.map +1 -0
- package/dist/internals/signals.js +39 -40
- package/dist/internals/signals.mjs +39 -39
- package/dist/internals/signals.mjs.map +1 -0
- package/dist/internals/transformer.d.mts +46 -0
- package/dist/internals/transformer.d.mts.map +1 -0
- package/dist/internals/transformer.d.ts +26 -22
- package/dist/internals/transformer.d.ts.map +1 -1
- package/dist/internals/transformer.js +25 -26
- package/dist/internals/transformer.mjs +25 -24
- package/dist/internals/transformer.mjs.map +1 -0
- package/dist/internals/types.d.mts +84 -0
- package/dist/internals/types.d.mts.map +1 -0
- package/dist/internals/types.d.ts +44 -42
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/links/HTTPBatchLinkOptions.d.mts +25 -0
- package/dist/links/HTTPBatchLinkOptions.d.mts.map +1 -0
- package/dist/links/HTTPBatchLinkOptions.d.ts +23 -18
- package/dist/links/HTTPBatchLinkOptions.d.ts.map +1 -1
- package/dist/links/httpBatchLink.d.mts +15 -0
- package/dist/links/httpBatchLink.d.mts.map +1 -0
- package/dist/links/httpBatchLink.d.ts +11 -4
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.js +90 -106
- package/dist/links/httpBatchLink.mjs +89 -103
- package/dist/links/httpBatchLink.mjs.map +1 -0
- package/dist/links/httpBatchStreamLink.d.mts +19 -0
- package/dist/links/httpBatchStreamLink.d.mts.map +1 -0
- package/dist/links/httpBatchStreamLink.d.ts +12 -5
- package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
- package/dist/links/httpBatchStreamLink.js +120 -144
- package/dist/links/httpBatchStreamLink.mjs +119 -141
- package/dist/links/httpBatchStreamLink.mjs.map +1 -0
- package/dist/links/httpLink.d.mts +23 -0
- package/dist/links/httpLink.d.mts.map +1 -0
- package/dist/links/httpLink.d.ts +18 -12
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/httpLink.js +74 -90
- package/dist/links/httpLink.mjs +73 -87
- package/dist/links/httpLink.mjs.map +1 -0
- package/dist/links/httpSubscriptionLink.d.mts +29 -0
- package/dist/links/httpSubscriptionLink.d.mts.map +1 -0
- package/dist/links/httpSubscriptionLink.d.ts +20 -17
- package/dist/links/httpSubscriptionLink.d.ts.map +1 -1
- package/dist/links/httpSubscriptionLink.js +134 -179
- package/dist/links/httpSubscriptionLink.mjs +133 -176
- package/dist/links/httpSubscriptionLink.mjs.map +1 -0
- package/dist/links/internals/contentTypes.d.mts +9 -0
- package/dist/links/internals/contentTypes.d.mts.map +1 -0
- package/dist/links/internals/contentTypes.d.ts +8 -3
- package/dist/links/internals/contentTypes.d.ts.map +1 -1
- package/dist/links/internals/contentTypes.js +6 -6
- package/dist/links/internals/contentTypes.mjs +6 -4
- package/dist/links/internals/contentTypes.mjs.map +1 -0
- package/dist/links/internals/createChain.js +23 -23
- package/dist/links/internals/createChain.mjs +22 -20
- package/dist/links/internals/createChain.mjs.map +1 -0
- package/dist/links/internals/httpUtils.d.mts +25 -0
- package/dist/links/internals/httpUtils.d.mts.map +1 -0
- package/dist/links/internals/httpUtils.d.ts +20 -63
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/links/internals/httpUtils.js +93 -116
- package/dist/links/internals/httpUtils.mjs +94 -113
- package/dist/links/internals/httpUtils.mjs.map +1 -0
- package/dist/links/internals/subscriptions.d.mts +19 -0
- package/dist/links/internals/subscriptions.d.mts.map +1 -0
- package/dist/links/internals/subscriptions.d.ts +10 -8
- package/dist/links/internals/subscriptions.d.ts.map +1 -1
- package/dist/links/internals/urlWithConnectionParams.d.mts +24 -0
- package/dist/links/internals/urlWithConnectionParams.d.mts.map +1 -0
- package/dist/links/internals/urlWithConnectionParams.d.ts +19 -18
- package/dist/links/internals/urlWithConnectionParams.d.ts.map +1 -1
- package/dist/links/internals/urlWithConnectionParams.js +8 -6
- package/dist/links/internals/urlWithConnectionParams.mjs +8 -4
- package/dist/links/internals/urlWithConnectionParams.mjs.map +1 -0
- package/dist/links/localLink.d.mts +21 -0
- package/dist/links/localLink.d.mts.map +1 -0
- package/dist/links/localLink.d.ts +21 -0
- package/dist/links/localLink.d.ts.map +1 -0
- package/dist/links/localLink.js +192 -0
- package/dist/links/localLink.mjs +193 -0
- package/dist/links/localLink.mjs.map +1 -0
- package/dist/links/loggerLink.d.mts +55 -0
- package/dist/links/loggerLink.d.mts.map +1 -0
- package/dist/links/loggerLink.d.ts +39 -36
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/dist/links/loggerLink.js +113 -166
- package/dist/links/loggerLink.mjs +112 -163
- package/dist/links/loggerLink.mjs.map +1 -0
- package/dist/links/retryLink.d.mts +36 -0
- package/dist/links/retryLink.d.mts.map +1 -0
- package/dist/links/retryLink.d.ts +28 -25
- package/dist/links/retryLink.d.ts.map +1 -1
- package/dist/links/retryLink.js +60 -68
- package/dist/links/retryLink.mjs +59 -65
- package/dist/links/retryLink.mjs.map +1 -0
- package/dist/links/splitLink.d.mts +20 -0
- package/dist/links/splitLink.d.mts.map +1 -0
- package/dist/links/splitLink.d.ts +18 -12
- package/dist/links/splitLink.d.ts.map +1 -1
- package/dist/links/splitLink.js +20 -21
- package/dist/links/splitLink.mjs +19 -18
- package/dist/links/splitLink.mjs.map +1 -0
- package/dist/links/types.d.mts +68 -0
- package/dist/links/types.d.mts.map +1 -0
- package/dist/links/types.d.ts +34 -29
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links/wsLink/createWsClient.d.mts +9 -0
- package/dist/links/wsLink/createWsClient.d.mts.map +1 -0
- package/dist/links/wsLink/createWsClient.d.ts +8 -5
- package/dist/links/wsLink/createWsClient.d.ts.map +1 -1
- package/dist/links/wsLink/createWsClient.js +5 -5
- package/dist/links/wsLink/createWsClient.mjs +5 -2
- package/dist/links/wsLink/createWsClient.mjs.map +1 -0
- package/dist/links/wsLink/wsClient/options.d.mts +69 -0
- package/dist/links/wsLink/wsClient/options.d.mts.map +1 -0
- package/dist/links/wsLink/wsClient/options.d.ts +53 -63
- package/dist/links/wsLink/wsClient/options.d.ts.map +1 -1
- package/dist/links/wsLink/wsClient/options.js +14 -12
- package/dist/links/wsLink/wsClient/options.mjs +14 -10
- package/dist/links/wsLink/wsClient/options.mjs.map +1 -0
- package/dist/links/wsLink/wsClient/requestManager.js +133 -140
- package/dist/links/wsLink/wsClient/requestManager.mjs +133 -137
- package/dist/links/wsLink/wsClient/requestManager.mjs.map +1 -0
- package/dist/links/wsLink/wsClient/utils.js +64 -81
- package/dist/links/wsLink/wsClient/utils.mjs +64 -78
- package/dist/links/wsLink/wsClient/utils.mjs.map +1 -0
- package/dist/links/wsLink/wsClient/wsClient.d.mts +101 -0
- package/dist/links/wsLink/wsClient/wsClient.d.mts.map +1 -0
- package/dist/links/wsLink/wsClient/wsClient.d.ts +95 -78
- package/dist/links/wsLink/wsClient/wsClient.d.ts.map +1 -1
- package/dist/links/wsLink/wsClient/wsClient.js +273 -322
- package/dist/links/wsLink/wsClient/wsClient.mjs +272 -319
- package/dist/links/wsLink/wsClient/wsClient.mjs.map +1 -0
- package/dist/links/wsLink/wsClient/wsConnection.js +155 -178
- package/dist/links/wsLink/wsClient/wsConnection.mjs +154 -175
- package/dist/links/wsLink/wsClient/wsConnection.mjs.map +1 -0
- package/dist/links/wsLink/wsLink.d.mts +14 -0
- package/dist/links/wsLink/wsLink.d.mts.map +1 -0
- package/dist/links/wsLink/wsLink.d.ts +12 -9
- package/dist/links/wsLink/wsLink.d.ts.map +1 -1
- package/dist/links/wsLink/wsLink.js +30 -31
- package/dist/links/wsLink/wsLink.mjs +29 -28
- package/dist/links/wsLink/wsLink.mjs.map +1 -0
- package/dist/links.js +11 -0
- package/dist/links.mjs +11 -0
- package/dist/node_modules/.pnpm/@oxc-project_runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js +68 -0
- package/dist/node_modules/.pnpm/@oxc-project_runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.mjs +66 -0
- package/dist/node_modules/.pnpm/@oxc-project_runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.mjs.map +1 -0
- package/dist/unstable-internals.d.mts +3 -0
- package/dist/unstable-internals.d.ts +3 -3
- package/dist/unstable-internals.js +2 -6
- package/dist/unstable-internals.mjs +3 -1
- package/links/httpBatchLink/package.json +1 -0
- package/links/httpLink/package.json +1 -0
- package/links/loggerLink/package.json +1 -0
- package/links/splitLink/package.json +1 -0
- package/links/wsLink/wsLink/package.json +1 -0
- package/package.json +63 -30
- package/src/TRPCClientError.ts +4 -9
- package/src/internals/signals.ts +16 -0
- package/src/links/httpSubscriptionLink.ts +3 -18
- package/src/links/localLink.ts +277 -0
- package/src/links.ts +1 -0
- package/unstable-internals/package.json +1 -0
- package/dist/bundle-analysis.json +0 -433
- package/dist/index.d.ts.map +0 -1
- package/dist/internals/dataLoader.d.ts +0 -13
- package/dist/internals/dataLoader.d.ts.map +0 -1
- package/dist/internals/inputWithTrackedEventId.d.ts +0 -2
- package/dist/internals/inputWithTrackedEventId.d.ts.map +0 -1
- package/dist/internals/signals.d.ts +0 -15
- package/dist/internals/signals.d.ts.map +0 -1
- package/dist/links/internals/createChain.d.ts +0 -8
- package/dist/links/internals/createChain.d.ts.map +0 -1
- package/dist/links/internals/dedupeLink.d.ts +0 -7
- package/dist/links/internals/dedupeLink.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/requestManager.d.ts +0 -106
- package/dist/links/wsLink/wsClient/requestManager.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/utils.d.ts +0 -38
- package/dist/links/wsLink/wsClient/utils.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/wsConnection.d.ts +0 -79
- package/dist/links/wsLink/wsClient/wsConnection.d.ts.map +0 -1
- package/dist/links.d.ts +0 -11
- package/dist/links.d.ts.map +0 -1
- package/dist/unstable-internals.d.ts.map +0 -1
- package/links/httpBatchLink/index.d.ts +0 -1
- package/links/httpBatchLink/index.js +0 -1
- package/links/httpLink/index.d.ts +0 -1
- package/links/httpLink/index.js +0 -1
- package/links/loggerLink/index.d.ts +0 -1
- package/links/loggerLink/index.js +0 -1
- package/links/splitLink/index.d.ts +0 -1
- package/links/splitLink/index.js +0 -1
- package/links/wsLink/wsLink/index.d.ts +0 -1
- package/links/wsLink/wsLink/index.js +0 -1
- package/unstable-internals/index.d.ts +0 -1
- package/unstable-internals/index.js +0 -1
package/dist/links/loggerLink.js
CHANGED
|
@@ -1,178 +1,125 @@
|
|
|
1
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const __trpc_server_observable = require_rolldown_runtime.__toESM(require("@trpc/server/observable"));
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/// <reference lib="dom.iterable" />
|
|
6
|
-
// `dom.iterable` types are explicitly required for extracting `FormData` values,
|
|
7
|
-
// as all implementations of `Symbol.iterable` are separated from the main `dom` types.
|
|
8
|
-
// Using triple-slash directive makes sure that it will be available,
|
|
9
|
-
// even if end-user `tsconfig.json` omits it in the `lib` array.
|
|
4
|
+
//#region src/links/loggerLink.ts
|
|
10
5
|
function isFormData(value) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return value instanceof FormData;
|
|
6
|
+
if (typeof FormData === "undefined") return false;
|
|
7
|
+
return value instanceof FormData;
|
|
16
8
|
}
|
|
17
9
|
const palettes = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
query: [
|
|
36
|
-
'\x1b[30;46m',
|
|
37
|
-
'\x1b[97;46m'
|
|
38
|
-
],
|
|
39
|
-
// Magenta background, black and white text respectively
|
|
40
|
-
mutation: [
|
|
41
|
-
'\x1b[30;45m',
|
|
42
|
-
'\x1b[97;45m'
|
|
43
|
-
],
|
|
44
|
-
// Green background, black and white text respectively
|
|
45
|
-
subscription: [
|
|
46
|
-
'\x1b[30;42m',
|
|
47
|
-
'\x1b[97;42m'
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
bold: {
|
|
51
|
-
query: [
|
|
52
|
-
'\x1b[1;30;46m',
|
|
53
|
-
'\x1b[1;97;46m'
|
|
54
|
-
],
|
|
55
|
-
mutation: [
|
|
56
|
-
'\x1b[1;30;45m',
|
|
57
|
-
'\x1b[1;97;45m'
|
|
58
|
-
],
|
|
59
|
-
subscription: [
|
|
60
|
-
'\x1b[1;30;42m',
|
|
61
|
-
'\x1b[1;97;42m'
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
10
|
+
css: {
|
|
11
|
+
query: ["72e3ff", "3fb0d8"],
|
|
12
|
+
mutation: ["c5a3fc", "904dfc"],
|
|
13
|
+
subscription: ["ff49e1", "d83fbe"]
|
|
14
|
+
},
|
|
15
|
+
ansi: {
|
|
16
|
+
regular: {
|
|
17
|
+
query: ["\x1B[30;46m", "\x1B[97;46m"],
|
|
18
|
+
mutation: ["\x1B[30;45m", "\x1B[97;45m"],
|
|
19
|
+
subscription: ["\x1B[30;42m", "\x1B[97;42m"]
|
|
20
|
+
},
|
|
21
|
+
bold: {
|
|
22
|
+
query: ["\x1B[1;30;46m", "\x1B[1;97;46m"],
|
|
23
|
+
mutation: ["\x1B[1;30;45m", "\x1B[1;97;45m"],
|
|
24
|
+
subscription: ["\x1B[1;30;42m", "\x1B[1;97;42m"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
65
27
|
};
|
|
66
28
|
function constructPartsAndArgs(opts) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
background-color: #${direction === 'up' ? light : dark};
|
|
82
|
-
color: ${direction === 'up' ? 'black' : 'white'};
|
|
29
|
+
const { direction, type, withContext, path, id, input } = opts;
|
|
30
|
+
const parts = [];
|
|
31
|
+
const args = [];
|
|
32
|
+
if (opts.colorMode === "none") parts.push(direction === "up" ? ">>" : "<<", type, `#${id}`, path);
|
|
33
|
+
else if (opts.colorMode === "ansi") {
|
|
34
|
+
const [lightRegular, darkRegular] = palettes.ansi.regular[type];
|
|
35
|
+
const [lightBold, darkBold] = palettes.ansi.bold[type];
|
|
36
|
+
const reset = "\x1B[0m";
|
|
37
|
+
parts.push(direction === "up" ? lightRegular : darkRegular, direction === "up" ? ">>" : "<<", type, direction === "up" ? lightBold : darkBold, `#${id}`, path, reset);
|
|
38
|
+
} else {
|
|
39
|
+
const [light, dark] = palettes.css[type];
|
|
40
|
+
const css = `
|
|
41
|
+
background-color: #${direction === "up" ? light : dark};
|
|
42
|
+
color: ${direction === "up" ? "black" : "white"};
|
|
83
43
|
padding: 2px;
|
|
84
44
|
`;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
parts,
|
|
107
|
-
args
|
|
108
|
-
};
|
|
45
|
+
parts.push("%c", direction === "up" ? ">>" : "<<", type, `#${id}`, `%c${path}%c`, "%O");
|
|
46
|
+
args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`);
|
|
47
|
+
}
|
|
48
|
+
if (direction === "up") args.push(withContext ? {
|
|
49
|
+
input,
|
|
50
|
+
context: opts.context
|
|
51
|
+
} : { input });
|
|
52
|
+
else args.push({
|
|
53
|
+
input,
|
|
54
|
+
result: opts.result,
|
|
55
|
+
elapsedMs: opts.elapsedMs,
|
|
56
|
+
...withContext && { context: opts.context }
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
parts,
|
|
60
|
+
args
|
|
61
|
+
};
|
|
109
62
|
}
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
parts.join(' ')
|
|
123
|
-
].concat(args));
|
|
124
|
-
};
|
|
63
|
+
const defaultLogger = ({ c = console, colorMode = "css", withContext }) => (props) => {
|
|
64
|
+
const rawInput = props.input;
|
|
65
|
+
const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
|
|
66
|
+
const { parts, args } = constructPartsAndArgs({
|
|
67
|
+
...props,
|
|
68
|
+
colorMode,
|
|
69
|
+
input,
|
|
70
|
+
withContext
|
|
71
|
+
});
|
|
72
|
+
const fn = props.direction === "down" && props.result && (props.result instanceof Error || "error" in props.result.result && props.result.result.error) ? "error" : "log";
|
|
73
|
+
c[fn].apply(null, [parts.join(" ")].concat(args));
|
|
74
|
+
};
|
|
125
75
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
})).subscribe(observer);
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
};
|
|
76
|
+
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
|
77
|
+
*/
|
|
78
|
+
function loggerLink(opts = {}) {
|
|
79
|
+
const { enabled = () => true } = opts;
|
|
80
|
+
const colorMode = opts.colorMode ?? (typeof window === "undefined" ? "ansi" : "css");
|
|
81
|
+
const withContext = opts.withContext ?? colorMode === "css";
|
|
82
|
+
const { logger = defaultLogger({
|
|
83
|
+
c: opts.console,
|
|
84
|
+
colorMode,
|
|
85
|
+
withContext
|
|
86
|
+
}) } = opts;
|
|
87
|
+
return () => {
|
|
88
|
+
return ({ op, next }) => {
|
|
89
|
+
return (0, __trpc_server_observable.observable)((observer) => {
|
|
90
|
+
if (enabled({
|
|
91
|
+
...op,
|
|
92
|
+
direction: "up"
|
|
93
|
+
})) logger({
|
|
94
|
+
...op,
|
|
95
|
+
direction: "up"
|
|
96
|
+
});
|
|
97
|
+
const requestStartTime = Date.now();
|
|
98
|
+
function logResult(result) {
|
|
99
|
+
const elapsedMs = Date.now() - requestStartTime;
|
|
100
|
+
if (enabled({
|
|
101
|
+
...op,
|
|
102
|
+
direction: "down",
|
|
103
|
+
result
|
|
104
|
+
})) logger({
|
|
105
|
+
...op,
|
|
106
|
+
direction: "down",
|
|
107
|
+
elapsedMs,
|
|
108
|
+
result
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return next(op).pipe((0, __trpc_server_observable.tap)({
|
|
112
|
+
next(result) {
|
|
113
|
+
logResult(result);
|
|
114
|
+
},
|
|
115
|
+
error(result) {
|
|
116
|
+
logResult(result);
|
|
117
|
+
}
|
|
118
|
+
})).subscribe(observer);
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
};
|
|
176
122
|
}
|
|
177
123
|
|
|
178
|
-
|
|
124
|
+
//#endregion
|
|
125
|
+
exports.loggerLink = loggerLink;
|
|
@@ -1,176 +1,125 @@
|
|
|
1
|
-
import { observable, tap } from
|
|
1
|
+
import { observable, tap } from "@trpc/server/observable";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// `dom.iterable` types are explicitly required for extracting `FormData` values,
|
|
5
|
-
// as all implementations of `Symbol.iterable` are separated from the main `dom` types.
|
|
6
|
-
// Using triple-slash directive makes sure that it will be available,
|
|
7
|
-
// even if end-user `tsconfig.json` omits it in the `lib` array.
|
|
3
|
+
//#region src/links/loggerLink.ts
|
|
8
4
|
function isFormData(value) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
return value instanceof FormData;
|
|
5
|
+
if (typeof FormData === "undefined") return false;
|
|
6
|
+
return value instanceof FormData;
|
|
14
7
|
}
|
|
15
8
|
const palettes = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
query: [
|
|
34
|
-
'\x1b[30;46m',
|
|
35
|
-
'\x1b[97;46m'
|
|
36
|
-
],
|
|
37
|
-
// Magenta background, black and white text respectively
|
|
38
|
-
mutation: [
|
|
39
|
-
'\x1b[30;45m',
|
|
40
|
-
'\x1b[97;45m'
|
|
41
|
-
],
|
|
42
|
-
// Green background, black and white text respectively
|
|
43
|
-
subscription: [
|
|
44
|
-
'\x1b[30;42m',
|
|
45
|
-
'\x1b[97;42m'
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
bold: {
|
|
49
|
-
query: [
|
|
50
|
-
'\x1b[1;30;46m',
|
|
51
|
-
'\x1b[1;97;46m'
|
|
52
|
-
],
|
|
53
|
-
mutation: [
|
|
54
|
-
'\x1b[1;30;45m',
|
|
55
|
-
'\x1b[1;97;45m'
|
|
56
|
-
],
|
|
57
|
-
subscription: [
|
|
58
|
-
'\x1b[1;30;42m',
|
|
59
|
-
'\x1b[1;97;42m'
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
9
|
+
css: {
|
|
10
|
+
query: ["72e3ff", "3fb0d8"],
|
|
11
|
+
mutation: ["c5a3fc", "904dfc"],
|
|
12
|
+
subscription: ["ff49e1", "d83fbe"]
|
|
13
|
+
},
|
|
14
|
+
ansi: {
|
|
15
|
+
regular: {
|
|
16
|
+
query: ["\x1B[30;46m", "\x1B[97;46m"],
|
|
17
|
+
mutation: ["\x1B[30;45m", "\x1B[97;45m"],
|
|
18
|
+
subscription: ["\x1B[30;42m", "\x1B[97;42m"]
|
|
19
|
+
},
|
|
20
|
+
bold: {
|
|
21
|
+
query: ["\x1B[1;30;46m", "\x1B[1;97;46m"],
|
|
22
|
+
mutation: ["\x1B[1;30;45m", "\x1B[1;97;45m"],
|
|
23
|
+
subscription: ["\x1B[1;30;42m", "\x1B[1;97;42m"]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
63
26
|
};
|
|
64
27
|
function constructPartsAndArgs(opts) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
background-color: #${direction === 'up' ? light : dark};
|
|
80
|
-
color: ${direction === 'up' ? 'black' : 'white'};
|
|
28
|
+
const { direction, type, withContext, path, id, input } = opts;
|
|
29
|
+
const parts = [];
|
|
30
|
+
const args = [];
|
|
31
|
+
if (opts.colorMode === "none") parts.push(direction === "up" ? ">>" : "<<", type, `#${id}`, path);
|
|
32
|
+
else if (opts.colorMode === "ansi") {
|
|
33
|
+
const [lightRegular, darkRegular] = palettes.ansi.regular[type];
|
|
34
|
+
const [lightBold, darkBold] = palettes.ansi.bold[type];
|
|
35
|
+
const reset = "\x1B[0m";
|
|
36
|
+
parts.push(direction === "up" ? lightRegular : darkRegular, direction === "up" ? ">>" : "<<", type, direction === "up" ? lightBold : darkBold, `#${id}`, path, reset);
|
|
37
|
+
} else {
|
|
38
|
+
const [light, dark] = palettes.css[type];
|
|
39
|
+
const css = `
|
|
40
|
+
background-color: #${direction === "up" ? light : dark};
|
|
41
|
+
color: ${direction === "up" ? "black" : "white"};
|
|
81
42
|
padding: 2px;
|
|
82
43
|
`;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
parts,
|
|
105
|
-
args
|
|
106
|
-
};
|
|
44
|
+
parts.push("%c", direction === "up" ? ">>" : "<<", type, `#${id}`, `%c${path}%c`, "%O");
|
|
45
|
+
args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`);
|
|
46
|
+
}
|
|
47
|
+
if (direction === "up") args.push(withContext ? {
|
|
48
|
+
input,
|
|
49
|
+
context: opts.context
|
|
50
|
+
} : { input });
|
|
51
|
+
else args.push({
|
|
52
|
+
input,
|
|
53
|
+
result: opts.result,
|
|
54
|
+
elapsedMs: opts.elapsedMs,
|
|
55
|
+
...withContext && { context: opts.context }
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
parts,
|
|
59
|
+
args
|
|
60
|
+
};
|
|
107
61
|
}
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
parts.join(' ')
|
|
121
|
-
].concat(args));
|
|
122
|
-
};
|
|
62
|
+
const defaultLogger = ({ c = console, colorMode = "css", withContext }) => (props) => {
|
|
63
|
+
const rawInput = props.input;
|
|
64
|
+
const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
|
|
65
|
+
const { parts, args } = constructPartsAndArgs({
|
|
66
|
+
...props,
|
|
67
|
+
colorMode,
|
|
68
|
+
input,
|
|
69
|
+
withContext
|
|
70
|
+
});
|
|
71
|
+
const fn = props.direction === "down" && props.result && (props.result instanceof Error || "error" in props.result.result && props.result.result.error) ? "error" : "log";
|
|
72
|
+
c[fn].apply(null, [parts.join(" ")].concat(args));
|
|
73
|
+
};
|
|
123
74
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
})).subscribe(observer);
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
};
|
|
75
|
+
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
|
76
|
+
*/
|
|
77
|
+
function loggerLink(opts = {}) {
|
|
78
|
+
const { enabled = () => true } = opts;
|
|
79
|
+
const colorMode = opts.colorMode ?? (typeof window === "undefined" ? "ansi" : "css");
|
|
80
|
+
const withContext = opts.withContext ?? colorMode === "css";
|
|
81
|
+
const { logger = defaultLogger({
|
|
82
|
+
c: opts.console,
|
|
83
|
+
colorMode,
|
|
84
|
+
withContext
|
|
85
|
+
}) } = opts;
|
|
86
|
+
return () => {
|
|
87
|
+
return ({ op, next }) => {
|
|
88
|
+
return observable((observer) => {
|
|
89
|
+
if (enabled({
|
|
90
|
+
...op,
|
|
91
|
+
direction: "up"
|
|
92
|
+
})) logger({
|
|
93
|
+
...op,
|
|
94
|
+
direction: "up"
|
|
95
|
+
});
|
|
96
|
+
const requestStartTime = Date.now();
|
|
97
|
+
function logResult(result) {
|
|
98
|
+
const elapsedMs = Date.now() - requestStartTime;
|
|
99
|
+
if (enabled({
|
|
100
|
+
...op,
|
|
101
|
+
direction: "down",
|
|
102
|
+
result
|
|
103
|
+
})) logger({
|
|
104
|
+
...op,
|
|
105
|
+
direction: "down",
|
|
106
|
+
elapsedMs,
|
|
107
|
+
result
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return next(op).pipe(tap({
|
|
111
|
+
next(result) {
|
|
112
|
+
logResult(result);
|
|
113
|
+
},
|
|
114
|
+
error(result) {
|
|
115
|
+
logResult(result);
|
|
116
|
+
}
|
|
117
|
+
})).subscribe(observer);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
};
|
|
174
121
|
}
|
|
175
122
|
|
|
123
|
+
//#endregion
|
|
176
124
|
export { loggerLink };
|
|
125
|
+
//# sourceMappingURL=loggerLink.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loggerLink.mjs","names":["value: unknown","opts: LoggerLinkFnOptions<any> & {\n colorMode: ColorMode;\n withContext?: boolean;\n }","parts: string[]","args: any[]","fn: 'error' | 'log'","opts: LoggerLinkOptions<TRouter>","result:\n | OperationResultEnvelope<unknown, TRPCClientError<TRouter>>\n | TRPCClientError<TRouter>"],"sources":["../../src/links/loggerLink.ts"],"sourcesContent":["/// <reference lib=\"dom.iterable\" />\n\n// `dom.iterable` types are explicitly required for extracting `FormData` values,\n// as all implementations of `Symbol.iterable` are separated from the main `dom` types.\n// Using triple-slash directive makes sure that it will be available,\n// even if end-user `tsconfig.json` omits it in the `lib` array.\n\nimport { observable, tap } from '@trpc/server/observable';\nimport type {\n AnyRouter,\n InferrableClientTypes,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type { TRPCClientError } from '../TRPCClientError';\nimport type { Operation, OperationResultEnvelope, TRPCLink } from './types';\n\ntype ConsoleEsque = {\n log: (...args: any[]) => void;\n error: (...args: any[]) => void;\n};\n\ntype EnableFnOptions<TRouter extends InferrableClientTypes> =\n | {\n direction: 'down';\n result:\n | OperationResultEnvelope<unknown, TRPCClientError<TRouter>>\n | TRPCClientError<TRouter>;\n }\n | (Operation & {\n direction: 'up';\n });\ntype EnabledFn<TRouter extends AnyRouter> = (\n opts: EnableFnOptions<TRouter>,\n) => boolean;\n\ntype LoggerLinkFnOptions<TRouter extends AnyRouter> = Operation &\n (\n | {\n /**\n * Request result\n */\n direction: 'down';\n result:\n | OperationResultEnvelope<unknown, TRPCClientError<TRouter>>\n | TRPCClientError<TRouter>;\n elapsedMs: number;\n }\n | {\n /**\n * Request was just initialized\n */\n direction: 'up';\n }\n );\n\ntype LoggerLinkFn<TRouter extends AnyRouter> = (\n opts: LoggerLinkFnOptions<TRouter>,\n) => void;\n\ntype ColorMode = 'ansi' | 'css' | 'none';\n\nexport interface LoggerLinkOptions<TRouter extends AnyRouter> {\n logger?: LoggerLinkFn<TRouter>;\n enabled?: EnabledFn<TRouter>;\n /**\n * Used in the built-in defaultLogger\n */\n console?: ConsoleEsque;\n /**\n * Color mode\n * @default typeof window === 'undefined' ? 'ansi' : 'css'\n */\n colorMode?: ColorMode;\n\n /**\n * Include context in the log - defaults to false unless `colorMode` is 'css'\n */\n withContext?: boolean;\n}\n\nfunction isFormData(value: unknown): value is FormData {\n if (typeof FormData === 'undefined') {\n // FormData is not supported\n return false;\n }\n return value instanceof FormData;\n}\n\nconst palettes = {\n css: {\n query: ['72e3ff', '3fb0d8'],\n mutation: ['c5a3fc', '904dfc'],\n subscription: ['ff49e1', 'd83fbe'],\n },\n ansi: {\n regular: {\n // Cyan background, black and white text respectively\n query: ['\\x1b[30;46m', '\\x1b[97;46m'],\n // Magenta background, black and white text respectively\n mutation: ['\\x1b[30;45m', '\\x1b[97;45m'],\n // Green background, black and white text respectively\n subscription: ['\\x1b[30;42m', '\\x1b[97;42m'],\n },\n bold: {\n query: ['\\x1b[1;30;46m', '\\x1b[1;97;46m'],\n mutation: ['\\x1b[1;30;45m', '\\x1b[1;97;45m'],\n subscription: ['\\x1b[1;30;42m', '\\x1b[1;97;42m'],\n },\n },\n} as const;\n\nfunction constructPartsAndArgs(\n opts: LoggerLinkFnOptions<any> & {\n colorMode: ColorMode;\n withContext?: boolean;\n },\n) {\n const { direction, type, withContext, path, id, input } = opts;\n\n const parts: string[] = [];\n const args: any[] = [];\n\n if (opts.colorMode === 'none') {\n parts.push(direction === 'up' ? '>>' : '<<', type, `#${id}`, path);\n } else if (opts.colorMode === 'ansi') {\n const [lightRegular, darkRegular] = palettes.ansi.regular[type];\n const [lightBold, darkBold] = palettes.ansi.bold[type];\n const reset = '\\x1b[0m';\n\n parts.push(\n direction === 'up' ? lightRegular : darkRegular,\n direction === 'up' ? '>>' : '<<',\n type,\n direction === 'up' ? lightBold : darkBold,\n `#${id}`,\n path,\n reset,\n );\n } else {\n // css color mode\n const [light, dark] = palettes.css[type];\n const css = `\n background-color: #${direction === 'up' ? light : dark};\n color: ${direction === 'up' ? 'black' : 'white'};\n padding: 2px;\n `;\n\n parts.push(\n '%c',\n direction === 'up' ? '>>' : '<<',\n type,\n `#${id}`,\n `%c${path}%c`,\n '%O',\n );\n args.push(\n css,\n `${css}; font-weight: bold;`,\n `${css}; font-weight: normal;`,\n );\n }\n\n if (direction === 'up') {\n args.push(withContext ? { input, context: opts.context } : { input });\n } else {\n args.push({\n input,\n result: opts.result,\n elapsedMs: opts.elapsedMs,\n ...(withContext && { context: opts.context }),\n });\n }\n\n return { parts, args };\n}\n\n// maybe this should be moved to it's own package\nconst defaultLogger =\n <TRouter extends AnyRouter>({\n c = console,\n colorMode = 'css',\n withContext,\n }: {\n c?: ConsoleEsque;\n colorMode?: ColorMode;\n withContext?: boolean;\n }): LoggerLinkFn<TRouter> =>\n (props) => {\n const rawInput = props.input;\n const input = isFormData(rawInput)\n ? Object.fromEntries(rawInput)\n : rawInput;\n\n const { parts, args } = constructPartsAndArgs({\n ...props,\n colorMode,\n input,\n withContext,\n });\n\n const fn: 'error' | 'log' =\n props.direction === 'down' &&\n props.result &&\n (props.result instanceof Error ||\n ('error' in props.result.result && props.result.result.error))\n ? 'error'\n : 'log';\n\n c[fn].apply(null, [parts.join(' ')].concat(args));\n };\n\n/**\n * @see https://trpc.io/docs/v11/client/links/loggerLink\n */\nexport function loggerLink<TRouter extends AnyRouter = AnyRouter>(\n opts: LoggerLinkOptions<TRouter> = {},\n): TRPCLink<TRouter> {\n const { enabled = () => true } = opts;\n\n const colorMode =\n opts.colorMode ?? (typeof window === 'undefined' ? 'ansi' : 'css');\n const withContext = opts.withContext ?? colorMode === 'css';\n const {\n logger = defaultLogger({ c: opts.console, colorMode, withContext }),\n } = opts;\n\n return () => {\n return ({ op, next }) => {\n return observable((observer) => {\n // ->\n if (enabled({ ...op, direction: 'up' })) {\n logger({\n ...op,\n direction: 'up',\n });\n }\n const requestStartTime = Date.now();\n function logResult(\n result:\n | OperationResultEnvelope<unknown, TRPCClientError<TRouter>>\n | TRPCClientError<TRouter>,\n ) {\n const elapsedMs = Date.now() - requestStartTime;\n\n if (enabled({ ...op, direction: 'down', result })) {\n logger({\n ...op,\n direction: 'down',\n elapsedMs,\n result,\n });\n }\n }\n return next(op)\n .pipe(\n tap({\n next(result) {\n logResult(result);\n },\n error(result) {\n logResult(result);\n },\n }),\n )\n .subscribe(observer);\n });\n };\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TRPCClientError } from "../TRPCClientError.mjs";
|
|
2
|
+
import { Operation, TRPCLink } from "./types.mjs";
|
|
3
|
+
import { InferrableClientTypes } from "@trpc/server/unstable-core-do-not-import";
|
|
4
|
+
|
|
5
|
+
//#region src/links/retryLink.d.ts
|
|
6
|
+
interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
|
|
7
|
+
/**
|
|
8
|
+
* The retry function
|
|
9
|
+
*/
|
|
10
|
+
retry: (opts: RetryFnOptions<TInferrable>) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The delay between retries in ms (defaults to 0)
|
|
13
|
+
*/
|
|
14
|
+
retryDelayMs?: (attempt: number) => number;
|
|
15
|
+
}
|
|
16
|
+
interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
|
|
17
|
+
/**
|
|
18
|
+
* The operation that failed
|
|
19
|
+
*/
|
|
20
|
+
op: Operation;
|
|
21
|
+
/**
|
|
22
|
+
* The error that occurred
|
|
23
|
+
*/
|
|
24
|
+
error: TRPCClientError<TInferrable>;
|
|
25
|
+
/**
|
|
26
|
+
* The number of attempts that have been made (including the first call)
|
|
27
|
+
*/
|
|
28
|
+
attempts: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @see https://trpc.io/docs/v11/client/links/retryLink
|
|
32
|
+
*/
|
|
33
|
+
declare function retryLink<TInferrable extends InferrableClientTypes>(opts: RetryLinkOptions<TInferrable>): TRPCLink<TInferrable>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { retryLink };
|
|
36
|
+
//# sourceMappingURL=retryLink.d.mts.map
|