@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.
Files changed (244) hide show
  1. package/dist/TRPCClientError.d.mts +32 -0
  2. package/dist/TRPCClientError.d.mts.map +1 -0
  3. package/dist/TRPCClientError.d.ts +28 -25
  4. package/dist/TRPCClientError.d.ts.map +1 -1
  5. package/dist/TRPCClientError.js +48 -72
  6. package/dist/TRPCClientError.mjs +48 -71
  7. package/dist/TRPCClientError.mjs.map +1 -0
  8. package/dist/_virtual/rolldown_runtime.js +39 -0
  9. package/dist/_virtual/rolldown_runtime.mjs +27 -0
  10. package/dist/createTRPCClient.d.mts +69 -0
  11. package/dist/createTRPCClient.d.mts.map +1 -0
  12. package/dist/createTRPCClient.d.ts +34 -34
  13. package/dist/createTRPCClient.d.ts.map +1 -1
  14. package/dist/createTRPCClient.js +34 -34
  15. package/dist/createTRPCClient.mjs +33 -31
  16. package/dist/createTRPCClient.mjs.map +1 -0
  17. package/dist/createTRPCUntypedClient.d.mts +8 -0
  18. package/dist/createTRPCUntypedClient.d.mts.map +1 -0
  19. package/dist/createTRPCUntypedClient.d.ts +7 -6
  20. package/dist/createTRPCUntypedClient.d.ts.map +1 -1
  21. package/dist/createTRPCUntypedClient.js +5 -6
  22. package/dist/createTRPCUntypedClient.mjs +6 -3
  23. package/dist/createTRPCUntypedClient.mjs.map +1 -0
  24. package/dist/getFetch.d.mts +9 -0
  25. package/dist/getFetch.d.mts.map +1 -0
  26. package/dist/getFetch.d.ts +8 -2
  27. package/dist/getFetch.d.ts.map +1 -1
  28. package/dist/getFetch.js +8 -13
  29. package/dist/getFetch.mjs +8 -11
  30. package/dist/getFetch.mjs.map +1 -0
  31. package/dist/index.d.mts +21 -0
  32. package/dist/index.d.ts +21 -16
  33. package/dist/index.js +42 -42
  34. package/dist/index.mjs +19 -15
  35. package/dist/internals/TRPCUntypedClient.d.mts +45 -0
  36. package/dist/internals/TRPCUntypedClient.d.mts.map +1 -0
  37. package/dist/internals/TRPCUntypedClient.d.ts +39 -33
  38. package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
  39. package/dist/internals/TRPCUntypedClient.js +94 -113
  40. package/dist/internals/TRPCUntypedClient.mjs +93 -110
  41. package/dist/internals/TRPCUntypedClient.mjs.map +1 -0
  42. package/dist/internals/dataLoader.js +101 -112
  43. package/dist/internals/dataLoader.mjs +101 -110
  44. package/dist/internals/dataLoader.mjs.map +1 -0
  45. package/dist/internals/inputWithTrackedEventId.js +9 -12
  46. package/dist/internals/inputWithTrackedEventId.mjs +9 -10
  47. package/dist/internals/inputWithTrackedEventId.mjs.map +1 -0
  48. package/dist/internals/signals.js +39 -40
  49. package/dist/internals/signals.mjs +39 -39
  50. package/dist/internals/signals.mjs.map +1 -0
  51. package/dist/internals/transformer.d.mts +46 -0
  52. package/dist/internals/transformer.d.mts.map +1 -0
  53. package/dist/internals/transformer.d.ts +26 -22
  54. package/dist/internals/transformer.d.ts.map +1 -1
  55. package/dist/internals/transformer.js +25 -26
  56. package/dist/internals/transformer.mjs +25 -24
  57. package/dist/internals/transformer.mjs.map +1 -0
  58. package/dist/internals/types.d.mts +84 -0
  59. package/dist/internals/types.d.mts.map +1 -0
  60. package/dist/internals/types.d.ts +44 -42
  61. package/dist/internals/types.d.ts.map +1 -1
  62. package/dist/links/HTTPBatchLinkOptions.d.mts +25 -0
  63. package/dist/links/HTTPBatchLinkOptions.d.mts.map +1 -0
  64. package/dist/links/HTTPBatchLinkOptions.d.ts +23 -18
  65. package/dist/links/HTTPBatchLinkOptions.d.ts.map +1 -1
  66. package/dist/links/httpBatchLink.d.mts +15 -0
  67. package/dist/links/httpBatchLink.d.mts.map +1 -0
  68. package/dist/links/httpBatchLink.d.ts +11 -4
  69. package/dist/links/httpBatchLink.d.ts.map +1 -1
  70. package/dist/links/httpBatchLink.js +90 -106
  71. package/dist/links/httpBatchLink.mjs +89 -103
  72. package/dist/links/httpBatchLink.mjs.map +1 -0
  73. package/dist/links/httpBatchStreamLink.d.mts +19 -0
  74. package/dist/links/httpBatchStreamLink.d.mts.map +1 -0
  75. package/dist/links/httpBatchStreamLink.d.ts +12 -5
  76. package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
  77. package/dist/links/httpBatchStreamLink.js +120 -144
  78. package/dist/links/httpBatchStreamLink.mjs +119 -141
  79. package/dist/links/httpBatchStreamLink.mjs.map +1 -0
  80. package/dist/links/httpLink.d.mts +23 -0
  81. package/dist/links/httpLink.d.mts.map +1 -0
  82. package/dist/links/httpLink.d.ts +18 -12
  83. package/dist/links/httpLink.d.ts.map +1 -1
  84. package/dist/links/httpLink.js +74 -90
  85. package/dist/links/httpLink.mjs +73 -87
  86. package/dist/links/httpLink.mjs.map +1 -0
  87. package/dist/links/httpSubscriptionLink.d.mts +29 -0
  88. package/dist/links/httpSubscriptionLink.d.mts.map +1 -0
  89. package/dist/links/httpSubscriptionLink.d.ts +20 -17
  90. package/dist/links/httpSubscriptionLink.d.ts.map +1 -1
  91. package/dist/links/httpSubscriptionLink.js +134 -179
  92. package/dist/links/httpSubscriptionLink.mjs +133 -176
  93. package/dist/links/httpSubscriptionLink.mjs.map +1 -0
  94. package/dist/links/internals/contentTypes.d.mts +9 -0
  95. package/dist/links/internals/contentTypes.d.mts.map +1 -0
  96. package/dist/links/internals/contentTypes.d.ts +8 -3
  97. package/dist/links/internals/contentTypes.d.ts.map +1 -1
  98. package/dist/links/internals/contentTypes.js +6 -6
  99. package/dist/links/internals/contentTypes.mjs +6 -4
  100. package/dist/links/internals/contentTypes.mjs.map +1 -0
  101. package/dist/links/internals/createChain.js +23 -23
  102. package/dist/links/internals/createChain.mjs +22 -20
  103. package/dist/links/internals/createChain.mjs.map +1 -0
  104. package/dist/links/internals/httpUtils.d.mts +25 -0
  105. package/dist/links/internals/httpUtils.d.mts.map +1 -0
  106. package/dist/links/internals/httpUtils.d.ts +20 -63
  107. package/dist/links/internals/httpUtils.d.ts.map +1 -1
  108. package/dist/links/internals/httpUtils.js +93 -116
  109. package/dist/links/internals/httpUtils.mjs +94 -113
  110. package/dist/links/internals/httpUtils.mjs.map +1 -0
  111. package/dist/links/internals/subscriptions.d.mts +19 -0
  112. package/dist/links/internals/subscriptions.d.mts.map +1 -0
  113. package/dist/links/internals/subscriptions.d.ts +10 -8
  114. package/dist/links/internals/subscriptions.d.ts.map +1 -1
  115. package/dist/links/internals/urlWithConnectionParams.d.mts +24 -0
  116. package/dist/links/internals/urlWithConnectionParams.d.mts.map +1 -0
  117. package/dist/links/internals/urlWithConnectionParams.d.ts +19 -18
  118. package/dist/links/internals/urlWithConnectionParams.d.ts.map +1 -1
  119. package/dist/links/internals/urlWithConnectionParams.js +8 -6
  120. package/dist/links/internals/urlWithConnectionParams.mjs +8 -4
  121. package/dist/links/internals/urlWithConnectionParams.mjs.map +1 -0
  122. package/dist/links/localLink.d.mts +21 -0
  123. package/dist/links/localLink.d.mts.map +1 -0
  124. package/dist/links/localLink.d.ts +21 -0
  125. package/dist/links/localLink.d.ts.map +1 -0
  126. package/dist/links/localLink.js +192 -0
  127. package/dist/links/localLink.mjs +193 -0
  128. package/dist/links/localLink.mjs.map +1 -0
  129. package/dist/links/loggerLink.d.mts +55 -0
  130. package/dist/links/loggerLink.d.mts.map +1 -0
  131. package/dist/links/loggerLink.d.ts +39 -36
  132. package/dist/links/loggerLink.d.ts.map +1 -1
  133. package/dist/links/loggerLink.js +113 -166
  134. package/dist/links/loggerLink.mjs +112 -163
  135. package/dist/links/loggerLink.mjs.map +1 -0
  136. package/dist/links/retryLink.d.mts +36 -0
  137. package/dist/links/retryLink.d.mts.map +1 -0
  138. package/dist/links/retryLink.d.ts +28 -25
  139. package/dist/links/retryLink.d.ts.map +1 -1
  140. package/dist/links/retryLink.js +60 -68
  141. package/dist/links/retryLink.mjs +59 -65
  142. package/dist/links/retryLink.mjs.map +1 -0
  143. package/dist/links/splitLink.d.mts +20 -0
  144. package/dist/links/splitLink.d.mts.map +1 -0
  145. package/dist/links/splitLink.d.ts +18 -12
  146. package/dist/links/splitLink.d.ts.map +1 -1
  147. package/dist/links/splitLink.js +20 -21
  148. package/dist/links/splitLink.mjs +19 -18
  149. package/dist/links/splitLink.mjs.map +1 -0
  150. package/dist/links/types.d.mts +68 -0
  151. package/dist/links/types.d.mts.map +1 -0
  152. package/dist/links/types.d.ts +34 -29
  153. package/dist/links/types.d.ts.map +1 -1
  154. package/dist/links/wsLink/createWsClient.d.mts +9 -0
  155. package/dist/links/wsLink/createWsClient.d.mts.map +1 -0
  156. package/dist/links/wsLink/createWsClient.d.ts +8 -5
  157. package/dist/links/wsLink/createWsClient.d.ts.map +1 -1
  158. package/dist/links/wsLink/createWsClient.js +5 -5
  159. package/dist/links/wsLink/createWsClient.mjs +5 -2
  160. package/dist/links/wsLink/createWsClient.mjs.map +1 -0
  161. package/dist/links/wsLink/wsClient/options.d.mts +69 -0
  162. package/dist/links/wsLink/wsClient/options.d.mts.map +1 -0
  163. package/dist/links/wsLink/wsClient/options.d.ts +53 -63
  164. package/dist/links/wsLink/wsClient/options.d.ts.map +1 -1
  165. package/dist/links/wsLink/wsClient/options.js +14 -12
  166. package/dist/links/wsLink/wsClient/options.mjs +14 -10
  167. package/dist/links/wsLink/wsClient/options.mjs.map +1 -0
  168. package/dist/links/wsLink/wsClient/requestManager.js +133 -140
  169. package/dist/links/wsLink/wsClient/requestManager.mjs +133 -137
  170. package/dist/links/wsLink/wsClient/requestManager.mjs.map +1 -0
  171. package/dist/links/wsLink/wsClient/utils.js +64 -81
  172. package/dist/links/wsLink/wsClient/utils.mjs +64 -78
  173. package/dist/links/wsLink/wsClient/utils.mjs.map +1 -0
  174. package/dist/links/wsLink/wsClient/wsClient.d.mts +101 -0
  175. package/dist/links/wsLink/wsClient/wsClient.d.mts.map +1 -0
  176. package/dist/links/wsLink/wsClient/wsClient.d.ts +95 -78
  177. package/dist/links/wsLink/wsClient/wsClient.d.ts.map +1 -1
  178. package/dist/links/wsLink/wsClient/wsClient.js +273 -322
  179. package/dist/links/wsLink/wsClient/wsClient.mjs +272 -319
  180. package/dist/links/wsLink/wsClient/wsClient.mjs.map +1 -0
  181. package/dist/links/wsLink/wsClient/wsConnection.js +155 -178
  182. package/dist/links/wsLink/wsClient/wsConnection.mjs +154 -175
  183. package/dist/links/wsLink/wsClient/wsConnection.mjs.map +1 -0
  184. package/dist/links/wsLink/wsLink.d.mts +14 -0
  185. package/dist/links/wsLink/wsLink.d.mts.map +1 -0
  186. package/dist/links/wsLink/wsLink.d.ts +12 -9
  187. package/dist/links/wsLink/wsLink.d.ts.map +1 -1
  188. package/dist/links/wsLink/wsLink.js +30 -31
  189. package/dist/links/wsLink/wsLink.mjs +29 -28
  190. package/dist/links/wsLink/wsLink.mjs.map +1 -0
  191. package/dist/links.js +11 -0
  192. package/dist/links.mjs +11 -0
  193. package/dist/node_modules/.pnpm/@oxc-project_runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js +68 -0
  194. package/dist/node_modules/.pnpm/@oxc-project_runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.mjs +66 -0
  195. package/dist/node_modules/.pnpm/@oxc-project_runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.mjs.map +1 -0
  196. package/dist/unstable-internals.d.mts +3 -0
  197. package/dist/unstable-internals.d.ts +3 -3
  198. package/dist/unstable-internals.js +2 -6
  199. package/dist/unstable-internals.mjs +3 -1
  200. package/links/httpBatchLink/package.json +1 -0
  201. package/links/httpLink/package.json +1 -0
  202. package/links/loggerLink/package.json +1 -0
  203. package/links/splitLink/package.json +1 -0
  204. package/links/wsLink/wsLink/package.json +1 -0
  205. package/package.json +63 -30
  206. package/src/TRPCClientError.ts +4 -9
  207. package/src/internals/signals.ts +16 -0
  208. package/src/links/httpSubscriptionLink.ts +3 -18
  209. package/src/links/localLink.ts +277 -0
  210. package/src/links.ts +1 -0
  211. package/unstable-internals/package.json +1 -0
  212. package/dist/bundle-analysis.json +0 -433
  213. package/dist/index.d.ts.map +0 -1
  214. package/dist/internals/dataLoader.d.ts +0 -13
  215. package/dist/internals/dataLoader.d.ts.map +0 -1
  216. package/dist/internals/inputWithTrackedEventId.d.ts +0 -2
  217. package/dist/internals/inputWithTrackedEventId.d.ts.map +0 -1
  218. package/dist/internals/signals.d.ts +0 -15
  219. package/dist/internals/signals.d.ts.map +0 -1
  220. package/dist/links/internals/createChain.d.ts +0 -8
  221. package/dist/links/internals/createChain.d.ts.map +0 -1
  222. package/dist/links/internals/dedupeLink.d.ts +0 -7
  223. package/dist/links/internals/dedupeLink.d.ts.map +0 -1
  224. package/dist/links/wsLink/wsClient/requestManager.d.ts +0 -106
  225. package/dist/links/wsLink/wsClient/requestManager.d.ts.map +0 -1
  226. package/dist/links/wsLink/wsClient/utils.d.ts +0 -38
  227. package/dist/links/wsLink/wsClient/utils.d.ts.map +0 -1
  228. package/dist/links/wsLink/wsClient/wsConnection.d.ts +0 -79
  229. package/dist/links/wsLink/wsClient/wsConnection.d.ts.map +0 -1
  230. package/dist/links.d.ts +0 -11
  231. package/dist/links.d.ts.map +0 -1
  232. package/dist/unstable-internals.d.ts.map +0 -1
  233. package/links/httpBatchLink/index.d.ts +0 -1
  234. package/links/httpBatchLink/index.js +0 -1
  235. package/links/httpLink/index.d.ts +0 -1
  236. package/links/httpLink/index.js +0 -1
  237. package/links/loggerLink/index.d.ts +0 -1
  238. package/links/loggerLink/index.js +0 -1
  239. package/links/splitLink/index.d.ts +0 -1
  240. package/links/splitLink/index.js +0 -1
  241. package/links/wsLink/wsLink/index.d.ts +0 -1
  242. package/links/wsLink/wsLink/index.js +0 -1
  243. package/unstable-internals/index.d.ts +0 -1
  244. package/unstable-internals/index.js +0 -1
@@ -1,178 +1,125 @@
1
- 'use strict';
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
- var observable = require('@trpc/server/observable');
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
- if (typeof FormData === 'undefined') {
12
- // FormData is not supported
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
- css: {
19
- query: [
20
- '72e3ff',
21
- '3fb0d8'
22
- ],
23
- mutation: [
24
- 'c5a3fc',
25
- '904dfc'
26
- ],
27
- subscription: [
28
- 'ff49e1',
29
- 'd83fbe'
30
- ]
31
- },
32
- ansi: {
33
- regular: {
34
- // Cyan background, black and white text respectively
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
- const { direction, type, withContext, path, id, input } = opts;
68
- const parts = [];
69
- const args = [];
70
- if (opts.colorMode === 'none') {
71
- parts.push(direction === 'up' ? '>>' : '<<', type, `#${id}`, path);
72
- } else if (opts.colorMode === 'ansi') {
73
- const [lightRegular, darkRegular] = palettes.ansi.regular[type];
74
- const [lightBold, darkBold] = palettes.ansi.bold[type];
75
- const reset = '\x1b[0m';
76
- parts.push(direction === 'up' ? lightRegular : darkRegular, direction === 'up' ? '>>' : '<<', type, direction === 'up' ? lightBold : darkBold, `#${id}`, path, reset);
77
- } else {
78
- // css color mode
79
- const [light, dark] = palettes.css[type];
80
- const css = `
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
- parts.push('%c', direction === 'up' ? '>>' : '<<', type, `#${id}`, `%c${path}%c`, '%O');
86
- args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`);
87
- }
88
- if (direction === 'up') {
89
- args.push(withContext ? {
90
- input,
91
- context: opts.context
92
- } : {
93
- input
94
- });
95
- } else {
96
- args.push({
97
- input,
98
- result: opts.result,
99
- elapsedMs: opts.elapsedMs,
100
- ...withContext && {
101
- context: opts.context
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
- // maybe this should be moved to it's own package
111
- const defaultLogger = ({ c = console, colorMode = 'css', withContext })=>(props)=>{
112
- const rawInput = props.input;
113
- const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
114
- const { parts, args } = constructPartsAndArgs({
115
- ...props,
116
- colorMode,
117
- input,
118
- withContext
119
- });
120
- const fn = props.direction === 'down' && props.result && (props.result instanceof Error || 'error' in props.result.result && props.result.result.error) ? 'error' : 'log';
121
- c[fn].apply(null, [
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
- * @see https://trpc.io/docs/v11/client/links/loggerLink
127
- */ function loggerLink(opts = {}) {
128
- const { enabled = ()=>true } = opts;
129
- const colorMode = opts.colorMode ?? (typeof window === 'undefined' ? 'ansi' : 'css');
130
- const withContext = opts.withContext ?? colorMode === 'css';
131
- const { logger = defaultLogger({
132
- c: opts.console,
133
- colorMode,
134
- withContext
135
- }) } = opts;
136
- return ()=>{
137
- return ({ op, next })=>{
138
- return observable.observable((observer)=>{
139
- // ->
140
- if (enabled({
141
- ...op,
142
- direction: 'up'
143
- })) {
144
- logger({
145
- ...op,
146
- direction: 'up'
147
- });
148
- }
149
- const requestStartTime = Date.now();
150
- function logResult(result) {
151
- const elapsedMs = Date.now() - requestStartTime;
152
- if (enabled({
153
- ...op,
154
- direction: 'down',
155
- result
156
- })) {
157
- logger({
158
- ...op,
159
- direction: 'down',
160
- elapsedMs,
161
- result
162
- });
163
- }
164
- }
165
- return next(op).pipe(observable.tap({
166
- next (result) {
167
- logResult(result);
168
- },
169
- error (result) {
170
- logResult(result);
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
- exports.loggerLink = loggerLink;
124
+ //#endregion
125
+ exports.loggerLink = loggerLink;
@@ -1,176 +1,125 @@
1
- import { observable, tap } from '@trpc/server/observable';
1
+ import { observable, tap } from "@trpc/server/observable";
2
2
 
3
- /// <reference lib="dom.iterable" />
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
- if (typeof FormData === 'undefined') {
10
- // FormData is not supported
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
- css: {
17
- query: [
18
- '72e3ff',
19
- '3fb0d8'
20
- ],
21
- mutation: [
22
- 'c5a3fc',
23
- '904dfc'
24
- ],
25
- subscription: [
26
- 'ff49e1',
27
- 'd83fbe'
28
- ]
29
- },
30
- ansi: {
31
- regular: {
32
- // Cyan background, black and white text respectively
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
- const { direction, type, withContext, path, id, input } = opts;
66
- const parts = [];
67
- const args = [];
68
- if (opts.colorMode === 'none') {
69
- parts.push(direction === 'up' ? '>>' : '<<', type, `#${id}`, path);
70
- } else if (opts.colorMode === 'ansi') {
71
- const [lightRegular, darkRegular] = palettes.ansi.regular[type];
72
- const [lightBold, darkBold] = palettes.ansi.bold[type];
73
- const reset = '\x1b[0m';
74
- parts.push(direction === 'up' ? lightRegular : darkRegular, direction === 'up' ? '>>' : '<<', type, direction === 'up' ? lightBold : darkBold, `#${id}`, path, reset);
75
- } else {
76
- // css color mode
77
- const [light, dark] = palettes.css[type];
78
- const css = `
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
- parts.push('%c', direction === 'up' ? '>>' : '<<', type, `#${id}`, `%c${path}%c`, '%O');
84
- args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`);
85
- }
86
- if (direction === 'up') {
87
- args.push(withContext ? {
88
- input,
89
- context: opts.context
90
- } : {
91
- input
92
- });
93
- } else {
94
- args.push({
95
- input,
96
- result: opts.result,
97
- elapsedMs: opts.elapsedMs,
98
- ...withContext && {
99
- context: opts.context
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
- // maybe this should be moved to it's own package
109
- const defaultLogger = ({ c = console, colorMode = 'css', withContext })=>(props)=>{
110
- const rawInput = props.input;
111
- const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
112
- const { parts, args } = constructPartsAndArgs({
113
- ...props,
114
- colorMode,
115
- input,
116
- withContext
117
- });
118
- const fn = props.direction === 'down' && props.result && (props.result instanceof Error || 'error' in props.result.result && props.result.result.error) ? 'error' : 'log';
119
- c[fn].apply(null, [
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
- * @see https://trpc.io/docs/v11/client/links/loggerLink
125
- */ function loggerLink(opts = {}) {
126
- const { enabled = ()=>true } = opts;
127
- const colorMode = opts.colorMode ?? (typeof window === 'undefined' ? 'ansi' : 'css');
128
- const withContext = opts.withContext ?? colorMode === 'css';
129
- const { logger = defaultLogger({
130
- c: opts.console,
131
- colorMode,
132
- withContext
133
- }) } = opts;
134
- return ()=>{
135
- return ({ op, next })=>{
136
- return observable((observer)=>{
137
- // ->
138
- if (enabled({
139
- ...op,
140
- direction: 'up'
141
- })) {
142
- logger({
143
- ...op,
144
- direction: 'up'
145
- });
146
- }
147
- const requestStartTime = Date.now();
148
- function logResult(result) {
149
- const elapsedMs = Date.now() - requestStartTime;
150
- if (enabled({
151
- ...op,
152
- direction: 'down',
153
- result
154
- })) {
155
- logger({
156
- ...op,
157
- direction: 'down',
158
- elapsedMs,
159
- result
160
- });
161
- }
162
- }
163
- return next(op).pipe(tap({
164
- next (result) {
165
- logResult(result);
166
- },
167
- error (result) {
168
- logResult(result);
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