@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
|
@@ -1,133 +1,114 @@
|
|
|
1
|
-
import { getFetch } from
|
|
2
|
-
import { getTransformer } from
|
|
1
|
+
import { getFetch } from "../../getFetch.mjs";
|
|
2
|
+
import { getTransformer } from "../../internals/transformer.mjs";
|
|
3
3
|
|
|
4
|
+
//#region src/links/internals/httpUtils.ts
|
|
4
5
|
function resolveHTTPLinkOptions(opts) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
return {
|
|
7
|
+
url: opts.url.toString(),
|
|
8
|
+
fetch: opts.fetch,
|
|
9
|
+
transformer: getTransformer(opts.transformer),
|
|
10
|
+
methodOverride: opts.methodOverride
|
|
11
|
+
};
|
|
11
12
|
}
|
|
12
|
-
// https://github.com/trpc/trpc/pull/669
|
|
13
13
|
function arrayToDict(array) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const dict = {};
|
|
15
|
+
for (let index = 0; index < array.length; index++) {
|
|
16
|
+
const element = array[index];
|
|
17
|
+
dict[index] = element;
|
|
18
|
+
}
|
|
19
|
+
return dict;
|
|
20
20
|
}
|
|
21
21
|
const METHOD = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
query: "GET",
|
|
23
|
+
mutation: "POST",
|
|
24
|
+
subscription: "PATCH"
|
|
25
25
|
};
|
|
26
26
|
function getInput(opts) {
|
|
27
|
-
|
|
27
|
+
return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input)));
|
|
28
28
|
}
|
|
29
|
-
const getUrl = (opts)=>{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (input !== undefined && opts.methodOverride !== 'POST') {
|
|
43
|
-
queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (queryParts.length) {
|
|
47
|
-
url += '?' + queryParts.join('&');
|
|
48
|
-
}
|
|
49
|
-
return url;
|
|
29
|
+
const getUrl = (opts) => {
|
|
30
|
+
const parts = opts.url.split("?");
|
|
31
|
+
const base = parts[0].replace(/\/$/, "");
|
|
32
|
+
let url = base + "/" + opts.path;
|
|
33
|
+
const queryParts = [];
|
|
34
|
+
if (parts[1]) queryParts.push(parts[1]);
|
|
35
|
+
if ("inputs" in opts) queryParts.push("batch=1");
|
|
36
|
+
if (opts.type === "query" || opts.type === "subscription") {
|
|
37
|
+
const input = getInput(opts);
|
|
38
|
+
if (input !== void 0 && opts.methodOverride !== "POST") queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
|
39
|
+
}
|
|
40
|
+
if (queryParts.length) url += "?" + queryParts.join("&");
|
|
41
|
+
return url;
|
|
50
42
|
};
|
|
51
|
-
const getBody = (opts)=>{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const input = getInput(opts);
|
|
56
|
-
return input !== undefined ? JSON.stringify(input) : undefined;
|
|
43
|
+
const getBody = (opts) => {
|
|
44
|
+
if (opts.type === "query" && opts.methodOverride !== "POST") return void 0;
|
|
45
|
+
const input = getInput(opts);
|
|
46
|
+
return input !== void 0 ? JSON.stringify(input) : void 0;
|
|
57
47
|
};
|
|
58
|
-
const jsonHttpRequester = (opts)=>{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
const jsonHttpRequester = (opts) => {
|
|
49
|
+
return httpRequest({
|
|
50
|
+
...opts,
|
|
51
|
+
contentTypeHeader: "application/json",
|
|
52
|
+
getUrl,
|
|
53
|
+
getBody
|
|
54
|
+
});
|
|
65
55
|
};
|
|
66
56
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
57
|
+
* Polyfill for DOMException with AbortError name
|
|
58
|
+
*/
|
|
59
|
+
var AbortError = class extends Error {
|
|
60
|
+
constructor() {
|
|
61
|
+
const name = "AbortError";
|
|
62
|
+
super(name);
|
|
63
|
+
this.name = name;
|
|
64
|
+
this.message = name;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
76
67
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// If we have `DOMException`, use it
|
|
87
|
-
if (typeof DOMException !== 'undefined') {
|
|
88
|
-
throw new DOMException('AbortError', 'AbortError');
|
|
89
|
-
}
|
|
90
|
-
// Otherwise, use our own implementation
|
|
91
|
-
throw new AbortError();
|
|
68
|
+
* Polyfill for `signal.throwIfAborted()`
|
|
69
|
+
*
|
|
70
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted
|
|
71
|
+
*/
|
|
72
|
+
const throwIfAborted = (signal) => {
|
|
73
|
+
if (!signal?.aborted) return;
|
|
74
|
+
signal.throwIfAborted?.();
|
|
75
|
+
if (typeof DOMException !== "undefined") throw new DOMException("AbortError", "AbortError");
|
|
76
|
+
throw new AbortError();
|
|
92
77
|
};
|
|
93
78
|
async function fetchHTTPResponse(opts) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return getFetch(opts.fetch)(url, {
|
|
115
|
-
method: opts.methodOverride ?? METHOD[type],
|
|
116
|
-
signal: opts.signal,
|
|
117
|
-
body,
|
|
118
|
-
headers
|
|
119
|
-
});
|
|
79
|
+
throwIfAborted(opts.signal);
|
|
80
|
+
const url = opts.getUrl(opts);
|
|
81
|
+
const body = opts.getBody(opts);
|
|
82
|
+
const { type } = opts;
|
|
83
|
+
const resolvedHeaders = await (async () => {
|
|
84
|
+
const heads = await opts.headers();
|
|
85
|
+
if (Symbol.iterator in heads) return Object.fromEntries(heads);
|
|
86
|
+
return heads;
|
|
87
|
+
})();
|
|
88
|
+
const headers = {
|
|
89
|
+
...opts.contentTypeHeader ? { "content-type": opts.contentTypeHeader } : {},
|
|
90
|
+
...opts.trpcAcceptHeader ? { "trpc-accept": opts.trpcAcceptHeader } : void 0,
|
|
91
|
+
...resolvedHeaders
|
|
92
|
+
};
|
|
93
|
+
return getFetch(opts.fetch)(url, {
|
|
94
|
+
method: opts.methodOverride ?? METHOD[type],
|
|
95
|
+
signal: opts.signal,
|
|
96
|
+
body,
|
|
97
|
+
headers
|
|
98
|
+
});
|
|
120
99
|
}
|
|
121
100
|
async function httpRequest(opts) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
101
|
+
const meta = {};
|
|
102
|
+
const res = await fetchHTTPResponse(opts);
|
|
103
|
+
meta.response = res;
|
|
104
|
+
const json = await res.json();
|
|
105
|
+
meta.responseJSON = json;
|
|
106
|
+
return {
|
|
107
|
+
json,
|
|
108
|
+
meta
|
|
109
|
+
};
|
|
131
110
|
}
|
|
132
111
|
|
|
133
|
-
|
|
112
|
+
//#endregion
|
|
113
|
+
export { fetchHTTPResponse, getBody, getUrl, httpRequest, jsonHttpRequester, resolveHTTPLinkOptions };
|
|
114
|
+
//# sourceMappingURL=httpUtils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpUtils.mjs","names":["opts: HTTPLinkBaseOptions<AnyClientTypes>","array: unknown[]","dict: Record<number, unknown>","opts: GetInputOptions","getUrl: GetUrl","queryParts: string[]","getBody: GetBody","jsonHttpRequester: Requester","signal: Maybe<AbortSignal>","opts: HTTPRequestOptions"],"sources":["../../../src/links/internals/httpUtils.ts"],"sourcesContent":["import type {\n AnyClientTypes,\n CombinedDataTransformer,\n Maybe,\n ProcedureType,\n TRPCAcceptHeader,\n TRPCResponse,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { getFetch } from '../../getFetch';\nimport type {\n FetchEsque,\n RequestInitEsque,\n ResponseEsque,\n} from '../../internals/types';\nimport type { TransformerOptions } from '../../unstable-internals';\nimport { getTransformer } from '../../unstable-internals';\nimport type { HTTPHeaders } from '../types';\n\n/**\n * @internal\n */\nexport type HTTPLinkBaseOptions<\n TRoot extends Pick<AnyClientTypes, 'transformer'>,\n> = {\n url: string | URL;\n /**\n * Add ponyfill for fetch\n */\n fetch?: FetchEsque;\n /**\n * Send all requests `as POST`s requests regardless of the procedure type\n * The HTTP handler must separately allow overriding the method. See:\n * @see https://trpc.io/docs/rpc\n */\n methodOverride?: 'POST';\n} & TransformerOptions<TRoot>;\n\nexport interface ResolvedHTTPLinkOptions {\n url: string;\n fetch?: FetchEsque;\n transformer: CombinedDataTransformer;\n methodOverride?: 'POST';\n}\n\nexport function resolveHTTPLinkOptions(\n opts: HTTPLinkBaseOptions<AnyClientTypes>,\n): ResolvedHTTPLinkOptions {\n return {\n url: opts.url.toString(),\n fetch: opts.fetch,\n transformer: getTransformer(opts.transformer),\n methodOverride: opts.methodOverride,\n };\n}\n\n// https://github.com/trpc/trpc/pull/669\nfunction arrayToDict(array: unknown[]) {\n const dict: Record<number, unknown> = {};\n for (let index = 0; index < array.length; index++) {\n const element = array[index];\n dict[index] = element;\n }\n return dict;\n}\n\nconst METHOD = {\n query: 'GET',\n mutation: 'POST',\n subscription: 'PATCH',\n} as const;\n\nexport interface HTTPResult {\n json: TRPCResponse;\n meta: {\n response: ResponseEsque;\n responseJSON?: unknown;\n };\n}\n\ntype GetInputOptions = {\n transformer: CombinedDataTransformer;\n} & ({ input: unknown } | { inputs: unknown[] });\n\nexport function getInput(opts: GetInputOptions) {\n return 'input' in opts\n ? opts.transformer.input.serialize(opts.input)\n : arrayToDict(\n opts.inputs.map((_input) => opts.transformer.input.serialize(_input)),\n );\n}\n\nexport type HTTPBaseRequestOptions = GetInputOptions &\n ResolvedHTTPLinkOptions & {\n type: ProcedureType;\n path: string;\n signal: Maybe<AbortSignal>;\n };\n\ntype GetUrl = (opts: HTTPBaseRequestOptions) => string;\ntype GetBody = (opts: HTTPBaseRequestOptions) => RequestInitEsque['body'];\n\nexport type ContentOptions = {\n trpcAcceptHeader?: TRPCAcceptHeader;\n contentTypeHeader?: string;\n getUrl: GetUrl;\n getBody: GetBody;\n};\n\nexport const getUrl: GetUrl = (opts) => {\n const parts = opts.url.split('?') as [string, string?];\n const base = parts[0].replace(/\\/$/, ''); // Remove any trailing slashes\n\n let url = base + '/' + opts.path;\n const queryParts: string[] = [];\n\n if (parts[1]) {\n queryParts.push(parts[1]);\n }\n if ('inputs' in opts) {\n queryParts.push('batch=1');\n }\n if (opts.type === 'query' || opts.type === 'subscription') {\n const input = getInput(opts);\n if (input !== undefined && opts.methodOverride !== 'POST') {\n queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);\n }\n }\n if (queryParts.length) {\n url += '?' + queryParts.join('&');\n }\n return url;\n};\n\nexport const getBody: GetBody = (opts) => {\n if (opts.type === 'query' && opts.methodOverride !== 'POST') {\n return undefined;\n }\n const input = getInput(opts);\n return input !== undefined ? JSON.stringify(input) : undefined;\n};\n\nexport type Requester = (\n opts: HTTPBaseRequestOptions & {\n headers: () => HTTPHeaders | Promise<HTTPHeaders>;\n },\n) => Promise<HTTPResult>;\n\nexport const jsonHttpRequester: Requester = (opts) => {\n return httpRequest({\n ...opts,\n contentTypeHeader: 'application/json',\n getUrl,\n getBody,\n });\n};\n\n/**\n * Polyfill for DOMException with AbortError name\n */\nclass AbortError extends Error {\n constructor() {\n const name = 'AbortError';\n super(name);\n this.name = name;\n this.message = name;\n }\n}\n\nexport type HTTPRequestOptions = ContentOptions &\n HTTPBaseRequestOptions & {\n headers: () => HTTPHeaders | Promise<HTTPHeaders>;\n };\n\n/**\n * Polyfill for `signal.throwIfAborted()`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted\n */\nconst throwIfAborted = (signal: Maybe<AbortSignal>) => {\n if (!signal?.aborted) {\n return;\n }\n // If available, use the native implementation\n signal.throwIfAborted?.();\n\n // If we have `DOMException`, use it\n if (typeof DOMException !== 'undefined') {\n throw new DOMException('AbortError', 'AbortError');\n }\n\n // Otherwise, use our own implementation\n throw new AbortError();\n};\n\nexport async function fetchHTTPResponse(opts: HTTPRequestOptions) {\n throwIfAborted(opts.signal);\n\n const url = opts.getUrl(opts);\n const body = opts.getBody(opts);\n const { type } = opts;\n const resolvedHeaders = await (async () => {\n const heads = await opts.headers();\n if (Symbol.iterator in heads) {\n return Object.fromEntries(heads);\n }\n return heads;\n })();\n const headers = {\n ...(opts.contentTypeHeader\n ? { 'content-type': opts.contentTypeHeader }\n : {}),\n ...(opts.trpcAcceptHeader\n ? { 'trpc-accept': opts.trpcAcceptHeader }\n : undefined),\n ...resolvedHeaders,\n };\n\n return getFetch(opts.fetch)(url, {\n method: opts.methodOverride ?? METHOD[type],\n signal: opts.signal,\n body,\n headers,\n });\n}\n\nexport async function httpRequest(\n opts: HTTPRequestOptions,\n): Promise<HTTPResult> {\n const meta = {} as HTTPResult['meta'];\n\n const res = await fetchHTTPResponse(opts);\n meta.response = res;\n\n const json = await res.json();\n\n meta.responseJSON = json;\n\n return {\n json: json as TRPCResponse,\n meta,\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/links/internals/subscriptions.d.ts
|
|
2
|
+
interface ConnectionStateBase<TError> {
|
|
3
|
+
type: 'state';
|
|
4
|
+
data?: never;
|
|
5
|
+
error: TError | null;
|
|
6
|
+
}
|
|
7
|
+
interface ConnectionIdleState extends ConnectionStateBase<null> {
|
|
8
|
+
state: 'idle';
|
|
9
|
+
}
|
|
10
|
+
interface ConnectionConnectingState<TError> extends ConnectionStateBase<TError | null> {
|
|
11
|
+
state: 'connecting';
|
|
12
|
+
}
|
|
13
|
+
interface ConnectionPendingState extends ConnectionStateBase<null> {
|
|
14
|
+
state: 'pending';
|
|
15
|
+
}
|
|
16
|
+
type TRPCConnectionState<TError> = ConnectionIdleState | ConnectionConnectingState<TError> | ConnectionPendingState;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { TRPCConnectionState };
|
|
19
|
+
//# sourceMappingURL=subscriptions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.d.mts","names":[],"sources":["../../../src/links/internals/subscriptions.ts"],"sourcesContent":[],"mappings":";UAAU;EAAA,IAAA,EAAA,OAAA;EAMA,IAAA,CAAA,EAAA,KAAA;EAIA,KAAA,EAPD,MAOC,GAAA,IAAA;;UAJA,mBAAA,SAA4B,mBAKR,CAAA,IAAA,CAAA,CAAA;EAAM,KAA1B,EAAA,MAAA;AAAmB;AAAA,UADnB,yBAKuB,CAAA,MAAQ,CAAA,SAJ/B,mBAIkD,CAJ9B,MAI8B,GAAA,IAAA,CAAA,CAAA;EAIhD,KAAA,EAAA,YAAA;;UAJF,sBAAA,SAA+B,mBAKrC,CAAA,IAAA,CAAA,CAAA;EAAmB,KACO,EAAA,SAAA;;AAC1B,KAHQ,mBAGR,CAAA,MAAA,CAAA,GAFA,mBAEA,GADA,yBACA,CAD0B,MAC1B,CAAA,GAAA,sBAAA"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
//#region src/links/internals/subscriptions.d.ts
|
|
1
2
|
interface ConnectionStateBase<TError> {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type: 'state';
|
|
4
|
+
data?: never;
|
|
5
|
+
error: TError | null;
|
|
5
6
|
}
|
|
6
7
|
interface ConnectionIdleState extends ConnectionStateBase<null> {
|
|
7
|
-
|
|
8
|
+
state: 'idle';
|
|
8
9
|
}
|
|
9
10
|
interface ConnectionConnectingState<TError> extends ConnectionStateBase<TError | null> {
|
|
10
|
-
|
|
11
|
+
state: 'connecting';
|
|
11
12
|
}
|
|
12
13
|
interface ConnectionPendingState extends ConnectionStateBase<null> {
|
|
13
|
-
|
|
14
|
+
state: 'pending';
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
type TRPCConnectionState<TError> = ConnectionIdleState | ConnectionConnectingState<TError> | ConnectionPendingState;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { TRPCConnectionState };
|
|
17
19
|
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.d.ts","
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","names":[],"sources":["../../../src/links/internals/subscriptions.ts"],"sourcesContent":[],"mappings":";UAAU;EAAA,IAAA,EAAA,OAAA;EAMA,IAAA,CAAA,EAAA,KAAA;EAIA,KAAA,EAPD,MAOC,GAAA,IAAA;;UAJA,mBAAA,SAA4B,mBAKR,CAAA,IAAA,CAAA,CAAA;EAAM,KAA1B,EAAA,MAAA;AAAmB;AAAA,UADnB,yBAKuB,CAAA,MAAQ,CAAA,SAJ/B,mBAIkD,CAJ9B,MAI8B,GAAA,IAAA,CAAA,CAAA;EAIhD,KAAA,EAAA,YAAA;;UAJF,sBAAA,SAA+B,mBAKrC,CAAA,IAAA,CAAA,CAAA;EAAmB,KACO,EAAA,SAAA;;AAC1B,KAHQ,mBAGR,CAAA,MAAA,CAAA,GAFA,mBAEA,GADA,yBACA,CAD0B,MAC1B,CAAA,GAAA,sBAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TRPCRequestInfo } from "@trpc/server/http";
|
|
2
|
+
|
|
3
|
+
//#region src/links/internals/urlWithConnectionParams.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A value that can be wrapped in callback
|
|
7
|
+
*/
|
|
8
|
+
type CallbackOrValue<T> = T | (() => T | Promise<T>);
|
|
9
|
+
interface UrlOptionsWithConnectionParams {
|
|
10
|
+
/**
|
|
11
|
+
* The URL to connect to (can be a function that returns a URL)
|
|
12
|
+
*/
|
|
13
|
+
url: CallbackOrValue<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Connection params that are available in `createContext()`
|
|
16
|
+
* - For `wsLink`/`wsClient`, these are sent as the first message
|
|
17
|
+
* - For `httpSubscriptionLink`, these are serialized as part of the URL under the `connectionParams` query
|
|
18
|
+
*/
|
|
19
|
+
connectionParams?: CallbackOrValue<TRPCRequestInfo['connectionParams']>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=urlWithConnectionParams.d.ts.map
|
|
22
|
+
//#endregion
|
|
23
|
+
export { UrlOptionsWithConnectionParams };
|
|
24
|
+
//# sourceMappingURL=urlWithConnectionParams.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlWithConnectionParams.d.mts","names":[],"sources":["../../../src/links/internals/urlWithConnectionParams.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkBuD,KAA3C,eAA2C,CAAA,CAAA,CAAA,GAAtB,CAAsB,GAAA,CAAA,GAAA,GAAX,CAAW,GAAP,OAAO,CAAC,CAAD,CAAA,CAAA;AAEtC,UAAA,8BAAA,CAA8B;EAAA;;;EAWK,GAA/B,EAPd,eAOc,CAAA,MAAA,CAAA;EAAe;;;;;qBAAf,gBAAgB"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare const resultOf: <T, TArgs extends any[]>(value: T | ((...args: TArgs) => T), ...args: TArgs) => T;
|
|
1
|
+
import { TRPCRequestInfo } from "@trpc/server/http";
|
|
2
|
+
|
|
3
|
+
//#region src/links/internals/urlWithConnectionParams.d.ts
|
|
4
|
+
|
|
7
5
|
/**
|
|
8
6
|
* A value that can be wrapped in callback
|
|
9
7
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
type CallbackOrValue<T> = T | (() => T | Promise<T>);
|
|
9
|
+
interface UrlOptionsWithConnectionParams {
|
|
10
|
+
/**
|
|
11
|
+
* The URL to connect to (can be a function that returns a URL)
|
|
12
|
+
*/
|
|
13
|
+
url: CallbackOrValue<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Connection params that are available in `createContext()`
|
|
16
|
+
* - For `wsLink`/`wsClient`, these are sent as the first message
|
|
17
|
+
* - For `httpSubscriptionLink`, these are serialized as part of the URL under the `connectionParams` query
|
|
18
|
+
*/
|
|
19
|
+
connectionParams?: CallbackOrValue<TRPCRequestInfo['connectionParams']>;
|
|
22
20
|
}
|
|
21
|
+
//# sourceMappingURL=urlWithConnectionParams.d.ts.map
|
|
22
|
+
//#endregion
|
|
23
|
+
export { UrlOptionsWithConnectionParams };
|
|
23
24
|
//# sourceMappingURL=urlWithConnectionParams.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlWithConnectionParams.d.ts","
|
|
1
|
+
{"version":3,"file":"urlWithConnectionParams.d.ts","names":[],"sources":["../../../src/links/internals/urlWithConnectionParams.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkBuD,KAA3C,eAA2C,CAAA,CAAA,CAAA,GAAtB,CAAsB,GAAA,CAAA,GAAA,GAAX,CAAW,GAAP,OAAO,CAAC,CAAD,CAAA,CAAA;AAEtC,UAAA,8BAAA,CAA8B;EAAA;;;EAWK,GAA/B,EAPd,eAOc,CAAA,MAAA,CAAA;EAAe;;;;;qBAAf,gBAAgB"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
|
|
2
|
+
//#region src/links/internals/urlWithConnectionParams.ts
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
* Get the result of a value or function that returns a value
|
|
5
|
+
* It also optionally accepts typesafe arguments for the function
|
|
6
|
+
*/
|
|
7
|
+
const resultOf = (value, ...args) => {
|
|
8
|
+
return typeof value === "function" ? value(...args) : value;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.resultOf = resultOf;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
//#region src/links/internals/urlWithConnectionParams.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Get the result of a value or function that returns a value
|
|
4
|
+
* It also optionally accepts typesafe arguments for the function
|
|
5
|
+
*/
|
|
6
|
+
const resultOf = (value, ...args) => {
|
|
7
|
+
return typeof value === "function" ? value(...args) : value;
|
|
6
8
|
};
|
|
7
9
|
|
|
10
|
+
//#endregion
|
|
8
11
|
export { resultOf };
|
|
12
|
+
//# sourceMappingURL=urlWithConnectionParams.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlWithConnectionParams.mjs","names":["value: T | ((...args: TArgs) => T)"],"sources":["../../../src/links/internals/urlWithConnectionParams.ts"],"sourcesContent":["import { type TRPCRequestInfo } from '@trpc/server/http';\n\n/**\n * Get the result of a value or function that returns a value\n * It also optionally accepts typesafe arguments for the function\n */\nexport const resultOf = <T, TArgs extends any[]>(\n value: T | ((...args: TArgs) => T),\n ...args: TArgs\n): T => {\n return typeof value === 'function'\n ? (value as (...args: TArgs) => T)(...args)\n : value;\n};\n\n/**\n * A value that can be wrapped in callback\n */\nexport type CallbackOrValue<T> = T | (() => T | Promise<T>);\n\nexport interface UrlOptionsWithConnectionParams {\n /**\n * The URL to connect to (can be a function that returns a URL)\n */\n url: CallbackOrValue<string>;\n\n /**\n * Connection params that are available in `createContext()`\n * - For `wsLink`/`wsClient`, these are sent as the first message\n * - For `httpSubscriptionLink`, these are serialized as part of the URL under the `connectionParams` query\n */\n connectionParams?: CallbackOrValue<TRPCRequestInfo['connectionParams']>;\n}\n"],"mappings":";;;;;AAMA,MAAa,WAAW,CACtBA,OACA,GAAG,SACG;AACN,eAAc,UAAU,aACpB,AAAC,MAAgC,GAAG,KAAK,GACzC;AACL"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TRPCLink } from "./types.mjs";
|
|
2
|
+
import { TransformerOptions } from "../internals/transformer.mjs";
|
|
3
|
+
import { AnyRouter, ErrorHandlerOptions, inferClientTypes, inferRouterContext } from "@trpc/server/unstable-core-do-not-import";
|
|
4
|
+
|
|
5
|
+
//#region src/links/localLink.d.ts
|
|
6
|
+
type LocalLinkOptions<TRouter extends AnyRouter> = {
|
|
7
|
+
router: TRouter;
|
|
8
|
+
createContext: () => Promise<inferRouterContext<TRouter>>;
|
|
9
|
+
onError?: (opts: ErrorHandlerOptions<inferRouterContext<TRouter>>) => void;
|
|
10
|
+
} & TransformerOptions<inferClientTypes<TRouter>>;
|
|
11
|
+
/**
|
|
12
|
+
* localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
|
|
13
|
+
*
|
|
14
|
+
* @see https://trpc.io/docs/links/localLink
|
|
15
|
+
*/
|
|
16
|
+
declare function experimental_localLink<TRouter extends AnyRouter>(opts: LocalLinkOptions<TRouter>): TRPCLink<TRouter>;
|
|
17
|
+
//# sourceMappingURL=localLink.d.ts.map
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { LocalLinkOptions, experimental_localLink };
|
|
21
|
+
//# sourceMappingURL=localLink.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localLink.d.mts","names":[],"sources":["../../src/links/localLink.ts"],"sourcesContent":[],"mappings":";;;;;KA4BY,iCAAiC;UACnC;EADE,aAAA,EAAA,GAAA,GAEW,OAFK,CAEG,kBAFH,CAEsB,OAFtB,CAAA,CAAA;EAAA,OAAA,CAAA,EAAA,CAAA,IAAA,EAGT,mBAHS,CAGW,kBAHX,CAG8B,OAH9B,CAAA,CAAA,EAAA,GAAA,IAAA;CAAA,GAIxB,kBAJyC,CAItB,gBAJsB,CAIL,OAJK,CAAA,CAAA;;;;;;AAGN,iBAQvB,sBARuB,CAAA,gBAQgB,SARhB,CAAA,CAAA,IAAA,EAS/B,gBAT+B,CASd,OATc,CAAA,CAAA,EAUpC,QAVoC,CAU3B,OAV2B,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TRPCLink } from "./types.js";
|
|
2
|
+
import { TransformerOptions } from "../internals/transformer.js";
|
|
3
|
+
import { AnyRouter, ErrorHandlerOptions, inferClientTypes, inferRouterContext } from "@trpc/server/unstable-core-do-not-import";
|
|
4
|
+
|
|
5
|
+
//#region src/links/localLink.d.ts
|
|
6
|
+
type LocalLinkOptions<TRouter extends AnyRouter> = {
|
|
7
|
+
router: TRouter;
|
|
8
|
+
createContext: () => Promise<inferRouterContext<TRouter>>;
|
|
9
|
+
onError?: (opts: ErrorHandlerOptions<inferRouterContext<TRouter>>) => void;
|
|
10
|
+
} & TransformerOptions<inferClientTypes<TRouter>>;
|
|
11
|
+
/**
|
|
12
|
+
* localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
|
|
13
|
+
*
|
|
14
|
+
* @see https://trpc.io/docs/links/localLink
|
|
15
|
+
*/
|
|
16
|
+
declare function experimental_localLink<TRouter extends AnyRouter>(opts: LocalLinkOptions<TRouter>): TRPCLink<TRouter>;
|
|
17
|
+
//# sourceMappingURL=localLink.d.ts.map
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { LocalLinkOptions, experimental_localLink };
|
|
21
|
+
//# sourceMappingURL=localLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localLink.d.ts","names":[],"sources":["../../src/links/localLink.ts"],"sourcesContent":[],"mappings":";;;;;KA4BY,iCAAiC;UACnC;EADE,aAAA,EAAA,GAAA,GAEW,OAFK,CAEG,kBAFH,CAEsB,OAFtB,CAAA,CAAA;EAAA,OAAA,CAAA,EAAA,CAAA,IAAA,EAGT,mBAHS,CAGW,kBAHX,CAG8B,OAH9B,CAAA,CAAA,EAAA,GAAA,IAAA;CAAA,GAIxB,kBAJyC,CAItB,gBAJsB,CAIL,OAJK,CAAA,CAAA;;;;;;AAGN,iBAQvB,sBARuB,CAAA,gBAQgB,SARhB,CAAA,CAAA,IAAA,EAS/B,gBAT+B,CASd,OATc,CAAA,CAAA,EAUpC,QAVoC,CAU3B,OAV2B,CAAA"}
|