@orpc/server 2.0.0-beta.3 → 2.0.0-beta.31

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 (56) hide show
  1. package/README.md +71 -101
  2. package/dist/adapters/aws-lambda/index.d.mts +93 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +93 -0
  4. package/dist/adapters/aws-lambda/index.mjs +66 -0
  5. package/dist/adapters/crossws/index.d.mts +17 -8
  6. package/dist/adapters/crossws/index.d.ts +17 -8
  7. package/dist/adapters/crossws/index.mjs +10 -7
  8. package/dist/adapters/fastify/index.d.mts +85 -0
  9. package/dist/adapters/fastify/index.d.ts +85 -0
  10. package/dist/adapters/fastify/index.mjs +66 -0
  11. package/dist/adapters/fetch/index.d.mts +16 -67
  12. package/dist/adapters/fetch/index.d.ts +16 -67
  13. package/dist/adapters/fetch/index.mjs +8 -144
  14. package/dist/adapters/message-port/index.d.mts +19 -16
  15. package/dist/adapters/message-port/index.d.ts +19 -16
  16. package/dist/adapters/message-port/index.mjs +28 -32
  17. package/dist/adapters/node/index.d.mts +15 -49
  18. package/dist/adapters/node/index.d.ts +15 -49
  19. package/dist/adapters/node/index.mjs +9 -120
  20. package/dist/adapters/standard/index.d.mts +6 -6
  21. package/dist/adapters/standard/index.d.ts +6 -6
  22. package/dist/adapters/standard/index.mjs +3 -3
  23. package/dist/adapters/standard-peer/index.d.mts +2 -2
  24. package/dist/adapters/standard-peer/index.d.ts +2 -2
  25. package/dist/adapters/websocket/index.d.mts +42 -26
  26. package/dist/adapters/websocket/index.d.ts +42 -26
  27. package/dist/adapters/websocket/index.mjs +33 -25
  28. package/dist/extensions/callable.d.mts +2 -2
  29. package/dist/extensions/callable.d.ts +2 -2
  30. package/dist/extensions/callable.mjs +2 -2
  31. package/dist/helpers/index.d.mts +23 -6
  32. package/dist/helpers/index.d.ts +23 -6
  33. package/dist/helpers/index.mjs +13 -5
  34. package/dist/index.d.mts +311 -16
  35. package/dist/index.d.ts +311 -16
  36. package/dist/index.mjs +126 -34
  37. package/dist/plugins/index.d.mts +241 -32
  38. package/dist/plugins/index.d.ts +241 -32
  39. package/dist/plugins/index.mjs +479 -15
  40. package/dist/shared/server.BhHrioCw.d.ts +34 -0
  41. package/dist/shared/{server.T9F3bzZx.d.ts → server.C2n16pp0.d.ts} +34 -9
  42. package/dist/shared/server.Cd4Z1hpV.mjs +69 -0
  43. package/dist/shared/{server.CrlKQucM.mjs → server.CkButhNT.mjs} +21 -38
  44. package/dist/shared/{server.B_U9y00a.d.mts → server.CkNnZ5F-.d.mts} +34 -9
  45. package/dist/shared/{server.BL22TloH.d.mts → server.CwrYlF72.d.mts} +31 -41
  46. package/dist/shared/{server.BL22TloH.d.ts → server.CwrYlF72.d.ts} +31 -41
  47. package/dist/shared/server.D0Ipbmdv.d.mts +34 -0
  48. package/dist/shared/{server.BwHnWUuN.mjs → server.Dh77P3ii.mjs} +17 -10
  49. package/dist/shared/{server.Pa0F03f_.d.ts → server.Dm0os-OP.d.mts} +24 -12
  50. package/dist/shared/{server.GDpX6Df8.mjs → server.DpUGXBi2.mjs} +84 -51
  51. package/dist/shared/{server.EOHJ3NJr.d.ts → server.DrN1Pj1-.d.ts} +3 -3
  52. package/dist/shared/{server.BsNNjG5J.d.mts → server.DtfwuV6U.d.ts} +24 -12
  53. package/dist/shared/{server.BB_Ik9Ph.d.mts → server.JbCIPL4P.d.mts} +3 -3
  54. package/dist/shared/{server.CjOb6ItT.mjs → server.eCTV8Vpp.mjs} +1 -1
  55. package/package.json +46 -12
  56. package/dist/shared/server.D_QauotT.mjs +0 -30
@@ -1,11 +1,11 @@
1
1
  import { MaybeOptionalOptions } from '@orpc/shared';
2
2
  import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
3
3
  import { Message, Peer } from 'crossws';
4
- import { C as Context } from '../../shared/server.BL22TloH.mjs';
5
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BB_Ik9Ph.mjs';
4
+ import { Context } from '../../index.mjs';
5
+ import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
6
6
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.mjs';
7
- import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.B_U9y00a.mjs';
7
+ import { Router } from '../../index.mjs';
8
+ import { RPCHandlerCodecOptions } from '../standard/index.mjs';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -29,23 +29,32 @@ declare class experimental_CrosswsHandler<T extends Context> {
29
29
  private readonly decodePeerMessageOptions;
30
30
  constructor(handler: StandardHandler<T>, options?: NoInfer<experimental_CrosswsHandlerOptions<T>>);
31
31
  /**
32
- * Handles a single message received from a crossws Peer.
32
+ * Handles a single WebSocket message.
33
33
  *
34
- * @param ws The crossws Peer instance, require consistent instance across messages for proper peer management
34
+ * Message order matters. Call this immediately after receiving a message,
35
+ * before any other async work, to preserve ordering.
36
+ *
37
+ * @param ws The crossws peer instance. Use the same instance for all messages.
35
38
  */
36
39
  message(ws: CrosswsPeerLike, message: CrosswsMessageLike, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): Promise<{
37
40
  matched: boolean;
38
41
  }>;
39
42
  /**
40
- * Closes the peer connection and cleans up associated resources.
43
+ * Cleans up peer state for a closed WebSocket.
41
44
  *
42
- * @param ws The crossws Peer instance to close, require consistent instance for proper peer management
45
+ * @param ws The same crossws peer instance passed to `.message()`.
43
46
  */
44
47
  close(ws: CrosswsPeerLike): Promise<void>;
45
48
  }
46
49
 
47
50
  interface experimental_RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, experimental_CrosswsHandlerOptions<T> {
48
51
  }
52
+ /**
53
+ * Serves an oRPC router over the RPC protocol on a WebSocket connection
54
+ * managed by [crossws](https://github.com/h3js/crossws).
55
+ *
56
+ * @see {@link https://orpc.dev/docs/adapters/websocket | WebSocket Adapters}
57
+ */
49
58
  declare class experimental_RPCHandler<T extends Context> extends experimental_CrosswsHandler<T> {
50
59
  constructor(router: Router<T>, options?: NoInfer<experimental_RPCHandlerOptions<T>>);
51
60
  }
@@ -1,11 +1,11 @@
1
1
  import { MaybeOptionalOptions } from '@orpc/shared';
2
2
  import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
3
3
  import { Message, Peer } from 'crossws';
4
- import { C as Context } from '../../shared/server.BL22TloH.js';
5
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.EOHJ3NJr.js';
4
+ import { Context } from '../../index.js';
5
+ import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
6
6
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
7
- import { R as Router } from '../../shared/server.Pa0F03f_.js';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.T9F3bzZx.js';
7
+ import { Router } from '../../index.js';
8
+ import { RPCHandlerCodecOptions } from '../standard/index.js';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -29,23 +29,32 @@ declare class experimental_CrosswsHandler<T extends Context> {
29
29
  private readonly decodePeerMessageOptions;
30
30
  constructor(handler: StandardHandler<T>, options?: NoInfer<experimental_CrosswsHandlerOptions<T>>);
31
31
  /**
32
- * Handles a single message received from a crossws Peer.
32
+ * Handles a single WebSocket message.
33
33
  *
34
- * @param ws The crossws Peer instance, require consistent instance across messages for proper peer management
34
+ * Message order matters. Call this immediately after receiving a message,
35
+ * before any other async work, to preserve ordering.
36
+ *
37
+ * @param ws The crossws peer instance. Use the same instance for all messages.
35
38
  */
36
39
  message(ws: CrosswsPeerLike, message: CrosswsMessageLike, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): Promise<{
37
40
  matched: boolean;
38
41
  }>;
39
42
  /**
40
- * Closes the peer connection and cleans up associated resources.
43
+ * Cleans up peer state for a closed WebSocket.
41
44
  *
42
- * @param ws The crossws Peer instance to close, require consistent instance for proper peer management
45
+ * @param ws The same crossws peer instance passed to `.message()`.
43
46
  */
44
47
  close(ws: CrosswsPeerLike): Promise<void>;
45
48
  }
46
49
 
47
50
  interface experimental_RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, experimental_CrosswsHandlerOptions<T> {
48
51
  }
52
+ /**
53
+ * Serves an oRPC router over the RPC protocol on a WebSocket connection
54
+ * managed by [crossws](https://github.com/h3js/crossws).
55
+ *
56
+ * @see {@link https://orpc.dev/docs/adapters/websocket | WebSocket Adapters}
57
+ */
49
58
  declare class experimental_RPCHandler<T extends Context> extends experimental_CrosswsHandler<T> {
50
59
  constructor(router: Router<T>, options?: NoInfer<experimental_RPCHandlerOptions<T>>);
51
60
  }
@@ -1,12 +1,12 @@
1
1
  import { resolveMaybeOptionalOptions } 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.DpUGXBi2.mjs';
5
5
  import '@orpc/client';
6
6
  import '@standardserver/core';
7
- import '../../shared/server.CrlKQucM.mjs';
7
+ import '../../shared/server.CkButhNT.mjs';
8
8
  import '@orpc/contract';
9
- import '../../shared/server.BwHnWUuN.mjs';
9
+ import '../../shared/server.Dh77P3ii.mjs';
10
10
 
11
11
  class experimental_CrosswsHandler {
12
12
  constructor(handler, options = {}) {
@@ -18,9 +18,12 @@ class experimental_CrosswsHandler {
18
18
  encodePeerMessageOptions;
19
19
  decodePeerMessageOptions;
20
20
  /**
21
- * Handles a single message received from a crossws Peer.
21
+ * Handles a single WebSocket message.
22
22
  *
23
- * @param ws The crossws Peer instance, require consistent instance across messages for proper peer management
23
+ * Message order matters. Call this immediately after receiving a message,
24
+ * before any other async work, to preserve ordering.
25
+ *
26
+ * @param ws The crossws peer instance. Use the same instance for all messages.
24
27
  */
25
28
  async message(ws, message, ...rest) {
26
29
  let peer = this.peers.get(ws);
@@ -40,9 +43,9 @@ class experimental_CrosswsHandler {
40
43
  return result;
41
44
  }
42
45
  /**
43
- * Closes the peer connection and cleans up associated resources.
46
+ * Cleans up peer state for a closed WebSocket.
44
47
  *
45
- * @param ws The crossws Peer instance to close, require consistent instance for proper peer management
48
+ * @param ws The same crossws peer instance passed to `.message()`.
46
49
  */
47
50
  async close(ws) {
48
51
  const server = this.peers.get(ws);
@@ -0,0 +1,85 @@
1
+ import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
2
+ import { SendStandardResponseOptions, AnyFastifyRequest, AnyFastifyReply } from '@standardserver/fastify';
3
+ import { Context } from '../../index.mjs';
4
+ import { StandardHandlerPlugin, StandardHandlerHandleOptions, StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
5
+ import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
6
+ import { Router } from '../../index.mjs';
7
+ import { RPCHandlerCodecOptions } from '../standard/index.mjs';
8
+ import '@orpc/client';
9
+ import '@orpc/contract';
10
+ import '@standardserver/core';
11
+
12
+ interface FastifyHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
13
+ /**
14
+ * Initializes the plugin and returns new Fastify handler options.
15
+ * Called once per plugin instance during composition.
16
+ *
17
+ * This method allows plugins to wrap, extend, or transform Fastify handler options
18
+ * such as interceptors, or other configuration.
19
+ *
20
+ * @param options - The current handler options from previous plugins or base configuration
21
+ * @returns Transformed handler options with plugin's modifications applied
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * initFastifyHandlerOptions(options) {
26
+ * return {
27
+ * ...options,
28
+ * fastifyInterceptors: [...(options.fastifyInterceptors || []), myInterceptor]
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ initFastifyHandlerOptions?(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
34
+ }
35
+ declare class CompositeFastifyHandlerPlugin<T extends Context> implements FastifyHandlerPlugin<T> {
36
+ readonly name = "~composite/fastify";
37
+ protected readonly plugins: FastifyHandlerPlugin<T>[];
38
+ constructor(plugins?: FastifyHandlerPlugin<T>[]);
39
+ initFastifyHandlerOptions(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
40
+ }
41
+
42
+ type FastifyHandlerHandleResult = {
43
+ matched: true;
44
+ } | {
45
+ matched: false;
46
+ };
47
+ interface FastifyHandlerFastifyInterceptorOptions<T extends Context> extends StandardHandlerHandleOptions<T> {
48
+ request: AnyFastifyRequest;
49
+ reply: AnyFastifyReply;
50
+ sendStandardResponseOptions: SendStandardResponseOptions | undefined;
51
+ }
52
+ type FastifyHandlerFastifyInterceptor<T extends Context> = Interceptor<FastifyHandlerFastifyInterceptorOptions<T>, Promise<FastifyHandlerHandleResult>>;
53
+ interface FastifyHandlerOptions<T extends Context> {
54
+ /**
55
+ * Custom options for `sendStandardResponse`, used to send a `Standard Response`
56
+ */
57
+ sendStandardResponse?: SendStandardResponseOptions | undefined;
58
+ /**
59
+ * Interceptors that run before the mapping between the Standard API and Fastify API,
60
+ * useful for extending the Fastify request/reply before handling, ...
61
+ */
62
+ fastifyInterceptors?: FastifyHandlerFastifyInterceptor<T>[] | undefined;
63
+ plugins?: FastifyHandlerPlugin<T>[] | undefined;
64
+ }
65
+ declare class FastifyHandler<T extends Context> {
66
+ private readonly standardHandler;
67
+ private readonly sendStandardResponseOptions;
68
+ private readonly fastifyInterceptors;
69
+ constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
70
+ handle(request: AnyFastifyRequest, reply: AnyFastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FastifyHandlerHandleResult>;
71
+ }
72
+
73
+ interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
74
+ }
75
+ /**
76
+ * Serves an oRPC router over the RPC protocol inside a Fastify server.
77
+ *
78
+ * @see {@link https://orpc.dev/docs/adapters/fastify | Fastify Adapter}
79
+ */
80
+ declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
81
+ constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
82
+ }
83
+
84
+ export { CompositeFastifyHandlerPlugin, FastifyHandler, RPCHandler };
85
+ export type { FastifyHandlerFastifyInterceptor, FastifyHandlerFastifyInterceptorOptions, FastifyHandlerHandleResult, FastifyHandlerOptions, FastifyHandlerPlugin, RPCHandlerOptions };
@@ -0,0 +1,85 @@
1
+ import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
2
+ import { SendStandardResponseOptions, AnyFastifyRequest, AnyFastifyReply } from '@standardserver/fastify';
3
+ import { Context } from '../../index.js';
4
+ import { StandardHandlerPlugin, StandardHandlerHandleOptions, StandardHandler, StandardHandlerOptions } from '../standard/index.js';
5
+ import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
6
+ import { Router } from '../../index.js';
7
+ import { RPCHandlerCodecOptions } from '../standard/index.js';
8
+ import '@orpc/client';
9
+ import '@orpc/contract';
10
+ import '@standardserver/core';
11
+
12
+ interface FastifyHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
13
+ /**
14
+ * Initializes the plugin and returns new Fastify handler options.
15
+ * Called once per plugin instance during composition.
16
+ *
17
+ * This method allows plugins to wrap, extend, or transform Fastify handler options
18
+ * such as interceptors, or other configuration.
19
+ *
20
+ * @param options - The current handler options from previous plugins or base configuration
21
+ * @returns Transformed handler options with plugin's modifications applied
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * initFastifyHandlerOptions(options) {
26
+ * return {
27
+ * ...options,
28
+ * fastifyInterceptors: [...(options.fastifyInterceptors || []), myInterceptor]
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ initFastifyHandlerOptions?(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
34
+ }
35
+ declare class CompositeFastifyHandlerPlugin<T extends Context> implements FastifyHandlerPlugin<T> {
36
+ readonly name = "~composite/fastify";
37
+ protected readonly plugins: FastifyHandlerPlugin<T>[];
38
+ constructor(plugins?: FastifyHandlerPlugin<T>[]);
39
+ initFastifyHandlerOptions(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
40
+ }
41
+
42
+ type FastifyHandlerHandleResult = {
43
+ matched: true;
44
+ } | {
45
+ matched: false;
46
+ };
47
+ interface FastifyHandlerFastifyInterceptorOptions<T extends Context> extends StandardHandlerHandleOptions<T> {
48
+ request: AnyFastifyRequest;
49
+ reply: AnyFastifyReply;
50
+ sendStandardResponseOptions: SendStandardResponseOptions | undefined;
51
+ }
52
+ type FastifyHandlerFastifyInterceptor<T extends Context> = Interceptor<FastifyHandlerFastifyInterceptorOptions<T>, Promise<FastifyHandlerHandleResult>>;
53
+ interface FastifyHandlerOptions<T extends Context> {
54
+ /**
55
+ * Custom options for `sendStandardResponse`, used to send a `Standard Response`
56
+ */
57
+ sendStandardResponse?: SendStandardResponseOptions | undefined;
58
+ /**
59
+ * Interceptors that run before the mapping between the Standard API and Fastify API,
60
+ * useful for extending the Fastify request/reply before handling, ...
61
+ */
62
+ fastifyInterceptors?: FastifyHandlerFastifyInterceptor<T>[] | undefined;
63
+ plugins?: FastifyHandlerPlugin<T>[] | undefined;
64
+ }
65
+ declare class FastifyHandler<T extends Context> {
66
+ private readonly standardHandler;
67
+ private readonly sendStandardResponseOptions;
68
+ private readonly fastifyInterceptors;
69
+ constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
70
+ handle(request: AnyFastifyRequest, reply: AnyFastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FastifyHandlerHandleResult>;
71
+ }
72
+
73
+ interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
74
+ }
75
+ /**
76
+ * Serves an oRPC router over the RPC protocol inside a Fastify server.
77
+ *
78
+ * @see {@link https://orpc.dev/docs/adapters/fastify | Fastify Adapter}
79
+ */
80
+ declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
81
+ constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
82
+ }
83
+
84
+ export { CompositeFastifyHandlerPlugin, FastifyHandler, RPCHandler };
85
+ export type { FastifyHandlerFastifyInterceptor, FastifyHandlerFastifyInterceptorOptions, FastifyHandlerHandleResult, FastifyHandlerOptions, FastifyHandlerPlugin, RPCHandlerOptions };
@@ -0,0 +1,66 @@
1
+ import { sortPlugins, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
2
+ import { toStandardLazyRequest, sendStandardResponse } from '@standardserver/fastify';
3
+ import { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
4
+ import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.DpUGXBi2.mjs';
5
+ import '@orpc/client';
6
+ import '@standardserver/core';
7
+ import '../../shared/server.CkButhNT.mjs';
8
+ import '@orpc/contract';
9
+ import '../../shared/server.Dh77P3ii.mjs';
10
+
11
+ class CompositeFastifyHandlerPlugin {
12
+ name = "~composite/fastify";
13
+ plugins;
14
+ constructor(plugins = []) {
15
+ this.plugins = sortPlugins(plugins);
16
+ }
17
+ initFastifyHandlerOptions(options) {
18
+ for (const plugin of this.plugins) {
19
+ if (plugin.initFastifyHandlerOptions) {
20
+ options = plugin.initFastifyHandlerOptions(options);
21
+ }
22
+ }
23
+ return options;
24
+ }
25
+ }
26
+
27
+ class FastifyHandler {
28
+ constructor(standardHandler, options = {}) {
29
+ this.standardHandler = standardHandler;
30
+ options = new CompositeFastifyHandlerPlugin(options.plugins).initFastifyHandlerOptions(options);
31
+ this.fastifyInterceptors = options.fastifyInterceptors;
32
+ this.sendStandardResponseOptions = options.sendStandardResponse;
33
+ }
34
+ sendStandardResponseOptions;
35
+ fastifyInterceptors;
36
+ async handle(request, reply, ...rest) {
37
+ return intercept(
38
+ this.fastifyInterceptors,
39
+ {
40
+ ...resolveFriendlyStandardHandlerHandleOptions(resolveMaybeOptionalOptions(rest)),
41
+ request,
42
+ reply,
43
+ sendStandardResponseOptions: this.sendStandardResponseOptions
44
+ },
45
+ async ({ request: request2, reply: reply2, sendStandardResponseOptions, ...options }) => {
46
+ const standardRequest = toStandardLazyRequest(request2, reply2);
47
+ const result = await this.standardHandler.handle(standardRequest, options);
48
+ if (!result.matched) {
49
+ return result;
50
+ }
51
+ await sendStandardResponse(reply2, result.response, sendStandardResponseOptions);
52
+ return result;
53
+ }
54
+ );
55
+ }
56
+ }
57
+
58
+ class RPCHandler extends FastifyHandler {
59
+ constructor(router, options = {}) {
60
+ const codec = new RPCHandlerCodec(router, options);
61
+ const handler = new StandardHandler(codec, options);
62
+ super(handler, options);
63
+ }
64
+ }
65
+
66
+ export { CompositeFastifyHandlerPlugin, FastifyHandler, RPCHandler };
@@ -1,10 +1,11 @@
1
- import { C as Context } from '../../shared/server.BL22TloH.mjs';
1
+ export { R as BodyLimitPlugin } from '../../shared/server.D0Ipbmdv.mjs';
2
2
  import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
3
  import { ToFetchResponseOptions } from '@standardserver/fetch';
4
- import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BB_Ik9Ph.mjs';
4
+ import { Context } from '../../index.mjs';
5
+ import { StandardHandlerPlugin, StandardHandlerHandleOptions, StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
5
6
  import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
6
- import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.B_U9y00a.mjs';
7
+ import { Router } from '../../index.mjs';
8
+ import { RPCHandlerCodecOptions } from '../standard/index.mjs';
8
9
  import '@orpc/client';
9
10
  import '@orpc/contract';
10
11
  import '@standardserver/core';
@@ -33,7 +34,7 @@ interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T>
33
34
  initFetchHandlerOptions?(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
34
35
  }
35
36
  declare class CompositeFetchHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
36
- readonly name = "~composite/fetch-handler";
37
+ readonly name = "~composite/fetch";
37
38
  protected readonly plugins: FetchHandlerPlugin<T>[];
38
39
  constructor(plugins?: FetchHandlerPlugin<T>[]);
39
40
  initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
@@ -53,7 +54,7 @@ interface FetchHandlerFetchInterceptorOptions<T extends Context> extends Standar
53
54
  type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
54
55
  interface FetchHandlerOptions<T extends Context> {
55
56
  /**
56
- * Options for how to convert the Fetch Response to a Standard Response, like event iterator options, etc.
57
+ * Options for how to convert the Fetch Response to a Standard Response, like event stream options, etc.
57
58
  */
58
59
  toFetchResponse?: undefined | ToFetchResponseOptions;
59
60
  /**
@@ -71,70 +72,18 @@ declare class FetchHandler<T extends Context> {
71
72
  handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FetchHandlerHandleResult>;
72
73
  }
73
74
 
74
- declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
75
- interface BodyCompressionHandlerPluginOptions {
76
- /**
77
- * The compression schemes to use for response compression.
78
- * Schemes are prioritized by their order in this array and
79
- * only applied if the client supports them.
80
- *
81
- * @default ['gzip', 'deflate']
82
- */
83
- encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
84
- /**
85
- * The minimum response size in bytes required to trigger compression.
86
- * Responses smaller than this threshold will not be compressed to avoid overhead.
87
- * If the response size cannot be determined, compression will still be applied.
88
- *
89
- * @default 1024 (1KB)
90
- */
91
- threshold?: number;
92
- /**
93
- * Override the default content-type filter used to determine which responses should be compressed.
94
- *
95
- * @warning Event stream responses are never compressed, regardless of this filter's return value.
96
- * @default only responses with compressible content types are compressed.
97
- */
98
- filter?: (request: Request, response: Response) => boolean;
99
- }
100
- declare class BodyCompressionHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
101
- name: string;
102
- private readonly encodings;
103
- private readonly threshold;
104
- private readonly filter;
105
- constructor(options?: BodyCompressionHandlerPluginOptions);
106
- initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
107
- }
108
-
109
- interface BodyLimitHandlerPluginOptions {
110
- /**
111
- * The maximum size of the body in bytes.
112
- */
113
- maxBodySize: number;
114
- }
115
- declare class BodyLimitHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
116
- name: string;
117
- private readonly maxBodySize;
118
- constructor(options: BodyLimitHandlerPluginOptions);
119
- initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
120
- }
121
-
122
75
  interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
123
- /**
124
- * Configuration for {@link CSRFGuardHandlerPlugin}, which is enabled by default for `RPCHandler` over HTTP.
125
- */
126
- csrfGuardHandlerPlugin?: {
127
- /**
128
- * If `false`, this plugin is disabled.
129
- *
130
- * @default true
131
- */
132
- enabled?: boolean;
133
- };
134
76
  }
77
+ /**
78
+ * Serves an oRPC router over the RPC protocol using the Fetch API
79
+ * (Request/Response), supported by modern runtimes like Deno, Bun,
80
+ * Cloudflare Workers, and browsers.
81
+ *
82
+ * @see {@link https://orpc.dev/docs/adapters/fetch-api | Fetch API Adapter}
83
+ */
135
84
  declare class RPCHandler<T extends Context> extends FetchHandler<T> {
136
85
  constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
137
86
  }
138
87
 
139
- export { BodyCompressionHandlerPlugin, BodyLimitHandlerPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
140
- export type { BodyCompressionHandlerPluginOptions, BodyLimitHandlerPluginOptions, FetchHandlerFetchInterceptor, FetchHandlerFetchInterceptorOptions, FetchHandlerHandleResult, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
88
+ export { CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
89
+ export type { FetchHandlerFetchInterceptor, FetchHandlerFetchInterceptorOptions, FetchHandlerHandleResult, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
@@ -1,10 +1,11 @@
1
- import { C as Context } from '../../shared/server.BL22TloH.js';
1
+ export { R as BodyLimitPlugin } from '../../shared/server.BhHrioCw.js';
2
2
  import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
3
  import { ToFetchResponseOptions } from '@standardserver/fetch';
4
- import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.EOHJ3NJr.js';
4
+ import { Context } from '../../index.js';
5
+ import { StandardHandlerPlugin, StandardHandlerHandleOptions, StandardHandler, StandardHandlerOptions } from '../standard/index.js';
5
6
  import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
6
- import { R as Router } from '../../shared/server.Pa0F03f_.js';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.T9F3bzZx.js';
7
+ import { Router } from '../../index.js';
8
+ import { RPCHandlerCodecOptions } from '../standard/index.js';
8
9
  import '@orpc/client';
9
10
  import '@orpc/contract';
10
11
  import '@standardserver/core';
@@ -33,7 +34,7 @@ interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T>
33
34
  initFetchHandlerOptions?(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
34
35
  }
35
36
  declare class CompositeFetchHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
36
- readonly name = "~composite/fetch-handler";
37
+ readonly name = "~composite/fetch";
37
38
  protected readonly plugins: FetchHandlerPlugin<T>[];
38
39
  constructor(plugins?: FetchHandlerPlugin<T>[]);
39
40
  initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
@@ -53,7 +54,7 @@ interface FetchHandlerFetchInterceptorOptions<T extends Context> extends Standar
53
54
  type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
54
55
  interface FetchHandlerOptions<T extends Context> {
55
56
  /**
56
- * Options for how to convert the Fetch Response to a Standard Response, like event iterator options, etc.
57
+ * Options for how to convert the Fetch Response to a Standard Response, like event stream options, etc.
57
58
  */
58
59
  toFetchResponse?: undefined | ToFetchResponseOptions;
59
60
  /**
@@ -71,70 +72,18 @@ declare class FetchHandler<T extends Context> {
71
72
  handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FetchHandlerHandleResult>;
72
73
  }
73
74
 
74
- declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
75
- interface BodyCompressionHandlerPluginOptions {
76
- /**
77
- * The compression schemes to use for response compression.
78
- * Schemes are prioritized by their order in this array and
79
- * only applied if the client supports them.
80
- *
81
- * @default ['gzip', 'deflate']
82
- */
83
- encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
84
- /**
85
- * The minimum response size in bytes required to trigger compression.
86
- * Responses smaller than this threshold will not be compressed to avoid overhead.
87
- * If the response size cannot be determined, compression will still be applied.
88
- *
89
- * @default 1024 (1KB)
90
- */
91
- threshold?: number;
92
- /**
93
- * Override the default content-type filter used to determine which responses should be compressed.
94
- *
95
- * @warning Event stream responses are never compressed, regardless of this filter's return value.
96
- * @default only responses with compressible content types are compressed.
97
- */
98
- filter?: (request: Request, response: Response) => boolean;
99
- }
100
- declare class BodyCompressionHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
101
- name: string;
102
- private readonly encodings;
103
- private readonly threshold;
104
- private readonly filter;
105
- constructor(options?: BodyCompressionHandlerPluginOptions);
106
- initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
107
- }
108
-
109
- interface BodyLimitHandlerPluginOptions {
110
- /**
111
- * The maximum size of the body in bytes.
112
- */
113
- maxBodySize: number;
114
- }
115
- declare class BodyLimitHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
116
- name: string;
117
- private readonly maxBodySize;
118
- constructor(options: BodyLimitHandlerPluginOptions);
119
- initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
120
- }
121
-
122
75
  interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
123
- /**
124
- * Configuration for {@link CSRFGuardHandlerPlugin}, which is enabled by default for `RPCHandler` over HTTP.
125
- */
126
- csrfGuardHandlerPlugin?: {
127
- /**
128
- * If `false`, this plugin is disabled.
129
- *
130
- * @default true
131
- */
132
- enabled?: boolean;
133
- };
134
76
  }
77
+ /**
78
+ * Serves an oRPC router over the RPC protocol using the Fetch API
79
+ * (Request/Response), supported by modern runtimes like Deno, Bun,
80
+ * Cloudflare Workers, and browsers.
81
+ *
82
+ * @see {@link https://orpc.dev/docs/adapters/fetch-api | Fetch API Adapter}
83
+ */
135
84
  declare class RPCHandler<T extends Context> extends FetchHandler<T> {
136
85
  constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
137
86
  }
138
87
 
139
- export { BodyCompressionHandlerPlugin, BodyLimitHandlerPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
140
- export type { BodyCompressionHandlerPluginOptions, BodyLimitHandlerPluginOptions, FetchHandlerFetchInterceptor, FetchHandlerFetchInterceptorOptions, FetchHandlerHandleResult, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
88
+ export { CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
89
+ export type { FetchHandlerFetchInterceptor, FetchHandlerFetchInterceptorOptions, FetchHandlerHandleResult, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };