@orpc/server 0.0.0-next.fe39bf3 → 0.0.0-next.ff5907c

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.
@@ -2,7 +2,7 @@ import {
2
2
  RPCCodec,
3
3
  RPCMatcher,
4
4
  StandardHandler
5
- } from "./chunk-LXOL226G.js";
5
+ } from "./chunk-77FU7QSO.js";
6
6
 
7
7
  // src/adapters/fetch/rpc-handler.ts
8
8
  import { toFetchResponse, toStandardRequest } from "@orpc/server-standard-fetch";
@@ -29,4 +29,4 @@ var RPCHandler = class {
29
29
  export {
30
30
  RPCHandler
31
31
  };
32
- //# sourceMappingURL=chunk-KPT6FDBK.js.map
32
+ //# sourceMappingURL=chunk-47YYO5JS.js.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-MHVECKBC.js";
10
10
  import {
11
11
  CompositePlugin
12
- } from "./chunk-XI6WGCB3.js";
12
+ } from "./chunk-WQNNSBXW.js";
13
13
 
14
14
  // src/adapters/standard/handler.ts
15
15
  import { ORPCError, toORPCError } from "@orpc/client";
@@ -19,14 +19,14 @@ var StandardHandler = class {
19
19
  this.matcher = matcher;
20
20
  this.codec = codec;
21
21
  this.options = options;
22
- this.plugin = new CompositePlugin(options?.plugins);
22
+ this.plugin = new CompositePlugin(options.plugins);
23
23
  this.plugin.init(this.options);
24
24
  this.matcher.init(router);
25
25
  }
26
26
  plugin;
27
27
  handle(request, ...[options]) {
28
28
  return intercept(
29
- this.options.interceptorsRoot ?? [],
29
+ this.options.rootInterceptors ?? [],
30
30
  {
31
31
  request,
32
32
  ...options,
@@ -47,12 +47,11 @@ var StandardHandler = class {
47
47
  if (!match) {
48
48
  return { matched: false, response: void 0 };
49
49
  }
50
- const clientOptions = {
50
+ const client = createProcedureClient(match.procedure, {
51
51
  context: interceptorOptions2.context,
52
- path: match.path
53
- };
54
- this.plugin.beforeCreateProcedureClient(clientOptions, interceptorOptions2);
55
- const client = createProcedureClient(match.procedure, clientOptions);
52
+ path: match.path,
53
+ interceptors: this.options.clientInterceptors
54
+ });
56
55
  isDecoding = true;
57
56
  const input = await this.codec.decode(request, match.params, match.procedure);
58
57
  isDecoding = false;
@@ -179,4 +178,4 @@ export {
179
178
  RPCCodec,
180
179
  RPCMatcher
181
180
  };
182
- //# sourceMappingURL=chunk-LXOL226G.js.map
181
+ //# sourceMappingURL=chunk-77FU7QSO.js.map
@@ -8,11 +8,6 @@ var CompositePlugin = class {
8
8
  plugin.init?.(options);
9
9
  }
10
10
  }
11
- beforeCreateProcedureClient(clientOptions, interceptorOptions) {
12
- for (const plugin of this.plugins) {
13
- plugin.beforeCreateProcedureClient?.(clientOptions, interceptorOptions);
14
- }
15
- }
16
11
  };
17
12
 
18
13
  // src/plugins/cors.ts
@@ -30,8 +25,8 @@ var CORSPlugin = class {
30
25
  };
31
26
  }
32
27
  init(options) {
33
- options.interceptorsRoot ??= [];
34
- options.interceptorsRoot.unshift(async (interceptorOptions) => {
28
+ options.rootInterceptors ??= [];
29
+ options.rootInterceptors.unshift(async (interceptorOptions) => {
35
30
  if (interceptorOptions.request.method === "OPTIONS") {
36
31
  const resHeaders = {};
37
32
  if (this.options.maxAge !== void 0) {
@@ -57,7 +52,7 @@ var CORSPlugin = class {
57
52
  }
58
53
  return interceptorOptions.next();
59
54
  });
60
- options.interceptorsRoot.unshift(async (interceptorOptions) => {
55
+ options.rootInterceptors.unshift(async (interceptorOptions) => {
61
56
  const result = await interceptorOptions.next();
62
57
  if (!result.matched) {
63
58
  return result;
@@ -94,8 +89,8 @@ var CORSPlugin = class {
94
89
  // src/plugins/response-headers.ts
95
90
  var ResponseHeadersPlugin = class {
96
91
  init(options) {
97
- options.interceptorsRoot ??= [];
98
- options.interceptorsRoot.push(async (interceptorOptions) => {
92
+ options.rootInterceptors ??= [];
93
+ options.rootInterceptors.push(async (interceptorOptions) => {
99
94
  const headers = new Headers();
100
95
  interceptorOptions.context.resHeaders = headers;
101
96
  const result = await interceptorOptions.next();
@@ -122,4 +117,4 @@ export {
122
117
  CORSPlugin,
123
118
  ResponseHeadersPlugin
124
119
  };
125
- //# sourceMappingURL=chunk-XI6WGCB3.js.map
120
+ //# sourceMappingURL=chunk-WQNNSBXW.js.map
package/dist/fetch.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  RPCHandler
3
- } from "./chunk-KPT6FDBK.js";
4
- import "./chunk-LXOL226G.js";
3
+ } from "./chunk-47YYO5JS.js";
4
+ import "./chunk-77FU7QSO.js";
5
5
  import "./chunk-MHVECKBC.js";
6
- import "./chunk-XI6WGCB3.js";
6
+ import "./chunk-WQNNSBXW.js";
7
7
  export {
8
8
  RPCHandler
9
9
  };
package/dist/hono.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  RPCHandler
3
- } from "./chunk-KPT6FDBK.js";
4
- import "./chunk-LXOL226G.js";
3
+ } from "./chunk-47YYO5JS.js";
4
+ import "./chunk-77FU7QSO.js";
5
5
  import "./chunk-MHVECKBC.js";
6
- import "./chunk-XI6WGCB3.js";
6
+ import "./chunk-WQNNSBXW.js";
7
7
 
8
8
  // src/adapters/hono/middleware.ts
9
9
  import { value } from "@orpc/shared";
package/dist/next.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  RPCHandler
3
- } from "./chunk-KPT6FDBK.js";
4
- import "./chunk-LXOL226G.js";
3
+ } from "./chunk-47YYO5JS.js";
4
+ import "./chunk-77FU7QSO.js";
5
5
  import "./chunk-MHVECKBC.js";
6
- import "./chunk-XI6WGCB3.js";
6
+ import "./chunk-WQNNSBXW.js";
7
7
 
8
8
  // src/adapters/next/serve.ts
9
9
  import { value } from "@orpc/shared";
package/dist/node.js CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  RPCCodec,
3
3
  RPCMatcher,
4
4
  StandardHandler
5
- } from "./chunk-LXOL226G.js";
5
+ } from "./chunk-77FU7QSO.js";
6
6
  import "./chunk-MHVECKBC.js";
7
- import "./chunk-XI6WGCB3.js";
7
+ import "./chunk-WQNNSBXW.js";
8
8
 
9
9
  // src/adapters/node/rpc-handler.ts
10
10
  import { sendStandardResponse, toStandardRequest } from "@orpc/server-standard-node";
package/dist/plugins.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  CORSPlugin,
3
3
  CompositePlugin,
4
4
  ResponseHeadersPlugin
5
- } from "./chunk-XI6WGCB3.js";
5
+ } from "./chunk-WQNNSBXW.js";
6
6
  export {
7
7
  CORSPlugin,
8
8
  CompositePlugin,
@@ -1,9 +1,9 @@
1
- import type { ErrorMap, HTTPPath, Meta, Schema } from '@orpc/contract';
1
+ import type { ErrorFromErrorMap, HTTPPath, Meta, Schema, SchemaOutput } from '@orpc/contract';
2
2
  import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
3
3
  import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
4
4
  import type { Context } from '../../context';
5
5
  import type { Plugin } from '../../plugins';
6
- import type { CreateProcedureClientOptions } from '../../procedure-client';
6
+ import type { ProcedureClientInterceptorOptions } from '../../procedure-client';
7
7
  import type { Router } from '../../router';
8
8
  import type { StandardCodec, StandardMatcher } from './types';
9
9
  export type StandardHandleOptions<T extends Context> = {
@@ -26,9 +26,6 @@ export type StandardHandleResult = {
26
26
  export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
27
27
  request: StandardRequest;
28
28
  };
29
- export type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, Record<never, never>> & {
30
- context: TContext;
31
- };
32
29
  export interface StandardHandlerOptions<TContext extends Context> {
33
30
  plugins?: Plugin<TContext>[];
34
31
  /**
@@ -36,9 +33,14 @@ export interface StandardHandlerOptions<TContext extends Context> {
36
33
  */
37
34
  interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
38
35
  /**
39
- * Interceptors at the root level, helpful when you want override the response
36
+ * Interceptors at the root level, helpful when you want override the request/response
37
+ */
38
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
39
+ /**
40
+ *
41
+ * Interceptors for procedure client.
40
42
  */
41
- interceptorsRoot?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
43
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Schema, Record<never, never>, Meta>, SchemaOutput<Schema, unknown>, ErrorFromErrorMap<Record<never, never>>>[];
42
44
  }
43
45
  export declare class StandardHandler<T extends Context> {
44
46
  private readonly matcher;
@@ -1,13 +1,11 @@
1
- import type { StandardHandlerInterceptorOptions, StandardHandlerOptions, WellCreateProcedureClientOptions } from '../adapters/standard';
1
+ import type { StandardHandlerOptions } from '../adapters/standard';
2
2
  import type { Context } from '../context';
3
3
  export interface Plugin<TContext extends Context> {
4
4
  init?(options: StandardHandlerOptions<TContext>): void;
5
- beforeCreateProcedureClient?(clientOptions: WellCreateProcedureClientOptions<TContext>, interceptorOptions: StandardHandlerInterceptorOptions<TContext>): void;
6
5
  }
7
6
  export declare class CompositePlugin<TContext extends Context> implements Plugin<TContext> {
8
7
  private readonly plugins;
9
8
  constructor(plugins?: Plugin<TContext>[]);
10
9
  init(options: StandardHandlerOptions<TContext>): void;
11
- beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>, interceptorOptions: StandardHandlerInterceptorOptions<TContext>): void;
12
10
  }
13
11
  //# sourceMappingURL=base.d.ts.map
package/dist/standard.js CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  RPCCodec,
3
3
  RPCMatcher,
4
4
  StandardHandler
5
- } from "./chunk-LXOL226G.js";
5
+ } from "./chunk-77FU7QSO.js";
6
6
  import "./chunk-MHVECKBC.js";
7
- import "./chunk-XI6WGCB3.js";
7
+ import "./chunk-WQNNSBXW.js";
8
8
  export {
9
9
  RPCCodec,
10
10
  RPCMatcher,
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.fe39bf3",
4
+ "version": "0.0.0-next.ff5907c",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -66,9 +66,9 @@
66
66
  "@orpc/server-standard": "^0.4.0",
67
67
  "@orpc/server-standard-fetch": "^0.4.0",
68
68
  "@orpc/server-standard-node": "^0.4.0",
69
- "@orpc/client": "0.0.0-next.fe39bf3",
70
- "@orpc/shared": "0.0.0-next.fe39bf3",
71
- "@orpc/contract": "0.0.0-next.fe39bf3"
69
+ "@orpc/client": "0.0.0-next.ff5907c",
70
+ "@orpc/shared": "0.0.0-next.ff5907c",
71
+ "@orpc/contract": "0.0.0-next.ff5907c"
72
72
  },
73
73
  "devDependencies": {
74
74
  "light-my-request": "^6.5.1"