@orpc/server 2.0.0-beta.44 → 2.0.0-beta.46

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.
Files changed (42) hide show
  1. package/README.md +100 -62
  2. package/dist/adapters/aws-lambda/index.d.mts +1 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +1 -0
  4. package/dist/adapters/aws-lambda/index.mjs +3 -3
  5. package/dist/adapters/crossws/index.mjs +3 -3
  6. package/dist/adapters/fastify/index.mjs +3 -3
  7. package/dist/adapters/fetch/index.d.mts +2 -2
  8. package/dist/adapters/fetch/index.d.ts +2 -2
  9. package/dist/adapters/fetch/index.mjs +3 -3
  10. package/dist/adapters/message-port/index.d.mts +1 -1
  11. package/dist/adapters/message-port/index.d.ts +1 -1
  12. package/dist/adapters/message-port/index.mjs +3 -3
  13. package/dist/adapters/node/index.d.mts +1 -1
  14. package/dist/adapters/node/index.d.ts +1 -1
  15. package/dist/adapters/node/index.mjs +3 -3
  16. package/dist/adapters/standard/index.d.mts +8 -7
  17. package/dist/adapters/standard/index.d.ts +8 -7
  18. package/dist/adapters/standard/index.mjs +3 -3
  19. package/dist/adapters/websocket/index.mjs +3 -3
  20. package/dist/extensions/callable.mjs +2 -2
  21. package/dist/helpers/index.mjs +2 -8
  22. package/dist/index.d.mts +18 -33
  23. package/dist/index.d.ts +18 -33
  24. package/dist/index.mjs +12 -10
  25. package/dist/plugins/index.d.mts +57 -32
  26. package/dist/plugins/index.d.ts +57 -32
  27. package/dist/plugins/index.mjs +189 -48
  28. package/dist/shared/{server.DJNkZPfD.d.ts → server.9B1jEm5a.d.mts} +6 -16
  29. package/dist/shared/{server.FEqy7Hrj.mjs → server.BB464y-6.mjs} +6 -4
  30. package/dist/shared/{server.DD1roZl9.d.mts → server.BC5BIu02.d.mts} +1 -1
  31. package/dist/shared/{server.UG_xdTub.d.mts → server.BSYGskId.d.ts} +3 -3
  32. package/dist/shared/{server.DFEuNUt4.d.ts → server.BvG3boBj.d.mts} +3 -3
  33. package/dist/shared/{server.BllfVJLm.d.mts → server.CTV_mC2P.d.mts} +2 -2
  34. package/dist/shared/{server.BgvqVW_v.mjs → server.CYbIpHbH.mjs} +17 -5
  35. package/dist/shared/{server.COfbQ0D8.d.ts → server.CgBF3Vj1.d.ts} +2 -2
  36. package/dist/shared/{server.B34dZrzY.mjs → server.Chq5FpXf.mjs} +4 -10
  37. package/dist/shared/{server.BEdOJs6S.d.mts → server.DFPxP2v3.d.mts} +11 -8
  38. package/dist/shared/{server.BEdOJs6S.d.ts → server.DFPxP2v3.d.ts} +11 -8
  39. package/dist/shared/{server.CVO0hWyj.d.mts → server.DOg7ke6y.d.ts} +6 -16
  40. package/dist/shared/{server.DZeVx8K9.d.ts → server.Dz7j9BEh.d.ts} +1 -1
  41. package/dist/shared/{server.AVQWL-DI.mjs → server.sBQSgqK3.mjs} +1 -1
  42. package/package.json +12 -12
@@ -1,14 +1,15 @@
1
1
  import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
- import { StandardLazyRequest, StandardHeaders, StandardMethod, StandardResponse } from '@standard-server/core';
2
+ import { StandardLazyRequest, StandardResponse, StandardHeaders, StandardMethod } from '@standard-server/core';
3
3
  import { Context } from '../index.mjs';
4
4
  import { StandardHandlerPlugin, StandardHandlerRoutingInterceptorOptions, StandardHandlerOptions, StandardHandlerInterceptorOptions } from '../adapters/standard/index.mjs';
5
- export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.BllfVJLm.mjs';
5
+ export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.CTV_mC2P.mjs';
6
+ export { BATCH_HEADER, DEFAULT_BATCH_MAX_SIZE } from '@orpc/client/plugins';
6
7
  import '@orpc/client';
7
8
  import '@orpc/contract';
8
9
 
9
10
  /**
10
- * Content type for batch responses that use the length-prefixed binary framing
11
- * (streaming mode, and buffered mode when any sub-response contains binary or is a stream).
11
+ * Content type for batch responses that use the length-prefixed binary framing,
12
+ * which they do when any sub-response contains binary or is a stream.
12
13
  *
13
14
  * Decoding is driven by the `standard-server` body hint, not this header,
14
15
  * so it only serves to describe the payload to logs, proxies, and dev tools.
@@ -16,40 +17,51 @@ import '@orpc/contract';
16
17
  declare const BATCH_CONTENT_TYPE = "application/vnd.orpc.batch";
17
18
  interface BatchHandlerPluginOptions<T extends Context> {
18
19
  /**
19
- * The max size of the batch allowed.
20
+ * The max size of the batch allowed. Larger batches are rejected with a `413`,
21
+ * so keep the client Batch Link Plugin's `maxSize` at or below it.
20
22
  *
21
- * @default 10
23
+ * @default DEFAULT_BATCH_MAX_SIZE (10)
24
+ * @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
22
25
  */
23
- maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]>;
26
+ maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
24
27
  /**
25
28
  * Map each subrequest in the batch before it is processed.
26
29
  *
27
30
  * @default merges the batch request headers into the subrequest, giving them priority over
28
31
  * the subrequest headers, and removes the `orpc-batch` header to prevent nested batching
29
32
  */
30
- mapSubrequest?: (subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest;
33
+ mapSubrequest?: ((subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest) | undefined;
34
+ /**
35
+ * Map each sub-response in the batch before it is sent.
36
+ *
37
+ * @default removes the headers the batch response already has with the same value, which the client
38
+ * merges back, and `set-cookie`, which the browser ignores there and JavaScript could read
39
+ */
40
+ mapSubresponse?: ((subresponse: StandardResponse, partialBatchResponse: Pick<StandardResponse, 'status' | 'headers'>, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardResponse) | undefined;
31
41
  /**
32
42
  * Success batch response status code.
33
43
  *
34
44
  * @default 207
35
45
  */
36
- successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]>;
46
+ successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
37
47
  /**
38
48
  * Success batch response headers.
39
49
  *
50
+ * The batch response also gets the cookies its sub-responses set, and the headers they all share.
51
+ * Headers set here win, and setting one to `undefined` keeps it off, except `set-cookie` and `vary`, which merge.
52
+ *
40
53
  * @default {}
41
54
  */
42
- headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]>;
55
+ headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
43
56
  /**
44
- * Keep-alive settings for streaming batch responses.
57
+ * Keep-alive settings for batch responses that stream.
45
58
  *
46
59
  * When enabled, a zero-length length-prefixed frame is sent periodically while the
47
60
  * stream is idle (no message sent for `interval` ms). Clients ignore these frames.
48
- * Only applies to streaming responses: streaming mode, or a buffered batch with a stream sub-response.
49
61
  *
50
62
  * @default { enabled: true, interval: 15000 }
51
63
  */
52
- keepAlive?: undefined | {
64
+ keepAlive?: {
53
65
  /**
54
66
  * If true, a keep-alive frame is sent periodically while the stream is idle.
55
67
  *
@@ -61,16 +73,16 @@ interface BatchHandlerPluginOptions<T extends Context> {
61
73
  *
62
74
  * @default 15000
63
75
  */
64
- interval?: number;
65
- };
76
+ interval?: number | undefined;
77
+ } | undefined;
66
78
  }
67
79
  /**
68
80
  * Handles batch requests sent by the client Batch Link Plugin, splitting each
69
- * batch into sub-requests and streaming their responses back together.
81
+ * batch into sub-requests and sending their responses back together.
70
82
  *
71
83
  * @remarks
72
- * In buffered mode, the batch still streams once a sub-response is a stream
73
- * (an event iterator or a `ReadableStream`), since it may never end.
84
+ * The batch starts the response once every sub-response is ready, so it carries the cookies sub-requests
85
+ * set and the headers every sub-response shares. It streams when a sub-response is a stream.
74
86
  *
75
87
  * **Note**: HTTP/2 and later already multiplex requests over a single connection, which often makes this plugin unnecessary.
76
88
  *
@@ -85,6 +97,7 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
85
97
  after: string[];
86
98
  private readonly maxSize;
87
99
  private readonly mapSubrequest;
100
+ private readonly mapSubresponse;
88
101
  private readonly successStatus;
89
102
  private readonly headers;
90
103
  private readonly keepAliveEnabled;
@@ -103,40 +116,40 @@ interface CORSHandlerPluginOptions<T extends Context> {
103
116
  *
104
117
  * @default '*'
105
118
  */
106
- origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
119
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
107
120
  /**
108
121
  * Configures the `Timing-Allow-Origin` header.
109
122
  * Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
110
123
  */
111
- timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
124
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
112
125
  /**
113
126
  * Configures the `Access-Control-Allow-Methods` header for preflight requests.
114
127
  *
115
128
  * @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']
116
129
  */
117
- allowMethods?: readonly string[];
130
+ allowMethods?: readonly string[] | undefined;
118
131
  /**
119
132
  * Configures the `Access-Control-Allow-Headers` header for preflight requests.
120
133
  * Falls back to the request's `Access-Control-Request-Headers` if not set.
121
134
  * When set, it replaces that fallback, so include every non-safelisted header
122
135
  * clients send, such as `Content-Type`.
123
136
  */
124
- allowHeaders?: readonly string[];
137
+ allowHeaders?: readonly string[] | undefined;
125
138
  /**
126
139
  * Configures the `Access-Control-Max-Age` header (in seconds) for preflight requests.
127
140
  */
128
- maxAge?: number;
141
+ maxAge?: number | undefined;
129
142
  /**
130
143
  * Configures the `Access-Control-Allow-Credentials` header.
131
144
  *
132
145
  * When enabled, `origin` must allow trusted origins only: every allowed origin can send
133
146
  * authenticated requests as your users and read the responses.
134
147
  */
135
- credentials?: boolean;
148
+ credentials?: boolean | undefined;
136
149
  /**
137
150
  * Configures the `Access-Control-Expose-Headers` header.
138
151
  */
139
- exposeHeaders?: readonly string[];
152
+ exposeHeaders?: readonly string[] | undefined;
140
153
  }
141
154
  /**
142
155
  * Configures the [CORS Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
@@ -186,7 +199,7 @@ interface MethodOverrideHandlerPluginOptions {
186
199
  *
187
200
  * @default 'method'
188
201
  */
189
- param?: string;
202
+ param?: string | undefined;
190
203
  /**
191
204
  * The methods a POST request may be overridden to.
192
205
  *
@@ -195,7 +208,7 @@ interface MethodOverrideHandlerPluginOptions {
195
208
  *
196
209
  * @default ['PUT', 'PATCH', 'DELETE']
197
210
  */
198
- methods?: readonly StandardMethod[];
211
+ methods?: readonly StandardMethod[] | undefined;
199
212
  }
200
213
  /**
201
214
  * Overrides the HTTP method of a POST request based on a query parameter,
@@ -261,7 +274,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
261
274
  *
262
275
  * @default ['gzip', 'deflate']
263
276
  */
264
- encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
277
+ encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
265
278
  /**
266
279
  * The minimum response size in bytes required to trigger compression.
267
280
  * Responses smaller than this threshold will not be compressed to avoid overhead.
@@ -269,7 +282,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
269
282
  *
270
283
  * @default 1024 (1KB)
271
284
  */
272
- threshold?: number;
285
+ threshold?: number | undefined;
273
286
  /**
274
287
  * Determines whether a response with the given Content-Type should be compressed.
275
288
  * Only consulted for binary transfers (streams, files, and file form-data parts).
@@ -277,7 +290,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
277
290
  *
278
291
  * @default isCompressibleContentType (covers common text-based formats)
279
292
  */
280
- isCompressibleContentType?: (contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean;
293
+ isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean) | undefined;
281
294
  }
282
295
  /**
283
296
  * Compresses response bodies based on the client's Accept-Encoding header.
@@ -368,6 +381,18 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
368
381
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
369
382
  }
370
383
 
384
+ /**
385
+ * Keeps the request signal and a streaming output (async iterator object or readable stream) in sync:
386
+ * cancelling the output aborts the signal with an `AbortError`,
387
+ * and aborting the signal ends the output with the abort reason and cancels it.
388
+ *
389
+ * @see {@link https://orpc.dev/docs/plugins/signal-sync | Signal Sync Plugin}
390
+ */
391
+ declare class SignalSyncHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
392
+ name: string;
393
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
394
+ }
395
+
371
396
  interface TimeoutHandlerPluginOptions<T extends Context> {
372
397
  /**
373
398
  * Timeout in milliseconds before the request signal is aborted.
@@ -386,7 +411,7 @@ interface TimeoutHandlerPluginOptions<T extends Context> {
386
411
  *
387
412
  * @default undefined (streaming responses run without limit)
388
413
  */
389
- streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]>;
414
+ streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]> | undefined;
390
415
  }
391
416
  /**
392
417
  * The Timeout Handler Plugin aborts the request signal with an `AbortError`
@@ -403,5 +428,5 @@ declare class TimeoutHandlerPlugin<T extends Context> implements StandardHandler
403
428
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
404
429
  }
405
430
 
406
- export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
431
+ export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, SignalSyncHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
407
432
  export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, MethodOverrideHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestHeadersHandlerPluginContext as RequestHeadersPluginContext, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext as ResponseHeadersPluginContext, RethrowHandlerPluginOptions, TimeoutHandlerPluginOptions };
@@ -1,14 +1,15 @@
1
1
  import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
- import { StandardLazyRequest, StandardHeaders, StandardMethod, StandardResponse } from '@standard-server/core';
2
+ import { StandardLazyRequest, StandardResponse, StandardHeaders, StandardMethod } from '@standard-server/core';
3
3
  import { Context } from '../index.js';
4
4
  import { StandardHandlerPlugin, StandardHandlerRoutingInterceptorOptions, StandardHandlerOptions, StandardHandlerInterceptorOptions } from '../adapters/standard/index.js';
5
- export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.COfbQ0D8.js';
5
+ export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.CgBF3Vj1.js';
6
+ export { BATCH_HEADER, DEFAULT_BATCH_MAX_SIZE } from '@orpc/client/plugins';
6
7
  import '@orpc/client';
7
8
  import '@orpc/contract';
8
9
 
9
10
  /**
10
- * Content type for batch responses that use the length-prefixed binary framing
11
- * (streaming mode, and buffered mode when any sub-response contains binary or is a stream).
11
+ * Content type for batch responses that use the length-prefixed binary framing,
12
+ * which they do when any sub-response contains binary or is a stream.
12
13
  *
13
14
  * Decoding is driven by the `standard-server` body hint, not this header,
14
15
  * so it only serves to describe the payload to logs, proxies, and dev tools.
@@ -16,40 +17,51 @@ import '@orpc/contract';
16
17
  declare const BATCH_CONTENT_TYPE = "application/vnd.orpc.batch";
17
18
  interface BatchHandlerPluginOptions<T extends Context> {
18
19
  /**
19
- * The max size of the batch allowed.
20
+ * The max size of the batch allowed. Larger batches are rejected with a `413`,
21
+ * so keep the client Batch Link Plugin's `maxSize` at or below it.
20
22
  *
21
- * @default 10
23
+ * @default DEFAULT_BATCH_MAX_SIZE (10)
24
+ * @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
22
25
  */
23
- maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]>;
26
+ maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
24
27
  /**
25
28
  * Map each subrequest in the batch before it is processed.
26
29
  *
27
30
  * @default merges the batch request headers into the subrequest, giving them priority over
28
31
  * the subrequest headers, and removes the `orpc-batch` header to prevent nested batching
29
32
  */
30
- mapSubrequest?: (subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest;
33
+ mapSubrequest?: ((subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest) | undefined;
34
+ /**
35
+ * Map each sub-response in the batch before it is sent.
36
+ *
37
+ * @default removes the headers the batch response already has with the same value, which the client
38
+ * merges back, and `set-cookie`, which the browser ignores there and JavaScript could read
39
+ */
40
+ mapSubresponse?: ((subresponse: StandardResponse, partialBatchResponse: Pick<StandardResponse, 'status' | 'headers'>, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardResponse) | undefined;
31
41
  /**
32
42
  * Success batch response status code.
33
43
  *
34
44
  * @default 207
35
45
  */
36
- successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]>;
46
+ successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
37
47
  /**
38
48
  * Success batch response headers.
39
49
  *
50
+ * The batch response also gets the cookies its sub-responses set, and the headers they all share.
51
+ * Headers set here win, and setting one to `undefined` keeps it off, except `set-cookie` and `vary`, which merge.
52
+ *
40
53
  * @default {}
41
54
  */
42
- headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]>;
55
+ headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
43
56
  /**
44
- * Keep-alive settings for streaming batch responses.
57
+ * Keep-alive settings for batch responses that stream.
45
58
  *
46
59
  * When enabled, a zero-length length-prefixed frame is sent periodically while the
47
60
  * stream is idle (no message sent for `interval` ms). Clients ignore these frames.
48
- * Only applies to streaming responses: streaming mode, or a buffered batch with a stream sub-response.
49
61
  *
50
62
  * @default { enabled: true, interval: 15000 }
51
63
  */
52
- keepAlive?: undefined | {
64
+ keepAlive?: {
53
65
  /**
54
66
  * If true, a keep-alive frame is sent periodically while the stream is idle.
55
67
  *
@@ -61,16 +73,16 @@ interface BatchHandlerPluginOptions<T extends Context> {
61
73
  *
62
74
  * @default 15000
63
75
  */
64
- interval?: number;
65
- };
76
+ interval?: number | undefined;
77
+ } | undefined;
66
78
  }
67
79
  /**
68
80
  * Handles batch requests sent by the client Batch Link Plugin, splitting each
69
- * batch into sub-requests and streaming their responses back together.
81
+ * batch into sub-requests and sending their responses back together.
70
82
  *
71
83
  * @remarks
72
- * In buffered mode, the batch still streams once a sub-response is a stream
73
- * (an event iterator or a `ReadableStream`), since it may never end.
84
+ * The batch starts the response once every sub-response is ready, so it carries the cookies sub-requests
85
+ * set and the headers every sub-response shares. It streams when a sub-response is a stream.
74
86
  *
75
87
  * **Note**: HTTP/2 and later already multiplex requests over a single connection, which often makes this plugin unnecessary.
76
88
  *
@@ -85,6 +97,7 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
85
97
  after: string[];
86
98
  private readonly maxSize;
87
99
  private readonly mapSubrequest;
100
+ private readonly mapSubresponse;
88
101
  private readonly successStatus;
89
102
  private readonly headers;
90
103
  private readonly keepAliveEnabled;
@@ -103,40 +116,40 @@ interface CORSHandlerPluginOptions<T extends Context> {
103
116
  *
104
117
  * @default '*'
105
118
  */
106
- origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
119
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
107
120
  /**
108
121
  * Configures the `Timing-Allow-Origin` header.
109
122
  * Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
110
123
  */
111
- timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
124
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
112
125
  /**
113
126
  * Configures the `Access-Control-Allow-Methods` header for preflight requests.
114
127
  *
115
128
  * @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']
116
129
  */
117
- allowMethods?: readonly string[];
130
+ allowMethods?: readonly string[] | undefined;
118
131
  /**
119
132
  * Configures the `Access-Control-Allow-Headers` header for preflight requests.
120
133
  * Falls back to the request's `Access-Control-Request-Headers` if not set.
121
134
  * When set, it replaces that fallback, so include every non-safelisted header
122
135
  * clients send, such as `Content-Type`.
123
136
  */
124
- allowHeaders?: readonly string[];
137
+ allowHeaders?: readonly string[] | undefined;
125
138
  /**
126
139
  * Configures the `Access-Control-Max-Age` header (in seconds) for preflight requests.
127
140
  */
128
- maxAge?: number;
141
+ maxAge?: number | undefined;
129
142
  /**
130
143
  * Configures the `Access-Control-Allow-Credentials` header.
131
144
  *
132
145
  * When enabled, `origin` must allow trusted origins only: every allowed origin can send
133
146
  * authenticated requests as your users and read the responses.
134
147
  */
135
- credentials?: boolean;
148
+ credentials?: boolean | undefined;
136
149
  /**
137
150
  * Configures the `Access-Control-Expose-Headers` header.
138
151
  */
139
- exposeHeaders?: readonly string[];
152
+ exposeHeaders?: readonly string[] | undefined;
140
153
  }
141
154
  /**
142
155
  * Configures the [CORS Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
@@ -186,7 +199,7 @@ interface MethodOverrideHandlerPluginOptions {
186
199
  *
187
200
  * @default 'method'
188
201
  */
189
- param?: string;
202
+ param?: string | undefined;
190
203
  /**
191
204
  * The methods a POST request may be overridden to.
192
205
  *
@@ -195,7 +208,7 @@ interface MethodOverrideHandlerPluginOptions {
195
208
  *
196
209
  * @default ['PUT', 'PATCH', 'DELETE']
197
210
  */
198
- methods?: readonly StandardMethod[];
211
+ methods?: readonly StandardMethod[] | undefined;
199
212
  }
200
213
  /**
201
214
  * Overrides the HTTP method of a POST request based on a query parameter,
@@ -261,7 +274,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
261
274
  *
262
275
  * @default ['gzip', 'deflate']
263
276
  */
264
- encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
277
+ encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
265
278
  /**
266
279
  * The minimum response size in bytes required to trigger compression.
267
280
  * Responses smaller than this threshold will not be compressed to avoid overhead.
@@ -269,7 +282,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
269
282
  *
270
283
  * @default 1024 (1KB)
271
284
  */
272
- threshold?: number;
285
+ threshold?: number | undefined;
273
286
  /**
274
287
  * Determines whether a response with the given Content-Type should be compressed.
275
288
  * Only consulted for binary transfers (streams, files, and file form-data parts).
@@ -277,7 +290,7 @@ interface ResponseCompressionHandlerPluginOptions<T extends Context> {
277
290
  *
278
291
  * @default isCompressibleContentType (covers common text-based formats)
279
292
  */
280
- isCompressibleContentType?: (contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean;
293
+ isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardHandlerRoutingInterceptorOptions<T>) => boolean) | undefined;
281
294
  }
282
295
  /**
283
296
  * Compresses response bodies based on the client's Accept-Encoding header.
@@ -368,6 +381,18 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
368
381
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
369
382
  }
370
383
 
384
+ /**
385
+ * Keeps the request signal and a streaming output (async iterator object or readable stream) in sync:
386
+ * cancelling the output aborts the signal with an `AbortError`,
387
+ * and aborting the signal ends the output with the abort reason and cancels it.
388
+ *
389
+ * @see {@link https://orpc.dev/docs/plugins/signal-sync | Signal Sync Plugin}
390
+ */
391
+ declare class SignalSyncHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
392
+ name: string;
393
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
394
+ }
395
+
371
396
  interface TimeoutHandlerPluginOptions<T extends Context> {
372
397
  /**
373
398
  * Timeout in milliseconds before the request signal is aborted.
@@ -386,7 +411,7 @@ interface TimeoutHandlerPluginOptions<T extends Context> {
386
411
  *
387
412
  * @default undefined (streaming responses run without limit)
388
413
  */
389
- streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]>;
414
+ streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]> | undefined;
390
415
  }
391
416
  /**
392
417
  * The Timeout Handler Plugin aborts the request signal with an `AbortError`
@@ -403,5 +428,5 @@ declare class TimeoutHandlerPlugin<T extends Context> implements StandardHandler
403
428
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
404
429
  }
405
430
 
406
- export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
431
+ export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, SignalSyncHandlerPlugin, TimeoutHandlerPlugin, negotiateResponseCompressionEncoding, toCompressedHeaders };
407
432
  export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, MethodOverrideHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestHeadersHandlerPluginContext as RequestHeadersPluginContext, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext as ResponseHeadersPluginContext, RethrowHandlerPluginOptions, TimeoutHandlerPluginOptions };