@orpc/server 2.0.0-beta.14 → 2.0.0-beta.16

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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/adapters/crossws/index.d.mts +1 -1
  3. package/dist/adapters/crossws/index.d.ts +1 -1
  4. package/dist/adapters/crossws/index.mjs +3 -3
  5. package/dist/adapters/fetch/index.d.mts +5 -53
  6. package/dist/adapters/fetch/index.d.ts +5 -53
  7. package/dist/adapters/fetch/index.mjs +6 -136
  8. package/dist/adapters/message-port/index.d.mts +1 -1
  9. package/dist/adapters/message-port/index.d.ts +1 -1
  10. package/dist/adapters/message-port/index.mjs +3 -3
  11. package/dist/adapters/node/index.d.mts +4 -34
  12. package/dist/adapters/node/index.d.ts +4 -34
  13. package/dist/adapters/node/index.mjs +6 -112
  14. package/dist/adapters/standard/index.d.mts +1 -1
  15. package/dist/adapters/standard/index.d.ts +1 -1
  16. package/dist/adapters/standard/index.mjs +3 -3
  17. package/dist/adapters/websocket/index.d.mts +1 -1
  18. package/dist/adapters/websocket/index.d.ts +1 -1
  19. package/dist/adapters/websocket/index.mjs +3 -3
  20. package/dist/extensions/callable.mjs +2 -2
  21. package/dist/helpers/index.d.mts +3 -3
  22. package/dist/helpers/index.d.ts +3 -3
  23. package/dist/helpers/index.mjs +13 -5
  24. package/dist/index.d.mts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.mjs +7 -7
  27. package/dist/plugins/index.d.mts +77 -2
  28. package/dist/plugins/index.d.ts +77 -2
  29. package/dist/plugins/index.mjs +305 -5
  30. package/dist/shared/{server.CrlKQucM.mjs → server.BDeup7Ky.mjs} +3 -3
  31. package/dist/shared/{server.CjOb6ItT.mjs → server.CUsS2s2p.mjs} +1 -1
  32. package/dist/shared/{server.BwHnWUuN.mjs → server.C_osSBcd.mjs} +1 -1
  33. package/dist/shared/{server.d_2NS3g5.d.ts → server.D0WUu0EH.d.ts} +3 -2
  34. package/dist/shared/{server.Cj5lgPuG.d.mts → server.D8cib80w.d.mts} +3 -2
  35. package/dist/shared/{server.GDpX6Df8.mjs → server.DZEvIn7o.mjs} +3 -3
  36. package/package.json +9 -10
@@ -1,119 +1,13 @@
1
- import compression from '@orpc/interop/compression';
2
- import { toArray, sortPlugins, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
3
- import { ORPCError } from '@orpc/client';
1
+ import { sortPlugins, intercept, resolveMaybeOptionalOptions, toArray } from '@orpc/shared';
4
2
  import { toStandardLazyRequest, sendStandardResponse } from '@standardserver/node';
5
3
  import { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
6
4
  import { C as CSRFGuardHandlerPlugin } from '../../shared/server.D_QauotT.mjs';
7
- import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.GDpX6Df8.mjs';
5
+ import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.DZEvIn7o.mjs';
6
+ import '@orpc/client';
8
7
  import '@standardserver/core';
9
- import '../../shared/server.CrlKQucM.mjs';
8
+ import '../../shared/server.BDeup7Ky.mjs';
10
9
  import '@orpc/contract';
11
- import '../../shared/server.BwHnWUuN.mjs';
12
-
13
- class BodyCompressionHandlerPlugin {
14
- name = "~body-compression";
15
- compressionHandler;
16
- constructor(options = {}) {
17
- this.compressionHandler = compression({
18
- ...options,
19
- filter: (request, response) => {
20
- const hasContentDisposition = response.hasHeader("content-disposition");
21
- const contentType = response.getHeader("content-type")?.toString();
22
- if (!hasContentDisposition && contentType?.startsWith("text/event-stream")) {
23
- return false;
24
- }
25
- return options.filter ? options.filter(request, response) : compression.filter(request, response);
26
- }
27
- });
28
- }
29
- initNodeHttpHandlerOptions(options) {
30
- return {
31
- ...options,
32
- nodeHttpInterceptors: [
33
- async (interceptorOptions) => {
34
- let resolve;
35
- let reject;
36
- const promise = new Promise((res, rej) => {
37
- resolve = res;
38
- reject = rej;
39
- });
40
- const originalWrite = interceptorOptions.response.write;
41
- const originalEnd = interceptorOptions.response.end;
42
- const originalOn = interceptorOptions.response.on;
43
- this.compressionHandler(
44
- interceptorOptions.request,
45
- interceptorOptions.response,
46
- async (error) => {
47
- if (error) {
48
- reject(error);
49
- } else {
50
- try {
51
- resolve(await interceptorOptions.next(interceptorOptions));
52
- } catch (nextError) {
53
- reject(nextError);
54
- }
55
- }
56
- }
57
- );
58
- try {
59
- return await promise;
60
- } finally {
61
- interceptorOptions.response.write = originalWrite;
62
- interceptorOptions.response.end = originalEnd;
63
- interceptorOptions.response.on = originalOn;
64
- }
65
- },
66
- ...toArray(options.nodeHttpInterceptors)
67
- ]
68
- };
69
- }
70
- }
71
-
72
- class BodyLimitHandlerPlugin {
73
- name = "~body-limit";
74
- maxBodySize;
75
- constructor(options) {
76
- this.maxBodySize = options.maxBodySize;
77
- }
78
- initNodeHttpHandlerOptions(options) {
79
- return {
80
- ...options,
81
- nodeHttpInterceptors: [
82
- async (interceptorOptions) => {
83
- let isHeaderChecked = false;
84
- const checkHeader = () => {
85
- if (isHeaderChecked) {
86
- return;
87
- }
88
- isHeaderChecked = true;
89
- const contentLength = interceptorOptions.request.headers["content-length"];
90
- if (contentLength && Number(contentLength) > this.maxBodySize) {
91
- throw new ORPCError("PAYLOAD_TOO_LARGE");
92
- }
93
- };
94
- const originalEmit = interceptorOptions.request.emit;
95
- let currentBodySize = 0;
96
- interceptorOptions.request.emit = (event, ...args) => {
97
- if (event === "data") {
98
- checkHeader();
99
- currentBodySize += args[0]?.length ?? 0;
100
- if (currentBodySize > this.maxBodySize) {
101
- throw new ORPCError("PAYLOAD_TOO_LARGE");
102
- }
103
- }
104
- return originalEmit.call(interceptorOptions.request, event, ...args);
105
- };
106
- try {
107
- return await interceptorOptions.next(interceptorOptions);
108
- } finally {
109
- interceptorOptions.request.emit = originalEmit;
110
- }
111
- },
112
- ...toArray(options.nodeHttpInterceptors)
113
- ]
114
- };
115
- }
116
- }
10
+ import '../../shared/server.C_osSBcd.mjs';
117
11
 
118
12
  class CompositeNodeHttpHandlerPlugin {
119
13
  name = "~composite/node-http-handler";
@@ -176,4 +70,4 @@ class RPCHandler extends NodeHttpHandler {
176
70
  }
177
71
  }
178
72
 
179
- export { BodyCompressionHandlerPlugin, BodyLimitHandlerPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
73
+ export { CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
@@ -1,6 +1,6 @@
1
1
  import { b as StandardHandlerHandleOptions } from '../../shared/server.DJIkub_t.mjs';
2
2
  export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, S as StandardHandler, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure, h as StandardHandlerHandleResult, i as StandardHandlerInterceptor, g as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, e as StandardHandlerPlugin, j as StandardHandlerRoutingInterceptor, f as StandardHandlerRoutingInterceptorOptions } from '../../shared/server.DJIkub_t.mjs';
3
- export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.Cj5lgPuG.mjs';
3
+ export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.D8cib80w.mjs';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
5
5
  export { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl } from '@standardserver/core';
6
6
  import '@orpc/client';
@@ -1,6 +1,6 @@
1
1
  import { b as StandardHandlerHandleOptions } from '../../shared/server.DBANIheG.js';
2
2
  export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, S as StandardHandler, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure, h as StandardHandlerHandleResult, i as StandardHandlerInterceptor, g as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, e as StandardHandlerPlugin, j as StandardHandlerRoutingInterceptor, f as StandardHandlerRoutingInterceptorOptions } from '../../shared/server.DBANIheG.js';
3
- export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.d_2NS3g5.js';
3
+ export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.D0WUu0EH.js';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.js';
5
5
  export { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl } from '@standardserver/core';
6
6
  import '@orpc/client';
@@ -1,8 +1,8 @@
1
- export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, R as RPCHandlerCodec, a as RPCMatcher, S as StandardHandler } from '../../shared/server.GDpX6Df8.mjs';
1
+ export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, R as RPCHandlerCodec, a as RPCMatcher, S as StandardHandler } from '../../shared/server.DZEvIn7o.mjs';
2
2
  export { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
3
3
  import '@orpc/client';
4
4
  import '@orpc/shared';
5
5
  import '@standardserver/core';
6
- import '../../shared/server.CrlKQucM.mjs';
6
+ import '../../shared/server.BDeup7Ky.mjs';
7
7
  import '@orpc/contract';
8
- import '../../shared/server.BwHnWUuN.mjs';
8
+ import '../../shared/server.C_osSBcd.mjs';
@@ -4,7 +4,7 @@ import { C as Context } from '../../shared/server.BL22TloH.mjs';
4
4
  import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
5
5
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.mjs';
6
6
  import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.Cj5lgPuG.mjs';
7
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.D8cib80w.mjs';
8
8
  import '@orpc/client';
9
9
  import '@orpc/contract';
10
10
  import '@standardserver/core';
@@ -4,7 +4,7 @@ import { C as Context } from '../../shared/server.BL22TloH.js';
4
4
  import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
5
5
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
6
6
  import { R as Router } from '../../shared/server.Pa0F03f_.js';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.d_2NS3g5.js';
7
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.D0WUu0EH.js';
8
8
  import '@orpc/client';
9
9
  import '@orpc/contract';
10
10
  import '@standardserver/core';
@@ -1,12 +1,12 @@
1
1
  import { toStringOrBytes, resolveMaybeOptionalOptions, sequential, loadBytes } from '@orpc/shared';
2
2
  import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage } from '@standardserver/peer';
3
3
  import { c as createStandardPeerRequestHandler } from '../../shared/server.CX4vUnDk.mjs';
4
- import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.GDpX6Df8.mjs';
4
+ import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.DZEvIn7o.mjs';
5
5
  import '@orpc/client';
6
6
  import '@standardserver/core';
7
- import '../../shared/server.CrlKQucM.mjs';
7
+ import '../../shared/server.BDeup7Ky.mjs';
8
8
  import '@orpc/contract';
9
- import '../../shared/server.BwHnWUuN.mjs';
9
+ import '../../shared/server.C_osSBcd.mjs';
10
10
 
11
11
  class WebSocketHandler {
12
12
  constructor(handler, options = {}) {
@@ -1,5 +1,5 @@
1
- import { c as createProcedureClient } from '../shared/server.CrlKQucM.mjs';
2
- import { D as DecoratedProcedure } from '../shared/server.CjOb6ItT.mjs';
1
+ import { c as createProcedureClient } from '../shared/server.BDeup7Ky.mjs';
2
+ import { D as DecoratedProcedure } from '../shared/server.CUsS2s2p.mjs';
3
3
  import '@orpc/client';
4
4
  import '@orpc/contract';
5
5
  import '@orpc/shared';
@@ -1,4 +1,4 @@
1
- import { ParseOptions, SerializeOptions } from 'cookie';
1
+ import { ParseOptions, SetCookie, StringifyOptions } from 'cookie';
2
2
 
3
3
  /**
4
4
  * Encodes a Uint8Array to base64url format
@@ -27,7 +27,7 @@ declare function encodeBase64url(data: Uint8Array): string;
27
27
  */
28
28
  declare function decodeBase64url(base64url: string | undefined | null): Uint8Array<ArrayBuffer> | undefined;
29
29
 
30
- interface SetCookieOptions extends SerializeOptions {
30
+ interface SetCookieOptions extends Omit<SetCookie, 'name' | 'value'>, StringifyOptions {
31
31
  /**
32
32
  * Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
33
33
  *
@@ -46,7 +46,7 @@ interface SetCookieOptions extends SerializeOptions {
46
46
  *
47
47
  * setCookie(headers, 'sessionId', 'abc123', { httpOnly: true, maxAge: 3600 })
48
48
  *
49
- * expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; HttpOnly; Max-Age=3600')
49
+ * expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; Max-Age=3600; Path=/; HttpOnly')
50
50
  * ```
51
51
  *
52
52
  */
@@ -1,4 +1,4 @@
1
- import { ParseOptions, SerializeOptions } from 'cookie';
1
+ import { ParseOptions, SetCookie, StringifyOptions } from 'cookie';
2
2
 
3
3
  /**
4
4
  * Encodes a Uint8Array to base64url format
@@ -27,7 +27,7 @@ declare function encodeBase64url(data: Uint8Array): string;
27
27
  */
28
28
  declare function decodeBase64url(base64url: string | undefined | null): Uint8Array<ArrayBuffer> | undefined;
29
29
 
30
- interface SetCookieOptions extends SerializeOptions {
30
+ interface SetCookieOptions extends Omit<SetCookie, 'name' | 'value'>, StringifyOptions {
31
31
  /**
32
32
  * Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
33
33
  *
@@ -46,7 +46,7 @@ interface SetCookieOptions extends SerializeOptions {
46
46
  *
47
47
  * setCookie(headers, 'sessionId', 'abc123', { httpOnly: true, maxAge: 3600 })
48
48
  *
49
- * expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; HttpOnly; Max-Age=3600')
49
+ * expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; Max-Age=3600; Path=/; HttpOnly')
50
50
  * ```
51
51
  *
52
52
  */
@@ -1,4 +1,4 @@
1
- import { parse, serialize } from 'cookie';
1
+ import { parseCookie, stringifySetCookie } from 'cookie';
2
2
 
3
3
  function encodeBase64url(data) {
4
4
  const chunkSize = 8192;
@@ -34,10 +34,17 @@ function setCookie(headers, name, value, options = {}) {
34
34
  if (headers === void 0) {
35
35
  return;
36
36
  }
37
- const cookieString = serialize(name, value, {
37
+ const cookieString = stringifySetCookie({
38
+ // Force path to '/' by default so the cookie is available across the
39
+ // entire app, not just under the directory of the request that set it
40
+ // (which is what browsers do per RFC 6265 §5.1.4 when Path is omitted).
38
41
  path: "/",
39
- ...options
40
- });
42
+ ...options,
43
+ name,
44
+ // prioritize
45
+ value
46
+ // prioritize
47
+ }, options);
41
48
  headers.append("Set-Cookie", cookieString);
42
49
  }
43
50
  function getCookie(headers, name, options = {}) {
@@ -48,12 +55,13 @@ function getCookie(headers, name, options = {}) {
48
55
  if (cookieHeader === null) {
49
56
  return void 0;
50
57
  }
51
- return parse(cookieHeader, options)[name];
58
+ return parseCookie(cookieHeader, options)[name];
52
59
  }
53
60
  function deleteCookie(headers, name, options = {}) {
54
61
  return setCookie(headers, name, "", {
55
62
  ...options,
56
63
  maxAge: 0
64
+ // prioritize
57
65
  });
58
66
  }
59
67
 
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
2
2
  export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
3
3
  import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
4
- export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
4
+ export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
5
5
  import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
6
- export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
6
+ export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
7
7
  import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as AnyMiddleware, g as Lazy, A as AnyProcedure, L as Lazyable, h as ProcedureHandler, O as ORPCErrorConstructorMap, i as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.BL22TloH.mjs';
8
8
  export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, r as ORPCErrorConstructorMapItem, s as ORPCErrorConstructorMapItemOptions, c as ProcedureClientInterceptor, t as ProcedureClientInterceptorOptions, u as ProcedureDefinition, v as ProcedureHandlerOptions, w as createORPCErrorConstructorMap, x as createProcedureClient, y as unlazy } from './shared/server.BL22TloH.mjs';
9
9
  import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.BsNNjG5J.mjs';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
2
2
  export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
3
3
  import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
4
- export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
4
+ export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
5
5
  import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
6
- export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
6
+ export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
7
7
  import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as AnyMiddleware, g as Lazy, A as AnyProcedure, L as Lazyable, h as ProcedureHandler, O as ORPCErrorConstructorMap, i as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.BL22TloH.js';
8
8
  export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, r as ORPCErrorConstructorMapItem, s as ORPCErrorConstructorMapItemOptions, c as ProcedureClientInterceptor, t as ProcedureClientInterceptorOptions, u as ProcedureDefinition, v as ProcedureHandlerOptions, w as createORPCErrorConstructorMap, x as createProcedureClient, y as unlazy } from './shared/server.BL22TloH.js';
9
9
  import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.Pa0F03f_.js';
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { mergeErrorMap, resolveMetaPlugins, getHiddenMetaPlugins, ProcedureContract } from '@orpc/contract';
2
- export { ValidationError, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
2
+ export { ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
3
3
  import { toArray, bindMethods, getOrBind, isTypescriptObject, resolveMaybeOptionalOptions } from '@orpc/shared';
4
- export { AsyncIteratorClass, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
5
- import { L as Lazy, P as Procedure, c as createProcedureClient } from './shared/server.CrlKQucM.mjs';
6
- export { a as createORPCErrorConstructorMap, u as unlazy } from './shared/server.CrlKQucM.mjs';
7
- import { D as DecoratedProcedure } from './shared/server.CjOb6ItT.mjs';
8
- import { b as augmentRouter, d as augmentImplementedRouter, e as withHiddenRouterContract, f as createGuardedProcedureLazy, g as getRouter } from './shared/server.BwHnWUuN.mjs';
9
- export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS, h as call, c as createContractProcedure, i as getHiddenRouterContract, u as unlazyRouter, j as walkProcedureContractsAsync, w as walkProcedureContractsSync } from './shared/server.BwHnWUuN.mjs';
4
+ export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
5
+ import { L as Lazy, P as Procedure, c as createProcedureClient } from './shared/server.BDeup7Ky.mjs';
6
+ export { a as createORPCErrorConstructorMap, u as unlazy } from './shared/server.BDeup7Ky.mjs';
7
+ import { D as DecoratedProcedure } from './shared/server.CUsS2s2p.mjs';
8
+ import { b as augmentRouter, d as augmentImplementedRouter, e as withHiddenRouterContract, f as createGuardedProcedureLazy, g as getRouter } from './shared/server.C_osSBcd.mjs';
9
+ export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS, h as call, c as createContractProcedure, i as getHiddenRouterContract, u as unlazyRouter, j as walkProcedureContractsAsync, w as walkProcedureContractsSync } from './shared/server.C_osSBcd.mjs';
10
10
  import { RECURSIVE_CLIENT_UNWRAP_KEYS } from '@orpc/client';
11
11
  export { COMMON_ERROR_STATUS_MAP, ORPCError, RPCJsonSerializer, RPCSerializer, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
12
12
  export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
@@ -123,6 +123,15 @@ declare class CSRFGuardHandlerPlugin<T extends Context> implements StandardHandl
123
123
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
124
124
  }
125
125
 
126
+ declare class RequestCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
127
+ name: string;
128
+ /**
129
+ * Should decompress the original batch request body instead of sub-requests.
130
+ */
131
+ after: string[];
132
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
133
+ }
134
+
126
135
  interface RequestHeadersHandlerPluginContext {
127
136
  /**
128
137
  * Request headers as a Headers instance. This is injected by the Request Headers Plugin.
@@ -140,6 +149,72 @@ declare class RequestHeadersHandlerPlugin<T extends RequestHeadersHandlerPluginC
140
149
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
141
150
  }
142
151
 
152
+ interface RequestLimitHandlerPluginOptions {
153
+ /**
154
+ * The maximum allowed request body size in bytes.
155
+ */
156
+ maxBodySize: number;
157
+ }
158
+ /**
159
+ * Rejects requests whose body exceeds `maxBodySize`.
160
+ *
161
+ * When used with the request compression plugin, the limit applies to the
162
+ * decompressed payload rather than the compressed wire size.
163
+ *
164
+ * @see {@link https://orpc.dev/docs/plugins/request-limit Request Limit Plugin Docs}
165
+ */
166
+ declare class RequestLimitHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
167
+ name: string;
168
+ /**
169
+ * Should limit the original batch request body instead of sub-requests.
170
+ */
171
+ after: string[];
172
+ /**
173
+ * Should limit the final body size instead of the compressed one.
174
+ */
175
+ before: string[];
176
+ private readonly maxBodySize;
177
+ constructor(options: RequestLimitHandlerPluginOptions);
178
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
179
+ }
180
+
181
+ interface ResponseCompressionHandlerPluginOptions<_T extends Context> {
182
+ /**
183
+ * The compression schemes to use for response compression.
184
+ * Schemes are prioritized by their order in this array and
185
+ * only applied if the client supports them (via Accept-Encoding).
186
+ *
187
+ * @default ['gzip', 'deflate']
188
+ */
189
+ encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
190
+ /**
191
+ * The minimum response size in bytes required to trigger compression.
192
+ * Responses smaller than this threshold will not be compressed to avoid overhead.
193
+ * If the response size cannot be determined, compression will still be applied.
194
+ *
195
+ * @default 1024 (1KB)
196
+ */
197
+ threshold?: number;
198
+ }
199
+ /**
200
+ * Compresses response bodies based on the client's Accept-Encoding header.
201
+ * Works at the standard handler level, so it supports all adapters.
202
+ *
203
+ * @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin Docs}
204
+ */
205
+ declare class ResponseCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
206
+ name: string;
207
+ /**
208
+ * Compression should be done after batching, to compress the final response.
209
+ * Compression should also be done after response headers are set, to access final headers like Content-Type and Cache-Control.
210
+ */
211
+ after: string[];
212
+ private readonly encodings;
213
+ private readonly threshold;
214
+ constructor(options?: ResponseCompressionHandlerPluginOptions<T>);
215
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
216
+ }
217
+
143
218
  interface ResponseHeadersHandlerPluginContext {
144
219
  /**
145
220
  * Response headers as a Headers instance. This is injected by the Response Headers Plugin.
@@ -193,5 +268,5 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
193
268
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
194
269
  }
195
270
 
196
- export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
197
- export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext, RethrowHandlerPluginOptions };
271
+ export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestLimitHandlerPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
272
+ export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestLimitHandlerPluginOptions, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, RethrowHandlerPluginOptions };
@@ -123,6 +123,15 @@ declare class CSRFGuardHandlerPlugin<T extends Context> implements StandardHandl
123
123
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
124
124
  }
125
125
 
126
+ declare class RequestCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
127
+ name: string;
128
+ /**
129
+ * Should decompress the original batch request body instead of sub-requests.
130
+ */
131
+ after: string[];
132
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
133
+ }
134
+
126
135
  interface RequestHeadersHandlerPluginContext {
127
136
  /**
128
137
  * Request headers as a Headers instance. This is injected by the Request Headers Plugin.
@@ -140,6 +149,72 @@ declare class RequestHeadersHandlerPlugin<T extends RequestHeadersHandlerPluginC
140
149
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
141
150
  }
142
151
 
152
+ interface RequestLimitHandlerPluginOptions {
153
+ /**
154
+ * The maximum allowed request body size in bytes.
155
+ */
156
+ maxBodySize: number;
157
+ }
158
+ /**
159
+ * Rejects requests whose body exceeds `maxBodySize`.
160
+ *
161
+ * When used with the request compression plugin, the limit applies to the
162
+ * decompressed payload rather than the compressed wire size.
163
+ *
164
+ * @see {@link https://orpc.dev/docs/plugins/request-limit Request Limit Plugin Docs}
165
+ */
166
+ declare class RequestLimitHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
167
+ name: string;
168
+ /**
169
+ * Should limit the original batch request body instead of sub-requests.
170
+ */
171
+ after: string[];
172
+ /**
173
+ * Should limit the final body size instead of the compressed one.
174
+ */
175
+ before: string[];
176
+ private readonly maxBodySize;
177
+ constructor(options: RequestLimitHandlerPluginOptions);
178
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
179
+ }
180
+
181
+ interface ResponseCompressionHandlerPluginOptions<_T extends Context> {
182
+ /**
183
+ * The compression schemes to use for response compression.
184
+ * Schemes are prioritized by their order in this array and
185
+ * only applied if the client supports them (via Accept-Encoding).
186
+ *
187
+ * @default ['gzip', 'deflate']
188
+ */
189
+ encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
190
+ /**
191
+ * The minimum response size in bytes required to trigger compression.
192
+ * Responses smaller than this threshold will not be compressed to avoid overhead.
193
+ * If the response size cannot be determined, compression will still be applied.
194
+ *
195
+ * @default 1024 (1KB)
196
+ */
197
+ threshold?: number;
198
+ }
199
+ /**
200
+ * Compresses response bodies based on the client's Accept-Encoding header.
201
+ * Works at the standard handler level, so it supports all adapters.
202
+ *
203
+ * @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin Docs}
204
+ */
205
+ declare class ResponseCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
206
+ name: string;
207
+ /**
208
+ * Compression should be done after batching, to compress the final response.
209
+ * Compression should also be done after response headers are set, to access final headers like Content-Type and Cache-Control.
210
+ */
211
+ after: string[];
212
+ private readonly encodings;
213
+ private readonly threshold;
214
+ constructor(options?: ResponseCompressionHandlerPluginOptions<T>);
215
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
216
+ }
217
+
143
218
  interface ResponseHeadersHandlerPluginContext {
144
219
  /**
145
220
  * Response headers as a Headers instance. This is injected by the Response Headers Plugin.
@@ -193,5 +268,5 @@ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandler
193
268
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
194
269
  }
195
270
 
196
- export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
197
- export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext, RethrowHandlerPluginOptions };
271
+ export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestLimitHandlerPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
272
+ export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestLimitHandlerPluginOptions, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, RethrowHandlerPluginOptions };