@trpc/client 10.22.0 → 10.23.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/{httpUtils-0e44d50d.js → httpUtils-1a07b2e6.js} +18 -8
- package/dist/{httpUtils-f08fd191.mjs → httpUtils-8a5c637a.mjs} +18 -8
- package/dist/{httpUtils-0c7ec827.js → httpUtils-90a6bccb.js} +18 -7
- package/dist/index.js +31 -2
- package/dist/index.mjs +34 -5
- package/dist/internals/types.d.ts +1 -1
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/isObject-246cec0f.js +6 -0
- package/dist/isObject-3ec9fe00.mjs +6 -0
- package/dist/isObject-617ad59e.js +8 -0
- package/dist/links/httpBatchLink.js +4 -3
- package/dist/links/httpBatchLink.mjs +4 -3
- package/dist/links/httpFormDataLink.d.ts +2 -0
- package/dist/links/httpFormDataLink.d.ts.map +1 -0
- package/dist/links/httpLink.d.ts +5 -2
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/httpLink.js +46 -39
- package/dist/links/httpLink.mjs +46 -40
- package/dist/links/index.d.ts +2 -1
- package/dist/links/index.d.ts.map +1 -1
- package/dist/links/internals/httpUtils.d.ts +16 -10
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/links/internals/isObject.d.ts +2 -0
- package/dist/links/internals/isObject.d.ts.map +1 -0
- package/dist/links/internals/transformResult.d.ts.map +1 -1
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/dist/links/loggerLink.js +11 -1
- package/dist/links/loggerLink.mjs +11 -1
- package/dist/links/wsLink.js +2 -1
- package/dist/links/wsLink.mjs +2 -1
- package/dist/{transformResult-e7a1e69e.js → transformResult-12020457.js} +4 -6
- package/dist/{transformResult-6fb67924.mjs → transformResult-403dc1d4.mjs} +2 -4
- package/dist/{transformResult-4e205a12.js → transformResult-51c1bc81.js} +2 -4
- package/package.json +5 -5
- package/src/internals/types.ts +1 -1
- package/src/links/httpBatchLink.ts +2 -2
- package/src/links/httpFormDataLink.ts +30 -0
- package/src/links/httpLink.ts +54 -50
- package/src/links/index.ts +3 -1
- package/src/links/internals/httpUtils.ts +40 -14
- package/src/links/internals/isObject.ts +4 -0
- package/src/links/internals/transformResult.ts +1 -5
- package/src/links/loggerLink.ts +17 -1
|
@@ -54,7 +54,7 @@ function getInput(opts) {
|
|
|
54
54
|
? opts.runtime.transformer.serialize(opts.input)
|
|
55
55
|
: arrayToDict(opts.inputs.map((_input) => opts.runtime.transformer.serialize(_input)));
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
const getUrl = (opts) => {
|
|
58
58
|
let url = opts.url + '/' + opts.path;
|
|
59
59
|
const queryParts = [];
|
|
60
60
|
if ('inputs' in opts) {
|
|
@@ -70,20 +70,28 @@ function getUrl(opts) {
|
|
|
70
70
|
url += '?' + queryParts.join('&');
|
|
71
71
|
}
|
|
72
72
|
return url;
|
|
73
|
-
}
|
|
74
|
-
|
|
73
|
+
};
|
|
74
|
+
const getBody = (opts) => {
|
|
75
75
|
if (opts.type === 'query') {
|
|
76
76
|
return undefined;
|
|
77
77
|
}
|
|
78
78
|
const input = getInput(opts);
|
|
79
79
|
return input !== undefined ? JSON.stringify(input) : undefined;
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
|
+
const jsonHttpRequester = (opts) => {
|
|
82
|
+
return httpRequest({
|
|
83
|
+
...opts,
|
|
84
|
+
contentTypeHeader: 'application/json',
|
|
85
|
+
getUrl,
|
|
86
|
+
getBody,
|
|
87
|
+
});
|
|
88
|
+
};
|
|
81
89
|
function httpRequest(opts) {
|
|
82
90
|
const { type } = opts;
|
|
83
91
|
const ac = opts.AbortController ? new opts.AbortController() : null;
|
|
84
92
|
const promise = new Promise((resolve, reject) => {
|
|
85
|
-
const url = getUrl(opts);
|
|
86
|
-
const body = getBody(opts);
|
|
93
|
+
const url = opts.getUrl(opts);
|
|
94
|
+
const body = opts.getBody(opts);
|
|
87
95
|
const meta = {};
|
|
88
96
|
Promise.resolve(opts.headers())
|
|
89
97
|
.then((headers) => {
|
|
@@ -96,7 +104,9 @@ function httpRequest(opts) {
|
|
|
96
104
|
signal: ac?.signal,
|
|
97
105
|
body: body,
|
|
98
106
|
headers: {
|
|
99
|
-
|
|
107
|
+
...(opts.contentTypeHeader
|
|
108
|
+
? { 'content-type': opts.contentTypeHeader }
|
|
109
|
+
: {}),
|
|
100
110
|
...headers,
|
|
101
111
|
},
|
|
102
112
|
});
|
|
@@ -119,4 +129,4 @@ function httpRequest(opts) {
|
|
|
119
129
|
return { promise, cancel };
|
|
120
130
|
}
|
|
121
131
|
|
|
122
|
-
export { getUrl as a, getFetch as g, httpRequest as h, resolveHTTPLinkOptions as r };
|
|
132
|
+
export { getUrl as a, getFetch as g, httpRequest as h, jsonHttpRequester as j, resolveHTTPLinkOptions as r };
|
|
@@ -52,7 +52,7 @@ const METHOD = {
|
|
|
52
52
|
function getInput(opts) {
|
|
53
53
|
return 'input' in opts ? opts.runtime.transformer.serialize(opts.input) : arrayToDict(opts.inputs.map((_input)=>opts.runtime.transformer.serialize(_input)));
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
const getUrl = (opts)=>{
|
|
56
56
|
let url = opts.url + '/' + opts.path;
|
|
57
57
|
const queryParts = [];
|
|
58
58
|
if ('inputs' in opts) {
|
|
@@ -68,20 +68,28 @@ function getUrl(opts) {
|
|
|
68
68
|
url += '?' + queryParts.join('&');
|
|
69
69
|
}
|
|
70
70
|
return url;
|
|
71
|
-
}
|
|
72
|
-
|
|
71
|
+
};
|
|
72
|
+
const getBody = (opts)=>{
|
|
73
73
|
if (opts.type === 'query') {
|
|
74
74
|
return undefined;
|
|
75
75
|
}
|
|
76
76
|
const input = getInput(opts);
|
|
77
77
|
return input !== undefined ? JSON.stringify(input) : undefined;
|
|
78
|
-
}
|
|
78
|
+
};
|
|
79
|
+
const jsonHttpRequester = (opts)=>{
|
|
80
|
+
return httpRequest({
|
|
81
|
+
...opts,
|
|
82
|
+
contentTypeHeader: 'application/json',
|
|
83
|
+
getUrl,
|
|
84
|
+
getBody
|
|
85
|
+
});
|
|
86
|
+
};
|
|
79
87
|
function httpRequest(opts) {
|
|
80
88
|
const { type } = opts;
|
|
81
89
|
const ac = opts.AbortController ? new opts.AbortController() : null;
|
|
82
90
|
const promise = new Promise((resolve, reject)=>{
|
|
83
|
-
const url = getUrl(opts);
|
|
84
|
-
const body = getBody(opts);
|
|
91
|
+
const url = opts.getUrl(opts);
|
|
92
|
+
const body = opts.getBody(opts);
|
|
85
93
|
const meta = {};
|
|
86
94
|
Promise.resolve(opts.headers()).then((headers)=>{
|
|
87
95
|
/* istanbul ignore if -- @preserve */ if (type === 'subscription') {
|
|
@@ -92,7 +100,9 @@ function httpRequest(opts) {
|
|
|
92
100
|
signal: ac?.signal,
|
|
93
101
|
body: body,
|
|
94
102
|
headers: {
|
|
95
|
-
|
|
103
|
+
...opts.contentTypeHeader ? {
|
|
104
|
+
'content-type': opts.contentTypeHeader
|
|
105
|
+
} : {},
|
|
96
106
|
...headers
|
|
97
107
|
}
|
|
98
108
|
});
|
|
@@ -115,4 +125,4 @@ function httpRequest(opts) {
|
|
|
115
125
|
};
|
|
116
126
|
}
|
|
117
127
|
|
|
118
|
-
export { getUrl as a, getFetch as g, httpRequest as h, resolveHTTPLinkOptions as r };
|
|
128
|
+
export { getUrl as a, getFetch as g, httpRequest as h, jsonHttpRequester as j, resolveHTTPLinkOptions as r };
|
|
@@ -54,7 +54,7 @@ const METHOD = {
|
|
|
54
54
|
function getInput(opts) {
|
|
55
55
|
return 'input' in opts ? opts.runtime.transformer.serialize(opts.input) : arrayToDict(opts.inputs.map((_input)=>opts.runtime.transformer.serialize(_input)));
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
const getUrl = (opts)=>{
|
|
58
58
|
let url = opts.url + '/' + opts.path;
|
|
59
59
|
const queryParts = [];
|
|
60
60
|
if ('inputs' in opts) {
|
|
@@ -70,20 +70,28 @@ function getUrl(opts) {
|
|
|
70
70
|
url += '?' + queryParts.join('&');
|
|
71
71
|
}
|
|
72
72
|
return url;
|
|
73
|
-
}
|
|
74
|
-
|
|
73
|
+
};
|
|
74
|
+
const getBody = (opts)=>{
|
|
75
75
|
if (opts.type === 'query') {
|
|
76
76
|
return undefined;
|
|
77
77
|
}
|
|
78
78
|
const input = getInput(opts);
|
|
79
79
|
return input !== undefined ? JSON.stringify(input) : undefined;
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
|
+
const jsonHttpRequester = (opts)=>{
|
|
82
|
+
return httpRequest({
|
|
83
|
+
...opts,
|
|
84
|
+
contentTypeHeader: 'application/json',
|
|
85
|
+
getUrl,
|
|
86
|
+
getBody
|
|
87
|
+
});
|
|
88
|
+
};
|
|
81
89
|
function httpRequest(opts) {
|
|
82
90
|
const { type } = opts;
|
|
83
91
|
const ac = opts.AbortController ? new opts.AbortController() : null;
|
|
84
92
|
const promise = new Promise((resolve, reject)=>{
|
|
85
|
-
const url = getUrl(opts);
|
|
86
|
-
const body = getBody(opts);
|
|
93
|
+
const url = opts.getUrl(opts);
|
|
94
|
+
const body = opts.getBody(opts);
|
|
87
95
|
const meta = {};
|
|
88
96
|
Promise.resolve(opts.headers()).then((headers)=>{
|
|
89
97
|
/* istanbul ignore if -- @preserve */ if (type === 'subscription') {
|
|
@@ -94,7 +102,9 @@ function httpRequest(opts) {
|
|
|
94
102
|
signal: ac?.signal,
|
|
95
103
|
body: body,
|
|
96
104
|
headers: {
|
|
97
|
-
|
|
105
|
+
...opts.contentTypeHeader ? {
|
|
106
|
+
'content-type': opts.contentTypeHeader
|
|
107
|
+
} : {},
|
|
98
108
|
...headers
|
|
99
109
|
}
|
|
100
110
|
});
|
|
@@ -120,4 +130,5 @@ function httpRequest(opts) {
|
|
|
120
130
|
exports.getFetch = getFetch;
|
|
121
131
|
exports.getUrl = getUrl;
|
|
122
132
|
exports.httpRequest = httpRequest;
|
|
133
|
+
exports.jsonHttpRequester = jsonHttpRequester;
|
|
123
134
|
exports.resolveHTTPLinkOptions = resolveHTTPLinkOptions;
|
package/dist/index.js
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var observable = require('@trpc/server/observable');
|
|
6
|
-
var transformResult = require('./transformResult-
|
|
6
|
+
var transformResult = require('./transformResult-12020457.js');
|
|
7
7
|
var links_splitLink = require('./splitLink-f29e84be.js');
|
|
8
8
|
var shared = require('@trpc/server/shared');
|
|
9
|
-
var httpUtils = require('./httpUtils-
|
|
9
|
+
var httpUtils = require('./httpUtils-90a6bccb.js');
|
|
10
10
|
var links_httpBatchLink = require('./links/httpBatchLink.js');
|
|
11
11
|
var links_httpLink = require('./links/httpLink.js');
|
|
12
12
|
var links_loggerLink = require('./links/loggerLink.js');
|
|
13
13
|
var links_wsLink = require('./links/wsLink.js');
|
|
14
|
+
require('./isObject-617ad59e.js');
|
|
14
15
|
|
|
15
16
|
class TRPCUntypedClient {
|
|
16
17
|
$request({ type , input , path , context ={} }) {
|
|
@@ -161,11 +162,38 @@ function createTRPCProxyClient(opts) {
|
|
|
161
162
|
return proxy;
|
|
162
163
|
}
|
|
163
164
|
|
|
165
|
+
const getBody = (opts)=>{
|
|
166
|
+
if (!('input' in opts)) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
if (!(opts.input instanceof FormData)) {
|
|
170
|
+
throw new Error('Input is not FormData');
|
|
171
|
+
}
|
|
172
|
+
return opts.input;
|
|
173
|
+
};
|
|
174
|
+
const formDataRequester = (opts)=>{
|
|
175
|
+
if (opts.type !== 'mutation') {
|
|
176
|
+
// TODO(?) handle formdata queries
|
|
177
|
+
throw new Error('We only handle mutations with formdata');
|
|
178
|
+
}
|
|
179
|
+
return httpUtils.httpRequest({
|
|
180
|
+
...opts,
|
|
181
|
+
getUrl () {
|
|
182
|
+
return `${opts.url}/${opts.path}`;
|
|
183
|
+
},
|
|
184
|
+
getBody
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
const experimental_formDataLink = links_httpLink.httpLinkFactory({
|
|
188
|
+
requester: formDataRequester
|
|
189
|
+
});
|
|
190
|
+
|
|
164
191
|
exports.TRPCClientError = transformResult.TRPCClientError;
|
|
165
192
|
exports.splitLink = links_splitLink.splitLink;
|
|
166
193
|
exports.getFetch = httpUtils.getFetch;
|
|
167
194
|
exports.httpBatchLink = links_httpBatchLink.httpBatchLink;
|
|
168
195
|
exports.httpLink = links_httpLink.httpLink;
|
|
196
|
+
exports.httpLinkFactory = links_httpLink.httpLinkFactory;
|
|
169
197
|
exports.loggerLink = links_loggerLink.loggerLink;
|
|
170
198
|
exports.createWSClient = links_wsLink.createWSClient;
|
|
171
199
|
exports.wsLink = links_wsLink.wsLink;
|
|
@@ -173,3 +201,4 @@ exports.createTRPCClient = createTRPCClient;
|
|
|
173
201
|
exports.createTRPCClientProxy = createTRPCClientProxy;
|
|
174
202
|
exports.createTRPCProxyClient = createTRPCProxyClient;
|
|
175
203
|
exports.createTRPCUntypedClient = createTRPCUntypedClient;
|
|
204
|
+
exports.experimental_formDataLink = experimental_formDataLink;
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { share, observableToPromise } from '@trpc/server/observable';
|
|
2
|
-
import { T as TRPCClientError } from './transformResult-
|
|
3
|
-
export { T as TRPCClientError } from './transformResult-
|
|
2
|
+
import { T as TRPCClientError } from './transformResult-403dc1d4.mjs';
|
|
3
|
+
export { T as TRPCClientError } from './transformResult-403dc1d4.mjs';
|
|
4
4
|
import { c as createChain } from './splitLink-4c75f7be.mjs';
|
|
5
5
|
export { s as splitLink } from './splitLink-4c75f7be.mjs';
|
|
6
6
|
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared';
|
|
7
|
-
|
|
7
|
+
import { h as httpRequest } from './httpUtils-8a5c637a.mjs';
|
|
8
|
+
export { g as getFetch } from './httpUtils-8a5c637a.mjs';
|
|
8
9
|
export { httpBatchLink } from './links/httpBatchLink.mjs';
|
|
9
|
-
|
|
10
|
+
import { httpLinkFactory } from './links/httpLink.mjs';
|
|
11
|
+
export { httpLink, httpLinkFactory } from './links/httpLink.mjs';
|
|
10
12
|
export { loggerLink } from './links/loggerLink.mjs';
|
|
11
13
|
export { createWSClient, wsLink } from './links/wsLink.mjs';
|
|
14
|
+
import './isObject-3ec9fe00.mjs';
|
|
12
15
|
|
|
13
16
|
class TRPCUntypedClient {
|
|
14
17
|
$request({ type , input , path , context ={} }) {
|
|
@@ -159,4 +162,30 @@ function createTRPCProxyClient(opts) {
|
|
|
159
162
|
return proxy;
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
|
|
165
|
+
const getBody = (opts)=>{
|
|
166
|
+
if (!('input' in opts)) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
if (!(opts.input instanceof FormData)) {
|
|
170
|
+
throw new Error('Input is not FormData');
|
|
171
|
+
}
|
|
172
|
+
return opts.input;
|
|
173
|
+
};
|
|
174
|
+
const formDataRequester = (opts)=>{
|
|
175
|
+
if (opts.type !== 'mutation') {
|
|
176
|
+
// TODO(?) handle formdata queries
|
|
177
|
+
throw new Error('We only handle mutations with formdata');
|
|
178
|
+
}
|
|
179
|
+
return httpRequest({
|
|
180
|
+
...opts,
|
|
181
|
+
getUrl () {
|
|
182
|
+
return `${opts.url}/${opts.path}`;
|
|
183
|
+
},
|
|
184
|
+
getBody
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
const experimental_formDataLink = httpLinkFactory({
|
|
188
|
+
requester: formDataRequester
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export { createTRPCClient, createTRPCClientProxy, createTRPCProxyClient, createTRPCUntypedClient, experimental_formDataLink };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internals/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,4BAA4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oBAAY,YAAY,GACpB,OAAO,GACP,MAAM,GACN,SAAS,GACT,OAAO,GACP,QAAQ,GACR,gBAAgB,CAAC;AAErB;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,QAAQ,GAAG,IAAI,CAAC;IAEjD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,KAAK,IAAI,aAAa,CAAC;IAEvB;;;;;OAKG;IACH,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,oBAAY,aAAa,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var observable = require('@trpc/server/observable');
|
|
6
|
-
var transformResult = require('../transformResult-
|
|
7
|
-
var httpUtils = require('../httpUtils-
|
|
6
|
+
var transformResult = require('../transformResult-12020457.js');
|
|
7
|
+
var httpUtils = require('../httpUtils-90a6bccb.js');
|
|
8
|
+
require('../isObject-617ad59e.js');
|
|
8
9
|
|
|
9
10
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
|
|
10
11
|
* A function that should never be called unless we messed something up.
|
|
@@ -152,7 +153,7 @@ function httpBatchLink(opts) {
|
|
|
152
153
|
const fetch = (batchOps)=>{
|
|
153
154
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
154
155
|
const inputs = batchOps.map((op)=>op.input);
|
|
155
|
-
const { promise , cancel } = httpUtils.
|
|
156
|
+
const { promise , cancel } = httpUtils.jsonHttpRequester({
|
|
156
157
|
...resolvedOpts,
|
|
157
158
|
runtime,
|
|
158
159
|
type,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { observable } from '@trpc/server/observable';
|
|
2
|
-
import { t as transformResult, T as TRPCClientError } from '../transformResult-
|
|
3
|
-
import { r as resolveHTTPLinkOptions, a as getUrl,
|
|
2
|
+
import { t as transformResult, T as TRPCClientError } from '../transformResult-403dc1d4.mjs';
|
|
3
|
+
import { r as resolveHTTPLinkOptions, a as getUrl, j as jsonHttpRequester } from '../httpUtils-8a5c637a.mjs';
|
|
4
|
+
import '../isObject-3ec9fe00.mjs';
|
|
4
5
|
|
|
5
6
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
|
|
6
7
|
* A function that should never be called unless we messed something up.
|
|
@@ -148,7 +149,7 @@ function httpBatchLink(opts) {
|
|
|
148
149
|
const fetch = (batchOps)=>{
|
|
149
150
|
const path = batchOps.map((op)=>op.path).join(',');
|
|
150
151
|
const inputs = batchOps.map((op)=>op.input);
|
|
151
|
-
const { promise , cancel } =
|
|
152
|
+
const { promise , cancel } = jsonHttpRequester({
|
|
152
153
|
...resolvedOpts,
|
|
153
154
|
runtime,
|
|
154
155
|
type,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpFormDataLink.d.ts","sourceRoot":"","sources":["../../src/links/httpFormDataLink.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,yBAAyB,uIAEpC,CAAC"}
|
package/dist/links/httpLink.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyRouter } from '@trpc/server';
|
|
2
|
-
import { HTTPLinkBaseOptions } from './internals/httpUtils';
|
|
2
|
+
import { HTTPLinkBaseOptions, Requester } from './internals/httpUtils';
|
|
3
3
|
import { HTTPHeaders, Operation, TRPCLink } from './types';
|
|
4
4
|
export interface HTTPLinkOptions extends HTTPLinkBaseOptions {
|
|
5
5
|
/**
|
|
@@ -10,5 +10,8 @@ export interface HTTPLinkOptions extends HTTPLinkBaseOptions {
|
|
|
10
10
|
op: Operation;
|
|
11
11
|
}) => HTTPHeaders | Promise<HTTPHeaders>);
|
|
12
12
|
}
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function httpLinkFactory(factoryOpts: {
|
|
14
|
+
requester: Requester;
|
|
15
|
+
}): <TRouter extends AnyRouter>(opts: HTTPLinkOptions) => TRPCLink<TRouter>;
|
|
16
|
+
export declare const httpLink: <TRouter extends AnyRouter>(opts: HTTPLinkOptions) => TRPCLink<TRouter>;
|
|
14
17
|
//# sourceMappingURL=httpLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACL,mBAAmB,EACnB,SAAS,EAGV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D;;;OAGG;IACH,OAAO,CAAC,EACJ,WAAW,GACX,CAAC,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;CACvE;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,qCAE3D,eAAe,uBAmDxB;AAED,eAAO,MAAM,QAAQ,oCArDX,eAAe,sBAqDgD,CAAC"}
|
package/dist/links/httpLink.js
CHANGED
|
@@ -3,49 +3,56 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var observable = require('@trpc/server/observable');
|
|
6
|
-
var transformResult = require('../transformResult-
|
|
7
|
-
var httpUtils = require('../httpUtils-
|
|
6
|
+
var transformResult = require('../transformResult-12020457.js');
|
|
7
|
+
var httpUtils = require('../httpUtils-90a6bccb.js');
|
|
8
|
+
require('../isObject-617ad59e.js');
|
|
8
9
|
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
function httpLinkFactory(factoryOpts) {
|
|
11
|
+
return (opts)=>{
|
|
12
|
+
const resolvedOpts = httpUtils.resolveHTTPLinkOptions(opts);
|
|
13
|
+
return (runtime)=>({ op })=>observable.observable((observer)=>{
|
|
14
|
+
const { path , input , type } = op;
|
|
15
|
+
const { promise , cancel } = factoryOpts.requester({
|
|
16
|
+
...resolvedOpts,
|
|
17
|
+
runtime,
|
|
18
|
+
type,
|
|
19
|
+
path,
|
|
20
|
+
input,
|
|
21
|
+
headers () {
|
|
22
|
+
if (!opts.headers) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
if (typeof opts.headers === 'function') {
|
|
26
|
+
return opts.headers({
|
|
27
|
+
op
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return opts.headers;
|
|
22
31
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
});
|
|
33
|
+
promise.then((res)=>{
|
|
34
|
+
const transformed = transformResult.transformResult(res.json, runtime);
|
|
35
|
+
if (!transformed.ok) {
|
|
36
|
+
observer.error(transformResult.TRPCClientError.from(transformed.error, {
|
|
37
|
+
meta: res.meta
|
|
38
|
+
}));
|
|
39
|
+
return;
|
|
27
40
|
}
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
observer.next({
|
|
42
|
+
context: res.meta,
|
|
43
|
+
result: transformed.result
|
|
44
|
+
});
|
|
45
|
+
observer.complete();
|
|
46
|
+
}).catch((cause)=>observer.error(transformResult.TRPCClientError.from(cause)));
|
|
47
|
+
return ()=>{
|
|
48
|
+
cancel();
|
|
49
|
+
};
|
|
30
50
|
});
|
|
31
|
-
|
|
32
|
-
const transformed = transformResult.transformResult(res.json, runtime);
|
|
33
|
-
if (!transformed.ok) {
|
|
34
|
-
observer.error(transformResult.TRPCClientError.from(transformed.error, {
|
|
35
|
-
meta: res.meta
|
|
36
|
-
}));
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
observer.next({
|
|
40
|
-
context: res.meta,
|
|
41
|
-
result: transformed.result
|
|
42
|
-
});
|
|
43
|
-
observer.complete();
|
|
44
|
-
}).catch((cause)=>observer.error(transformResult.TRPCClientError.from(cause)));
|
|
45
|
-
return ()=>{
|
|
46
|
-
cancel();
|
|
47
|
-
};
|
|
48
|
-
});
|
|
51
|
+
};
|
|
49
52
|
}
|
|
53
|
+
const httpLink = httpLinkFactory({
|
|
54
|
+
requester: httpUtils.jsonHttpRequester
|
|
55
|
+
});
|
|
50
56
|
|
|
51
57
|
exports.httpLink = httpLink;
|
|
58
|
+
exports.httpLinkFactory = httpLinkFactory;
|
package/dist/links/httpLink.mjs
CHANGED
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
import { observable } from '@trpc/server/observable';
|
|
2
|
-
import { t as transformResult, T as TRPCClientError } from '../transformResult-
|
|
3
|
-
import { r as resolveHTTPLinkOptions,
|
|
2
|
+
import { t as transformResult, T as TRPCClientError } from '../transformResult-403dc1d4.mjs';
|
|
3
|
+
import { r as resolveHTTPLinkOptions, j as jsonHttpRequester } from '../httpUtils-8a5c637a.mjs';
|
|
4
|
+
import '../isObject-3ec9fe00.mjs';
|
|
4
5
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
function httpLinkFactory(factoryOpts) {
|
|
7
|
+
return (opts)=>{
|
|
8
|
+
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
9
|
+
return (runtime)=>({ op })=>observable((observer)=>{
|
|
10
|
+
const { path , input , type } = op;
|
|
11
|
+
const { promise , cancel } = factoryOpts.requester({
|
|
12
|
+
...resolvedOpts,
|
|
13
|
+
runtime,
|
|
14
|
+
type,
|
|
15
|
+
path,
|
|
16
|
+
input,
|
|
17
|
+
headers () {
|
|
18
|
+
if (!opts.headers) {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
if (typeof opts.headers === 'function') {
|
|
22
|
+
return opts.headers({
|
|
23
|
+
op
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return opts.headers;
|
|
18
27
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
});
|
|
29
|
+
promise.then((res)=>{
|
|
30
|
+
const transformed = transformResult(res.json, runtime);
|
|
31
|
+
if (!transformed.ok) {
|
|
32
|
+
observer.error(TRPCClientError.from(transformed.error, {
|
|
33
|
+
meta: res.meta
|
|
34
|
+
}));
|
|
35
|
+
return;
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
observer.next({
|
|
38
|
+
context: res.meta,
|
|
39
|
+
result: transformed.result
|
|
40
|
+
});
|
|
41
|
+
observer.complete();
|
|
42
|
+
}).catch((cause)=>observer.error(TRPCClientError.from(cause)));
|
|
43
|
+
return ()=>{
|
|
44
|
+
cancel();
|
|
45
|
+
};
|
|
26
46
|
});
|
|
27
|
-
|
|
28
|
-
const transformed = transformResult(res.json, runtime);
|
|
29
|
-
if (!transformed.ok) {
|
|
30
|
-
observer.error(TRPCClientError.from(transformed.error, {
|
|
31
|
-
meta: res.meta
|
|
32
|
-
}));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
observer.next({
|
|
36
|
-
context: res.meta,
|
|
37
|
-
result: transformed.result
|
|
38
|
-
});
|
|
39
|
-
observer.complete();
|
|
40
|
-
}).catch((cause)=>observer.error(TRPCClientError.from(cause)));
|
|
41
|
-
return ()=>{
|
|
42
|
-
cancel();
|
|
43
|
-
};
|
|
44
|
-
});
|
|
47
|
+
};
|
|
45
48
|
}
|
|
49
|
+
const httpLink = httpLinkFactory({
|
|
50
|
+
requester: jsonHttpRequester
|
|
51
|
+
});
|
|
46
52
|
|
|
47
|
-
export { httpLink };
|
|
53
|
+
export { httpLink, httpLinkFactory };
|
package/dist/links/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export * from './types';
|
|
1
2
|
export * from './httpBatchLink';
|
|
2
3
|
export * from './httpLink';
|
|
3
4
|
export * from './loggerLink';
|
|
4
5
|
export * from './splitLink';
|
|
5
6
|
export * from './wsLink';
|
|
6
|
-
export * from './
|
|
7
|
+
export * from './httpFormDataLink';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/links/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/links/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC"}
|