@trpc/client 11.0.0-rc.452 → 11.0.0-rc.456
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.map +1 -1
- package/dist/TRPCClientError.js +11 -8
- package/dist/TRPCClientError.mjs +12 -9
- package/dist/bundle-analysis.json +52 -66
- package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
- package/dist/internals/TRPCUntypedClient.js +15 -19
- package/dist/internals/TRPCUntypedClient.mjs +15 -19
- package/dist/internals/dataLoader.d.ts +2 -6
- package/dist/internals/dataLoader.d.ts.map +1 -1
- package/dist/internals/dataLoader.js +3 -16
- package/dist/internals/dataLoader.mjs +3 -16
- package/dist/internals/types.d.ts +0 -15
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.js +15 -17
- package/dist/links/httpBatchLink.mjs +16 -18
- package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
- package/dist/links/httpBatchStreamLink.js +40 -43
- package/dist/links/httpBatchStreamLink.mjs +41 -44
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/httpLink.js +3 -2
- package/dist/links/httpLink.mjs +3 -2
- package/dist/links/httpSubscriptionLink.js +1 -1
- package/dist/links/httpSubscriptionLink.mjs +1 -1
- package/dist/links/internals/httpUtils.d.ts +14 -11
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/links/internals/httpUtils.js +39 -33
- package/dist/links/internals/httpUtils.mjs +39 -34
- package/dist/links/types.d.ts +2 -12
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links/wsLink.js +2 -1
- package/dist/links/wsLink.mjs +2 -1
- package/package.json +4 -4
- package/src/TRPCClientError.ts +15 -10
- package/src/internals/TRPCUntypedClient.ts +18 -28
- package/src/internals/dataLoader.ts +4 -22
- package/src/internals/types.ts +0 -18
- package/src/links/httpBatchLink.ts +16 -19
- package/src/links/httpBatchStreamLink.ts +65 -72
- package/src/links/httpLink.ts +3 -2
- package/src/links/httpSubscriptionLink.ts +1 -1
- package/src/links/internals/httpUtils.ts +58 -44
- package/src/links/types.ts +2 -13
- package/src/links/wsLink.ts +1 -1
- package/dist/internals/getAbortController.d.ts +0 -4
- package/dist/internals/getAbortController.d.ts.map +0 -1
- package/dist/internals/getAbortController.js +0 -16
- package/dist/internals/getAbortController.mjs +0 -14
- package/src/internals/getAbortController.ts +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCClientError.d.ts","sourceRoot":"","sources":["../src/TRPCClientError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,EACL,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"TRPCClientError.d.ts","sourceRoot":"","sources":["../src/TRPCClientError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,EACL,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;AAElD,KAAK,eAAe,CAAC,WAAW,SAAS,qBAAqB,IAC5D,gBAAgB,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;AAC9C,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,iBAAiB;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;CACtC;AACD,MAAM,MAAM,mBAAmB,CAAC,WAAW,SAAS,qBAAqB,IACvE,mBAAmB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;AAgCpD,qBAAa,eAAe,CAAC,kBAAkB,SAAS,qBAAqB,CAC3E,SAAQ,KACR,YAAW,mBAAmB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAInE,SAAyB,KAAK,oBAAC;IAC/B,SAAgB,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAClE,SAAgB,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzE;;;OAGG;IACI,IAAI,sCAAC;gBAGV,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACvE,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC;WAkBW,IAAI,CAAC,kBAAkB,SAAS,qBAAqB,EACjE,MAAM,EAAE,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,EACtC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAO,GAC5C,eAAe,CAAC,kBAAkB,CAAC;CA2BvC"}
|
package/dist/TRPCClientError.js
CHANGED
|
@@ -11,6 +11,15 @@ function isTRPCClientError(cause) {
|
|
|
11
11
|
function isTRPCErrorResponse(obj) {
|
|
12
12
|
return unstableCoreDoNotImport.isObject(obj) && unstableCoreDoNotImport.isObject(obj['error']) && typeof obj['error']['code'] === 'number' && typeof obj['error']['message'] === 'string';
|
|
13
13
|
}
|
|
14
|
+
function getMessageFromUnknownError(err, fallback) {
|
|
15
|
+
if (typeof err === 'string') {
|
|
16
|
+
return err;
|
|
17
|
+
}
|
|
18
|
+
if (unstableCoreDoNotImport.isObject(err) && typeof err['message'] === 'string') {
|
|
19
|
+
return err['message'];
|
|
20
|
+
}
|
|
21
|
+
return fallback;
|
|
22
|
+
}
|
|
14
23
|
class TRPCClientError extends Error {
|
|
15
24
|
static from(_cause, opts = {}) {
|
|
16
25
|
const cause = _cause;
|
|
@@ -30,15 +39,9 @@ class TRPCClientError extends Error {
|
|
|
30
39
|
result: cause
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
return new TRPCClientError('Unknown error', {
|
|
35
|
-
...opts,
|
|
36
|
-
cause: cause
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return new TRPCClientError(cause.message, {
|
|
42
|
+
return new TRPCClientError(getMessageFromUnknownError(cause, 'Unknown error'), {
|
|
40
43
|
...opts,
|
|
41
|
-
cause:
|
|
44
|
+
cause: cause
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
constructor(message, opts){
|
package/dist/TRPCClientError.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObject } from '@trpc/server/unstable-core-do-not-import';
|
|
2
2
|
|
|
3
3
|
function isTRPCClientError(cause) {
|
|
4
4
|
return cause instanceof TRPCClientError || /**
|
|
@@ -9,6 +9,15 @@ function isTRPCClientError(cause) {
|
|
|
9
9
|
function isTRPCErrorResponse(obj) {
|
|
10
10
|
return isObject(obj) && isObject(obj['error']) && typeof obj['error']['code'] === 'number' && typeof obj['error']['message'] === 'string';
|
|
11
11
|
}
|
|
12
|
+
function getMessageFromUnknownError(err, fallback) {
|
|
13
|
+
if (typeof err === 'string') {
|
|
14
|
+
return err;
|
|
15
|
+
}
|
|
16
|
+
if (isObject(err) && typeof err['message'] === 'string') {
|
|
17
|
+
return err['message'];
|
|
18
|
+
}
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
12
21
|
class TRPCClientError extends Error {
|
|
13
22
|
static from(_cause, opts = {}) {
|
|
14
23
|
const cause = _cause;
|
|
@@ -28,15 +37,9 @@ class TRPCClientError extends Error {
|
|
|
28
37
|
result: cause
|
|
29
38
|
});
|
|
30
39
|
}
|
|
31
|
-
|
|
32
|
-
return new TRPCClientError('Unknown error', {
|
|
33
|
-
...opts,
|
|
34
|
-
cause: cause
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return new TRPCClientError(cause.message, {
|
|
40
|
+
return new TRPCClientError(getMessageFromUnknownError(cause, 'Unknown error'), {
|
|
38
41
|
...opts,
|
|
39
|
-
cause:
|
|
42
|
+
cause: cause
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
constructor(message, opts){
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 25.
|
|
2
|
+
"bundleSize": 50976,
|
|
3
|
+
"bundleOrigSize": 68169,
|
|
4
|
+
"bundleReduction": 25.22,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/links/wsLink.ts",
|
|
8
|
-
"size":
|
|
9
|
-
"origSize":
|
|
8
|
+
"size": 13069,
|
|
9
|
+
"origSize": 14556,
|
|
10
10
|
"renderedExports": [
|
|
11
11
|
"createWSClient",
|
|
12
12
|
"wsLink"
|
|
13
13
|
],
|
|
14
14
|
"removedExports": [],
|
|
15
15
|
"dependents": [],
|
|
16
|
-
"percent":
|
|
17
|
-
"reduction": 10.
|
|
16
|
+
"percent": 25.64,
|
|
17
|
+
"reduction": 10.22
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"id": "/src/links/httpBatchStreamLink.ts",
|
|
21
|
-
"size":
|
|
22
|
-
"origSize":
|
|
21
|
+
"size": 5861,
|
|
22
|
+
"origSize": 6074,
|
|
23
23
|
"renderedExports": [
|
|
24
24
|
"unstable_httpBatchStreamLink"
|
|
25
25
|
],
|
|
26
26
|
"removedExports": [],
|
|
27
27
|
"dependents": [],
|
|
28
|
-
"percent": 11.
|
|
29
|
-
"reduction":
|
|
28
|
+
"percent": 11.5,
|
|
29
|
+
"reduction": 3.51
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"id": "/src/links/loggerLink.ts",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
],
|
|
38
38
|
"removedExports": [],
|
|
39
39
|
"dependents": [],
|
|
40
|
-
"percent": 10.
|
|
40
|
+
"percent": 10.71,
|
|
41
41
|
"reduction": 18.48
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"id": "/src/internals/dataLoader.ts",
|
|
45
|
-
"size":
|
|
46
|
-
"origSize":
|
|
45
|
+
"size": 4084,
|
|
46
|
+
"origSize": 4328,
|
|
47
47
|
"renderedExports": [
|
|
48
48
|
"dataLoader"
|
|
49
49
|
],
|
|
@@ -52,25 +52,25 @@
|
|
|
52
52
|
"/src/links/httpBatchLink.ts",
|
|
53
53
|
"/src/links/httpBatchStreamLink.ts"
|
|
54
54
|
],
|
|
55
|
-
"percent": 8.
|
|
56
|
-
"reduction":
|
|
55
|
+
"percent": 8.01,
|
|
56
|
+
"reduction": 5.64
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"id": "/src/links/httpBatchLink.ts",
|
|
60
|
-
"size":
|
|
61
|
-
"origSize":
|
|
60
|
+
"size": 3925,
|
|
61
|
+
"origSize": 4118,
|
|
62
62
|
"renderedExports": [
|
|
63
63
|
"httpBatchLink"
|
|
64
64
|
],
|
|
65
65
|
"removedExports": [],
|
|
66
66
|
"dependents": [],
|
|
67
|
-
"percent": 7.
|
|
68
|
-
"reduction":
|
|
67
|
+
"percent": 7.7,
|
|
68
|
+
"reduction": 4.69
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
"id": "/src/links/internals/httpUtils.ts",
|
|
72
|
-
"size":
|
|
73
|
-
"origSize":
|
|
72
|
+
"size": 3704,
|
|
73
|
+
"origSize": 5903,
|
|
74
74
|
"renderedExports": [
|
|
75
75
|
"resolveHTTPLinkOptions",
|
|
76
76
|
"getInput",
|
|
@@ -78,7 +78,8 @@
|
|
|
78
78
|
"getBody",
|
|
79
79
|
"jsonHttpRequester",
|
|
80
80
|
"fetchHTTPResponse",
|
|
81
|
-
"httpRequest"
|
|
81
|
+
"httpRequest",
|
|
82
|
+
"mergeAbortSignals"
|
|
82
83
|
],
|
|
83
84
|
"removedExports": [],
|
|
84
85
|
"dependents": [
|
|
@@ -87,37 +88,37 @@
|
|
|
87
88
|
"/src/links/httpBatchStreamLink.ts",
|
|
88
89
|
"/src/links/httpSubscriptionLink.ts"
|
|
89
90
|
],
|
|
90
|
-
"percent":
|
|
91
|
-
"reduction":
|
|
91
|
+
"percent": 7.27,
|
|
92
|
+
"reduction": 37.25
|
|
92
93
|
},
|
|
93
94
|
{
|
|
94
95
|
"id": "/src/links/httpSubscriptionLink.ts",
|
|
95
|
-
"size":
|
|
96
|
-
"origSize":
|
|
96
|
+
"size": 3522,
|
|
97
|
+
"origSize": 3752,
|
|
97
98
|
"renderedExports": [
|
|
98
99
|
"unstable_httpSubscriptionLink"
|
|
99
100
|
],
|
|
100
101
|
"removedExports": [],
|
|
101
102
|
"dependents": [],
|
|
102
|
-
"percent": 6.
|
|
103
|
-
"reduction": 6.
|
|
103
|
+
"percent": 6.91,
|
|
104
|
+
"reduction": 6.13
|
|
104
105
|
},
|
|
105
106
|
{
|
|
106
107
|
"id": "/src/links/httpLink.ts",
|
|
107
|
-
"size":
|
|
108
|
-
"origSize":
|
|
108
|
+
"size": 3184,
|
|
109
|
+
"origSize": 3709,
|
|
109
110
|
"renderedExports": [
|
|
110
111
|
"httpLink"
|
|
111
112
|
],
|
|
112
113
|
"removedExports": [],
|
|
113
114
|
"dependents": [],
|
|
114
|
-
"percent": 6.
|
|
115
|
-
"reduction": 14.
|
|
115
|
+
"percent": 6.25,
|
|
116
|
+
"reduction": 14.15
|
|
116
117
|
},
|
|
117
118
|
{
|
|
118
119
|
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
119
|
-
"size":
|
|
120
|
-
"origSize":
|
|
120
|
+
"size": 2162,
|
|
121
|
+
"origSize": 4126,
|
|
121
122
|
"renderedExports": [
|
|
122
123
|
"TRPCUntypedClient"
|
|
123
124
|
],
|
|
@@ -126,13 +127,13 @@
|
|
|
126
127
|
"/src/createTRPCUntypedClient.ts",
|
|
127
128
|
"/src/createTRPCClient.ts"
|
|
128
129
|
],
|
|
129
|
-
"percent": 4.
|
|
130
|
-
"reduction":
|
|
130
|
+
"percent": 4.24,
|
|
131
|
+
"reduction": 47.6
|
|
131
132
|
},
|
|
132
133
|
{
|
|
133
134
|
"id": "/src/TRPCClientError.ts",
|
|
134
|
-
"size":
|
|
135
|
-
"origSize":
|
|
135
|
+
"size": 1940,
|
|
136
|
+
"origSize": 3555,
|
|
136
137
|
"renderedExports": [
|
|
137
138
|
"TRPCClientError"
|
|
138
139
|
],
|
|
@@ -144,11 +145,10 @@
|
|
|
144
145
|
"/src/links/wsLink.ts",
|
|
145
146
|
"/src/links/httpBatchStreamLink.ts",
|
|
146
147
|
"/src/links/httpSubscriptionLink.ts",
|
|
147
|
-
"/src/internals/TRPCUntypedClient.ts"
|
|
148
|
-
"/src/links/internals/httpUtils.ts"
|
|
148
|
+
"/src/internals/TRPCUntypedClient.ts"
|
|
149
149
|
],
|
|
150
|
-
"percent": 3.
|
|
151
|
-
"reduction": 45.
|
|
150
|
+
"percent": 3.81,
|
|
151
|
+
"reduction": 45.43
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
154
|
"id": "/src/createTRPCClient.ts",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"dependents": [
|
|
165
165
|
"/src/index.ts"
|
|
166
166
|
],
|
|
167
|
-
"percent": 2.
|
|
167
|
+
"percent": 2.33,
|
|
168
168
|
"reduction": 73.19
|
|
169
169
|
},
|
|
170
170
|
{
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"/src/links/splitLink.ts",
|
|
180
180
|
"/src/internals/TRPCUntypedClient.ts"
|
|
181
181
|
],
|
|
182
|
-
"percent": 1.
|
|
182
|
+
"percent": 1.35,
|
|
183
183
|
"reduction": 32.75
|
|
184
184
|
},
|
|
185
185
|
{
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
],
|
|
192
192
|
"removedExports": [],
|
|
193
193
|
"dependents": [],
|
|
194
|
-
"percent": 1.
|
|
194
|
+
"percent": 1.2,
|
|
195
195
|
"reduction": 44.95
|
|
196
196
|
},
|
|
197
197
|
{
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
"dependents": [
|
|
206
206
|
"/src/unstable-internals.ts"
|
|
207
207
|
],
|
|
208
|
-
"percent": 1.
|
|
208
|
+
"percent": 1.11,
|
|
209
209
|
"reduction": 66.75
|
|
210
210
|
},
|
|
211
211
|
{
|
|
@@ -220,23 +220,9 @@
|
|
|
220
220
|
"/src/index.ts",
|
|
221
221
|
"/src/links/internals/httpUtils.ts"
|
|
222
222
|
],
|
|
223
|
-
"percent": 0.
|
|
223
|
+
"percent": 0.84,
|
|
224
224
|
"reduction": 33.54
|
|
225
225
|
},
|
|
226
|
-
{
|
|
227
|
-
"id": "/src/internals/getAbortController.ts",
|
|
228
|
-
"size": 396,
|
|
229
|
-
"origSize": 569,
|
|
230
|
-
"renderedExports": [
|
|
231
|
-
"getAbortController"
|
|
232
|
-
],
|
|
233
|
-
"removedExports": [],
|
|
234
|
-
"dependents": [
|
|
235
|
-
"/src/links/internals/httpUtils.ts"
|
|
236
|
-
],
|
|
237
|
-
"percent": 0.76,
|
|
238
|
-
"reduction": 30.4
|
|
239
|
-
},
|
|
240
226
|
{
|
|
241
227
|
"id": "/src/links/internals/contentTypes.ts",
|
|
242
228
|
"size": 330,
|
|
@@ -248,7 +234,7 @@
|
|
|
248
234
|
],
|
|
249
235
|
"removedExports": [],
|
|
250
236
|
"dependents": [],
|
|
251
|
-
"percent": 0.
|
|
237
|
+
"percent": 0.65,
|
|
252
238
|
"reduction": 15.17
|
|
253
239
|
},
|
|
254
240
|
{
|
|
@@ -263,7 +249,7 @@
|
|
|
263
249
|
"/src/links/wsLink.ts",
|
|
264
250
|
"/src/links/httpSubscriptionLink.ts"
|
|
265
251
|
],
|
|
266
|
-
"percent": 0.
|
|
252
|
+
"percent": 0.31,
|
|
267
253
|
"reduction": 81.56
|
|
268
254
|
},
|
|
269
255
|
{
|
|
@@ -277,7 +263,7 @@
|
|
|
277
263
|
"dependents": [
|
|
278
264
|
"/src/index.ts"
|
|
279
265
|
],
|
|
280
|
-
"percent": 0.
|
|
266
|
+
"percent": 0.2,
|
|
281
267
|
"reduction": 82.58
|
|
282
268
|
},
|
|
283
269
|
{
|
|
@@ -305,5 +291,5 @@
|
|
|
305
291
|
"reduction": 100
|
|
306
292
|
}
|
|
307
293
|
],
|
|
308
|
-
"moduleCount":
|
|
294
|
+
"moduleCount": 20
|
|
309
295
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCUntypedClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,
|
|
1
|
+
{"version":3,"file":"TRPCUntypedClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EAErB,SAAS,EACV,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACV,gBAAgB,EAEhB,iBAAiB,EACjB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB,CAAC,MAAM,E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AAS,CAAC,CAAC,CAC9D,GACC,kBAAkB,GACnB,cAAc;CA4BlB"}
|
|
@@ -5,31 +5,26 @@ var createChain = require('../links/internals/createChain.js');
|
|
|
5
5
|
var TRPCClientError = require('../TRPCClientError.js');
|
|
6
6
|
|
|
7
7
|
class TRPCUntypedClient {
|
|
8
|
-
$request(
|
|
8
|
+
$request(opts) {
|
|
9
9
|
const chain$ = createChain.createChain({
|
|
10
10
|
links: this.links,
|
|
11
11
|
op: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
input,
|
|
16
|
-
context
|
|
12
|
+
...opts,
|
|
13
|
+
context: opts.context ?? {},
|
|
14
|
+
id: ++this.requestId
|
|
17
15
|
}
|
|
18
16
|
});
|
|
19
17
|
return chain$.pipe(observable.share());
|
|
20
18
|
}
|
|
21
|
-
requestAsPromise(opts) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
return abortablePromise;
|
|
19
|
+
async requestAsPromise(opts) {
|
|
20
|
+
try {
|
|
21
|
+
const req$ = this.$request(opts);
|
|
22
|
+
const envelope = await observable.observableToPromise(req$);
|
|
23
|
+
const data = envelope.result.data;
|
|
24
|
+
return data;
|
|
25
|
+
} catch (err) {
|
|
26
|
+
throw TRPCClientError.TRPCClientError.from(err);
|
|
27
|
+
}
|
|
33
28
|
}
|
|
34
29
|
query(path, input, opts) {
|
|
35
30
|
return this.requestAsPromise({
|
|
@@ -54,7 +49,8 @@ class TRPCUntypedClient {
|
|
|
54
49
|
type: 'subscription',
|
|
55
50
|
path,
|
|
56
51
|
input,
|
|
57
|
-
context: opts?.context
|
|
52
|
+
context: opts?.context,
|
|
53
|
+
signal: null
|
|
58
54
|
});
|
|
59
55
|
return observable$.subscribe({
|
|
60
56
|
next (envelope) {
|
|
@@ -3,31 +3,26 @@ import { createChain } from '../links/internals/createChain.mjs';
|
|
|
3
3
|
import { TRPCClientError } from '../TRPCClientError.mjs';
|
|
4
4
|
|
|
5
5
|
class TRPCUntypedClient {
|
|
6
|
-
$request(
|
|
6
|
+
$request(opts) {
|
|
7
7
|
const chain$ = createChain({
|
|
8
8
|
links: this.links,
|
|
9
9
|
op: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
input,
|
|
14
|
-
context
|
|
10
|
+
...opts,
|
|
11
|
+
context: opts.context ?? {},
|
|
12
|
+
id: ++this.requestId
|
|
15
13
|
}
|
|
16
14
|
});
|
|
17
15
|
return chain$.pipe(share());
|
|
18
16
|
}
|
|
19
|
-
requestAsPromise(opts) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
return abortablePromise;
|
|
17
|
+
async requestAsPromise(opts) {
|
|
18
|
+
try {
|
|
19
|
+
const req$ = this.$request(opts);
|
|
20
|
+
const envelope = await observableToPromise(req$);
|
|
21
|
+
const data = envelope.result.data;
|
|
22
|
+
return data;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
throw TRPCClientError.from(err);
|
|
25
|
+
}
|
|
31
26
|
}
|
|
32
27
|
query(path, input, opts) {
|
|
33
28
|
return this.requestAsPromise({
|
|
@@ -52,7 +47,8 @@ class TRPCUntypedClient {
|
|
|
52
47
|
type: 'subscription',
|
|
53
48
|
path,
|
|
54
49
|
input,
|
|
55
|
-
context: opts?.context
|
|
50
|
+
context: opts?.context,
|
|
51
|
+
signal: null
|
|
56
52
|
});
|
|
57
53
|
return observable$.subscribe({
|
|
58
54
|
next (envelope) {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type { CancelFn, PromiseAndCancel } from '../links/types';
|
|
2
1
|
export type BatchLoader<TKey, TValue> = {
|
|
3
2
|
validate: (keys: TKey[]) => boolean;
|
|
4
|
-
fetch: (keys: TKey[]) =>
|
|
5
|
-
promise: Promise<TValue[] | Promise<TValue>[]>;
|
|
6
|
-
cancel: CancelFn;
|
|
7
|
-
};
|
|
3
|
+
fetch: (keys: TKey[]) => Promise<TValue[] | Promise<TValue>[]>;
|
|
8
4
|
};
|
|
9
5
|
/**
|
|
10
6
|
* Dataloader that's very inspired by https://github.com/graphql/dataloader
|
|
@@ -12,6 +8,6 @@ export type BatchLoader<TKey, TValue> = {
|
|
|
12
8
|
* When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled
|
|
13
9
|
*/
|
|
14
10
|
export declare function dataLoader<TKey, TValue>(batchLoader: BatchLoader<TKey, TValue>): {
|
|
15
|
-
load: (key: TKey) =>
|
|
11
|
+
load: (key: TKey) => Promise<TValue>;
|
|
16
12
|
};
|
|
17
13
|
//# sourceMappingURL=dataLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../src/internals/dataLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../src/internals/dataLoader.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CAChE,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EACrC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;gBAsGnB,IAAI,KAAG,OAAO,CAAC,MAAM,CAAC;EA6B1C"}
|
|
@@ -61,14 +61,12 @@
|
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
63
|
const batch = {
|
|
64
|
-
items
|
|
65
|
-
cancel: throwFatalError
|
|
64
|
+
items
|
|
66
65
|
};
|
|
67
66
|
for (const item of items){
|
|
68
67
|
item.batch = batch;
|
|
69
68
|
}
|
|
70
|
-
const
|
|
71
|
-
batch.cancel = cancel;
|
|
69
|
+
const promise = batchLoader.fetch(batch.items.map((_item)=>_item.key));
|
|
72
70
|
promise.then(async (result)=>{
|
|
73
71
|
await Promise.all(result.map(async (valueOrPromise, index)=>{
|
|
74
72
|
const item = batch.items[index];
|
|
@@ -113,18 +111,7 @@
|
|
|
113
111
|
if (!dispatchTimer) {
|
|
114
112
|
dispatchTimer = setTimeout(dispatch);
|
|
115
113
|
}
|
|
116
|
-
|
|
117
|
-
item.aborted = true;
|
|
118
|
-
if (item.batch?.items.every((item)=>item.aborted)) {
|
|
119
|
-
// All items in the batch have been cancelled
|
|
120
|
-
item.batch.cancel();
|
|
121
|
-
item.batch = null;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
return {
|
|
125
|
-
promise,
|
|
126
|
-
cancel
|
|
127
|
-
};
|
|
114
|
+
return promise;
|
|
128
115
|
}
|
|
129
116
|
return {
|
|
130
117
|
load
|
|
@@ -59,14 +59,12 @@
|
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
61
|
const batch = {
|
|
62
|
-
items
|
|
63
|
-
cancel: throwFatalError
|
|
62
|
+
items
|
|
64
63
|
};
|
|
65
64
|
for (const item of items){
|
|
66
65
|
item.batch = batch;
|
|
67
66
|
}
|
|
68
|
-
const
|
|
69
|
-
batch.cancel = cancel;
|
|
67
|
+
const promise = batchLoader.fetch(batch.items.map((_item)=>_item.key));
|
|
70
68
|
promise.then(async (result)=>{
|
|
71
69
|
await Promise.all(result.map(async (valueOrPromise, index)=>{
|
|
72
70
|
const item = batch.items[index];
|
|
@@ -111,18 +109,7 @@
|
|
|
111
109
|
if (!dispatchTimer) {
|
|
112
110
|
dispatchTimer = setTimeout(dispatch);
|
|
113
111
|
}
|
|
114
|
-
|
|
115
|
-
item.aborted = true;
|
|
116
|
-
if (item.batch?.items.every((item)=>item.aborted)) {
|
|
117
|
-
// All items in the batch have been cancelled
|
|
118
|
-
item.batch.cancel();
|
|
119
|
-
item.batch = null;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return {
|
|
123
|
-
promise,
|
|
124
|
-
cancel
|
|
125
|
-
};
|
|
112
|
+
return promise;
|
|
126
113
|
}
|
|
127
114
|
return {
|
|
128
115
|
load
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
export type AbortControllerEsque = new () => AbortControllerInstanceEsque;
|
|
2
|
-
/**
|
|
3
|
-
* Allows you to abort one or more requests.
|
|
4
|
-
*/
|
|
5
|
-
export interface AbortControllerInstanceEsque {
|
|
6
|
-
/**
|
|
7
|
-
* The AbortSignal object associated with this object.
|
|
8
|
-
*/
|
|
9
|
-
readonly signal: AbortSignal;
|
|
10
|
-
/**
|
|
11
|
-
* Sets this object's AbortSignal's aborted flag and signals to
|
|
12
|
-
* any observers that the associated activity is to be aborted.
|
|
13
|
-
*/
|
|
14
|
-
abort(): void;
|
|
15
|
-
}
|
|
16
1
|
/**
|
|
17
2
|
* A subset of the standard fetch function type needed by tRPC internally.
|
|
18
3
|
* @see fetch from lib.dom.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internals/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internals/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,KAAK,EAAE,WAAW,GAAG,GAAG,GAAG,MAAM,EACjC,IAAI,CAAC,EAAE,WAAW,GAAG,gBAAgB,KAClC,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,GAAG,EAAE,G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"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,CAkHnB"}
|