@trpc/client 11.0.0-next-beta.299 → 11.0.0-next-beta.302

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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 46573,
3
- "bundleOrigSize": 65514,
4
- "bundleReduction": 28.91,
2
+ "bundleSize": 46703,
3
+ "bundleOrigSize": 65890,
4
+ "bundleReduction": 29.12,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/links/wsLink.ts",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "removedExports": [],
15
15
  "dependents": [],
16
- "percent": 25.89,
16
+ "percent": 25.82,
17
17
  "reduction": 11.68
18
18
  },
19
19
  {
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "removedExports": [],
27
27
  "dependents": [],
28
- "percent": 11.91,
28
+ "percent": 11.87,
29
29
  "reduction": 14.64
30
30
  },
31
31
  {
@@ -39,7 +39,7 @@
39
39
  "dependents": [
40
40
  "/src/links/internals/createHTTPBatchLink.ts"
41
41
  ],
42
- "percent": 9.47,
42
+ "percent": 9.44,
43
43
  "reduction": 7.49
44
44
  },
45
45
  {
@@ -54,13 +54,13 @@
54
54
  "dependents": [
55
55
  "/src/links/httpBatchStreamLink.ts"
56
56
  ],
57
- "percent": 8.6,
57
+ "percent": 8.58,
58
58
  "reduction": 19.75
59
59
  },
60
60
  {
61
61
  "id": "/src/links/internals/httpUtils.ts",
62
- "size": 3334,
63
- "origSize": 5631,
62
+ "size": 3464,
63
+ "origSize": 6007,
64
64
  "renderedExports": [
65
65
  "resolveHTTPLinkOptions",
66
66
  "getUrl",
@@ -77,8 +77,8 @@
77
77
  "/src/links/internals/createHTTPBatchLink.ts",
78
78
  "/src/links/internals/parseJSONStream.ts"
79
79
  ],
80
- "percent": 7.16,
81
- "reduction": 40.79
80
+ "percent": 7.42,
81
+ "reduction": 42.33
82
82
  },
83
83
  {
84
84
  "id": "/src/links/internals/createHTTPBatchLink.ts",
@@ -92,7 +92,7 @@
92
92
  "/src/links/httpBatchLink.ts",
93
93
  "/src/links/httpBatchStreamLink.ts"
94
94
  ],
95
- "percent": 6.32,
95
+ "percent": 6.3,
96
96
  "reduction": 20.67
97
97
  },
98
98
  {
@@ -107,7 +107,7 @@
107
107
  "/src/createTRPCUntypedClient.ts",
108
108
  "/src/createTRPCClient.ts"
109
109
  ],
110
- "percent": 4.94,
110
+ "percent": 4.92,
111
111
  "reduction": 45.35
112
112
  },
113
113
  {
@@ -122,7 +122,7 @@
122
122
  "dependents": [
123
123
  "/src/links/httpFormDataLink.ts"
124
124
  ],
125
- "percent": 4.66,
125
+ "percent": 4.64,
126
126
  "reduction": 21.21
127
127
  },
128
128
  {
@@ -141,7 +141,7 @@
141
141
  "/src/links/internals/createHTTPBatchLink.ts",
142
142
  "/src/links/internals/httpUtils.ts"
143
143
  ],
144
- "percent": 4.01,
144
+ "percent": 4,
145
145
  "reduction": 45.71
146
146
  },
147
147
  {
@@ -153,7 +153,7 @@
153
153
  ],
154
154
  "removedExports": [],
155
155
  "dependents": [],
156
- "percent": 2.88,
156
+ "percent": 2.87,
157
157
  "reduction": 38.42
158
158
  },
159
159
  {
@@ -170,7 +170,7 @@
170
170
  "dependents": [
171
171
  "/src/index.ts"
172
172
  ],
173
- "percent": 2.59,
173
+ "percent": 2.58,
174
174
  "reduction": 72.4
175
175
  },
176
176
  {
@@ -182,7 +182,7 @@
182
182
  ],
183
183
  "removedExports": [],
184
184
  "dependents": [],
185
- "percent": 2.59,
185
+ "percent": 2.58,
186
186
  "reduction": 21.09
187
187
  },
188
188
  {
@@ -249,7 +249,7 @@
249
249
  "dependents": [
250
250
  "/src/links/httpBatchStreamLink.ts"
251
251
  ],
252
- "percent": 1.19,
252
+ "percent": 1.18,
253
253
  "reduction": 12.78
254
254
  },
255
255
  {
@@ -16,12 +16,19 @@ export type HTTPLinkBaseOptions<TRoot extends Pick<AnyRootTypes, 'transformer'>>
16
16
  * Add ponyfill for AbortController
17
17
  */
18
18
  AbortController?: AbortControllerEsque | null;
19
+ /**
20
+ * Send all requests `as POST`s requests regardless of the procedure type
21
+ * The HTTP handler must separately allow overriding the method. See:
22
+ * @link https://trpc.io/docs/rpc
23
+ */
24
+ methodOverride?: 'POST';
19
25
  } & TransformerOptions<TRoot>;
20
26
  export interface ResolvedHTTPLinkOptions {
21
27
  url: string;
22
28
  fetch?: FetchEsque;
23
29
  AbortController: AbortControllerEsque | null;
24
30
  transformer: CombinedDataTransformer;
31
+ methodOverride?: 'POST';
25
32
  }
26
33
  export declare function resolveHTTPLinkOptions(opts: HTTPLinkBaseOptions<AnyRootTypes>): ResolvedHTTPLinkOptions;
27
34
  export interface HTTPResult {
@@ -1 +1 @@
1
- {"version":3,"file":"httpUtils.d.ts","sourceRoot":"","sources":["../../../src/links/internals/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,YAAY,EACb,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAC5B,UAAU,EACV,gBAAgB,EAChB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAC7B,KAAK,SAAS,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,IAC7C;IACF,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,eAAe,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC/C,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAE9B,MA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CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,OAMrB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CACtB,IAAI,EAAE,sBAAsB,GAAG;IAC7B,OAAO,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACnD,KACE,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAElC,eAAO,MAAM,iBAAiB,EAAE,SAO/B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAC7C,sBAAsB,GAAG;IACvB,OAAO,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAClD,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAEJ,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,kBAAkB,EACxB,EAAE,CAAC,EAAE,4BAA4B,GAAG,IAAI,0BAgCzC;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,kBAAkB,GACvB,gBAAgB,CAAC,UAAU,CAAC,CA8B9B"}
@@ -10,7 +10,8 @@ function resolveHTTPLinkOptions(opts) {
10
10
  url: opts.url.toString().replace(/\/$/, ''),
11
11
  fetch: opts.fetch,
12
12
  AbortController: getAbortController.getAbortController(opts.AbortController),
13
- transformer: transformer.getTransformer(opts.transformer)
13
+ transformer: transformer.getTransformer(opts.transformer),
14
+ methodOverride: opts.methodOverride
14
15
  };
15
16
  }
16
17
  // https://github.com/trpc/trpc/pull/669
@@ -37,7 +38,7 @@ const getUrl = (opts)=>{
37
38
  }
38
39
  if (opts.type === 'query') {
39
40
  const input = getInput(opts);
40
- if (input !== undefined) {
41
+ if (input !== undefined && opts.methodOverride !== 'POST') {
41
42
  queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
42
43
  }
43
44
  }
@@ -47,7 +48,7 @@ const getUrl = (opts)=>{
47
48
  return url;
48
49
  };
49
50
  const getBody = (opts)=>{
50
- if (opts.type === 'query') {
51
+ if (opts.type === 'query' && opts.methodOverride !== 'POST') {
51
52
  return undefined;
52
53
  }
53
54
  const input = getInput(opts);
@@ -85,9 +86,9 @@ async function fetchHTTPResponse(opts, ac) {
85
86
  ...resolvedHeaders
86
87
  };
87
88
  return getFetch.getFetch(opts.fetch)(url, {
88
- method: METHOD[type],
89
+ method: opts.methodOverride ?? METHOD[type],
89
90
  signal: ac?.signal,
90
- body: body,
91
+ body,
91
92
  headers
92
93
  });
93
94
  }
@@ -8,7 +8,8 @@ function resolveHTTPLinkOptions(opts) {
8
8
  url: opts.url.toString().replace(/\/$/, ''),
9
9
  fetch: opts.fetch,
10
10
  AbortController: getAbortController(opts.AbortController),
11
- transformer: getTransformer(opts.transformer)
11
+ transformer: getTransformer(opts.transformer),
12
+ methodOverride: opts.methodOverride
12
13
  };
13
14
  }
14
15
  // https://github.com/trpc/trpc/pull/669
@@ -35,7 +36,7 @@ const getUrl = (opts)=>{
35
36
  }
36
37
  if (opts.type === 'query') {
37
38
  const input = getInput(opts);
38
- if (input !== undefined) {
39
+ if (input !== undefined && opts.methodOverride !== 'POST') {
39
40
  queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
40
41
  }
41
42
  }
@@ -45,7 +46,7 @@ const getUrl = (opts)=>{
45
46
  return url;
46
47
  };
47
48
  const getBody = (opts)=>{
48
- if (opts.type === 'query') {
49
+ if (opts.type === 'query' && opts.methodOverride !== 'POST') {
49
50
  return undefined;
50
51
  }
51
52
  const input = getInput(opts);
@@ -83,9 +84,9 @@ async function fetchHTTPResponse(opts, ac) {
83
84
  ...resolvedHeaders
84
85
  };
85
86
  return getFetch(opts.fetch)(url, {
86
- method: METHOD[type],
87
+ method: opts.methodOverride ?? METHOD[type],
87
88
  signal: ac?.signal,
88
- body: body,
89
+ body,
89
90
  headers
90
91
  });
91
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "11.0.0-next-beta.299+7fa5c4432",
3
+ "version": "11.0.0-next-beta.302+95ed0a569",
4
4
  "description": "The tRPC client library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -76,11 +76,11 @@
76
76
  "!**/*.test.*"
77
77
  ],
78
78
  "peerDependencies": {
79
- "@trpc/server": "11.0.0-next-beta.299+7fa5c4432"
79
+ "@trpc/server": "11.0.0-next-beta.302+95ed0a569"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@testing-library/dom": "^9.0.0",
83
- "@trpc/server": "11.0.0-next-beta.299+7fa5c4432",
83
+ "@trpc/server": "11.0.0-next-beta.302+95ed0a569",
84
84
  "@types/isomorphic-fetch": "^0.0.39",
85
85
  "@types/node": "^20.10.0",
86
86
  "eslint": "^8.56.0",
@@ -97,5 +97,5 @@
97
97
  "funding": [
98
98
  "https://trpc.io/sponsor"
99
99
  ],
100
- "gitHead": "7fa5c443266d525f5742596c1cfa4683fa30dc2a"
100
+ "gitHead": "95ed0a569aa4ba8a0a5867f7df92f746f0d11f15"
101
101
  }
@@ -34,6 +34,12 @@ export type HTTPLinkBaseOptions<
34
34
  * Add ponyfill for AbortController
35
35
  */
36
36
  AbortController?: AbortControllerEsque | null;
37
+ /**
38
+ * Send all requests `as POST`s requests regardless of the procedure type
39
+ * The HTTP handler must separately allow overriding the method. See:
40
+ * @link https://trpc.io/docs/rpc
41
+ */
42
+ methodOverride?: 'POST';
37
43
  } & TransformerOptions<TRoot>;
38
44
 
39
45
  export interface ResolvedHTTPLinkOptions {
@@ -41,6 +47,7 @@ export interface ResolvedHTTPLinkOptions {
41
47
  fetch?: FetchEsque;
42
48
  AbortController: AbortControllerEsque | null;
43
49
  transformer: CombinedDataTransformer;
50
+ methodOverride?: 'POST';
44
51
  }
45
52
 
46
53
  export function resolveHTTPLinkOptions(
@@ -51,6 +58,7 @@ export function resolveHTTPLinkOptions(
51
58
  fetch: opts.fetch,
52
59
  AbortController: getAbortController(opts.AbortController),
53
60
  transformer: getTransformer(opts.transformer),
61
+ methodOverride: opts.methodOverride,
54
62
  };
55
63
  }
56
64
 
@@ -112,7 +120,7 @@ export const getUrl: GetUrl = (opts) => {
112
120
  }
113
121
  if (opts.type === 'query') {
114
122
  const input = getInput(opts);
115
- if (input !== undefined) {
123
+ if (input !== undefined && opts.methodOverride !== 'POST') {
116
124
  queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
117
125
  }
118
126
  }
@@ -123,7 +131,7 @@ export const getUrl: GetUrl = (opts) => {
123
131
  };
124
132
 
125
133
  export const getBody: GetBody = (opts) => {
126
- if (opts.type === 'query') {
134
+ if (opts.type === 'query' && opts.methodOverride !== 'POST') {
127
135
  return undefined;
128
136
  }
129
137
  const input = getInput(opts);
@@ -180,9 +188,9 @@ export async function fetchHTTPResponse(
180
188
  };
181
189
 
182
190
  return getFetch(opts.fetch)(url, {
183
- method: METHOD[type],
191
+ method: opts.methodOverride ?? METHOD[type],
184
192
  signal: ac?.signal,
185
- body: body,
193
+ body,
186
194
  headers,
187
195
  });
188
196
  }