@trpc/client 11.4.0 → 11.4.2-canary.1
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-CjKyS10w.mjs +47 -0
- package/dist/{TRPCClientError-COkhCKf3.mjs.map → TRPCClientError-CjKyS10w.mjs.map} +1 -1
- package/dist/{TRPCClientError-CGgRtttT.cjs → TRPCClientError-Dey88Uiy.cjs} +15 -24
- package/dist/{httpBatchLink-DIfnmmcu.mjs → httpBatchLink-BfUVex5U.mjs} +33 -24
- package/dist/{httpBatchLink-DIfnmmcu.mjs.map → httpBatchLink-BfUVex5U.mjs.map} +1 -1
- package/dist/{httpBatchLink-CIC9PZ_Z.cjs → httpBatchLink-JKXaA6dG.cjs} +32 -23
- package/dist/{httpBatchLink.d-BN2Iw_cK.d.mts → httpBatchLink.d-CAaMQOtX.d.mts} +3 -3
- package/dist/{httpBatchLink.d-BN2Iw_cK.d.mts.map → httpBatchLink.d-CAaMQOtX.d.mts.map} +1 -1
- package/dist/{httpLink-BbVj_TgM.cjs → httpLink-CbZZVG--.cjs} +10 -11
- package/dist/{httpLink-9bpwQ15c.mjs → httpLink-Dptv1zSJ.mjs} +11 -12
- package/dist/{httpLink-9bpwQ15c.mjs.map → httpLink-Dptv1zSJ.mjs.map} +1 -1
- package/dist/{httpLink.d-CTSOARfE.d.mts → httpLink.d-B0nHKy2W.d.mts} +3 -3
- package/dist/{httpLink.d-CTSOARfE.d.mts.map → httpLink.d-B0nHKy2W.d.mts.map} +1 -1
- package/dist/{httpUtils-3pbQzhUL.mjs → httpUtils-ZiawzpnD.mjs} +12 -13
- package/dist/{httpUtils-3pbQzhUL.mjs.map → httpUtils-ZiawzpnD.mjs.map} +1 -1
- package/dist/{httpUtils-Buf6jCgh.cjs → httpUtils-rn2lxsJO.cjs} +12 -12
- package/dist/{httpUtils.d-C8wPxU79.d.mts → httpUtils.d-cQRQZrfo.d.mts} +3 -3
- package/dist/{httpUtils.d-C8wPxU79.d.mts.map → httpUtils.d-cQRQZrfo.d.mts.map} +1 -1
- package/dist/index.cjs +268 -104
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +269 -131
- package/dist/index.mjs.map +1 -1
- package/dist/links/httpBatchLink.cjs +5 -4
- package/dist/links/httpBatchLink.d.mts +5 -5
- package/dist/links/httpBatchLink.mjs +5 -4
- package/dist/links/httpLink.cjs +5 -4
- package/dist/links/httpLink.d.mts +5 -5
- package/dist/links/httpLink.mjs +5 -4
- package/dist/links/loggerLink.cjs +2 -1
- package/dist/links/loggerLink.d.mts +3 -3
- package/dist/links/loggerLink.mjs +2 -1
- package/dist/links/splitLink.d.mts +3 -3
- package/dist/links/splitLink.mjs +1 -1
- package/dist/links/wsLink/wsLink.cjs +4 -3
- package/dist/links/wsLink/wsLink.d.mts +4 -4
- package/dist/links/wsLink/wsLink.mjs +4 -3
- package/dist/{loggerLink-CsDfg5Bb.cjs → loggerLink-CuYvRzyH.cjs} +14 -21
- package/dist/{loggerLink-PGBSQFcR.mjs → loggerLink-ineCN1PO.mjs} +15 -22
- package/dist/{loggerLink-PGBSQFcR.mjs.map → loggerLink-ineCN1PO.mjs.map} +1 -1
- package/dist/{loggerLink.d-CZjK1CXm.d.mts → loggerLink.d-g_uYSbus.d.mts} +2 -2
- package/dist/{loggerLink.d-CZjK1CXm.d.mts.map → loggerLink.d-g_uYSbus.d.mts.map} +1 -1
- package/dist/objectSpread2-Bsvh_OqM.cjs +100 -0
- package/dist/objectSpread2-BvkFp-_Y.mjs +114 -0
- package/dist/objectSpread2-BvkFp-_Y.mjs.map +1 -0
- package/dist/{splitLink-BVblHq4n.mjs → splitLink-B7Cuf2c_.mjs} +1 -1
- package/dist/{splitLink-BVblHq4n.mjs.map → splitLink-B7Cuf2c_.mjs.map} +1 -1
- package/dist/{splitLink.d-BAqgq0NG.d.mts → splitLink.d-od8YIcex.d.mts} +2 -2
- package/dist/{splitLink.d-BAqgq0NG.d.mts.map → splitLink.d-od8YIcex.d.mts.map} +1 -1
- package/dist/{subscriptions.d-U92STdZl.d.mts → subscriptions.d-Dlr1nWGD.d.mts} +1 -1
- package/dist/{subscriptions.d-U92STdZl.d.mts.map → subscriptions.d-Dlr1nWGD.d.mts.map} +1 -1
- package/dist/{types.d-DXbqQLCC.d.mts → types.d-POgEdUB1.d.mts} +2 -2
- package/dist/{types.d-DXbqQLCC.d.mts.map → types.d-POgEdUB1.d.mts.map} +1 -1
- package/dist/{unstable-internals-DU4WecoG.mjs → unstable-internals-Bg7n9BBj.mjs} +1 -1
- package/dist/{unstable-internals-DU4WecoG.mjs.map → unstable-internals-Bg7n9BBj.mjs.map} +1 -1
- package/dist/unstable-internals.cjs +1 -1
- package/dist/{unstable-internals.d-DyLd-B0J.d.mts → unstable-internals.d-BOmV7EK1.d.mts} +1 -1
- package/dist/{unstable-internals.d-DyLd-B0J.d.mts.map → unstable-internals.d-BOmV7EK1.d.mts.map} +1 -1
- package/dist/unstable-internals.d.mts +2 -2
- package/dist/unstable-internals.mjs +1 -1
- package/dist/{wsLink-DhJ50EC5.cjs → wsLink-BcTLPVgc.cjs} +93 -106
- package/dist/{wsLink-DbSHOzlB.mjs → wsLink-H5IjZfJW.mjs} +94 -107
- package/dist/wsLink-H5IjZfJW.mjs.map +1 -0
- package/dist/{wsLink.d-BqO7ltN_.d.mts → wsLink.d-BZxAJRBO.d.mts} +4 -4
- package/dist/{wsLink.d-BqO7ltN_.d.mts.map → wsLink.d-BZxAJRBO.d.mts.map} +1 -1
- package/package.json +32 -32
- package/dist/TRPCClientError-COkhCKf3.mjs +0 -56
- package/dist/wsLink-DbSHOzlB.mjs.map +0 -1
- /package/dist/{unstable-internals-CYBH4jbF.cjs → unstable-internals-M84gUQCV.cjs} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
2
|
const require_splitLink = require('./splitLink-BMgxggng.cjs');
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
3
|
+
const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
|
|
4
|
+
const require_TRPCClientError = require('./TRPCClientError-Dey88Uiy.cjs');
|
|
5
|
+
const require_httpUtils = require('./httpUtils-rn2lxsJO.cjs');
|
|
6
|
+
const require_httpLink = require('./httpLink-CbZZVG--.cjs');
|
|
7
|
+
const require_httpBatchLink = require('./httpBatchLink-JKXaA6dG.cjs');
|
|
8
|
+
const require_unstable_internals = require('./unstable-internals-M84gUQCV.cjs');
|
|
9
|
+
const require_loggerLink = require('./loggerLink-CuYvRzyH.cjs');
|
|
10
|
+
const require_wsLink = require('./wsLink-BcTLPVgc.cjs');
|
|
10
11
|
const __trpc_server_observable = require_chunk.__toESM(require("@trpc/server/observable"));
|
|
11
12
|
const __trpc_server_unstable_core_do_not_import = require_chunk.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
|
12
13
|
const __trpc_server = require_chunk.__toESM(require("@trpc/server"));
|
|
13
14
|
const __trpc_server_rpc = require_chunk.__toESM(require("@trpc/server/rpc"));
|
|
14
15
|
|
|
15
16
|
//#region src/internals/TRPCUntypedClient.ts
|
|
17
|
+
var import_defineProperty = require_chunk.__toESM(require_objectSpread2$1.require_defineProperty(), 1);
|
|
18
|
+
var import_objectSpread2$4 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
|
16
19
|
var TRPCUntypedClient = class {
|
|
17
|
-
links;
|
|
18
|
-
runtime;
|
|
19
|
-
requestId;
|
|
20
20
|
constructor(opts) {
|
|
21
|
+
(0, import_defineProperty.default)(this, "links", void 0);
|
|
22
|
+
(0, import_defineProperty.default)(this, "runtime", void 0);
|
|
23
|
+
(0, import_defineProperty.default)(this, "requestId", void 0);
|
|
21
24
|
this.requestId = 0;
|
|
22
25
|
this.runtime = {};
|
|
23
26
|
this.links = opts.links.map((link) => link(this.runtime));
|
|
24
27
|
}
|
|
25
28
|
$request(opts) {
|
|
29
|
+
var _opts$context;
|
|
26
30
|
const chain$ = require_splitLink.createChain({
|
|
27
31
|
links: this.links,
|
|
28
|
-
op: {
|
|
29
|
-
|
|
30
|
-
context: opts.context ?? {},
|
|
32
|
+
op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
|
|
33
|
+
context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
|
|
31
34
|
id: ++this.requestId
|
|
32
|
-
}
|
|
35
|
+
})
|
|
33
36
|
});
|
|
34
37
|
return chain$.pipe((0, __trpc_server_observable.share)());
|
|
35
38
|
}
|
|
36
39
|
async requestAsPromise(opts) {
|
|
40
|
+
var _this = this;
|
|
37
41
|
try {
|
|
38
|
-
const req$ =
|
|
42
|
+
const req$ = _this.$request(opts);
|
|
39
43
|
const envelope = await (0, __trpc_server_observable.observableToPromise)(req$);
|
|
40
44
|
const data = envelope.result.data;
|
|
41
45
|
return data;
|
|
@@ -48,8 +52,8 @@ var TRPCUntypedClient = class {
|
|
|
48
52
|
type: "query",
|
|
49
53
|
path,
|
|
50
54
|
input,
|
|
51
|
-
context: opts
|
|
52
|
-
signal: opts
|
|
55
|
+
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
56
|
+
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
mutation(path, input, opts) {
|
|
@@ -57,8 +61,8 @@ var TRPCUntypedClient = class {
|
|
|
57
61
|
type: "mutation",
|
|
58
62
|
path,
|
|
59
63
|
input,
|
|
60
|
-
context: opts
|
|
61
|
-
signal: opts
|
|
64
|
+
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
65
|
+
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
subscription(path, input, opts) {
|
|
@@ -73,29 +77,35 @@ var TRPCUntypedClient = class {
|
|
|
73
77
|
next(envelope) {
|
|
74
78
|
switch (envelope.result.type) {
|
|
75
79
|
case "state": {
|
|
76
|
-
|
|
80
|
+
var _opts$onConnectionSta;
|
|
81
|
+
(_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
|
|
77
82
|
break;
|
|
78
83
|
}
|
|
79
84
|
case "started": {
|
|
80
|
-
|
|
85
|
+
var _opts$onStarted;
|
|
86
|
+
(_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
|
|
81
87
|
break;
|
|
82
88
|
}
|
|
83
89
|
case "stopped": {
|
|
84
|
-
|
|
90
|
+
var _opts$onStopped;
|
|
91
|
+
(_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
|
|
85
92
|
break;
|
|
86
93
|
}
|
|
87
94
|
case "data":
|
|
88
95
|
case void 0: {
|
|
89
|
-
|
|
96
|
+
var _opts$onData;
|
|
97
|
+
(_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
|
|
90
98
|
break;
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
101
|
},
|
|
94
102
|
error(err) {
|
|
95
|
-
|
|
103
|
+
var _opts$onError;
|
|
104
|
+
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
|
|
96
105
|
},
|
|
97
106
|
complete() {
|
|
98
|
-
|
|
107
|
+
var _opts$onComplete;
|
|
108
|
+
(_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
|
|
99
109
|
}
|
|
100
110
|
});
|
|
101
111
|
}
|
|
@@ -149,13 +159,15 @@ function getUntypedClient(client) {
|
|
|
149
159
|
|
|
150
160
|
//#endregion
|
|
151
161
|
//#region src/links/httpBatchStreamLink.ts
|
|
162
|
+
var import_objectSpread2$3 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
|
152
163
|
/**
|
|
153
164
|
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
154
165
|
*/
|
|
155
166
|
function httpBatchStreamLink(opts) {
|
|
167
|
+
var _opts$maxURLLength, _opts$maxItems;
|
|
156
168
|
const resolvedOpts = require_httpUtils.resolveHTTPLinkOptions(opts);
|
|
157
|
-
const maxURLLength = opts.maxURLLength
|
|
158
|
-
const maxItems = opts.maxItems
|
|
169
|
+
const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
|
|
170
|
+
const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
|
|
159
171
|
return () => {
|
|
160
172
|
const batchLoader = (type) => {
|
|
161
173
|
return {
|
|
@@ -164,13 +176,12 @@ function httpBatchStreamLink(opts) {
|
|
|
164
176
|
if (batchOps.length > maxItems) return false;
|
|
165
177
|
const path = batchOps.map((op) => op.path).join(",");
|
|
166
178
|
const inputs = batchOps.map((op) => op.input);
|
|
167
|
-
const url = require_httpUtils.getUrl({
|
|
168
|
-
...resolvedOpts,
|
|
179
|
+
const url = require_httpUtils.getUrl((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
|
169
180
|
type,
|
|
170
181
|
path,
|
|
171
182
|
inputs,
|
|
172
183
|
signal: null
|
|
173
|
-
});
|
|
184
|
+
}));
|
|
174
185
|
return url.length <= maxURLLength;
|
|
175
186
|
},
|
|
176
187
|
async fetch(batchOps) {
|
|
@@ -178,8 +189,7 @@ function httpBatchStreamLink(opts) {
|
|
|
178
189
|
const inputs = batchOps.map((op) => op.input);
|
|
179
190
|
const batchSignals = require_httpBatchLink.allAbortSignals(...batchOps.map((op) => op.signal));
|
|
180
191
|
const abortController = new AbortController();
|
|
181
|
-
const responsePromise = require_httpUtils.fetchHTTPResponse({
|
|
182
|
-
...resolvedOpts,
|
|
192
|
+
const responsePromise = require_httpUtils.fetchHTTPResponse((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
|
183
193
|
signal: require_httpBatchLink.raceAbortSignals(batchSignals, abortController.signal),
|
|
184
194
|
type,
|
|
185
195
|
contentTypeHeader: "application/json",
|
|
@@ -193,7 +203,7 @@ function httpBatchStreamLink(opts) {
|
|
|
193
203
|
if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
|
|
194
204
|
return opts.headers;
|
|
195
205
|
}
|
|
196
|
-
});
|
|
206
|
+
}));
|
|
197
207
|
const res = await responsePromise;
|
|
198
208
|
const [head] = await (0, __trpc_server_unstable_core_do_not_import.jsonlStreamConsumer)({
|
|
199
209
|
from: res.body,
|
|
@@ -251,7 +261,7 @@ function httpBatchStreamLink(opts) {
|
|
|
251
261
|
}
|
|
252
262
|
observer.complete();
|
|
253
263
|
}).catch((err) => {
|
|
254
|
-
observer.error(require_TRPCClientError.TRPCClientError.from(err, { meta: _res
|
|
264
|
+
observer.error(require_TRPCClientError.TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
|
|
255
265
|
});
|
|
256
266
|
return () => {};
|
|
257
267
|
});
|
|
@@ -265,17 +275,63 @@ const unstable_httpBatchStreamLink = httpBatchStreamLink;
|
|
|
265
275
|
|
|
266
276
|
//#endregion
|
|
267
277
|
//#region src/internals/inputWithTrackedEventId.ts
|
|
278
|
+
var import_objectSpread2$2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
|
268
279
|
function inputWithTrackedEventId(input, lastEventId) {
|
|
269
280
|
if (!lastEventId) return input;
|
|
270
281
|
if (input != null && typeof input !== "object") return input;
|
|
271
|
-
return {
|
|
272
|
-
...input ?? {},
|
|
273
|
-
lastEventId
|
|
274
|
-
};
|
|
282
|
+
return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, input !== null && input !== void 0 ? input : {}), {}, { lastEventId });
|
|
275
283
|
}
|
|
276
284
|
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js
|
|
287
|
+
var require_asyncIterator = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
|
|
288
|
+
function _asyncIterator$1(r) {
|
|
289
|
+
var n, t, o, e = 2;
|
|
290
|
+
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
|
|
291
|
+
if (t && null != (n = r[t])) return n.call(r);
|
|
292
|
+
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
|
293
|
+
t = "@@asyncIterator", o = "@@iterator";
|
|
294
|
+
}
|
|
295
|
+
throw new TypeError("Object is not async iterable");
|
|
296
|
+
}
|
|
297
|
+
function AsyncFromSyncIterator(r) {
|
|
298
|
+
function AsyncFromSyncIteratorContinuation(r$1) {
|
|
299
|
+
if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
|
|
300
|
+
var n = r$1.done;
|
|
301
|
+
return Promise.resolve(r$1.value).then(function(r$2) {
|
|
302
|
+
return {
|
|
303
|
+
value: r$2,
|
|
304
|
+
done: n
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
|
|
309
|
+
this.s = r$1, this.n = r$1.next;
|
|
310
|
+
}, AsyncFromSyncIterator.prototype = {
|
|
311
|
+
s: null,
|
|
312
|
+
n: null,
|
|
313
|
+
next: function next() {
|
|
314
|
+
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
315
|
+
},
|
|
316
|
+
"return": function _return(r$1) {
|
|
317
|
+
var n = this.s["return"];
|
|
318
|
+
return void 0 === n ? Promise.resolve({
|
|
319
|
+
value: r$1,
|
|
320
|
+
done: !0
|
|
321
|
+
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
322
|
+
},
|
|
323
|
+
"throw": function _throw(r$1) {
|
|
324
|
+
var n = this.s["return"];
|
|
325
|
+
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
326
|
+
}
|
|
327
|
+
}, new AsyncFromSyncIterator(r);
|
|
328
|
+
}
|
|
329
|
+
module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
330
|
+
} });
|
|
331
|
+
|
|
277
332
|
//#endregion
|
|
278
333
|
//#region src/links/httpSubscriptionLink.ts
|
|
334
|
+
var import_asyncIterator = require_chunk.__toESM(require_asyncIterator(), 1);
|
|
279
335
|
async function urlWithConnectionParams(opts) {
|
|
280
336
|
let url = await require_wsLink.resultOf(opts.url);
|
|
281
337
|
if (opts.connectionParams) {
|
|
@@ -293,6 +349,7 @@ function httpSubscriptionLink(opts) {
|
|
|
293
349
|
return () => {
|
|
294
350
|
return ({ op }) => {
|
|
295
351
|
return (0, __trpc_server_observable.observable)((observer) => {
|
|
352
|
+
var _opts$EventSource;
|
|
296
353
|
const { type, path, input } = op;
|
|
297
354
|
/* istanbul ignore if -- @preserve */
|
|
298
355
|
if (type !== "subscription") throw new Error("httpSubscriptionLink only supports subscriptions");
|
|
@@ -311,7 +368,7 @@ function httpSubscriptionLink(opts) {
|
|
|
311
368
|
init: () => require_wsLink.resultOf(opts.eventSourceOptions, { op }),
|
|
312
369
|
signal,
|
|
313
370
|
deserialize: transformer.output.deserialize,
|
|
314
|
-
EventSource: opts.EventSource
|
|
371
|
+
EventSource: (_opts$EventSource = opts.EventSource) !== null && _opts$EventSource !== void 0 ? _opts$EventSource : globalThis.EventSource
|
|
315
372
|
});
|
|
316
373
|
const connectionState = (0, __trpc_server_observable.behaviorSubject)({
|
|
317
374
|
type: "state",
|
|
@@ -322,63 +379,80 @@ function httpSubscriptionLink(opts) {
|
|
|
322
379
|
observer.next({ result: state });
|
|
323
380
|
} });
|
|
324
381
|
(0, __trpc_server_unstable_core_do_not_import.run)(async () => {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
382
|
+
var _iteratorAbruptCompletion = false;
|
|
383
|
+
var _didIteratorError = false;
|
|
384
|
+
var _iteratorError;
|
|
385
|
+
try {
|
|
386
|
+
for (var _iterator = (0, import_asyncIterator.default)(eventSourceStream), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
|
387
|
+
const chunk = _step.value;
|
|
388
|
+
switch (chunk.type) {
|
|
389
|
+
case "ping": break;
|
|
390
|
+
case "data":
|
|
391
|
+
const chunkData = chunk.data;
|
|
392
|
+
let result;
|
|
393
|
+
if (chunkData.id) {
|
|
394
|
+
lastEventId = chunkData.id;
|
|
395
|
+
result = {
|
|
396
|
+
id: chunkData.id,
|
|
397
|
+
data: chunkData
|
|
398
|
+
};
|
|
399
|
+
} else result = { data: chunkData.data };
|
|
400
|
+
observer.next({
|
|
401
|
+
result,
|
|
402
|
+
context: { eventSource: chunk.eventSource }
|
|
403
|
+
});
|
|
404
|
+
break;
|
|
405
|
+
case "connected": {
|
|
406
|
+
observer.next({
|
|
407
|
+
result: { type: "started" },
|
|
408
|
+
context: { eventSource: chunk.eventSource }
|
|
409
|
+
});
|
|
410
|
+
connectionState.next({
|
|
411
|
+
type: "state",
|
|
412
|
+
state: "pending",
|
|
413
|
+
error: null
|
|
414
|
+
});
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
case "serialized-error": {
|
|
418
|
+
const error = require_TRPCClientError.TRPCClientError.from({ error: chunk.error });
|
|
419
|
+
if (__trpc_server_unstable_core_do_not_import.retryableRpcCodes.includes(chunk.error.code)) {
|
|
420
|
+
connectionState.next({
|
|
421
|
+
type: "state",
|
|
422
|
+
state: "connecting",
|
|
423
|
+
error
|
|
424
|
+
});
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
throw error;
|
|
428
|
+
}
|
|
429
|
+
case "connecting": {
|
|
430
|
+
const lastState = connectionState.get();
|
|
431
|
+
const error = chunk.event && require_TRPCClientError.TRPCClientError.from(chunk.event);
|
|
432
|
+
if (!error && lastState.state === "connecting") break;
|
|
433
|
+
connectionState.next({
|
|
434
|
+
type: "state",
|
|
435
|
+
state: "connecting",
|
|
436
|
+
error
|
|
437
|
+
});
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
case "timeout": connectionState.next({
|
|
358
441
|
type: "state",
|
|
359
442
|
state: "connecting",
|
|
360
|
-
error
|
|
443
|
+
error: new require_TRPCClientError.TRPCClientError(`Timeout of ${chunk.ms}ms reached while waiting for a response`)
|
|
361
444
|
});
|
|
362
|
-
break;
|
|
363
445
|
}
|
|
364
|
-
throw error;
|
|
365
446
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
});
|
|
375
|
-
break;
|
|
447
|
+
} catch (err) {
|
|
448
|
+
_didIteratorError = true;
|
|
449
|
+
_iteratorError = err;
|
|
450
|
+
} finally {
|
|
451
|
+
try {
|
|
452
|
+
if (_iteratorAbruptCompletion && _iterator.return != null) await _iterator.return();
|
|
453
|
+
} finally {
|
|
454
|
+
if (_didIteratorError) throw _iteratorError;
|
|
376
455
|
}
|
|
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
456
|
}
|
|
383
457
|
observer.next({ result: { type: "stopped" } });
|
|
384
458
|
connectionState.next({
|
|
@@ -406,6 +480,7 @@ const unstable_httpSubscriptionLink = httpSubscriptionLink;
|
|
|
406
480
|
|
|
407
481
|
//#endregion
|
|
408
482
|
//#region src/links/retryLink.ts
|
|
483
|
+
var import_objectSpread2$1 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
|
409
484
|
/**
|
|
410
485
|
* @see https://trpc.io/docs/v11/client/links/retryLink
|
|
411
486
|
*/
|
|
@@ -420,15 +495,13 @@ function retryLink(opts) {
|
|
|
420
495
|
function opWithLastEventId() {
|
|
421
496
|
const op = callOpts.op;
|
|
422
497
|
if (!lastEventId) return op;
|
|
423
|
-
return {
|
|
424
|
-
...op,
|
|
425
|
-
input: inputWithTrackedEventId(op.input, lastEventId)
|
|
426
|
-
};
|
|
498
|
+
return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, op), {}, { input: inputWithTrackedEventId(op.input, lastEventId) });
|
|
427
499
|
}
|
|
428
500
|
function attempt(attempts) {
|
|
429
501
|
const op = opWithLastEventId();
|
|
430
502
|
next$ = callOpts.next(op).subscribe({
|
|
431
503
|
error(error) {
|
|
504
|
+
var _opts$retryDelayMs, _opts$retryDelayMs2;
|
|
432
505
|
const shouldRetry = opts.retry({
|
|
433
506
|
op,
|
|
434
507
|
attempts,
|
|
@@ -438,7 +511,7 @@ function retryLink(opts) {
|
|
|
438
511
|
observer.error(error);
|
|
439
512
|
return;
|
|
440
513
|
}
|
|
441
|
-
const delayMs = opts.retryDelayMs
|
|
514
|
+
const delayMs = (_opts$retryDelayMs = (_opts$retryDelayMs2 = opts.retryDelayMs) === null || _opts$retryDelayMs2 === void 0 ? void 0 : _opts$retryDelayMs2.call(opts, attempts)) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : 0;
|
|
442
515
|
if (delayMs <= 0) {
|
|
443
516
|
attempt(attempts + 1);
|
|
444
517
|
return;
|
|
@@ -523,9 +596,102 @@ var require_usingCtx = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc
|
|
|
523
596
|
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
524
597
|
} });
|
|
525
598
|
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js
|
|
601
|
+
var require_OverloadYield = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
|
|
602
|
+
function _OverloadYield(e, d) {
|
|
603
|
+
this.v = e, this.k = d;
|
|
604
|
+
}
|
|
605
|
+
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
606
|
+
} });
|
|
607
|
+
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js
|
|
610
|
+
var require_awaitAsyncGenerator = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
|
|
611
|
+
var OverloadYield$1 = require_OverloadYield();
|
|
612
|
+
function _awaitAsyncGenerator$1(e) {
|
|
613
|
+
return new OverloadYield$1(e, 0);
|
|
614
|
+
}
|
|
615
|
+
module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
616
|
+
} });
|
|
617
|
+
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js
|
|
620
|
+
var require_wrapAsyncGenerator = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
|
|
621
|
+
var OverloadYield = require_OverloadYield();
|
|
622
|
+
function _wrapAsyncGenerator$1(e) {
|
|
623
|
+
return function() {
|
|
624
|
+
return new AsyncGenerator(e.apply(this, arguments));
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
function AsyncGenerator(e) {
|
|
628
|
+
var r, t;
|
|
629
|
+
function resume(r$1, t$1) {
|
|
630
|
+
try {
|
|
631
|
+
var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
|
|
632
|
+
Promise.resolve(u ? o.v : o).then(function(t$2) {
|
|
633
|
+
if (u) {
|
|
634
|
+
var i = "return" === r$1 ? "return" : "next";
|
|
635
|
+
if (!o.k || t$2.done) return resume(i, t$2);
|
|
636
|
+
t$2 = e[i](t$2).value;
|
|
637
|
+
}
|
|
638
|
+
settle(n.done ? "return" : "normal", t$2);
|
|
639
|
+
}, function(e$1) {
|
|
640
|
+
resume("throw", e$1);
|
|
641
|
+
});
|
|
642
|
+
} catch (e$1) {
|
|
643
|
+
settle("throw", e$1);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
function settle(e$1, n) {
|
|
647
|
+
switch (e$1) {
|
|
648
|
+
case "return":
|
|
649
|
+
r.resolve({
|
|
650
|
+
value: n,
|
|
651
|
+
done: !0
|
|
652
|
+
});
|
|
653
|
+
break;
|
|
654
|
+
case "throw":
|
|
655
|
+
r.reject(n);
|
|
656
|
+
break;
|
|
657
|
+
default: r.resolve({
|
|
658
|
+
value: n,
|
|
659
|
+
done: !1
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
|
663
|
+
}
|
|
664
|
+
this._invoke = function(e$1, n) {
|
|
665
|
+
return new Promise(function(o, u) {
|
|
666
|
+
var i = {
|
|
667
|
+
key: e$1,
|
|
668
|
+
arg: n,
|
|
669
|
+
resolve: o,
|
|
670
|
+
reject: u,
|
|
671
|
+
next: null
|
|
672
|
+
};
|
|
673
|
+
t ? t = t.next = i : (r = t = i, resume(e$1, n));
|
|
674
|
+
});
|
|
675
|
+
}, "function" != typeof e["return"] && (this["return"] = void 0);
|
|
676
|
+
}
|
|
677
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
678
|
+
return this;
|
|
679
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
680
|
+
return this._invoke("next", e);
|
|
681
|
+
}, AsyncGenerator.prototype["throw"] = function(e) {
|
|
682
|
+
return this._invoke("throw", e);
|
|
683
|
+
}, AsyncGenerator.prototype["return"] = function(e) {
|
|
684
|
+
return this._invoke("return", e);
|
|
685
|
+
};
|
|
686
|
+
module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
687
|
+
} });
|
|
688
|
+
|
|
526
689
|
//#endregion
|
|
527
690
|
//#region src/links/localLink.ts
|
|
528
691
|
var import_usingCtx = require_chunk.__toESM(require_usingCtx(), 1);
|
|
692
|
+
var import_awaitAsyncGenerator = require_chunk.__toESM(require_awaitAsyncGenerator(), 1);
|
|
693
|
+
var import_wrapAsyncGenerator = require_chunk.__toESM(require_wrapAsyncGenerator(), 1);
|
|
694
|
+
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
|
529
695
|
/**
|
|
530
696
|
* localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
|
|
531
697
|
*
|
|
@@ -560,8 +726,9 @@ function unstable_localLink(opts) {
|
|
|
560
726
|
});
|
|
561
727
|
}
|
|
562
728
|
function onErrorCallback(cause) {
|
|
729
|
+
var _opts$onError;
|
|
563
730
|
if ((0, __trpc_server_unstable_core_do_not_import.isAbortError)(cause)) return;
|
|
564
|
-
opts.onError
|
|
731
|
+
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
|
|
565
732
|
error: (0, __trpc_server.getTRPCErrorFromUnknown)(cause),
|
|
566
733
|
type: op.type,
|
|
567
734
|
path: op.path,
|
|
@@ -592,7 +759,7 @@ function unstable_localLink(opts) {
|
|
|
592
759
|
observer.complete();
|
|
593
760
|
break;
|
|
594
761
|
}
|
|
595
|
-
observer.next({ result: { data:
|
|
762
|
+
observer.next({ result: { data: (0, import_wrapAsyncGenerator.default)(function* () {
|
|
596
763
|
try {
|
|
597
764
|
var _usingCtx$1 = (0, import_usingCtx.default)();
|
|
598
765
|
const iterator = _usingCtx$1.a((0, __trpc_server_unstable_core_do_not_import.iteratorResource)(result));
|
|
@@ -601,7 +768,7 @@ function unstable_localLink(opts) {
|
|
|
601
768
|
}));
|
|
602
769
|
try {
|
|
603
770
|
while (true) {
|
|
604
|
-
const res =
|
|
771
|
+
const res = yield (0, import_awaitAsyncGenerator.default)(Promise.race([iterator.next(), signalPromise]));
|
|
605
772
|
if (res.done) return transformChunk(res.value);
|
|
606
773
|
yield transformChunk(res.value);
|
|
607
774
|
}
|
|
@@ -612,9 +779,9 @@ function unstable_localLink(opts) {
|
|
|
612
779
|
} catch (_) {
|
|
613
780
|
_usingCtx$1.e = _;
|
|
614
781
|
} finally {
|
|
615
|
-
|
|
782
|
+
yield (0, import_awaitAsyncGenerator.default)(_usingCtx$1.d());
|
|
616
783
|
}
|
|
617
|
-
}() } });
|
|
784
|
+
})() } });
|
|
618
785
|
break;
|
|
619
786
|
}
|
|
620
787
|
case "subscription": try {
|
|
@@ -676,10 +843,7 @@ function unstable_localLink(opts) {
|
|
|
676
843
|
}
|
|
677
844
|
};
|
|
678
845
|
} else chunk = { data: res.value };
|
|
679
|
-
observer.next({ result: {
|
|
680
|
-
...chunk,
|
|
681
|
-
data: transformChunk(chunk.data)
|
|
682
|
-
} });
|
|
846
|
+
observer.next({ result: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, chunk), {}, { data: transformChunk(chunk.data) }) });
|
|
683
847
|
}
|
|
684
848
|
} catch (_) {
|
|
685
849
|
_usingCtx4.e = _;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TRPCConnectionState } from "./subscriptions.d-
|
|
2
|
-
import { FetchEsque, HTTPHeaders, NativeFetchEsque, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError } from "./types.d-
|
|
3
|
-
import { TransformerOptions } from "./unstable-internals.d-
|
|
4
|
-
import "./httpUtils.d-
|
|
5
|
-
import { HTTPBatchLinkOptions, httpBatchLink } from "./httpBatchLink.d-
|
|
6
|
-
import { HTTPLinkOptions, httpLink } from "./httpLink.d-
|
|
7
|
-
import { LoggerLinkOptions, loggerLink } from "./loggerLink.d-
|
|
8
|
-
import { splitLink } from "./splitLink.d-
|
|
9
|
-
import { TRPCWebSocketClient, UrlOptionsWithConnectionParams, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, wsLink } from "./wsLink.d-
|
|
1
|
+
import { TRPCConnectionState } from "./subscriptions.d-Dlr1nWGD.mjs";
|
|
2
|
+
import { FetchEsque, HTTPHeaders, NativeFetchEsque, Operation, OperationContext, OperationLink, OperationResultEnvelope, OperationResultObservable, OperationResultObserver, TRPCClientError, TRPCClientErrorBase, TRPCClientErrorLike, TRPCClientRuntime, TRPCFetch, TRPCLink, TRPCProcedureOptions, isFormData, isNonJsonSerializable, isOctetType, isTRPCClientError } from "./types.d-POgEdUB1.mjs";
|
|
3
|
+
import { TransformerOptions } from "./unstable-internals.d-BOmV7EK1.mjs";
|
|
4
|
+
import "./httpUtils.d-cQRQZrfo.mjs";
|
|
5
|
+
import { HTTPBatchLinkOptions, httpBatchLink } from "./httpBatchLink.d-CAaMQOtX.mjs";
|
|
6
|
+
import { HTTPLinkOptions, httpLink } from "./httpLink.d-B0nHKy2W.mjs";
|
|
7
|
+
import { LoggerLinkOptions, loggerLink } from "./loggerLink.d-g_uYSbus.mjs";
|
|
8
|
+
import { splitLink } from "./splitLink.d-od8YIcex.mjs";
|
|
9
|
+
import { TRPCWebSocketClient, UrlOptionsWithConnectionParams, WebSocketClientOptions, WebSocketLinkOptions, createWSClient, wsLink } from "./wsLink.d-BZxAJRBO.mjs";
|
|
10
10
|
import { Unsubscribable } from "@trpc/server/observable";
|
|
11
11
|
import { AnyClientTypes, AnyProcedure, AnyRouter, ErrorHandlerOptions, EventSourceLike, InferrableClientTypes, ProcedureType, RouterRecord, TypeError, inferAsyncIterableYield, inferClientTypes, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput } from "@trpc/server/unstable-core-do-not-import";
|
|
12
12
|
import { AnyRouter as AnyRouter$1 } from "@trpc/server";
|