@trpc/client 10.0.0-alpha.45 → 10.0.0-alpha.48
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.ts +2 -2
- package/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/createTRPCClient.d.ts +3 -0
- package/dist/createTRPCClient.d.ts.map +1 -1
- package/dist/createTRPCClientProxy.d.ts +1 -1
- package/dist/httpUtils-44781613.mjs +76 -0
- package/dist/httpUtils-801112a6.js +79 -0
- package/dist/index.js +230 -339
- package/dist/index.mjs +232 -335
- package/dist/internals/TRPCClient.d.ts +3 -1
- package/dist/internals/TRPCClient.d.ts.map +1 -1
- package/dist/internals/dataLoader.d.ts.map +1 -1
- package/dist/internals/fetchHelpers.d.ts.map +1 -1
- package/dist/internals/retryDelay.d.ts.map +1 -1
- package/dist/links/dedupeLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.js +182 -304
- package/dist/links/httpBatchLink.mjs +182 -304
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/httpLink.js +30 -53
- package/dist/links/httpLink.mjs +30 -53
- package/dist/links/index.d.ts.map +1 -1
- package/dist/links/internals/createChain.d.ts.map +1 -1
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/links/internals/transformResult.d.ts.map +1 -1
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/dist/links/loggerLink.js +89 -94
- package/dist/links/loggerLink.mjs +89 -89
- package/dist/links/retryLink.d.ts.map +1 -1
- package/dist/links/splitLink.d.ts.map +1 -1
- package/dist/links/splitLink.js +1 -1
- package/dist/links/splitLink.mjs +1 -1
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links/wsLink.d.ts.map +1 -1
- package/dist/links/wsLink.js +248 -379
- package/dist/links/wsLink.mjs +248 -368
- package/dist/splitLink-695ae288.js +48 -0
- package/dist/splitLink-ad44a55d.mjs +45 -0
- package/dist/transformResult-106791d7.mjs +62 -0
- package/dist/transformResult-e15ccdf6.js +65 -0
- package/links/httpBatchLink/index.d.ts +1 -1
- package/links/httpBatchLink/index.js +1 -1
- package/links/httpLink/index.d.ts +1 -1
- package/links/httpLink/index.js +1 -1
- package/links/loggerLink/index.d.ts +1 -1
- package/links/loggerLink/index.js +1 -1
- package/links/splitLink/index.d.ts +1 -1
- package/links/splitLink/index.js +1 -1
- package/links/wsLink/index.d.ts +1 -1
- package/links/wsLink/index.js +1 -1
- package/package.json +7 -11
- package/src/TRPCClientError.ts +2 -2
- package/src/createTRPCClient.ts +3 -0
- package/src/createTRPCClientProxy.ts +1 -1
- package/src/internals/TRPCClient.ts +10 -9
- package/src/links/wsLink.ts +1 -1
- package/dist/httpUtils-089853f6.mjs +0 -99
- package/dist/httpUtils-a0169eef.js +0 -106
- package/dist/index.ts.js +0 -1
- package/dist/links/httpBatchLink.ts.js +0 -1
- package/dist/links/httpLink.ts.js +0 -1
- package/dist/links/loggerLink.ts.js +0 -1
- package/dist/links/splitLink.ts.js +0 -1
- package/dist/links/wsLink.ts.js +0 -1
- package/dist/splitLink-0202cd7b.mjs +0 -54
- package/dist/splitLink-23c5ce5c.js +0 -57
- package/dist/transformResult-06bec648.mjs +0 -108
- package/dist/transformResult-3ccc74ea.js +0 -122
package/dist/index.mjs
CHANGED
|
@@ -1,380 +1,277 @@
|
|
|
1
|
-
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
-
import _createClass from '@babel/runtime/helpers/createClass';
|
|
3
1
|
import { observable, share, observableToPromise } from '@trpc/server/observable';
|
|
4
|
-
import { T as TRPCClientError } from './transformResult-
|
|
5
|
-
export { T as TRPCClientError } from './transformResult-
|
|
2
|
+
import { T as TRPCClientError } from './transformResult-106791d7.mjs';
|
|
3
|
+
export { T as TRPCClientError } from './transformResult-106791d7.mjs';
|
|
6
4
|
import { httpBatchLink } from './links/httpBatchLink.mjs';
|
|
7
5
|
export { httpBatchLink } from './links/httpBatchLink.mjs';
|
|
8
|
-
import '
|
|
9
|
-
|
|
10
|
-
import { c as createChain } from './splitLink-0202cd7b.mjs';
|
|
11
|
-
export { s as splitLink } from './splitLink-0202cd7b.mjs';
|
|
12
|
-
import '@babel/runtime/helpers/assertThisInitialized';
|
|
13
|
-
import '@babel/runtime/helpers/inherits';
|
|
14
|
-
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
15
|
-
import '@babel/runtime/helpers/getPrototypeOf';
|
|
16
|
-
import '@babel/runtime/helpers/wrapNativeSuper';
|
|
17
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
|
+
import { c as createChain } from './splitLink-ad44a55d.mjs';
|
|
7
|
+
export { s as splitLink } from './splitLink-ad44a55d.mjs';
|
|
18
8
|
import { createProxy } from '@trpc/server/shared';
|
|
19
9
|
export { httpLink } from './links/httpLink.mjs';
|
|
20
10
|
export { loggerLink } from './links/loggerLink.mjs';
|
|
21
11
|
export { createWSClient, wsLink } from './links/wsLink.mjs';
|
|
22
|
-
import './httpUtils-
|
|
12
|
+
import './httpUtils-44781613.mjs';
|
|
23
13
|
|
|
24
14
|
function getWindow() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return global;
|
|
15
|
+
if (typeof window !== 'undefined') {
|
|
16
|
+
return window;
|
|
17
|
+
}
|
|
18
|
+
return global;
|
|
30
19
|
}
|
|
31
20
|
function getAbortController(ac) {
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
const win = getWindow();
|
|
22
|
+
return ac || win.AbortController || null;
|
|
34
23
|
}
|
|
35
24
|
|
|
36
25
|
function getFetch(f) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
throw new Error('No fetch implementation found');
|
|
26
|
+
if (f) {
|
|
27
|
+
return f;
|
|
28
|
+
}
|
|
29
|
+
const win = getWindow();
|
|
30
|
+
if (win.fetch) {
|
|
31
|
+
return typeof win.fetch.bind === 'function' ? win.fetch.bind(win) : win.fetch;
|
|
32
|
+
}
|
|
33
|
+
throw new Error('No fetch implementation found');
|
|
48
34
|
}
|
|
49
35
|
|
|
50
36
|
function dedupeLink() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
reset();
|
|
95
|
-
subscription.unsubscribe();
|
|
37
|
+
// initialized config
|
|
38
|
+
return ()=>{
|
|
39
|
+
// initialized in app
|
|
40
|
+
const pending = {};
|
|
41
|
+
return ({ op , next })=>{
|
|
42
|
+
// initialized for request
|
|
43
|
+
if (op.type !== 'query') {
|
|
44
|
+
// pass through
|
|
45
|
+
return next(op);
|
|
46
|
+
}
|
|
47
|
+
const key = JSON.stringify([
|
|
48
|
+
op.path,
|
|
49
|
+
op.input
|
|
50
|
+
]);
|
|
51
|
+
const obs$ = pending[key];
|
|
52
|
+
if (obs$) {
|
|
53
|
+
// console.log('hooking into pending', { op });
|
|
54
|
+
return observable((observer)=>obs$.subscribe(observer));
|
|
55
|
+
}
|
|
56
|
+
const shared$ = observable((observer)=>{
|
|
57
|
+
function reset() {
|
|
58
|
+
delete pending[key];
|
|
59
|
+
}
|
|
60
|
+
const subscription = next(op).subscribe({
|
|
61
|
+
next (v) {
|
|
62
|
+
observer.next(v);
|
|
63
|
+
},
|
|
64
|
+
error (e) {
|
|
65
|
+
reset();
|
|
66
|
+
observer.error(e);
|
|
67
|
+
},
|
|
68
|
+
complete () {
|
|
69
|
+
reset();
|
|
70
|
+
observer.complete();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return ()=>{
|
|
74
|
+
reset();
|
|
75
|
+
subscription.unsubscribe();
|
|
76
|
+
};
|
|
77
|
+
}).pipe(share());
|
|
78
|
+
pending[key] = shared$;
|
|
79
|
+
return shared$;
|
|
96
80
|
};
|
|
97
|
-
}).pipe(share());
|
|
98
|
-
pending[key] = shared$;
|
|
99
|
-
return shared$;
|
|
100
81
|
};
|
|
101
|
-
};
|
|
102
82
|
}
|
|
103
83
|
|
|
104
84
|
function retryLink(opts) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
attempt();
|
|
155
|
-
return function () {
|
|
156
|
-
var _next$2;
|
|
157
|
-
|
|
158
|
-
isDone = true;
|
|
159
|
-
(_next$2 = next$) === null || _next$2 === void 0 ? void 0 : _next$2.unsubscribe();
|
|
85
|
+
// initialized config
|
|
86
|
+
return ()=>{
|
|
87
|
+
// initialized in app
|
|
88
|
+
return ({ op , next })=>{
|
|
89
|
+
// initialized for request
|
|
90
|
+
return observable((observer)=>{
|
|
91
|
+
let next$ = null;
|
|
92
|
+
let attempts = 0;
|
|
93
|
+
let isDone = false;
|
|
94
|
+
function attempt() {
|
|
95
|
+
attempts++;
|
|
96
|
+
next$?.unsubscribe();
|
|
97
|
+
next$ = next(op).subscribe({
|
|
98
|
+
error (error) {
|
|
99
|
+
if (attempts >= opts.attempts) {
|
|
100
|
+
observer.error(error);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
attempt();
|
|
104
|
+
},
|
|
105
|
+
next (result) {
|
|
106
|
+
if ('result' in result.result) {
|
|
107
|
+
isDone = true;
|
|
108
|
+
observer.next(result);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (attempts >= opts.attempts) {
|
|
112
|
+
isDone = true;
|
|
113
|
+
observer.next(result);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
attempt();
|
|
117
|
+
},
|
|
118
|
+
complete () {
|
|
119
|
+
if (isDone) {
|
|
120
|
+
observer.complete();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
attempt();
|
|
126
|
+
return ()=>{
|
|
127
|
+
isDone = true;
|
|
128
|
+
next$?.unsubscribe();
|
|
129
|
+
};
|
|
130
|
+
});
|
|
160
131
|
};
|
|
161
|
-
});
|
|
162
132
|
};
|
|
163
|
-
};
|
|
164
133
|
}
|
|
165
134
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return ++idCounter;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
var TRPCClient = /*#__PURE__*/function () {
|
|
173
|
-
function TRPCClient(opts) {
|
|
174
|
-
var _this = this;
|
|
175
|
-
|
|
176
|
-
_classCallCheck(this, TRPCClient);
|
|
177
|
-
|
|
178
|
-
this.links = void 0;
|
|
179
|
-
this.runtime = void 0;
|
|
180
|
-
|
|
181
|
-
var _fetch = getFetch(opts === null || opts === void 0 ? void 0 : opts.fetch);
|
|
182
|
-
|
|
183
|
-
var AC = getAbortController(opts === null || opts === void 0 ? void 0 : opts.AbortController);
|
|
184
|
-
|
|
185
|
-
function getHeadersFn() {
|
|
186
|
-
if (opts.headers) {
|
|
187
|
-
var headers = opts.headers;
|
|
188
|
-
return typeof headers === 'function' ? headers : function () {
|
|
189
|
-
return headers;
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return function () {
|
|
194
|
-
return {};
|
|
195
|
-
};
|
|
135
|
+
class TRPCClient {
|
|
136
|
+
getRequestId() {
|
|
137
|
+
return ++this.requestId;
|
|
196
138
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.runtime = {
|
|
210
|
-
AbortController: AC,
|
|
211
|
-
fetch: _fetch,
|
|
212
|
-
headers: getHeadersFn(),
|
|
213
|
-
transformer: transformer
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
if ('links' in opts) {
|
|
217
|
-
this.links = opts.links.map(function (link) {
|
|
218
|
-
return link(_this.runtime);
|
|
219
|
-
});
|
|
220
|
-
} else {
|
|
221
|
-
this.links = [httpBatchLink({
|
|
222
|
-
url: opts.url
|
|
223
|
-
})(this.runtime)];
|
|
139
|
+
$request({ type , input , path , context ={} }) {
|
|
140
|
+
const chain$ = createChain({
|
|
141
|
+
links: this.links,
|
|
142
|
+
op: {
|
|
143
|
+
id: this.getRequestId(),
|
|
144
|
+
type,
|
|
145
|
+
path,
|
|
146
|
+
input,
|
|
147
|
+
context
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return chain$.pipe(share());
|
|
224
151
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
op: {
|
|
238
|
-
id: getRequestId(),
|
|
239
|
-
type: type,
|
|
240
|
-
path: path,
|
|
241
|
-
input: input,
|
|
242
|
-
context: context
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
return chain$.pipe(share());
|
|
152
|
+
requestAsPromise(opts) {
|
|
153
|
+
const req$ = this.$request(opts);
|
|
154
|
+
const { promise , abort } = observableToPromise(req$);
|
|
155
|
+
const cancellablePromise = new Promise((resolve, reject)=>{
|
|
156
|
+
promise.then((envelope)=>{
|
|
157
|
+
resolve(envelope.result.data);
|
|
158
|
+
}).catch((err)=>{
|
|
159
|
+
reject(TRPCClientError.from(err));
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
cancellablePromise.cancel = abort;
|
|
163
|
+
return cancellablePromise;
|
|
246
164
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
abort = _observableToPromise.abort;
|
|
255
|
-
|
|
256
|
-
var cancellablePromise = new Promise(function (resolve, reject) {
|
|
257
|
-
promise.then(function (envelope) {
|
|
258
|
-
resolve(envelope.result.data);
|
|
259
|
-
}).catch(function (err) {
|
|
260
|
-
reject(TRPCClientError.from(err));
|
|
165
|
+
query(path, ...args) {
|
|
166
|
+
const context = args[1]?.context;
|
|
167
|
+
return this.requestAsPromise({
|
|
168
|
+
type: 'query',
|
|
169
|
+
path,
|
|
170
|
+
input: args[0],
|
|
171
|
+
context
|
|
261
172
|
});
|
|
262
|
-
});
|
|
263
|
-
cancellablePromise.cancel = abort;
|
|
264
|
-
return cancellablePromise;
|
|
265
173
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
var context = (_args$ = args[1]) === null || _args$ === void 0 ? void 0 : _args$.requestContext;
|
|
276
|
-
return this.requestAsPromise({
|
|
277
|
-
type: 'query',
|
|
278
|
-
path: path,
|
|
279
|
-
input: args[0],
|
|
280
|
-
context: context
|
|
281
|
-
});
|
|
174
|
+
mutation(path, ...args) {
|
|
175
|
+
const context = args[1]?.context;
|
|
176
|
+
return this.requestAsPromise({
|
|
177
|
+
type: 'mutation',
|
|
178
|
+
path,
|
|
179
|
+
input: args[0],
|
|
180
|
+
context
|
|
181
|
+
});
|
|
282
182
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
183
|
+
subscription(path, input, opts) {
|
|
184
|
+
const observable$ = this.$request({
|
|
185
|
+
type: 'subscription',
|
|
186
|
+
path,
|
|
187
|
+
input,
|
|
188
|
+
context: opts?.context
|
|
189
|
+
});
|
|
190
|
+
return observable$.subscribe({
|
|
191
|
+
next (envelope) {
|
|
192
|
+
if (envelope.result.type === 'started') {
|
|
193
|
+
opts.onStarted?.();
|
|
194
|
+
} else if (envelope.result.type === 'stopped') {
|
|
195
|
+
opts.onStopped?.();
|
|
196
|
+
} else {
|
|
197
|
+
opts.onData?.(envelope.result.data);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
error (err) {
|
|
201
|
+
opts.onError?.(err);
|
|
202
|
+
},
|
|
203
|
+
complete () {
|
|
204
|
+
opts.onComplete?.();
|
|
205
|
+
}
|
|
206
|
+
});
|
|
299
207
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
(_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 ? void 0 : _opts$onComplete.call(opts);
|
|
208
|
+
constructor(opts){
|
|
209
|
+
const _fetch = getFetch(opts?.fetch);
|
|
210
|
+
const AC = getAbortController(opts?.AbortController);
|
|
211
|
+
this.requestId = 0;
|
|
212
|
+
function getHeadersFn() {
|
|
213
|
+
if (opts.headers) {
|
|
214
|
+
const headers = opts.headers;
|
|
215
|
+
return typeof headers === 'function' ? headers : ()=>headers;
|
|
216
|
+
}
|
|
217
|
+
return ()=>({});
|
|
218
|
+
}
|
|
219
|
+
const transformer = opts.transformer ? 'input' in opts.transformer ? {
|
|
220
|
+
serialize: opts.transformer.input.serialize,
|
|
221
|
+
deserialize: opts.transformer.output.deserialize
|
|
222
|
+
} : opts.transformer : {
|
|
223
|
+
serialize: (data)=>data,
|
|
224
|
+
deserialize: (data)=>data
|
|
225
|
+
};
|
|
226
|
+
this.runtime = {
|
|
227
|
+
AbortController: AC,
|
|
228
|
+
fetch: _fetch,
|
|
229
|
+
headers: getHeadersFn(),
|
|
230
|
+
transformer
|
|
231
|
+
};
|
|
232
|
+
if ('links' in opts) {
|
|
233
|
+
this.links = opts.links.map((link)=>link(this.runtime));
|
|
234
|
+
} else {
|
|
235
|
+
this.links = [
|
|
236
|
+
httpBatchLink({
|
|
237
|
+
url: opts.url
|
|
238
|
+
})(this.runtime),
|
|
239
|
+
];
|
|
334
240
|
}
|
|
335
|
-
});
|
|
336
241
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return TRPCClient;
|
|
340
|
-
}();
|
|
242
|
+
}
|
|
341
243
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
244
|
+
/**
|
|
245
|
+
* @deprecated use `createTRPCProxyClient` instead
|
|
246
|
+
*/ function createTRPCClient(opts) {
|
|
247
|
+
const client = new TRPCClient(opts);
|
|
248
|
+
return client;
|
|
249
|
+
}
|
|
347
250
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
251
|
+
const clientCallTypeMap = {
|
|
252
|
+
query: 'query',
|
|
253
|
+
mutate: 'mutation',
|
|
254
|
+
subscribe: 'subscription'
|
|
352
255
|
};
|
|
353
256
|
/**
|
|
354
|
-
* @deprecated use createTRPCProxyClient instead
|
|
257
|
+
* @deprecated use `createTRPCProxyClient` instead
|
|
355
258
|
* @internal
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
var clientCallType = pathCopy.pop();
|
|
368
|
-
var procedureType = clientCallTypeMap[clientCallType];
|
|
369
|
-
var fullPath = pathCopy.join('.');
|
|
370
|
-
return (_ref2 = client)[procedureType].apply(_ref2, [fullPath].concat(_toConsumableArray(args)));
|
|
371
|
-
});
|
|
372
|
-
return proxy;
|
|
259
|
+
*/ function createTRPCClientProxy(client) {
|
|
260
|
+
const proxy = createProxy(({ path , args })=>{
|
|
261
|
+
const pathCopy = [
|
|
262
|
+
...path
|
|
263
|
+
];
|
|
264
|
+
const clientCallType = pathCopy.pop();
|
|
265
|
+
const procedureType = clientCallTypeMap[clientCallType];
|
|
266
|
+
const fullPath = pathCopy.join('.');
|
|
267
|
+
return client[procedureType](fullPath, ...args);
|
|
268
|
+
});
|
|
269
|
+
return proxy;
|
|
373
270
|
}
|
|
374
271
|
function createTRPCProxyClient(opts) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
272
|
+
const client = createTRPCClient(opts);
|
|
273
|
+
const proxy = createTRPCClientProxy(client);
|
|
274
|
+
return proxy;
|
|
378
275
|
}
|
|
379
276
|
|
|
380
277
|
export { createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, dedupeLink, getFetch, retryLink };
|
|
@@ -44,7 +44,7 @@ export interface TRPCRequestOptions {
|
|
|
44
44
|
/**
|
|
45
45
|
* Pass additional context to links
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
context?: OperationContext;
|
|
48
48
|
}
|
|
49
49
|
export interface TRPCSubscriptionObserver<TValue, TError> {
|
|
50
50
|
onStarted: () => void;
|
|
@@ -67,6 +67,8 @@ export declare type AssertLegacyDef<TRouter extends AnyRouter> = TRouter['_def']
|
|
|
67
67
|
export declare class TRPCClient<TRouter extends AnyRouter> {
|
|
68
68
|
private readonly links;
|
|
69
69
|
readonly runtime: TRPCClientRuntime;
|
|
70
|
+
private requestId;
|
|
71
|
+
private getRequestId;
|
|
70
72
|
constructor(opts: CreateTRPCClientOptions<TRouter>);
|
|
71
73
|
private $request;
|
|
72
74
|
private requestAsPromise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCClient.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"TRPCClient.d.ts","sourceRoot":"","sources":["../../../../packages/client/src/internals/TRPCClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,4BAA4B,EAE5B,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAC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,SAAS,MAAM,GAAG,MAAM,UAAU,EAEvC,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE;QACP,GAAG,iBAAiB,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC;QACpE,kBAAkB,CAAC;KACpB;IAaI,YAAY,CACjB,cAAc,SAAS,eAAe,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,EAChE,KAAK,SAAS,MAAM,GAAG,MAAM,cAAc,EAC3C,OAAO,SAAS,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,EACvD,MAAM,SAAS,mBAAmB,CAChC,UAAU,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CACnD,EAED,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,kBAAkB,GACtB,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,GACrE,cAAc;CAyBlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../../../packages/client/src/internals/dataLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAa5D,aAAK,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK;QACvB,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3B,MAAM,EAAE,QAAQ,CAAC;KAClB,CAAC;CACH,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EACrC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;gBA2FnB,IAAI,KAAG,iBAAiB,MAAM,CAAC;EAsCnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchHelpers.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"fetchHelpers.d.ts","sourceRoot":"","sources":["../../../../packages/client/src/internals/fetchHelpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,sBAKxB;AACD,wBAAgB,kBAAkB,CAChC,EAAE,CAAC,EAAE,OAAO,eAAe,GAC1B,OAAO,eAAe,GAAG,IAAI,CAG/B"}
|