@orpc/server 0.0.0-next.c788572 → 0.0.0-next.c854c60

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 (45) hide show
  1. package/README.md +4 -5
  2. package/dist/adapters/aws-lambda/index.d.mts +45 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +45 -0
  4. package/dist/adapters/aws-lambda/index.mjs +41 -0
  5. package/dist/adapters/bun-ws/index.d.mts +35 -0
  6. package/dist/adapters/bun-ws/index.d.ts +35 -0
  7. package/dist/adapters/bun-ws/index.mjs +46 -0
  8. package/dist/adapters/crossws/index.d.mts +30 -0
  9. package/dist/adapters/crossws/index.d.ts +30 -0
  10. package/dist/adapters/crossws/index.mjs +46 -0
  11. package/dist/adapters/fetch/index.d.mts +17 -9
  12. package/dist/adapters/fetch/index.d.ts +17 -9
  13. package/dist/adapters/fetch/index.mjs +8 -3
  14. package/dist/adapters/message-port/index.d.mts +28 -0
  15. package/dist/adapters/message-port/index.d.ts +28 -0
  16. package/dist/adapters/message-port/index.mjs +41 -0
  17. package/dist/adapters/node/index.d.mts +17 -9
  18. package/dist/adapters/node/index.d.ts +17 -9
  19. package/dist/adapters/node/index.mjs +8 -3
  20. package/dist/adapters/standard/index.d.mts +4 -4
  21. package/dist/adapters/standard/index.d.ts +4 -4
  22. package/dist/adapters/standard/index.mjs +4 -5
  23. package/dist/adapters/websocket/index.d.mts +27 -0
  24. package/dist/adapters/websocket/index.d.ts +27 -0
  25. package/dist/adapters/websocket/index.mjs +39 -0
  26. package/dist/adapters/ws/index.d.mts +28 -0
  27. package/dist/adapters/ws/index.d.ts +28 -0
  28. package/dist/adapters/ws/index.mjs +39 -0
  29. package/dist/index.d.mts +12 -7
  30. package/dist/index.d.ts +12 -7
  31. package/dist/index.mjs +24 -7
  32. package/dist/plugins/index.d.mts +13 -13
  33. package/dist/plugins/index.d.ts +13 -13
  34. package/dist/plugins/index.mjs +10 -9
  35. package/dist/shared/{server.D5fBlF9j.d.ts → server.-ACo36I0.d.ts} +9 -9
  36. package/dist/shared/{server.CuD15qZB.d.ts → server.BPAWobQg.d.ts} +3 -9
  37. package/dist/shared/{server.CN0534_m.d.mts → server.Bd52nNaH.d.mts} +3 -9
  38. package/dist/shared/{server.DjgtLwKi.d.mts → server.BliFSTnG.d.mts} +2 -2
  39. package/dist/shared/{server.qf03T-Xn.mjs → server.CHvOkcM3.mjs} +11 -15
  40. package/dist/shared/{server.DPWk5pjW.d.mts → server.DD2C4ujN.d.mts} +4 -4
  41. package/dist/shared/{server.DPWk5pjW.d.ts → server.DD2C4ujN.d.ts} +4 -4
  42. package/dist/shared/{server.BVwwTHyO.mjs → server.DZ5BIITo.mjs} +1 -1
  43. package/dist/shared/{server.DY7OKEoj.d.mts → server.Dq8xr7PQ.d.mts} +9 -9
  44. package/dist/shared/{server.CjlA3NKP.d.ts → server.IG2MjhrD.d.ts} +2 -2
  45. package/package.json +56 -8
@@ -1,8 +1,8 @@
1
- import { Value } from '@orpc/shared';
1
+ import { Value, Promisable } from '@orpc/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
3
3
  import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.DY7OKEoj.mjs';
5
- import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DPWk5pjW.mjs';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.Dq8xr7PQ.mjs';
5
+ import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DD2C4ujN.mjs';
6
6
  import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
7
7
  import { ORPCError } from '@orpc/client';
8
8
 
@@ -12,7 +12,7 @@ interface BatchHandlerOptions<T extends Context> {
12
12
  *
13
13
  * @default 10
14
14
  */
15
- maxSize?: Value<number, [StandardHandlerInterceptorOptions<T>]>;
15
+ maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
16
16
  /**
17
17
  * Map the request before processing it.
18
18
  *
@@ -24,19 +24,19 @@ interface BatchHandlerOptions<T extends Context> {
24
24
  *
25
25
  * @default 207
26
26
  */
27
- successStatus?: Value<number, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
27
+ successStatus?: Value<Promisable<number>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
28
28
  /**
29
29
  * success batch response headers.
30
30
  *
31
31
  * @default {}
32
32
  */
33
- headers?: Value<StandardHeaders, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
33
+ headers?: Value<Promisable<StandardHeaders>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
34
34
  }
35
35
  /**
36
- * The Batch Request/Response Plugin allows you to combine multiple requests and responses into a single batch,
36
+ * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
37
37
  * reducing the overhead of sending each one separately.
38
38
  *
39
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-request-response Batch Request/Response Plugin Docs}
39
+ * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
40
40
  */
41
41
  declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
42
42
  private readonly maxSize;
@@ -49,8 +49,8 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
49
49
  }
50
50
 
51
51
  interface CORSOptions<T extends Context> {
52
- origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
- timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
52
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
54
54
  allowMethods?: readonly string[];
55
55
  allowHeaders?: readonly string[];
56
56
  maxAge?: number;
@@ -88,21 +88,21 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
88
88
  *
89
89
  * @default 'x-csrf-token'
90
90
  */
91
- headerName?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
91
+ headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
92
92
  /**
93
93
  * The value of the header to check.
94
94
  *
95
95
  * @default 'orpc'
96
96
  *
97
97
  */
98
- headerValue?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
98
+ headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
99
99
  /**
100
100
  * Exclude a procedure from the plugin.
101
101
  *
102
102
  * @default false
103
103
  *
104
104
  */
105
- exclude?: Value<boolean, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
105
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
106
106
  /**
107
107
  * The error thrown when the CSRF token is invalid.
108
108
  *
@@ -1,8 +1,8 @@
1
- import { Value } from '@orpc/shared';
1
+ import { Value, Promisable } from '@orpc/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
3
3
  import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.D5fBlF9j.js';
5
- import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DPWk5pjW.js';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.-ACo36I0.js';
5
+ import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DD2C4ujN.js';
6
6
  import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
7
7
  import { ORPCError } from '@orpc/client';
8
8
 
@@ -12,7 +12,7 @@ interface BatchHandlerOptions<T extends Context> {
12
12
  *
13
13
  * @default 10
14
14
  */
15
- maxSize?: Value<number, [StandardHandlerInterceptorOptions<T>]>;
15
+ maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
16
16
  /**
17
17
  * Map the request before processing it.
18
18
  *
@@ -24,19 +24,19 @@ interface BatchHandlerOptions<T extends Context> {
24
24
  *
25
25
  * @default 207
26
26
  */
27
- successStatus?: Value<number, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
27
+ successStatus?: Value<Promisable<number>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
28
28
  /**
29
29
  * success batch response headers.
30
30
  *
31
31
  * @default {}
32
32
  */
33
- headers?: Value<StandardHeaders, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
33
+ headers?: Value<Promisable<StandardHeaders>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
34
34
  }
35
35
  /**
36
- * The Batch Request/Response Plugin allows you to combine multiple requests and responses into a single batch,
36
+ * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
37
37
  * reducing the overhead of sending each one separately.
38
38
  *
39
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-request-response Batch Request/Response Plugin Docs}
39
+ * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
40
40
  */
41
41
  declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
42
42
  private readonly maxSize;
@@ -49,8 +49,8 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
49
49
  }
50
50
 
51
51
  interface CORSOptions<T extends Context> {
52
- origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
- timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
52
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
54
54
  allowMethods?: readonly string[];
55
55
  allowHeaders?: readonly string[];
56
56
  maxAge?: number;
@@ -88,21 +88,21 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
88
88
  *
89
89
  * @default 'x-csrf-token'
90
90
  */
91
- headerName?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
91
+ headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
92
92
  /**
93
93
  * The value of the header to check.
94
94
  *
95
95
  * @default 'orpc'
96
96
  *
97
97
  */
98
- headerValue?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
98
+ headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
99
99
  /**
100
100
  * Exclude a procedure from the plugin.
101
101
  *
102
102
  * @default false
103
103
  *
104
104
  */
105
- exclude?: Value<boolean, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
105
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
106
106
  /**
107
107
  * The error thrown when the CSRF token is invalid.
108
108
  *
@@ -1,4 +1,5 @@
1
1
  import { value, isAsyncIteratorObject } from '@orpc/shared';
2
+ import { flattenHeader } from '@orpc/standard-server';
2
3
  import { parseBatchRequest, toBatchResponse } from '@orpc/standard-server/batch';
3
4
  import { ORPCError } from '@orpc/client';
4
5
  export { S as StrictGetMethodPlugin } from '../shared/server.BW-nUGgA.mjs';
@@ -25,7 +26,8 @@ class BatchHandlerPlugin {
25
26
  init(options) {
26
27
  options.rootInterceptors ??= [];
27
28
  options.rootInterceptors.unshift(async (options2) => {
28
- if (options2.request.headers["x-orpc-batch"] !== "1") {
29
+ const xHeader = flattenHeader(options2.request.headers["x-orpc-batch"]);
30
+ if (xHeader === void 0) {
29
31
  return options2.next();
30
32
  }
31
33
  let isParsing = false;
@@ -68,9 +70,10 @@ class BatchHandlerPlugin {
68
70
  await Promise.race(responses);
69
71
  const status = await value(this.successStatus, responses, options2);
70
72
  const headers = await value(this.headers, responses, options2);
71
- const response = toBatchResponse({
73
+ const response = await toBatchResponse({
72
74
  status,
73
75
  headers,
76
+ mode: xHeader === "buffered" ? "buffered" : "streaming",
74
77
  body: async function* () {
75
78
  const promises = [...responses];
76
79
  while (true) {
@@ -123,13 +126,11 @@ class CORSPlugin {
123
126
  resHeaders["access-control-max-age"] = this.options.maxAge.toString();
124
127
  }
125
128
  if (this.options.allowMethods?.length) {
126
- resHeaders["access-control-allow-methods"] = this.options.allowMethods.join(",");
129
+ resHeaders["access-control-allow-methods"] = flattenHeader(this.options.allowMethods);
127
130
  }
128
131
  const allowHeaders = this.options.allowHeaders ?? interceptorOptions.request.headers["access-control-request-headers"];
129
- if (Array.isArray(allowHeaders) && allowHeaders.length) {
130
- resHeaders["access-control-allow-headers"] = allowHeaders.join(",");
131
- } else if (typeof allowHeaders === "string") {
132
- resHeaders["access-control-allow-headers"] = allowHeaders;
132
+ if (typeof allowHeaders === "string" || allowHeaders?.length) {
133
+ resHeaders["access-control-allow-headers"] = flattenHeader(allowHeaders);
133
134
  }
134
135
  return {
135
136
  matched: true,
@@ -147,7 +148,7 @@ class CORSPlugin {
147
148
  if (!result.matched) {
148
149
  return result;
149
150
  }
150
- const origin = Array.isArray(interceptorOptions.request.headers.origin) ? interceptorOptions.request.headers.origin.join(",") : interceptorOptions.request.headers.origin || "";
151
+ const origin = flattenHeader(interceptorOptions.request.headers.origin) ?? "";
151
152
  const allowedOrigin = await value(this.options.origin, origin, interceptorOptions);
152
153
  const allowedOriginArr = Array.isArray(allowedOrigin) ? allowedOrigin : [allowedOrigin];
153
154
  if (allowedOriginArr.includes("*")) {
@@ -169,7 +170,7 @@ class CORSPlugin {
169
170
  result.response.headers["access-control-allow-credentials"] = "true";
170
171
  }
171
172
  if (this.options.exposeHeaders?.length) {
172
- result.response.headers["access-control-expose-headers"] = this.options.exposeHeaders.join(",");
173
+ result.response.headers["access-control-expose-headers"] = flattenHeader(this.options.exposeHeaders);
173
174
  }
174
175
  return result;
175
176
  });
@@ -1,17 +1,17 @@
1
1
  import { HTTPPath, ORPCError } from '@orpc/client';
2
- import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
3
- import { Interceptor, ThrowableError } from '@orpc/shared';
2
+ import { Meta } from '@orpc/contract';
3
+ import { Interceptor } from '@orpc/shared';
4
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
5
- import { C as Context, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions, R as Router } from './server.DPWk5pjW.js';
5
+ import { C as Context, R as Router, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions } from './server.DD2C4ujN.js';
6
6
 
7
- interface StandardHandlerPlugin<TContext extends Context> {
7
+ interface StandardHandlerPlugin<T extends Context> {
8
8
  order?: number;
9
- init?(options: StandardHandlerOptions<TContext>): void;
9
+ init?(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
10
10
  }
11
11
  declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
12
12
  protected readonly plugins: TPlugin[];
13
13
  constructor(plugins?: readonly TPlugin[]);
14
- init(options: StandardHandlerOptions<T>): void;
14
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
15
15
  }
16
16
 
17
17
  type StandardParams = Record<string, string>;
@@ -49,16 +49,16 @@ interface StandardHandlerOptions<TContext extends Context> {
49
49
  /**
50
50
  * Interceptors at the request level, helpful when you want catch errors
51
51
  */
52
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
52
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
53
53
  /**
54
54
  * Interceptors at the root level, helpful when you want override the request/response
55
55
  */
56
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
56
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
57
57
  /**
58
58
  *
59
59
  * Interceptors for procedure client.
60
60
  */
61
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
61
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
62
62
  }
63
63
  declare class StandardHandler<T extends Context> {
64
64
  private readonly matcher;
@@ -1,17 +1,11 @@
1
1
  import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
- import { C as Context, R as Router } from './server.DPWk5pjW.js';
3
- import { b as StandardHandlerOptions, i as StandardHandler } from './server.D5fBlF9j.js';
2
+ import { C as Context, R as Router } from './server.DD2C4ujN.js';
3
+ import { b as StandardHandlerOptions, i as StandardHandler } from './server.-ACo36I0.js';
4
4
 
5
5
  interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
- /**
7
- * Enables or disables the StrictGetMethodPlugin.
8
- *
9
- * @default true
10
- */
11
- strictGetMethodPluginEnabled?: boolean;
12
6
  }
13
7
  declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
14
- constructor(router: Router<any, T>, options: StandardRPCHandlerOptions<T>);
8
+ constructor(router: Router<any, T>, options?: StandardRPCHandlerOptions<T>);
15
9
  }
16
10
 
17
11
  export { StandardRPCHandler as a };
@@ -1,17 +1,11 @@
1
1
  import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
- import { C as Context, R as Router } from './server.DPWk5pjW.mjs';
3
- import { b as StandardHandlerOptions, i as StandardHandler } from './server.DY7OKEoj.mjs';
2
+ import { C as Context, R as Router } from './server.DD2C4ujN.mjs';
3
+ import { b as StandardHandlerOptions, i as StandardHandler } from './server.Dq8xr7PQ.mjs';
4
4
 
5
5
  interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
- /**
7
- * Enables or disables the StrictGetMethodPlugin.
8
- *
9
- * @default true
10
- */
11
- strictGetMethodPluginEnabled?: boolean;
12
6
  }
13
7
  declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
14
- constructor(router: Router<any, T>, options: StandardRPCHandlerOptions<T>);
8
+ constructor(router: Router<any, T>, options?: StandardRPCHandlerOptions<T>);
15
9
  }
16
10
 
17
11
  export { StandardRPCHandler as a };
@@ -1,5 +1,5 @@
1
- import { C as Context } from './server.DPWk5pjW.mjs';
2
- import { g as StandardHandleOptions } from './server.DY7OKEoj.mjs';
1
+ import { C as Context } from './server.DD2C4ujN.mjs';
2
+ import { g as StandardHandleOptions } from './server.Dq8xr7PQ.mjs';
3
3
 
4
4
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
5
  context?: T;
@@ -1,8 +1,7 @@
1
1
  import { toHttpPath, StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
2
- import { toArray, intercept, parseEmptyableJSON } from '@orpc/shared';
3
- import '@orpc/standard-server/batch';
4
2
  import { ORPCError, toORPCError } from '@orpc/client';
5
- import { S as StrictGetMethodPlugin } from './server.BW-nUGgA.mjs';
3
+ import { toArray, intercept, parseEmptyableJSON, NullProtoObj } from '@orpc/shared';
4
+ import { flattenHeader } from '@orpc/standard-server';
6
5
  import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.DG7Tamti.mjs';
7
6
 
8
7
  class CompositeStandardHandlerPlugin {
@@ -10,9 +9,9 @@ class CompositeStandardHandlerPlugin {
10
9
  constructor(plugins = []) {
11
10
  this.plugins = [...plugins].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
12
11
  }
13
- init(options) {
12
+ init(options, router) {
14
13
  for (const plugin of this.plugins) {
15
- plugin.init?.(options);
14
+ plugin.init?.(options, router);
16
15
  }
17
16
  }
18
17
  }
@@ -22,7 +21,7 @@ class StandardHandler {
22
21
  this.matcher = matcher;
23
22
  this.codec = codec;
24
23
  const plugins = new CompositeStandardHandlerPlugin(options.plugins);
25
- plugins.init(options);
24
+ plugins.init(options, router);
26
25
  this.interceptors = toArray(options.interceptors);
27
26
  this.clientInterceptors = toArray(options.clientInterceptors);
28
27
  this.rootInterceptors = toArray(options.rootInterceptors);
@@ -61,8 +60,10 @@ class StandardHandler {
61
60
  isDecoding = true;
62
61
  const input = await this.codec.decode(request2, match.params, match.procedure);
63
62
  isDecoding = false;
64
- const lastEventId = Array.isArray(request2.headers["last-event-id"]) ? request2.headers["last-event-id"].at(-1) : request2.headers["last-event-id"];
65
- const output = await client(input, { signal: request2.signal, lastEventId });
63
+ const output = await client(input, {
64
+ signal: request2.signal,
65
+ lastEventId: flattenHeader(request2.headers["last-event-id"])
66
+ });
66
67
  const response = this.codec.encode(output, match.procedure);
67
68
  return {
68
69
  matched: true,
@@ -111,7 +112,7 @@ class StandardRPCCodec {
111
112
  }
112
113
 
113
114
  class StandardRPCMatcher {
114
- tree = {};
115
+ tree = new NullProtoObj();
115
116
  pendingRouters = [];
116
117
  init(router, path = []) {
117
118
  const laziedOptions = traverseContractProcedures({ router, path }, ({ path: path2, contract }) => {
@@ -173,12 +174,7 @@ class StandardRPCMatcher {
173
174
  }
174
175
 
175
176
  class StandardRPCHandler extends StandardHandler {
176
- constructor(router, options) {
177
- options.plugins ??= [];
178
- const strictGetMethodPluginEnabled = options.strictGetMethodPluginEnabled ?? true;
179
- if (strictGetMethodPluginEnabled) {
180
- options.plugins.push(new StrictGetMethodPlugin());
181
- }
177
+ constructor(router, options = {}) {
182
178
  const jsonSerializer = new StandardRPCJsonSerializer(options);
183
179
  const serializer = new StandardRPCSerializer(jsonSerializer);
184
180
  const matcher = new StandardRPCMatcher();
@@ -1,6 +1,6 @@
1
1
  import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
2
  import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
- import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
+ import { MaybeOptionalOptions, Promisable, Interceptor, PromiseWithError, Value } from '@orpc/shared';
4
4
 
5
5
  type Context = Record<PropertyKey, any>;
6
6
  type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
@@ -127,11 +127,11 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
127
127
  * This is helpful for logging and analytics.
128
128
  */
129
129
  path?: readonly string[];
130
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
130
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
131
131
  } & (Record<never, never> extends TInitialContext ? {
132
- context?: Value<TInitialContext, [clientContext: TClientContext]>;
132
+ context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
133
133
  } : {
134
- context: Value<TInitialContext, [clientContext: TClientContext]>;
134
+ context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
135
135
  });
136
136
  /**
137
137
  * Create Server-side client from a procedure.
@@ -1,6 +1,6 @@
1
1
  import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
2
  import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
- import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
+ import { MaybeOptionalOptions, Promisable, Interceptor, PromiseWithError, Value } from '@orpc/shared';
4
4
 
5
5
  type Context = Record<PropertyKey, any>;
6
6
  type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
@@ -127,11 +127,11 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
127
127
  * This is helpful for logging and analytics.
128
128
  */
129
129
  path?: readonly string[];
130
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
130
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
131
131
  } & (Record<never, never> extends TInitialContext ? {
132
- context?: Value<TInitialContext, [clientContext: TClientContext]>;
132
+ context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
133
133
  } : {
134
- context: Value<TInitialContext, [clientContext: TClientContext]>;
134
+ context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
135
135
  });
136
136
  /**
137
137
  * Create Server-side client from a procedure.
@@ -1,7 +1,7 @@
1
1
  function resolveFriendlyStandardHandleOptions(options) {
2
2
  return {
3
3
  ...options,
4
- context: options?.context ?? {}
4
+ context: options.context ?? {}
5
5
  // Context only optional if all fields are optional
6
6
  };
7
7
  }
@@ -1,17 +1,17 @@
1
1
  import { HTTPPath, ORPCError } from '@orpc/client';
2
- import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
3
- import { Interceptor, ThrowableError } from '@orpc/shared';
2
+ import { Meta } from '@orpc/contract';
3
+ import { Interceptor } from '@orpc/shared';
4
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
5
- import { C as Context, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions, R as Router } from './server.DPWk5pjW.mjs';
5
+ import { C as Context, R as Router, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions } from './server.DD2C4ujN.mjs';
6
6
 
7
- interface StandardHandlerPlugin<TContext extends Context> {
7
+ interface StandardHandlerPlugin<T extends Context> {
8
8
  order?: number;
9
- init?(options: StandardHandlerOptions<TContext>): void;
9
+ init?(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
10
10
  }
11
11
  declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
12
12
  protected readonly plugins: TPlugin[];
13
13
  constructor(plugins?: readonly TPlugin[]);
14
- init(options: StandardHandlerOptions<T>): void;
14
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
15
15
  }
16
16
 
17
17
  type StandardParams = Record<string, string>;
@@ -49,16 +49,16 @@ interface StandardHandlerOptions<TContext extends Context> {
49
49
  /**
50
50
  * Interceptors at the request level, helpful when you want catch errors
51
51
  */
52
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
52
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
53
53
  /**
54
54
  * Interceptors at the root level, helpful when you want override the request/response
55
55
  */
56
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
56
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
57
57
  /**
58
58
  *
59
59
  * Interceptors for procedure client.
60
60
  */
61
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
61
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
62
62
  }
63
63
  declare class StandardHandler<T extends Context> {
64
64
  private readonly matcher;
@@ -1,5 +1,5 @@
1
- import { C as Context } from './server.DPWk5pjW.js';
2
- import { g as StandardHandleOptions } from './server.D5fBlF9j.js';
1
+ import { C as Context } from './server.DD2C4ujN.js';
2
+ import { g as StandardHandleOptions } from './server.-ACo36I0.js';
3
3
 
4
4
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
5
  context?: T;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.0.0-next.c788572",
4
+ "version": "0.0.0-next.c854c60",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -38,21 +38,69 @@
38
38
  "types": "./dist/adapters/node/index.d.mts",
39
39
  "import": "./dist/adapters/node/index.mjs",
40
40
  "default": "./dist/adapters/node/index.mjs"
41
+ },
42
+ "./aws-lambda": {
43
+ "types": "./dist/adapters/aws-lambda/index.d.mts",
44
+ "import": "./dist/adapters/aws-lambda/index.mjs",
45
+ "default": "./dist/adapters/aws-lambda/index.mjs"
46
+ },
47
+ "./websocket": {
48
+ "types": "./dist/adapters/websocket/index.d.mts",
49
+ "import": "./dist/adapters/websocket/index.mjs",
50
+ "default": "./dist/adapters/websocket/index.mjs"
51
+ },
52
+ "./crossws": {
53
+ "types": "./dist/adapters/crossws/index.d.mts",
54
+ "import": "./dist/adapters/crossws/index.mjs",
55
+ "default": "./dist/adapters/crossws/index.mjs"
56
+ },
57
+ "./ws": {
58
+ "types": "./dist/adapters/ws/index.d.mts",
59
+ "import": "./dist/adapters/ws/index.mjs",
60
+ "default": "./dist/adapters/ws/index.mjs"
61
+ },
62
+ "./bun-ws": {
63
+ "types": "./dist/adapters/bun-ws/index.d.mts",
64
+ "import": "./dist/adapters/bun-ws/index.mjs",
65
+ "default": "./dist/adapters/bun-ws/index.mjs"
66
+ },
67
+ "./message-port": {
68
+ "types": "./dist/adapters/message-port/index.d.mts",
69
+ "import": "./dist/adapters/message-port/index.mjs",
70
+ "default": "./dist/adapters/message-port/index.mjs"
41
71
  }
42
72
  },
43
73
  "files": [
44
74
  "dist"
45
75
  ],
76
+ "peerDependencies": {
77
+ "crossws": ">=0.3.4",
78
+ "ws": ">=8.18.1"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "crossws": {
82
+ "optional": true
83
+ },
84
+ "ws": {
85
+ "optional": true
86
+ }
87
+ },
46
88
  "dependencies": {
47
- "@orpc/client": "0.0.0-next.c788572",
48
- "@orpc/contract": "0.0.0-next.c788572",
49
- "@orpc/shared": "0.0.0-next.c788572",
50
- "@orpc/standard-server": "0.0.0-next.c788572",
51
- "@orpc/standard-server-fetch": "0.0.0-next.c788572",
52
- "@orpc/standard-server-node": "0.0.0-next.c788572"
89
+ "@orpc/client": "0.0.0-next.c854c60",
90
+ "@orpc/contract": "0.0.0-next.c854c60",
91
+ "@orpc/standard-server": "0.0.0-next.c854c60",
92
+ "@orpc/standard-server-aws-lambda": "0.0.0-next.c854c60",
93
+ "@orpc/shared": "0.0.0-next.c854c60",
94
+ "@orpc/standard-server-fetch": "0.0.0-next.c854c60",
95
+ "@orpc/standard-server-node": "0.0.0-next.c854c60",
96
+ "@orpc/standard-server-peer": "0.0.0-next.c854c60"
53
97
  },
54
98
  "devDependencies": {
55
- "supertest": "^7.1.0"
99
+ "@types/ws": "^8.18.1",
100
+ "crossws": "^0.4.1",
101
+ "next": "^15.3.0",
102
+ "supertest": "^7.1.0",
103
+ "ws": "^8.18.1"
56
104
  },
57
105
  "scripts": {
58
106
  "build": "unbuild",