@trpc/client 11.3.1 → 11.3.2-canary.2

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 (238) hide show
  1. package/dist/TRPCClientError-CGgRtttT.cjs +67 -0
  2. package/dist/TRPCClientError-COkhCKf3.mjs +56 -0
  3. package/dist/TRPCClientError-COkhCKf3.mjs.map +1 -0
  4. package/dist/chunk-DWy1uDak.cjs +39 -0
  5. package/dist/httpBatchLink-CIC9PZ_Z.cjs +267 -0
  6. package/dist/httpBatchLink-DIfnmmcu.mjs +238 -0
  7. package/dist/httpBatchLink-DIfnmmcu.mjs.map +1 -0
  8. package/dist/httpBatchLink.d-BN2Iw_cK.d.mts +33 -0
  9. package/dist/httpBatchLink.d-BN2Iw_cK.d.mts.map +1 -0
  10. package/dist/httpBatchLink.d-CLAuJKNV.d.cts +33 -0
  11. package/dist/httpBatchLink.d-CLAuJKNV.d.cts.map +1 -0
  12. package/dist/httpLink-9bpwQ15c.mjs +90 -0
  13. package/dist/httpLink-9bpwQ15c.mjs.map +1 -0
  14. package/dist/httpLink-BbVj_TgM.cjs +113 -0
  15. package/dist/httpLink.d-CTSOARfE.d.mts +23 -0
  16. package/dist/httpLink.d-CTSOARfE.d.mts.map +1 -0
  17. package/dist/httpLink.d-yMKfOlTU.d.cts +23 -0
  18. package/dist/httpLink.d-yMKfOlTU.d.cts.map +1 -0
  19. package/dist/httpUtils-3pbQzhUL.mjs +123 -0
  20. package/dist/httpUtils-3pbQzhUL.mjs.map +1 -0
  21. package/dist/httpUtils-Buf6jCgh.cjs +163 -0
  22. package/dist/httpUtils.d-C8wPxU79.d.mts +25 -0
  23. package/dist/httpUtils.d-C8wPxU79.d.mts.map +1 -0
  24. package/dist/httpUtils.d-DNRVGNHs.d.cts +25 -0
  25. package/dist/httpUtils.d-DNRVGNHs.d.cts.map +1 -0
  26. package/dist/index.cjs +731 -0
  27. package/dist/index.d.cts +197 -0
  28. package/dist/index.d.cts.map +1 -0
  29. package/dist/index.d.mts +197 -0
  30. package/dist/index.d.mts.map +1 -0
  31. package/dist/index.mjs +733 -16
  32. package/dist/index.mjs.map +1 -0
  33. package/dist/links/httpBatchLink.cjs +6 -0
  34. package/dist/links/httpBatchLink.d.cts +6 -0
  35. package/dist/links/httpBatchLink.d.mts +6 -0
  36. package/dist/links/httpBatchLink.mjs +5 -107
  37. package/dist/links/httpLink.cjs +6 -0
  38. package/dist/links/httpLink.d.cts +6 -0
  39. package/dist/links/httpLink.d.mts +6 -0
  40. package/dist/links/httpLink.mjs +5 -92
  41. package/dist/links/loggerLink.cjs +3 -0
  42. package/dist/links/loggerLink.d.cts +4 -0
  43. package/dist/links/loggerLink.d.mts +4 -0
  44. package/dist/links/loggerLink.mjs +2 -175
  45. package/dist/links/splitLink.cjs +3 -0
  46. package/dist/links/splitLink.d.cts +4 -0
  47. package/dist/links/splitLink.d.mts +4 -0
  48. package/dist/links/splitLink.mjs +2 -24
  49. package/dist/links/wsLink/wsLink.cjs +6 -0
  50. package/dist/links/wsLink/wsLink.d.cts +5 -0
  51. package/dist/links/wsLink/wsLink.d.mts +5 -0
  52. package/dist/links/wsLink/wsLink.mjs +4 -31
  53. package/dist/loggerLink-CsDfg5Bb.cjs +130 -0
  54. package/dist/loggerLink-PGBSQFcR.mjs +125 -0
  55. package/dist/loggerLink-PGBSQFcR.mjs.map +1 -0
  56. package/dist/loggerLink.d-CZjK1CXm.d.mts +54 -0
  57. package/dist/loggerLink.d-CZjK1CXm.d.mts.map +1 -0
  58. package/dist/loggerLink.d-DU855urG.d.cts +54 -0
  59. package/dist/loggerLink.d-DU855urG.d.cts.map +1 -0
  60. package/dist/splitLink-BMgxggng.cjs +58 -0
  61. package/dist/splitLink-BVblHq4n.mjs +47 -0
  62. package/dist/splitLink-BVblHq4n.mjs.map +1 -0
  63. package/dist/splitLink.d-BAqgq0NG.d.mts +20 -0
  64. package/dist/splitLink.d-BAqgq0NG.d.mts.map +1 -0
  65. package/dist/splitLink.d-GdevSkGW.d.cts +20 -0
  66. package/dist/splitLink.d-GdevSkGW.d.cts.map +1 -0
  67. package/dist/subscriptions.d-Ciljg_dH.d.cts +19 -0
  68. package/dist/subscriptions.d-Ciljg_dH.d.cts.map +1 -0
  69. package/dist/subscriptions.d-U92STdZl.d.mts +19 -0
  70. package/dist/subscriptions.d-U92STdZl.d.mts.map +1 -0
  71. package/dist/types.d-DXbqQLCC.d.mts +182 -0
  72. package/dist/types.d-DXbqQLCC.d.mts.map +1 -0
  73. package/dist/types.d-DqGYG6S_.d.cts +182 -0
  74. package/dist/types.d-DqGYG6S_.d.cts.map +1 -0
  75. package/dist/unstable-internals-CYBH4jbF.cjs +34 -0
  76. package/dist/unstable-internals-DU4WecoG.mjs +29 -0
  77. package/dist/unstable-internals-DU4WecoG.mjs.map +1 -0
  78. package/dist/unstable-internals.cjs +3 -0
  79. package/dist/unstable-internals.d-DyLd-B0J.d.mts +46 -0
  80. package/dist/unstable-internals.d-DyLd-B0J.d.mts.map +1 -0
  81. package/dist/unstable-internals.d-kWsZTlQq.d.cts +46 -0
  82. package/dist/unstable-internals.d-kWsZTlQq.d.cts.map +1 -0
  83. package/dist/unstable-internals.d.cts +3 -0
  84. package/dist/unstable-internals.d.mts +3 -0
  85. package/dist/unstable-internals.mjs +3 -1
  86. package/dist/wsLink-DbSHOzlB.mjs +698 -0
  87. package/dist/wsLink-DbSHOzlB.mjs.map +1 -0
  88. package/dist/wsLink-DhJ50EC5.cjs +715 -0
  89. package/dist/wsLink.d-BqO7ltN_.d.mts +194 -0
  90. package/dist/wsLink.d-BqO7ltN_.d.mts.map +1 -0
  91. package/dist/wsLink.d-DtZjg09g.d.cts +194 -0
  92. package/dist/wsLink.d-DtZjg09g.d.cts.map +1 -0
  93. package/links/httpBatchLink/package.json +1 -0
  94. package/links/httpLink/package.json +1 -0
  95. package/links/loggerLink/package.json +1 -0
  96. package/links/splitLink/package.json +1 -0
  97. package/links/wsLink/wsLink/package.json +1 -0
  98. package/package.json +67 -33
  99. package/unstable-internals/package.json +1 -0
  100. package/dist/TRPCClientError.d.ts +0 -30
  101. package/dist/TRPCClientError.d.ts.map +0 -1
  102. package/dist/TRPCClientError.js +0 -79
  103. package/dist/TRPCClientError.mjs +0 -76
  104. package/dist/createTRPCClient.d.ts +0 -69
  105. package/dist/createTRPCClient.d.ts.map +0 -1
  106. package/dist/createTRPCClient.js +0 -48
  107. package/dist/createTRPCClient.mjs +0 -43
  108. package/dist/createTRPCUntypedClient.d.ts +0 -7
  109. package/dist/createTRPCUntypedClient.d.ts.map +0 -1
  110. package/dist/createTRPCUntypedClient.js +0 -10
  111. package/dist/createTRPCUntypedClient.mjs +0 -7
  112. package/dist/getFetch.d.ts +0 -3
  113. package/dist/getFetch.d.ts.map +0 -1
  114. package/dist/getFetch.js +0 -17
  115. package/dist/getFetch.mjs +0 -15
  116. package/dist/index.d.ts +0 -16
  117. package/dist/index.d.ts.map +0 -1
  118. package/dist/index.js +0 -46
  119. package/dist/internals/TRPCUntypedClient.d.ts +0 -39
  120. package/dist/internals/TRPCUntypedClient.d.ts.map +0 -1
  121. package/dist/internals/TRPCUntypedClient.js +0 -115
  122. package/dist/internals/TRPCUntypedClient.mjs +0 -113
  123. package/dist/internals/dataLoader.d.ts +0 -13
  124. package/dist/internals/dataLoader.d.ts.map +0 -1
  125. package/dist/internals/dataLoader.js +0 -117
  126. package/dist/internals/dataLoader.mjs +0 -115
  127. package/dist/internals/inputWithTrackedEventId.d.ts +0 -2
  128. package/dist/internals/inputWithTrackedEventId.d.ts.map +0 -1
  129. package/dist/internals/inputWithTrackedEventId.js +0 -16
  130. package/dist/internals/inputWithTrackedEventId.mjs +0 -14
  131. package/dist/internals/signals.d.ts +0 -16
  132. package/dist/internals/signals.d.ts.map +0 -1
  133. package/dist/internals/signals.js +0 -61
  134. package/dist/internals/signals.mjs +0 -57
  135. package/dist/internals/transformer.d.ts +0 -42
  136. package/dist/internals/transformer.d.ts.map +0 -1
  137. package/dist/internals/transformer.js +0 -30
  138. package/dist/internals/transformer.mjs +0 -28
  139. package/dist/internals/types.d.ts +0 -82
  140. package/dist/internals/types.d.ts.map +0 -1
  141. package/dist/links/HTTPBatchLinkOptions.d.ts +0 -20
  142. package/dist/links/HTTPBatchLinkOptions.d.ts.map +0 -1
  143. package/dist/links/httpBatchLink.d.ts +0 -8
  144. package/dist/links/httpBatchLink.d.ts.map +0 -1
  145. package/dist/links/httpBatchLink.js +0 -110
  146. package/dist/links/httpBatchStreamLink.d.ts +0 -12
  147. package/dist/links/httpBatchStreamLink.d.ts.map +0 -1
  148. package/dist/links/httpBatchStreamLink.js +0 -150
  149. package/dist/links/httpBatchStreamLink.mjs +0 -147
  150. package/dist/links/httpLink.d.ts +0 -17
  151. package/dist/links/httpLink.d.ts.map +0 -1
  152. package/dist/links/httpLink.js +0 -95
  153. package/dist/links/httpSubscriptionLink.d.ts +0 -26
  154. package/dist/links/httpSubscriptionLink.d.ts.map +0 -1
  155. package/dist/links/httpSubscriptionLink.js +0 -177
  156. package/dist/links/httpSubscriptionLink.mjs +0 -174
  157. package/dist/links/internals/contentTypes.d.ts +0 -4
  158. package/dist/links/internals/contentTypes.d.ts.map +0 -1
  159. package/dist/links/internals/contentTypes.js +0 -16
  160. package/dist/links/internals/contentTypes.mjs +0 -12
  161. package/dist/links/internals/createChain.d.ts +0 -8
  162. package/dist/links/internals/createChain.d.ts.map +0 -1
  163. package/dist/links/internals/createChain.js +0 -26
  164. package/dist/links/internals/createChain.mjs +0 -24
  165. package/dist/links/internals/dedupeLink.d.ts +0 -7
  166. package/dist/links/internals/dedupeLink.d.ts.map +0 -1
  167. package/dist/links/internals/httpUtils.d.ts +0 -68
  168. package/dist/links/internals/httpUtils.d.ts.map +0 -1
  169. package/dist/links/internals/httpUtils.js +0 -141
  170. package/dist/links/internals/httpUtils.mjs +0 -133
  171. package/dist/links/internals/subscriptions.d.ts +0 -17
  172. package/dist/links/internals/subscriptions.d.ts.map +0 -1
  173. package/dist/links/internals/urlWithConnectionParams.d.ts +0 -23
  174. package/dist/links/internals/urlWithConnectionParams.d.ts.map +0 -1
  175. package/dist/links/internals/urlWithConnectionParams.js +0 -10
  176. package/dist/links/internals/urlWithConnectionParams.mjs +0 -8
  177. package/dist/links/localLink.d.ts +0 -15
  178. package/dist/links/localLink.d.ts.map +0 -1
  179. package/dist/links/localLink.js +0 -333
  180. package/dist/links/localLink.mjs +0 -331
  181. package/dist/links/loggerLink.d.ts +0 -52
  182. package/dist/links/loggerLink.d.ts.map +0 -1
  183. package/dist/links/loggerLink.js +0 -178
  184. package/dist/links/retryLink.d.ts +0 -33
  185. package/dist/links/retryLink.d.ts.map +0 -1
  186. package/dist/links/retryLink.js +0 -72
  187. package/dist/links/retryLink.mjs +0 -70
  188. package/dist/links/splitLink.d.ts +0 -14
  189. package/dist/links/splitLink.d.ts.map +0 -1
  190. package/dist/links/splitLink.js +0 -27
  191. package/dist/links/types.d.ts +0 -63
  192. package/dist/links/types.d.ts.map +0 -1
  193. package/dist/links/wsLink/createWsClient.d.ts +0 -6
  194. package/dist/links/wsLink/createWsClient.d.ts.map +0 -1
  195. package/dist/links/wsLink/createWsClient.js +0 -9
  196. package/dist/links/wsLink/createWsClient.mjs +0 -7
  197. package/dist/links/wsLink/wsClient/options.d.ts +0 -79
  198. package/dist/links/wsLink/wsClient/options.d.ts.map +0 -1
  199. package/dist/links/wsLink/wsClient/options.js +0 -22
  200. package/dist/links/wsLink/wsClient/options.mjs +0 -18
  201. package/dist/links/wsLink/wsClient/requestManager.d.ts +0 -106
  202. package/dist/links/wsLink/wsClient/requestManager.d.ts.map +0 -1
  203. package/dist/links/wsLink/wsClient/requestManager.js +0 -143
  204. package/dist/links/wsLink/wsClient/requestManager.mjs +0 -141
  205. package/dist/links/wsLink/wsClient/utils.d.ts +0 -38
  206. package/dist/links/wsLink/wsClient/utils.d.ts.map +0 -1
  207. package/dist/links/wsLink/wsClient/utils.js +0 -94
  208. package/dist/links/wsLink/wsClient/utils.mjs +0 -88
  209. package/dist/links/wsLink/wsClient/wsClient.d.ts +0 -84
  210. package/dist/links/wsLink/wsClient/wsClient.d.ts.map +0 -1
  211. package/dist/links/wsLink/wsClient/wsClient.js +0 -325
  212. package/dist/links/wsLink/wsClient/wsClient.mjs +0 -323
  213. package/dist/links/wsLink/wsClient/wsConnection.d.ts +0 -79
  214. package/dist/links/wsLink/wsClient/wsConnection.d.ts.map +0 -1
  215. package/dist/links/wsLink/wsClient/wsConnection.js +0 -188
  216. package/dist/links/wsLink/wsClient/wsConnection.mjs +0 -185
  217. package/dist/links/wsLink/wsLink.d.ts +0 -11
  218. package/dist/links/wsLink/wsLink.d.ts.map +0 -1
  219. package/dist/links/wsLink/wsLink.js +0 -35
  220. package/dist/links.d.ts +0 -12
  221. package/dist/links.d.ts.map +0 -1
  222. package/dist/unstable-internals.d.ts +0 -3
  223. package/dist/unstable-internals.d.ts.map +0 -1
  224. package/dist/unstable-internals.js +0 -7
  225. package/links/httpBatchLink/index.d.ts +0 -1
  226. package/links/httpBatchLink/index.js +0 -1
  227. package/links/httpLink/index.d.ts +0 -1
  228. package/links/httpLink/index.js +0 -1
  229. package/links/loggerLink/index.d.ts +0 -1
  230. package/links/loggerLink/index.js +0 -1
  231. package/links/splitLink/index.d.ts +0 -1
  232. package/links/splitLink/index.js +0 -1
  233. package/links/wsLink/index.d.ts +0 -1
  234. package/links/wsLink/index.js +0 -1
  235. package/links/wsLink/wsLink/index.d.ts +0 -1
  236. package/links/wsLink/wsLink/index.js +0 -1
  237. package/unstable-internals/index.d.ts +0 -1
  238. package/unstable-internals/index.js +0 -1
package/dist/index.mjs CHANGED
@@ -1,16 +1,733 @@
1
- export { createTRPCUntypedClient } from './createTRPCUntypedClient.mjs';
2
- export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCClient as createTRPCProxyClient, getUntypedClient } from './createTRPCClient.mjs';
3
- export { getFetch } from './getFetch.mjs';
4
- export { TRPCClientError, isTRPCClientError } from './TRPCClientError.mjs';
5
- export { isFormData, isNonJsonSerializable, isOctetType } from './links/internals/contentTypes.mjs';
6
- export { httpBatchLink } from './links/httpBatchLink.mjs';
7
- export { httpBatchStreamLink, unstable_httpBatchStreamLink } from './links/httpBatchStreamLink.mjs';
8
- export { httpLink } from './links/httpLink.mjs';
9
- export { loggerLink } from './links/loggerLink.mjs';
10
- export { splitLink } from './links/splitLink.mjs';
11
- export { wsLink } from './links/wsLink/wsLink.mjs';
12
- export { httpSubscriptionLink, unstable_httpSubscriptionLink } from './links/httpSubscriptionLink.mjs';
13
- export { retryLink } from './links/retryLink.mjs';
14
- export { experimental_localLink } from './links/localLink.mjs';
15
- export { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
16
- export { createWSClient } from './links/wsLink/createWsClient.mjs';
1
+ import { createChain, splitLink } from "./splitLink-BVblHq4n.mjs";
2
+ import { TRPCClientError, isTRPCClientError } from "./TRPCClientError-COkhCKf3.mjs";
3
+ import { fetchHTTPResponse, getBody, getFetch, getUrl, resolveHTTPLinkOptions } from "./httpUtils-3pbQzhUL.mjs";
4
+ import { httpLink, isFormData, isNonJsonSerializable, isOctetType } from "./httpLink-9bpwQ15c.mjs";
5
+ import { abortSignalToPromise, allAbortSignals, dataLoader, httpBatchLink, raceAbortSignals } from "./httpBatchLink-DIfnmmcu.mjs";
6
+ import { getTransformer } from "./unstable-internals-DU4WecoG.mjs";
7
+ import { loggerLink } from "./loggerLink-PGBSQFcR.mjs";
8
+ import { createWSClient, resultOf, wsLink } from "./wsLink-DbSHOzlB.mjs";
9
+ import { behaviorSubject, observable, observableToPromise, share } from "@trpc/server/observable";
10
+ import { callProcedure, createFlatProxy, createRecursiveProxy, isAbortError, isAsyncIterable, iteratorResource, jsonlStreamConsumer, makeResource, retryableRpcCodes, run, sseStreamConsumer } from "@trpc/server/unstable-core-do-not-import";
11
+ import { getTRPCErrorFromUnknown, getTRPCErrorShape, isTrackedEnvelope } from "@trpc/server";
12
+ import { TRPC_ERROR_CODES_BY_KEY } from "@trpc/server/rpc";
13
+
14
+ //#region rolldown:runtime
15
+ var __create = Object.create;
16
+ var __defProp = Object.defineProperty;
17
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
18
+ var __getOwnPropNames = Object.getOwnPropertyNames;
19
+ var __getProtoOf = Object.getPrototypeOf;
20
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
21
+ var __commonJS = (cb, mod) => function() {
22
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
26
+ key = keys[i];
27
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
28
+ get: ((k) => from[k]).bind(null, key),
29
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
30
+ });
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
35
+ value: mod,
36
+ enumerable: true
37
+ }) : target, mod));
38
+
39
+ //#endregion
40
+ //#region src/internals/TRPCUntypedClient.ts
41
+ var TRPCUntypedClient = class {
42
+ links;
43
+ runtime;
44
+ requestId;
45
+ constructor(opts) {
46
+ this.requestId = 0;
47
+ this.runtime = {};
48
+ this.links = opts.links.map((link) => link(this.runtime));
49
+ }
50
+ $request(opts) {
51
+ const chain$ = createChain({
52
+ links: this.links,
53
+ op: {
54
+ ...opts,
55
+ context: opts.context ?? {},
56
+ id: ++this.requestId
57
+ }
58
+ });
59
+ return chain$.pipe(share());
60
+ }
61
+ async requestAsPromise(opts) {
62
+ try {
63
+ const req$ = this.$request(opts);
64
+ const envelope = await observableToPromise(req$);
65
+ const data = envelope.result.data;
66
+ return data;
67
+ } catch (err) {
68
+ throw TRPCClientError.from(err);
69
+ }
70
+ }
71
+ query(path, input, opts) {
72
+ return this.requestAsPromise({
73
+ type: "query",
74
+ path,
75
+ input,
76
+ context: opts?.context,
77
+ signal: opts?.signal
78
+ });
79
+ }
80
+ mutation(path, input, opts) {
81
+ return this.requestAsPromise({
82
+ type: "mutation",
83
+ path,
84
+ input,
85
+ context: opts?.context,
86
+ signal: opts?.signal
87
+ });
88
+ }
89
+ subscription(path, input, opts) {
90
+ const observable$ = this.$request({
91
+ type: "subscription",
92
+ path,
93
+ input,
94
+ context: opts.context,
95
+ signal: opts.signal
96
+ });
97
+ return observable$.subscribe({
98
+ next(envelope) {
99
+ switch (envelope.result.type) {
100
+ case "state": {
101
+ opts.onConnectionStateChange?.(envelope.result);
102
+ break;
103
+ }
104
+ case "started": {
105
+ opts.onStarted?.({ context: envelope.context });
106
+ break;
107
+ }
108
+ case "stopped": {
109
+ opts.onStopped?.();
110
+ break;
111
+ }
112
+ case "data":
113
+ case void 0: {
114
+ opts.onData?.(envelope.result.data);
115
+ break;
116
+ }
117
+ }
118
+ },
119
+ error(err) {
120
+ opts.onError?.(err);
121
+ },
122
+ complete() {
123
+ opts.onComplete?.();
124
+ }
125
+ });
126
+ }
127
+ };
128
+
129
+ //#endregion
130
+ //#region src/createTRPCUntypedClient.ts
131
+ function createTRPCUntypedClient(opts) {
132
+ return new TRPCUntypedClient(opts);
133
+ }
134
+
135
+ //#endregion
136
+ //#region src/createTRPCClient.ts
137
+ const untypedClientSymbol = Symbol.for("trpc_untypedClient");
138
+ const clientCallTypeMap = {
139
+ query: "query",
140
+ mutate: "mutation",
141
+ subscribe: "subscription"
142
+ };
143
+ /** @internal */
144
+ const clientCallTypeToProcedureType = (clientCallType) => {
145
+ return clientCallTypeMap[clientCallType];
146
+ };
147
+ /**
148
+ * @internal
149
+ */
150
+ function createTRPCClientProxy(client) {
151
+ const proxy = createRecursiveProxy(({ path, args }) => {
152
+ const pathCopy = [...path];
153
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
154
+ const fullPath = pathCopy.join(".");
155
+ return client[procedureType](fullPath, ...args);
156
+ });
157
+ return createFlatProxy((key) => {
158
+ if (key === untypedClientSymbol) return client;
159
+ return proxy[key];
160
+ });
161
+ }
162
+ function createTRPCClient(opts) {
163
+ const client = new TRPCUntypedClient(opts);
164
+ const proxy = createTRPCClientProxy(client);
165
+ return proxy;
166
+ }
167
+ /**
168
+ * Get an untyped client from a proxy client
169
+ * @internal
170
+ */
171
+ function getUntypedClient(client) {
172
+ return client[untypedClientSymbol];
173
+ }
174
+
175
+ //#endregion
176
+ //#region src/links/httpBatchStreamLink.ts
177
+ /**
178
+ * @see https://trpc.io/docs/client/links/httpBatchStreamLink
179
+ */
180
+ function httpBatchStreamLink(opts) {
181
+ const resolvedOpts = resolveHTTPLinkOptions(opts);
182
+ const maxURLLength = opts.maxURLLength ?? Infinity;
183
+ const maxItems = opts.maxItems ?? Infinity;
184
+ return () => {
185
+ const batchLoader = (type) => {
186
+ return {
187
+ validate(batchOps) {
188
+ if (maxURLLength === Infinity && maxItems === Infinity) return true;
189
+ if (batchOps.length > maxItems) return false;
190
+ const path = batchOps.map((op) => op.path).join(",");
191
+ const inputs = batchOps.map((op) => op.input);
192
+ const url = getUrl({
193
+ ...resolvedOpts,
194
+ type,
195
+ path,
196
+ inputs,
197
+ signal: null
198
+ });
199
+ return url.length <= maxURLLength;
200
+ },
201
+ async fetch(batchOps) {
202
+ const path = batchOps.map((op) => op.path).join(",");
203
+ const inputs = batchOps.map((op) => op.input);
204
+ const batchSignals = allAbortSignals(...batchOps.map((op) => op.signal));
205
+ const abortController = new AbortController();
206
+ const responsePromise = fetchHTTPResponse({
207
+ ...resolvedOpts,
208
+ signal: raceAbortSignals(batchSignals, abortController.signal),
209
+ type,
210
+ contentTypeHeader: "application/json",
211
+ trpcAcceptHeader: "application/jsonl",
212
+ getUrl,
213
+ getBody,
214
+ inputs,
215
+ path,
216
+ headers() {
217
+ if (!opts.headers) return {};
218
+ if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
219
+ return opts.headers;
220
+ }
221
+ });
222
+ const res = await responsePromise;
223
+ const [head] = await jsonlStreamConsumer({
224
+ from: res.body,
225
+ deserialize: resolvedOpts.transformer.output.deserialize,
226
+ formatError(opts$1) {
227
+ const error = opts$1.error;
228
+ return TRPCClientError.from({ error });
229
+ },
230
+ abortController
231
+ });
232
+ const promises = Object.keys(batchOps).map(async (key) => {
233
+ let json = await Promise.resolve(head[key]);
234
+ if ("result" in json) {
235
+ /**
236
+ * Not very pretty, but we need to unwrap nested data as promises
237
+ * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
238
+ */
239
+ const result = await Promise.resolve(json.result);
240
+ json = { result: { data: await Promise.resolve(result.data) } };
241
+ }
242
+ return {
243
+ json,
244
+ meta: { response: res }
245
+ };
246
+ });
247
+ return promises;
248
+ }
249
+ };
250
+ };
251
+ const query = dataLoader(batchLoader("query"));
252
+ const mutation = dataLoader(batchLoader("mutation"));
253
+ const loaders = {
254
+ query,
255
+ mutation
256
+ };
257
+ return ({ op }) => {
258
+ return observable((observer) => {
259
+ /* istanbul ignore if -- @preserve */
260
+ if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpBatchStreamLink` - use `httpSubscriptionLink` or `wsLink`");
261
+ const loader = loaders[op.type];
262
+ const promise = loader.load(op);
263
+ let _res = void 0;
264
+ promise.then((res) => {
265
+ _res = res;
266
+ if ("error" in res.json) {
267
+ observer.error(TRPCClientError.from(res.json, { meta: res.meta }));
268
+ return;
269
+ } else if ("result" in res.json) {
270
+ observer.next({
271
+ context: res.meta,
272
+ result: res.json.result
273
+ });
274
+ observer.complete();
275
+ return;
276
+ }
277
+ observer.complete();
278
+ }).catch((err) => {
279
+ observer.error(TRPCClientError.from(err, { meta: _res?.meta }));
280
+ });
281
+ return () => {};
282
+ });
283
+ };
284
+ };
285
+ }
286
+ /**
287
+ * @deprecated use {@link httpBatchStreamLink} instead
288
+ */
289
+ const unstable_httpBatchStreamLink = httpBatchStreamLink;
290
+
291
+ //#endregion
292
+ //#region src/internals/inputWithTrackedEventId.ts
293
+ function inputWithTrackedEventId(input, lastEventId) {
294
+ if (!lastEventId) return input;
295
+ if (input != null && typeof input !== "object") return input;
296
+ return {
297
+ ...input ?? {},
298
+ lastEventId
299
+ };
300
+ }
301
+
302
+ //#endregion
303
+ //#region src/links/httpSubscriptionLink.ts
304
+ async function urlWithConnectionParams(opts) {
305
+ let url = await resultOf(opts.url);
306
+ if (opts.connectionParams) {
307
+ const params = await resultOf(opts.connectionParams);
308
+ const prefix = url.includes("?") ? "&" : "?";
309
+ url += prefix + "connectionParams=" + encodeURIComponent(JSON.stringify(params));
310
+ }
311
+ return url;
312
+ }
313
+ /**
314
+ * @see https://trpc.io/docs/client/links/httpSubscriptionLink
315
+ */
316
+ function httpSubscriptionLink(opts) {
317
+ const transformer = getTransformer(opts.transformer);
318
+ return () => {
319
+ return ({ op }) => {
320
+ return observable((observer) => {
321
+ const { type, path, input } = op;
322
+ /* istanbul ignore if -- @preserve */
323
+ if (type !== "subscription") throw new Error("httpSubscriptionLink only supports subscriptions");
324
+ let lastEventId = void 0;
325
+ const ac = new AbortController();
326
+ const signal = raceAbortSignals(op.signal, ac.signal);
327
+ const eventSourceStream = sseStreamConsumer({
328
+ url: async () => getUrl({
329
+ transformer,
330
+ url: await urlWithConnectionParams(opts),
331
+ input: inputWithTrackedEventId(input, lastEventId),
332
+ path,
333
+ type,
334
+ signal: null
335
+ }),
336
+ init: () => resultOf(opts.eventSourceOptions, { op }),
337
+ signal,
338
+ deserialize: transformer.output.deserialize,
339
+ EventSource: opts.EventSource ?? globalThis.EventSource
340
+ });
341
+ const connectionState = behaviorSubject({
342
+ type: "state",
343
+ state: "connecting",
344
+ error: null
345
+ });
346
+ const connectionSub = connectionState.subscribe({ next(state) {
347
+ observer.next({ result: state });
348
+ } });
349
+ run(async () => {
350
+ for await (const chunk of eventSourceStream) switch (chunk.type) {
351
+ case "ping": break;
352
+ case "data":
353
+ const chunkData = chunk.data;
354
+ let result;
355
+ if (chunkData.id) {
356
+ lastEventId = chunkData.id;
357
+ result = {
358
+ id: chunkData.id,
359
+ data: chunkData
360
+ };
361
+ } else result = { data: chunkData.data };
362
+ observer.next({
363
+ result,
364
+ context: { eventSource: chunk.eventSource }
365
+ });
366
+ break;
367
+ case "connected": {
368
+ observer.next({
369
+ result: { type: "started" },
370
+ context: { eventSource: chunk.eventSource }
371
+ });
372
+ connectionState.next({
373
+ type: "state",
374
+ state: "pending",
375
+ error: null
376
+ });
377
+ break;
378
+ }
379
+ case "serialized-error": {
380
+ const error = TRPCClientError.from({ error: chunk.error });
381
+ if (retryableRpcCodes.includes(chunk.error.code)) {
382
+ connectionState.next({
383
+ type: "state",
384
+ state: "connecting",
385
+ error
386
+ });
387
+ break;
388
+ }
389
+ throw error;
390
+ }
391
+ case "connecting": {
392
+ const lastState = connectionState.get();
393
+ const error = chunk.event && TRPCClientError.from(chunk.event);
394
+ if (!error && lastState.state === "connecting") break;
395
+ connectionState.next({
396
+ type: "state",
397
+ state: "connecting",
398
+ error
399
+ });
400
+ break;
401
+ }
402
+ case "timeout": connectionState.next({
403
+ type: "state",
404
+ state: "connecting",
405
+ error: new TRPCClientError(`Timeout of ${chunk.ms}ms reached while waiting for a response`)
406
+ });
407
+ }
408
+ observer.next({ result: { type: "stopped" } });
409
+ connectionState.next({
410
+ type: "state",
411
+ state: "idle",
412
+ error: null
413
+ });
414
+ observer.complete();
415
+ }).catch((error) => {
416
+ observer.error(TRPCClientError.from(error));
417
+ });
418
+ return () => {
419
+ observer.complete();
420
+ ac.abort();
421
+ connectionSub.unsubscribe();
422
+ };
423
+ });
424
+ };
425
+ };
426
+ }
427
+ /**
428
+ * @deprecated use {@link httpSubscriptionLink} instead
429
+ */
430
+ const unstable_httpSubscriptionLink = httpSubscriptionLink;
431
+
432
+ //#endregion
433
+ //#region src/links/retryLink.ts
434
+ /**
435
+ * @see https://trpc.io/docs/v11/client/links/retryLink
436
+ */
437
+ function retryLink(opts) {
438
+ return () => {
439
+ return (callOpts) => {
440
+ return observable((observer) => {
441
+ let next$;
442
+ let callNextTimeout = void 0;
443
+ let lastEventId = void 0;
444
+ attempt(1);
445
+ function opWithLastEventId() {
446
+ const op = callOpts.op;
447
+ if (!lastEventId) return op;
448
+ return {
449
+ ...op,
450
+ input: inputWithTrackedEventId(op.input, lastEventId)
451
+ };
452
+ }
453
+ function attempt(attempts) {
454
+ const op = opWithLastEventId();
455
+ next$ = callOpts.next(op).subscribe({
456
+ error(error) {
457
+ const shouldRetry = opts.retry({
458
+ op,
459
+ attempts,
460
+ error
461
+ });
462
+ if (!shouldRetry) {
463
+ observer.error(error);
464
+ return;
465
+ }
466
+ const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
467
+ if (delayMs <= 0) {
468
+ attempt(attempts + 1);
469
+ return;
470
+ }
471
+ callNextTimeout = setTimeout(() => attempt(attempts + 1), delayMs);
472
+ },
473
+ next(envelope) {
474
+ if ((!envelope.result.type || envelope.result.type === "data") && envelope.result.id) lastEventId = envelope.result.id;
475
+ observer.next(envelope);
476
+ },
477
+ complete() {
478
+ observer.complete();
479
+ }
480
+ });
481
+ }
482
+ return () => {
483
+ next$.unsubscribe();
484
+ clearTimeout(callNextTimeout);
485
+ };
486
+ });
487
+ };
488
+ };
489
+ }
490
+
491
+ //#endregion
492
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
493
+ var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
494
+ function _usingCtx() {
495
+ var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
496
+ var n$1 = Error();
497
+ return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
498
+ }, e = {}, n = [];
499
+ function using(r$1, e$1) {
500
+ if (null != e$1) {
501
+ if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
502
+ if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
503
+ if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
504
+ if ("function" != typeof o) throw new TypeError("Object is not disposable.");
505
+ t && (o = function o$1() {
506
+ try {
507
+ t.call(e$1);
508
+ } catch (r$2) {
509
+ return Promise.reject(r$2);
510
+ }
511
+ }), n.push({
512
+ v: e$1,
513
+ d: o,
514
+ a: r$1
515
+ });
516
+ } else r$1 && n.push({
517
+ d: e$1,
518
+ a: r$1
519
+ });
520
+ return e$1;
521
+ }
522
+ return {
523
+ e,
524
+ u: using.bind(null, !1),
525
+ a: using.bind(null, !0),
526
+ d: function d() {
527
+ var o, t = this.e, s = 0;
528
+ function next() {
529
+ for (; o = n.pop();) try {
530
+ if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
531
+ if (o.d) {
532
+ var r$1 = o.d.call(o.v);
533
+ if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
534
+ } else s |= 1;
535
+ } catch (r$2) {
536
+ return err(r$2);
537
+ }
538
+ if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
539
+ if (t !== e) throw t;
540
+ }
541
+ function err(n$1) {
542
+ return t = t !== e ? new r(n$1, t) : n$1, next();
543
+ }
544
+ return next();
545
+ }
546
+ };
547
+ }
548
+ module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
549
+ } });
550
+
551
+ //#endregion
552
+ //#region src/links/localLink.ts
553
+ var import_usingCtx = __toESM(require_usingCtx(), 1);
554
+ /**
555
+ * localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
556
+ *
557
+ * @see https://trpc.io/docs/links/localLink
558
+ */
559
+ function experimental_localLink(opts) {
560
+ const transformer = getTransformer(opts.transformer);
561
+ const transformChunk = (chunk) => {
562
+ if (opts.transformer) return chunk;
563
+ if (chunk === void 0) return chunk;
564
+ const serialized = JSON.stringify(transformer.input.serialize(chunk));
565
+ const deserialized = JSON.parse(transformer.output.deserialize(serialized));
566
+ return deserialized;
567
+ };
568
+ return () => ({ op }) => observable((observer) => {
569
+ let ctx = void 0;
570
+ const ac = new AbortController();
571
+ const signal = raceAbortSignals(op.signal, ac.signal);
572
+ const signalPromise = abortSignalToPromise(signal);
573
+ signalPromise.catch(() => {});
574
+ let input = op.input;
575
+ async function runProcedure(newInput) {
576
+ input = newInput;
577
+ ctx = await opts.createContext();
578
+ return callProcedure({
579
+ router: opts.router,
580
+ path: op.path,
581
+ getRawInput: async () => newInput,
582
+ ctx,
583
+ type: op.type,
584
+ signal
585
+ });
586
+ }
587
+ function onErrorCallback(cause) {
588
+ if (isAbortError(cause)) return;
589
+ opts.onError?.({
590
+ error: getTRPCErrorFromUnknown(cause),
591
+ type: op.type,
592
+ path: op.path,
593
+ input,
594
+ ctx
595
+ });
596
+ }
597
+ function coerceToTRPCClientError(cause) {
598
+ if (isTRPCClientError(cause)) return cause;
599
+ const error = getTRPCErrorFromUnknown(cause);
600
+ const shape = getTRPCErrorShape({
601
+ config: opts.router._def._config,
602
+ ctx,
603
+ error,
604
+ input,
605
+ path: op.path,
606
+ type: op.type
607
+ });
608
+ return TRPCClientError.from({ error: transformChunk(shape) });
609
+ }
610
+ run(async () => {
611
+ switch (op.type) {
612
+ case "query":
613
+ case "mutation": {
614
+ const result = await runProcedure(op.input);
615
+ if (!isAsyncIterable(result)) {
616
+ observer.next({ result: { data: transformChunk(result) } });
617
+ observer.complete();
618
+ break;
619
+ }
620
+ observer.next({ result: { data: async function* () {
621
+ try {
622
+ var _usingCtx$1 = (0, import_usingCtx.default)();
623
+ const iterator = _usingCtx$1.a(iteratorResource(result));
624
+ const _finally = _usingCtx$1.u(makeResource({}, () => {
625
+ observer.complete();
626
+ }));
627
+ try {
628
+ while (true) {
629
+ const res = await Promise.race([iterator.next(), signalPromise]);
630
+ if (res.done) return transformChunk(res.value);
631
+ yield transformChunk(res.value);
632
+ }
633
+ } catch (cause) {
634
+ onErrorCallback(cause);
635
+ throw coerceToTRPCClientError(cause);
636
+ }
637
+ } catch (_) {
638
+ _usingCtx$1.e = _;
639
+ } finally {
640
+ await _usingCtx$1.d();
641
+ }
642
+ }() } });
643
+ break;
644
+ }
645
+ case "subscription": try {
646
+ var _usingCtx3 = (0, import_usingCtx.default)();
647
+ const connectionState = behaviorSubject({
648
+ type: "state",
649
+ state: "connecting",
650
+ error: null
651
+ });
652
+ const connectionSub = connectionState.subscribe({ next(state) {
653
+ observer.next({ result: state });
654
+ } });
655
+ let lastEventId = void 0;
656
+ const _finally = _usingCtx3.u(makeResource({}, async () => {
657
+ observer.complete();
658
+ connectionState.next({
659
+ type: "state",
660
+ state: "idle",
661
+ error: null
662
+ });
663
+ connectionSub.unsubscribe();
664
+ }));
665
+ while (true) try {
666
+ var _usingCtx4 = (0, import_usingCtx.default)();
667
+ const result = await runProcedure(inputWithTrackedEventId(op.input, lastEventId));
668
+ if (!isAsyncIterable(result)) throw new Error("Expected an async iterable");
669
+ const iterator = _usingCtx4.a(iteratorResource(result));
670
+ observer.next({ result: { type: "started" } });
671
+ connectionState.next({
672
+ type: "state",
673
+ state: "pending",
674
+ error: null
675
+ });
676
+ while (true) {
677
+ let res;
678
+ try {
679
+ res = await Promise.race([iterator.next(), signalPromise]);
680
+ } catch (cause) {
681
+ if (isAbortError(cause)) return;
682
+ const error = getTRPCErrorFromUnknown(cause);
683
+ if (!retryableRpcCodes.includes(TRPC_ERROR_CODES_BY_KEY[error.code])) throw coerceToTRPCClientError(error);
684
+ onErrorCallback(error);
685
+ connectionState.next({
686
+ type: "state",
687
+ state: "connecting",
688
+ error: coerceToTRPCClientError(error)
689
+ });
690
+ break;
691
+ }
692
+ if (res.done) return;
693
+ let chunk;
694
+ if (isTrackedEnvelope(res.value)) {
695
+ lastEventId = res.value[0];
696
+ chunk = {
697
+ id: res.value[0],
698
+ data: {
699
+ id: res.value[0],
700
+ data: res.value[1]
701
+ }
702
+ };
703
+ } else chunk = { data: res.value };
704
+ observer.next({ result: {
705
+ ...chunk,
706
+ data: transformChunk(chunk.data)
707
+ } });
708
+ }
709
+ } catch (_) {
710
+ _usingCtx4.e = _;
711
+ } finally {
712
+ await _usingCtx4.d();
713
+ }
714
+ break;
715
+ } catch (_) {
716
+ _usingCtx3.e = _;
717
+ } finally {
718
+ _usingCtx3.d();
719
+ }
720
+ }
721
+ }).catch((cause) => {
722
+ onErrorCallback(cause);
723
+ observer.error(coerceToTRPCClientError(cause));
724
+ });
725
+ return () => {
726
+ ac.abort();
727
+ };
728
+ });
729
+ }
730
+
731
+ //#endregion
732
+ export { TRPCClientError, TRPCUntypedClient, clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCClient as createTRPCProxyClient, createTRPCUntypedClient, createWSClient, experimental_localLink, getFetch, getUntypedClient, httpBatchLink, httpBatchStreamLink, httpLink, httpSubscriptionLink, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError, loggerLink, retryLink, splitLink, unstable_httpBatchStreamLink, unstable_httpSubscriptionLink, wsLink };
733
+ //# sourceMappingURL=index.mjs.map