@trpc/client 10.0.0-alpha.2 → 10.0.0-alpha.20
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/{declarations/src/TRPCClientError.d.ts → TRPCClientError.d.ts} +21 -29
- package/dist/TRPCClientError.d.ts.map +1 -0
- package/dist/{declarations/src/createTRPCClient.d.ts → createTRPCClient.d.ts} +5 -5
- package/dist/createTRPCClient.d.ts.map +1 -0
- package/dist/{declarations/src/getFetch.d.ts → getFetch.d.ts} +1 -1
- package/dist/getFetch.d.ts.map +1 -0
- package/dist/{declarations/src/index.d.ts → index.d.ts} +4 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1373 -0
- package/dist/index.mjs +1346 -0
- package/dist/index.ts.js +1 -0
- package/dist/{declarations/src/internals → internals}/TRPCClient.d.ts +56 -64
- package/dist/internals/TRPCClient.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/dataLoader.d.ts +16 -14
- package/dist/internals/dataLoader.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/fetchHelpers.d.ts +2 -2
- package/dist/internals/fetchHelpers.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/retryDelay.d.ts +1 -1
- package/dist/internals/retryDelay.d.ts.map +1 -0
- package/dist/links/dedupeLink.d.ts +4 -0
- package/dist/links/dedupeLink.d.ts.map +1 -0
- package/dist/links/httpBatchLink.d.ts +8 -0
- package/dist/links/httpBatchLink.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/httpLink.d.ts +4 -4
- package/dist/links/httpLink.d.ts.map +1 -0
- package/dist/links/index.d.ts +11 -0
- package/dist/links/index.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/internals/createChain.d.ts +7 -7
- package/dist/links/internals/createChain.d.ts.map +1 -0
- package/dist/{declarations/src/links → links/internals}/httpUtils.d.ts +21 -21
- package/dist/links/internals/httpUtils.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/internals/transformOperationResult.d.ts +15 -15
- package/dist/links/internals/transformOperationResult.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/loggerLink.d.ts +38 -38
- package/dist/links/loggerLink.d.ts.map +1 -0
- package/dist/links/retryLink.d.ts +6 -0
- package/dist/links/retryLink.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/splitLink.d.ts +13 -13
- package/dist/links/splitLink.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/transformerLink.d.ts +3 -3
- package/dist/links/transformerLink.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/types.d.ts +39 -39
- package/dist/links/types.d.ts.map +1 -0
- package/dist/{declarations/src/links → links}/wsLink.d.ts +19 -19
- package/dist/links/wsLink.d.ts.map +1 -0
- package/dist/observable/index.d.ts +4 -0
- package/dist/observable/index.d.ts.map +1 -0
- package/{rx/operators/dist/trpc-client-rx-operators.cjs.dev.js → dist/observable/index.js} +3 -4
- package/{rx/operators/dist/trpc-client-rx-operators.esm.js → dist/observable/index.mjs} +1 -3
- package/dist/observable/index.ts.js +1 -0
- package/dist/{declarations/src/rx/util → observable/internals}/identity.d.ts +1 -1
- package/dist/observable/internals/identity.d.ts.map +1 -0
- package/dist/{declarations/src/rx/util → observable/internals}/observableToPromise.d.ts +9 -9
- package/dist/observable/internals/observableToPromise.d.ts.map +1 -0
- package/dist/{declarations/src/rx/util → observable/internals}/pipe.d.ts +3 -3
- package/dist/observable/internals/pipe.d.ts.map +1 -0
- package/dist/{declarations/src/rx → observable}/observable.d.ts +3 -3
- package/dist/observable/observable.d.ts.map +1 -0
- package/dist/{declarations/src/rx → observable}/operators/index.d.ts +3 -3
- package/dist/observable/operators/index.d.ts.map +1 -0
- package/dist/{declarations/src/rx → observable}/operators/map.d.ts +2 -2
- package/dist/observable/operators/map.d.ts.map +1 -0
- package/dist/{declarations/src/rx → observable}/operators/share.d.ts +5 -5
- package/dist/observable/operators/share.d.ts.map +1 -0
- package/dist/{declarations/src/rx → observable}/operators/tap.d.ts +2 -2
- package/dist/observable/operators/tap.d.ts.map +1 -0
- package/dist/{declarations/src/rx → observable}/types.d.ts +28 -28
- package/dist/observable/types.d.ts.map +1 -0
- package/dist/tap-0dcdee86.js +243 -0
- package/dist/tap-136a9a90.mjs +239 -0
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.dev.js +68 -38
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.prod.js +68 -38
- package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.esm.js +67 -37
- package/links/httpLink/dist/trpc-client-links-httpLink.cjs.dev.js +52 -29
- package/links/httpLink/dist/trpc-client-links-httpLink.cjs.prod.js +52 -29
- package/links/httpLink/dist/trpc-client-links-httpLink.esm.js +52 -29
- package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.dev.js +19 -31
- package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.prod.js +19 -31
- package/links/loggerLink/dist/trpc-client-links-loggerLink.esm.js +19 -31
- package/links/splitLink/dist/trpc-client-links-splitLink.cjs.dev.js +7 -20
- package/links/splitLink/dist/trpc-client-links-splitLink.cjs.prod.js +7 -20
- package/links/splitLink/dist/trpc-client-links-splitLink.esm.js +7 -20
- package/links/wsLink/dist/trpc-client-links-wsLink.cjs.dev.js +84 -60
- package/links/wsLink/dist/trpc-client-links-wsLink.cjs.prod.js +84 -60
- package/links/wsLink/dist/trpc-client-links-wsLink.esm.js +84 -60
- package/{rx → observable}/dist/trpc-client-rx.cjs.d.ts +0 -0
- package/{rx → observable}/dist/trpc-client-rx.cjs.dev.js +0 -0
- package/{rx → observable}/dist/trpc-client-rx.cjs.js +0 -0
- package/{rx → observable}/dist/trpc-client-rx.cjs.prod.js +0 -0
- package/{rx → observable}/dist/trpc-client-rx.esm.js +0 -0
- package/observable/index.d.ts +1 -0
- package/observable/index.js +1 -0
- package/package.json +22 -21
- package/src/TRPCClientError.ts +3 -11
- package/src/createTRPCClient.ts +1 -1
- package/src/index.ts +1 -1
- package/src/internals/TRPCClient.ts +11 -19
- package/src/internals/dataLoader.ts +13 -1
- package/src/links/dedupeLink.test.ts +1 -1
- package/src/links/dedupeLink.ts +4 -5
- package/src/links/httpBatchLink.ts +15 -5
- package/src/links/httpLink.ts +2 -2
- package/src/links/index.ts +10 -0
- package/src/links/internals/createChain.test.ts +5 -5
- package/src/links/internals/createChain.ts +3 -3
- package/src/links/{httpUtils.ts → internals/httpUtils.ts} +2 -1
- package/src/links/loggerLink.ts +1 -2
- package/src/links/retryLink.ts +2 -2
- package/src/links/splitLink.test.ts +3 -3
- package/src/links/splitLink.ts +2 -2
- package/src/links/transformerLink.ts +9 -5
- package/src/links/types.ts +3 -3
- package/src/links/wsLink.ts +2 -3
- package/src/{rx → observable}/index.ts +1 -0
- package/src/{rx/util → observable/internals}/identity.ts +0 -0
- package/src/{rx/util → observable/internals}/observableToPromise.ts +0 -0
- package/src/{rx/util → observable/internals}/pipe.ts +1 -1
- package/src/{rx → observable}/observable.test.ts +22 -4
- package/src/{rx → observable}/observable.ts +1 -1
- package/src/{rx → observable}/operators/index.ts +0 -0
- package/src/{rx → observable}/operators/map.test.ts +2 -2
- package/src/{rx → observable}/operators/map.ts +0 -0
- package/src/{rx → observable}/operators/share.test.ts +0 -0
- package/src/{rx → observable}/operators/share.ts +0 -0
- package/src/{rx → observable}/operators/tap.ts +0 -0
- package/src/{rx → observable}/types.ts +0 -0
- package/dist/TRPCClientError-a5312a5f.cjs.dev.js +0 -74
- package/dist/TRPCClientError-e1da1ef0.esm.js +0 -72
- package/dist/TRPCClientError-ea7d89b2.cjs.prod.js +0 -74
- package/dist/createChain-93a38e1c.cjs.dev.js +0 -27
- package/dist/createChain-e45e052a.cjs.prod.js +0 -27
- package/dist/createChain-e45e6cf2.esm.js +0 -25
- package/dist/declarations/src/TRPCClientError.d.ts.map +0 -1
- package/dist/declarations/src/createTRPCClient.d.ts.map +0 -1
- package/dist/declarations/src/getFetch.d.ts.map +0 -1
- package/dist/declarations/src/index.d.ts.map +0 -1
- package/dist/declarations/src/internals/TRPCClient.d.ts.map +0 -1
- package/dist/declarations/src/internals/dataLoader.d.ts.map +0 -1
- package/dist/declarations/src/internals/fetchHelpers.d.ts.map +0 -1
- package/dist/declarations/src/internals/retryDelay.d.ts.map +0 -1
- package/dist/declarations/src/links/httpBatchLink.d.ts +0 -5
- package/dist/declarations/src/links/httpBatchLink.d.ts.map +0 -1
- package/dist/declarations/src/links/httpLink.d.ts.map +0 -1
- package/dist/declarations/src/links/httpUtils.d.ts.map +0 -1
- package/dist/declarations/src/links/internals/createChain.d.ts.map +0 -1
- package/dist/declarations/src/links/internals/transformOperationResult.d.ts.map +0 -1
- package/dist/declarations/src/links/loggerLink.d.ts.map +0 -1
- package/dist/declarations/src/links/splitLink.d.ts.map +0 -1
- package/dist/declarations/src/links/transformerLink.d.ts.map +0 -1
- package/dist/declarations/src/links/types.d.ts.map +0 -1
- package/dist/declarations/src/links/wsLink.d.ts.map +0 -1
- package/dist/declarations/src/rx/index.d.ts +0 -3
- package/dist/declarations/src/rx/index.d.ts.map +0 -1
- package/dist/declarations/src/rx/observable.d.ts.map +0 -1
- package/dist/declarations/src/rx/operators/index.d.ts.map +0 -1
- package/dist/declarations/src/rx/operators/map.d.ts.map +0 -1
- package/dist/declarations/src/rx/operators/share.d.ts.map +0 -1
- package/dist/declarations/src/rx/operators/tap.d.ts.map +0 -1
- package/dist/declarations/src/rx/types.d.ts.map +0 -1
- package/dist/declarations/src/rx/util/identity.d.ts.map +0 -1
- package/dist/declarations/src/rx/util/observableToPromise.d.ts.map +0 -1
- package/dist/declarations/src/rx/util/pipe.d.ts.map +0 -1
- package/dist/httpUtils-299a66f6.cjs.prod.js +0 -89
- package/dist/httpUtils-a1426e14.cjs.dev.js +0 -89
- package/dist/httpUtils-e45c9056.esm.js +0 -87
- package/dist/observable-01534ea8.esm.js +0 -102
- package/dist/observable-9aad8c3e.cjs.dev.js +0 -104
- package/dist/observable-ccb54234.cjs.prod.js +0 -104
- package/dist/share-5a8c2543.cjs.prod.js +0 -106
- package/dist/share-ca585761.esm.js +0 -104
- package/dist/share-f2ac9332.cjs.dev.js +0 -106
- package/dist/tap-2d565250.cjs.dev.js +0 -32
- package/dist/tap-606957cb.esm.js +0 -30
- package/dist/tap-d907998d.cjs.prod.js +0 -32
- package/dist/trpc-client.cjs.d.ts +0 -1
- package/dist/trpc-client.cjs.dev.js +0 -300
- package/dist/trpc-client.cjs.js +0 -7
- package/dist/trpc-client.cjs.prod.js +0 -300
- package/dist/trpc-client.esm.js +0 -295
- package/links/httpBatchLink/package.json +0 -4
- package/links/httpLink/package.json +0 -4
- package/links/loggerLink/package.json +0 -4
- package/links/splitLink/package.json +0 -4
- package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.d.ts +0 -1
- package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.dev.js +0 -67
- package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.js +0 -7
- package/links/transformerLink/dist/trpc-client-links-transformerLink.cjs.prod.js +0 -67
- package/links/transformerLink/dist/trpc-client-links-transformerLink.esm.js +0 -63
- package/links/transformerLink/package.json +0 -4
- package/links/wsLink/package.json +0 -4
- package/rx/operators/dist/trpc-client-rx-operators.cjs.d.ts +0 -1
- package/rx/operators/dist/trpc-client-rx-operators.cjs.js +0 -7
- package/rx/operators/dist/trpc-client-rx-operators.cjs.prod.js +0 -39
- package/rx/operators/package.json +0 -4
- package/rx/package.json +0 -4
- package/src/internals/transformRPCResponse.ts +0 -25
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import _createForOfIteratorHelper from '@babel/runtime/helpers/esm/createForOfIteratorHelper';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { T as TRPCAbortError, t as transformRPCResponse, h as httpRequest } from '../../../dist/transformRPCResponse-3700ef8b.esm.js';
|
|
3
|
+
import { T as TRPCClientError } from '../../../dist/TRPCClientError-09b8a26b.esm.js';
|
|
4
|
+
import '@babel/runtime/helpers/createClass';
|
|
5
|
+
import '@babel/runtime/helpers/classCallCheck';
|
|
6
|
+
import '@babel/runtime/helpers/assertThisInitialized';
|
|
7
|
+
import '@babel/runtime/helpers/inherits';
|
|
8
|
+
import '@babel/runtime/helpers/createSuper';
|
|
9
|
+
import '@babel/runtime/helpers/wrapNativeSuper';
|
|
4
10
|
import '@babel/runtime/helpers/objectSpread2';
|
|
5
11
|
|
|
6
12
|
/**
|
|
@@ -8,7 +14,7 @@ import '@babel/runtime/helpers/objectSpread2';
|
|
|
8
14
|
* Less configuration, no caching, and allows you to cancel requests
|
|
9
15
|
* When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled
|
|
10
16
|
*/
|
|
11
|
-
function dataLoader(fetchMany) {
|
|
17
|
+
function dataLoader(fetchMany, opts) {
|
|
12
18
|
var batch = null;
|
|
13
19
|
var dispatchTimer = null;
|
|
14
20
|
|
|
@@ -73,6 +79,11 @@ function dataLoader(fetchMany) {
|
|
|
73
79
|
item.reject = reject;
|
|
74
80
|
item.resolve = resolve;
|
|
75
81
|
thisBatch.items.push(item);
|
|
82
|
+
|
|
83
|
+
if (typeof (opts === null || opts === void 0 ? void 0 : opts.maxBatchSize) !== 'undefined' && thisBatch.items.length >= opts.maxBatchSize) {
|
|
84
|
+
dispatch();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
76
87
|
});
|
|
77
88
|
|
|
78
89
|
if (!dispatchTimer) {
|
|
@@ -104,8 +115,11 @@ function dataLoader(fetchMany) {
|
|
|
104
115
|
}
|
|
105
116
|
|
|
106
117
|
function httpBatchLink(opts) {
|
|
107
|
-
var url = opts.url
|
|
118
|
+
var url = opts.url,
|
|
119
|
+
maxBatchSize = opts.maxBatchSize; // initialized config
|
|
120
|
+
|
|
108
121
|
return function (runtime) {
|
|
122
|
+
// initialized in app
|
|
109
123
|
var fetcher = function fetcher(type) {
|
|
110
124
|
return function (keyInputPairs) {
|
|
111
125
|
var path = keyInputPairs.map(function (op) {
|
|
@@ -127,51 +141,67 @@ function httpBatchLink(opts) {
|
|
|
127
141
|
|
|
128
142
|
return {
|
|
129
143
|
promise: promise.then(function (res) {
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
return result;
|
|
144
|
+
if (!Array.isArray(res)) {
|
|
145
|
+
return keyInputPairs.map(function () {
|
|
146
|
+
return res;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return res;
|
|
140
151
|
}),
|
|
141
152
|
cancel: cancel
|
|
142
153
|
};
|
|
143
154
|
};
|
|
144
155
|
};
|
|
145
156
|
|
|
146
|
-
var query = dataLoader(fetcher('query')
|
|
147
|
-
|
|
148
|
-
|
|
157
|
+
var query = dataLoader(fetcher('query'), {
|
|
158
|
+
maxBatchSize: maxBatchSize
|
|
159
|
+
});
|
|
160
|
+
var mutation = dataLoader(fetcher('mutation'), {
|
|
161
|
+
maxBatchSize: maxBatchSize
|
|
162
|
+
});
|
|
163
|
+
var subscription = dataLoader(fetcher('subscription'), {
|
|
164
|
+
maxBatchSize: maxBatchSize
|
|
165
|
+
});
|
|
149
166
|
var loaders = {
|
|
150
167
|
query: query,
|
|
151
168
|
subscription: subscription,
|
|
152
169
|
mutation: mutation
|
|
153
170
|
};
|
|
154
171
|
return function (_ref) {
|
|
155
|
-
var op = _ref.op
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
var op = _ref.op,
|
|
173
|
+
prev = _ref.prev,
|
|
174
|
+
onDestroy = _ref.onDestroy;
|
|
175
|
+
var loader = loaders[op.type];
|
|
176
|
+
|
|
177
|
+
var _loader$load = loader.load(op),
|
|
178
|
+
promise = _loader$load.promise,
|
|
179
|
+
cancel = _loader$load.cancel;
|
|
180
|
+
|
|
181
|
+
var isDone = false;
|
|
182
|
+
|
|
183
|
+
var prevOnce = function prevOnce(result) {
|
|
184
|
+
if (isDone) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
isDone = true;
|
|
189
|
+
prev(result);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
onDestroy(function () {
|
|
193
|
+
prevOnce(TRPCClientError.from(new TRPCAbortError(), {
|
|
194
|
+
isDone: true
|
|
195
|
+
}));
|
|
196
|
+
cancel();
|
|
197
|
+
});
|
|
198
|
+
promise.then(function (envelope) {
|
|
199
|
+
prevOnce(transformRPCResponse({
|
|
200
|
+
envelope: envelope,
|
|
201
|
+
runtime: runtime
|
|
202
|
+
}));
|
|
203
|
+
}).catch(function (cause) {
|
|
204
|
+
prevOnce(TRPCClientError.from(cause));
|
|
175
205
|
});
|
|
176
206
|
};
|
|
177
207
|
};
|
|
@@ -2,40 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var TRPCClientError = require('../../../dist/TRPCClientError-bfee2bf5.cjs.dev.js');
|
|
6
|
+
var transformRPCResponse = require('../../../dist/transformRPCResponse-0ad3cc9f.cjs.dev.js');
|
|
7
7
|
require('@babel/runtime/helpers/objectSpread2');
|
|
8
|
+
require('@babel/runtime/helpers/classCallCheck');
|
|
9
|
+
require('@babel/runtime/helpers/createClass');
|
|
10
|
+
require('@babel/runtime/helpers/assertThisInitialized');
|
|
11
|
+
require('@babel/runtime/helpers/inherits');
|
|
12
|
+
require('@babel/runtime/helpers/createSuper');
|
|
13
|
+
require('@babel/runtime/helpers/wrapNativeSuper');
|
|
8
14
|
|
|
9
15
|
function httpLink(opts) {
|
|
10
|
-
var url = opts.url;
|
|
16
|
+
var url = opts.url; // initialized config
|
|
17
|
+
|
|
11
18
|
return function (runtime) {
|
|
19
|
+
// initialized in app
|
|
12
20
|
return function (_ref) {
|
|
13
|
-
var op = _ref.op
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
var op = _ref.op,
|
|
22
|
+
prev = _ref.prev,
|
|
23
|
+
onDestroy = _ref.onDestroy;
|
|
24
|
+
var path = op.path,
|
|
25
|
+
input = op.input,
|
|
26
|
+
type = op.type;
|
|
27
|
+
|
|
28
|
+
var _httpRequest = transformRPCResponse.httpRequest({
|
|
29
|
+
runtime: runtime,
|
|
30
|
+
type: type,
|
|
31
|
+
input: input,
|
|
32
|
+
url: url,
|
|
33
|
+
path: path
|
|
34
|
+
}),
|
|
35
|
+
promise = _httpRequest.promise,
|
|
36
|
+
cancel = _httpRequest.cancel;
|
|
37
|
+
|
|
38
|
+
var isDone = false;
|
|
39
|
+
|
|
40
|
+
var prevOnce = function prevOnce(result) {
|
|
41
|
+
if (isDone) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
isDone = true;
|
|
46
|
+
prev(result);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
onDestroy(function () {
|
|
50
|
+
prevOnce(TRPCClientError.TRPCClientError.from(new transformRPCResponse.TRPCAbortError(), {
|
|
51
|
+
isDone: true
|
|
52
|
+
}));
|
|
53
|
+
cancel();
|
|
54
|
+
});
|
|
55
|
+
promise.then(function (envelope) {
|
|
56
|
+
prevOnce(transformRPCResponse.transformRPCResponse({
|
|
57
|
+
envelope: envelope,
|
|
58
|
+
runtime: runtime
|
|
59
|
+
}));
|
|
60
|
+
}).catch(function (cause) {
|
|
61
|
+
prevOnce(TRPCClientError.TRPCClientError.from(cause));
|
|
39
62
|
});
|
|
40
63
|
};
|
|
41
64
|
};
|
|
@@ -2,40 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var TRPCClientError = require('../../../dist/TRPCClientError-e9bf96e9.cjs.prod.js');
|
|
6
|
+
var transformRPCResponse = require('../../../dist/transformRPCResponse-e6daeb02.cjs.prod.js');
|
|
7
7
|
require('@babel/runtime/helpers/objectSpread2');
|
|
8
|
+
require('@babel/runtime/helpers/classCallCheck');
|
|
9
|
+
require('@babel/runtime/helpers/createClass');
|
|
10
|
+
require('@babel/runtime/helpers/assertThisInitialized');
|
|
11
|
+
require('@babel/runtime/helpers/inherits');
|
|
12
|
+
require('@babel/runtime/helpers/createSuper');
|
|
13
|
+
require('@babel/runtime/helpers/wrapNativeSuper');
|
|
8
14
|
|
|
9
15
|
function httpLink(opts) {
|
|
10
|
-
var url = opts.url;
|
|
16
|
+
var url = opts.url; // initialized config
|
|
17
|
+
|
|
11
18
|
return function (runtime) {
|
|
19
|
+
// initialized in app
|
|
12
20
|
return function (_ref) {
|
|
13
|
-
var op = _ref.op
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
var op = _ref.op,
|
|
22
|
+
prev = _ref.prev,
|
|
23
|
+
onDestroy = _ref.onDestroy;
|
|
24
|
+
var path = op.path,
|
|
25
|
+
input = op.input,
|
|
26
|
+
type = op.type;
|
|
27
|
+
|
|
28
|
+
var _httpRequest = transformRPCResponse.httpRequest({
|
|
29
|
+
runtime: runtime,
|
|
30
|
+
type: type,
|
|
31
|
+
input: input,
|
|
32
|
+
url: url,
|
|
33
|
+
path: path
|
|
34
|
+
}),
|
|
35
|
+
promise = _httpRequest.promise,
|
|
36
|
+
cancel = _httpRequest.cancel;
|
|
37
|
+
|
|
38
|
+
var isDone = false;
|
|
39
|
+
|
|
40
|
+
var prevOnce = function prevOnce(result) {
|
|
41
|
+
if (isDone) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
isDone = true;
|
|
46
|
+
prev(result);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
onDestroy(function () {
|
|
50
|
+
prevOnce(TRPCClientError.TRPCClientError.from(new transformRPCResponse.TRPCAbortError(), {
|
|
51
|
+
isDone: true
|
|
52
|
+
}));
|
|
53
|
+
cancel();
|
|
54
|
+
});
|
|
55
|
+
promise.then(function (envelope) {
|
|
56
|
+
prevOnce(transformRPCResponse.transformRPCResponse({
|
|
57
|
+
envelope: envelope,
|
|
58
|
+
runtime: runtime
|
|
59
|
+
}));
|
|
60
|
+
}).catch(function (cause) {
|
|
61
|
+
prevOnce(TRPCClientError.TRPCClientError.from(cause));
|
|
39
62
|
});
|
|
40
63
|
};
|
|
41
64
|
};
|
|
@@ -1,37 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { h as httpRequest } from '../../../dist/
|
|
1
|
+
import { T as TRPCClientError } from '../../../dist/TRPCClientError-09b8a26b.esm.js';
|
|
2
|
+
import { h as httpRequest, T as TRPCAbortError, t as transformRPCResponse } from '../../../dist/transformRPCResponse-3700ef8b.esm.js';
|
|
3
3
|
import '@babel/runtime/helpers/objectSpread2';
|
|
4
|
+
import '@babel/runtime/helpers/classCallCheck';
|
|
5
|
+
import '@babel/runtime/helpers/createClass';
|
|
6
|
+
import '@babel/runtime/helpers/assertThisInitialized';
|
|
7
|
+
import '@babel/runtime/helpers/inherits';
|
|
8
|
+
import '@babel/runtime/helpers/createSuper';
|
|
9
|
+
import '@babel/runtime/helpers/wrapNativeSuper';
|
|
4
10
|
|
|
5
11
|
function httpLink(opts) {
|
|
6
|
-
var url = opts.url;
|
|
12
|
+
var url = opts.url; // initialized config
|
|
13
|
+
|
|
7
14
|
return function (runtime) {
|
|
15
|
+
// initialized in app
|
|
8
16
|
return function (_ref) {
|
|
9
|
-
var op = _ref.op
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
var op = _ref.op,
|
|
18
|
+
prev = _ref.prev,
|
|
19
|
+
onDestroy = _ref.onDestroy;
|
|
20
|
+
var path = op.path,
|
|
21
|
+
input = op.input,
|
|
22
|
+
type = op.type;
|
|
23
|
+
|
|
24
|
+
var _httpRequest = httpRequest({
|
|
25
|
+
runtime: runtime,
|
|
26
|
+
type: type,
|
|
27
|
+
input: input,
|
|
28
|
+
url: url,
|
|
29
|
+
path: path
|
|
30
|
+
}),
|
|
31
|
+
promise = _httpRequest.promise,
|
|
32
|
+
cancel = _httpRequest.cancel;
|
|
33
|
+
|
|
34
|
+
var isDone = false;
|
|
35
|
+
|
|
36
|
+
var prevOnce = function prevOnce(result) {
|
|
37
|
+
if (isDone) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
isDone = true;
|
|
42
|
+
prev(result);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
onDestroy(function () {
|
|
46
|
+
prevOnce(TRPCClientError.from(new TRPCAbortError(), {
|
|
47
|
+
isDone: true
|
|
48
|
+
}));
|
|
49
|
+
cancel();
|
|
50
|
+
});
|
|
51
|
+
promise.then(function (envelope) {
|
|
52
|
+
prevOnce(transformRPCResponse({
|
|
53
|
+
envelope: envelope,
|
|
54
|
+
runtime: runtime
|
|
55
|
+
}));
|
|
56
|
+
}).catch(function (cause) {
|
|
57
|
+
prevOnce(TRPCClientError.from(cause));
|
|
35
58
|
});
|
|
36
59
|
};
|
|
37
60
|
};
|
|
@@ -4,9 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
6
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
-
var observable = require('../../../dist/observable-9aad8c3e.cjs.dev.js');
|
|
8
|
-
require('@babel/runtime/helpers/createForOfIteratorHelper');
|
|
9
|
-
var tap = require('../../../dist/tap-2d565250.cjs.dev.js');
|
|
10
7
|
|
|
11
8
|
var palette = {
|
|
12
9
|
query: ['72e3ff', '3fb0d8'],
|
|
@@ -47,7 +44,7 @@ var defaultLogger = function defaultLogger() {
|
|
|
47
44
|
});
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
var fn = props.direction === 'down' && props.result &&
|
|
47
|
+
var fn = props.direction === 'down' && props.result && props.result instanceof Error ? 'error' : 'log';
|
|
51
48
|
c[fn].apply(null, [parts.join(' ')].concat(args));
|
|
52
49
|
};
|
|
53
50
|
};
|
|
@@ -63,36 +60,27 @@ function loggerLink() {
|
|
|
63
60
|
return function () {
|
|
64
61
|
return function (_ref) {
|
|
65
62
|
var op = _ref.op,
|
|
66
|
-
next = _ref.next
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
next = _ref.next,
|
|
64
|
+
prev = _ref.prev;
|
|
65
|
+
// ->
|
|
66
|
+
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
67
|
+
direction: 'up'
|
|
68
|
+
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
69
|
+
direction: 'up'
|
|
70
|
+
}));
|
|
71
|
+
var requestStartTime = Date.now();
|
|
72
|
+
next(op, function (result) {
|
|
73
|
+
var elapsedMs = Date.now() - requestStartTime;
|
|
69
74
|
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
70
|
-
direction: '
|
|
75
|
+
direction: 'down',
|
|
76
|
+
result: result
|
|
71
77
|
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
72
|
-
direction: '
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
direction: 'down',
|
|
79
|
+
elapsedMs: elapsedMs,
|
|
80
|
+
result: result
|
|
81
|
+
})); // <-
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
var elapsedMs = Date.now() - requestStartTime;
|
|
78
|
-
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
79
|
-
direction: 'down',
|
|
80
|
-
result: result
|
|
81
|
-
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
82
|
-
direction: 'down',
|
|
83
|
-
elapsedMs: elapsedMs,
|
|
84
|
-
result: result
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return next(op).pipe(tap.tap({
|
|
89
|
-
next: function next(result) {
|
|
90
|
-
logResult(result);
|
|
91
|
-
},
|
|
92
|
-
error: function error(result) {
|
|
93
|
-
logResult(result);
|
|
94
|
-
}
|
|
95
|
-
})).subscribe(observer);
|
|
83
|
+
prev(result);
|
|
96
84
|
});
|
|
97
85
|
};
|
|
98
86
|
};
|
|
@@ -4,9 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
6
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
-
var observable = require('../../../dist/observable-ccb54234.cjs.prod.js');
|
|
8
|
-
require('@babel/runtime/helpers/createForOfIteratorHelper');
|
|
9
|
-
var tap = require('../../../dist/tap-d907998d.cjs.prod.js');
|
|
10
7
|
|
|
11
8
|
var palette = {
|
|
12
9
|
query: ['72e3ff', '3fb0d8'],
|
|
@@ -47,7 +44,7 @@ var defaultLogger = function defaultLogger() {
|
|
|
47
44
|
});
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
var fn = props.direction === 'down' && props.result &&
|
|
47
|
+
var fn = props.direction === 'down' && props.result && props.result instanceof Error ? 'error' : 'log';
|
|
51
48
|
c[fn].apply(null, [parts.join(' ')].concat(args));
|
|
52
49
|
};
|
|
53
50
|
};
|
|
@@ -63,36 +60,27 @@ function loggerLink() {
|
|
|
63
60
|
return function () {
|
|
64
61
|
return function (_ref) {
|
|
65
62
|
var op = _ref.op,
|
|
66
|
-
next = _ref.next
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
next = _ref.next,
|
|
64
|
+
prev = _ref.prev;
|
|
65
|
+
// ->
|
|
66
|
+
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
67
|
+
direction: 'up'
|
|
68
|
+
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
69
|
+
direction: 'up'
|
|
70
|
+
}));
|
|
71
|
+
var requestStartTime = Date.now();
|
|
72
|
+
next(op, function (result) {
|
|
73
|
+
var elapsedMs = Date.now() - requestStartTime;
|
|
69
74
|
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
70
|
-
direction: '
|
|
75
|
+
direction: 'down',
|
|
76
|
+
result: result
|
|
71
77
|
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
72
|
-
direction: '
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
direction: 'down',
|
|
79
|
+
elapsedMs: elapsedMs,
|
|
80
|
+
result: result
|
|
81
|
+
})); // <-
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
var elapsedMs = Date.now() - requestStartTime;
|
|
78
|
-
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
79
|
-
direction: 'down',
|
|
80
|
-
result: result
|
|
81
|
-
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
82
|
-
direction: 'down',
|
|
83
|
-
elapsedMs: elapsedMs,
|
|
84
|
-
result: result
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return next(op).pipe(tap.tap({
|
|
89
|
-
next: function next(result) {
|
|
90
|
-
logResult(result);
|
|
91
|
-
},
|
|
92
|
-
error: function error(result) {
|
|
93
|
-
logResult(result);
|
|
94
|
-
}
|
|
95
|
-
})).subscribe(observer);
|
|
83
|
+
prev(result);
|
|
96
84
|
});
|
|
97
85
|
};
|
|
98
86
|
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
|
|
3
|
-
import { o as observable } from '../../../dist/observable-01534ea8.esm.js';
|
|
4
|
-
import '@babel/runtime/helpers/createForOfIteratorHelper';
|
|
5
|
-
import { t as tap } from '../../../dist/tap-606957cb.esm.js';
|
|
6
3
|
|
|
7
4
|
var palette = {
|
|
8
5
|
query: ['72e3ff', '3fb0d8'],
|
|
@@ -43,7 +40,7 @@ var defaultLogger = function defaultLogger() {
|
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
var fn = props.direction === 'down' && props.result &&
|
|
43
|
+
var fn = props.direction === 'down' && props.result && props.result instanceof Error ? 'error' : 'log';
|
|
47
44
|
c[fn].apply(null, [parts.join(' ')].concat(args));
|
|
48
45
|
};
|
|
49
46
|
};
|
|
@@ -59,36 +56,27 @@ function loggerLink() {
|
|
|
59
56
|
return function () {
|
|
60
57
|
return function (_ref) {
|
|
61
58
|
var op = _ref.op,
|
|
62
|
-
next = _ref.next
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
next = _ref.next,
|
|
60
|
+
prev = _ref.prev;
|
|
61
|
+
// ->
|
|
62
|
+
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
63
|
+
direction: 'up'
|
|
64
|
+
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
65
|
+
direction: 'up'
|
|
66
|
+
}));
|
|
67
|
+
var requestStartTime = Date.now();
|
|
68
|
+
next(op, function (result) {
|
|
69
|
+
var elapsedMs = Date.now() - requestStartTime;
|
|
65
70
|
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
66
|
-
direction: '
|
|
71
|
+
direction: 'down',
|
|
72
|
+
result: result
|
|
67
73
|
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
68
|
-
direction: '
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
direction: 'down',
|
|
75
|
+
elapsedMs: elapsedMs,
|
|
76
|
+
result: result
|
|
77
|
+
})); // <-
|
|
71
78
|
|
|
72
|
-
|
|
73
|
-
var elapsedMs = Date.now() - requestStartTime;
|
|
74
|
-
enabled(_objectSpread(_objectSpread({}, op), {}, {
|
|
75
|
-
direction: 'down',
|
|
76
|
-
result: result
|
|
77
|
-
})) && logger(_objectSpread(_objectSpread({}, op), {}, {
|
|
78
|
-
direction: 'down',
|
|
79
|
-
elapsedMs: elapsedMs,
|
|
80
|
-
result: result
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return next(op).pipe(tap({
|
|
85
|
-
next: function next(result) {
|
|
86
|
-
logResult(result);
|
|
87
|
-
},
|
|
88
|
-
error: function error(result) {
|
|
89
|
-
logResult(result);
|
|
90
|
-
}
|
|
91
|
-
})).subscribe(observer);
|
|
79
|
+
prev(result);
|
|
92
80
|
});
|
|
93
81
|
};
|
|
94
82
|
};
|