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