@orpc/server 0.0.0-next.9125edb → 0.0.0-next.92faaf9

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.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ <div align="center">
2
+ <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 />
3
+ </div>
4
+
5
+ <h1></h1>
6
+
7
+ <div align="center">
8
+ <a href="https://codecov.io/gh/unnoq/orpc">
9
+ <img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@orpc/server">
12
+ <img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fserver?logo=npm" />
13
+ </a>
14
+ <a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
15
+ <img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
16
+ </a>
17
+ <a href="https://discord.gg/TXEbwRBvQn">
18
+ <img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
19
+ </a>
20
+ </div>
21
+
22
+ <h3 align="center">Typesafe APIs Made Simple 🪄</h3>
23
+
24
+ **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards, ensuring a smooth and enjoyable developer experience.
25
+
26
+ ---
27
+
28
+ ## Highlights
29
+
30
+ - **End-to-End Type Safety 🔒**: Ensure complete type safety from inputs to outputs and errors, bridging server and client seamlessly.
31
+ - **First-Class OpenAPI 📄**: Adheres to the OpenAPI standard out of the box, ensuring seamless integration and comprehensive API documentation.
32
+ - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
+ - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
+ - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
+ - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
36
+ - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
+ - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
+ - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
39
+ - **Native Types 📦**: Enjoy built-in support for Date, File, Blob, BigInt, URL and more with no extra setup.
40
+ - **Lazy Router ⏱️**: Improve cold start times with our lazy routing feature.
41
+ - **SSE & Streaming 📡**: Provides SSE and streaming features – perfect for real-time notifications and AI-powered streaming responses.
42
+ - **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
43
+ - **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
44
+ - **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
45
+ - **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
46
+
47
+ ## Documentation
48
+
49
+ You can find the full documentation [here](https://orpc.unnoq.com).
50
+
51
+ ## Packages
52
+
53
+ - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
54
+ - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
55
+ - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
56
+ - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
57
+ - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
58
+ - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
+ - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
61
+
62
+ ## `@orpc/server`
63
+
64
+ Build your API or implement API contract. Read the [documentation](https://orpc.unnoq.com/docs/getting-started) for more information.
65
+
66
+ ```ts
67
+ import type { IncomingHttpHeaders } from 'node:http'
68
+ import { ORPCError, os } from '@orpc/server'
69
+ import { z } from 'zod'
70
+
71
+ const PlanetSchema = z.object({
72
+ id: z.number().int().min(1),
73
+ name: z.string(),
74
+ description: z.string().optional(),
75
+ })
76
+
77
+ export const listPlanet = os
78
+ .input(
79
+ z.object({
80
+ limit: z.number().int().min(1).max(100).optional(),
81
+ cursor: z.number().int().min(0).default(0),
82
+ }),
83
+ )
84
+ .handler(async ({ input }) => {
85
+ // your list code here
86
+ return [{ id: 1, name: 'name' }]
87
+ })
88
+
89
+ export const findPlanet = os
90
+ .input(PlanetSchema.pick({ id: true }))
91
+ .handler(async ({ input }) => {
92
+ // your find code here
93
+ return { id: 1, name: 'name' }
94
+ })
95
+
96
+ export const createPlanet = os
97
+ .$context<{ headers: IncomingHttpHeaders }>()
98
+ .use(({ context, next }) => {
99
+ const user = parseJWT(context.headers.authorization?.split(' ')[1])
100
+
101
+ if (user) {
102
+ return next({ context: { user } })
103
+ }
104
+
105
+ throw new ORPCError('UNAUTHORIZED')
106
+ })
107
+ .input(PlanetSchema.omit({ id: true }))
108
+ .handler(async ({ input, context }) => {
109
+ // your create code here
110
+ return { id: 1, name: 'name' }
111
+ })
112
+
113
+ export const router = { planet: { list: listPlanet, find: findPlanet, create: createPlanet } }
114
+ ```
115
+
116
+ ## License
117
+
118
+ Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
@@ -2,10 +2,10 @@ import {
2
2
  RPCCodec,
3
3
  RPCMatcher,
4
4
  StandardHandler
5
- } from "./chunk-GBL3M2PB.js";
5
+ } from "./chunk-NTHCS5CK.js";
6
6
 
7
7
  // src/adapters/fetch/rpc-handler.ts
8
- import { toFetchResponse, toStandardRequest } from "@orpc/server-standard-fetch";
8
+ import { toFetchResponse, toStandardRequest } from "@orpc/standard-server-fetch";
9
9
  var RPCHandler = class {
10
10
  standardHandler;
11
11
  constructor(router, options) {
@@ -29,4 +29,4 @@ var RPCHandler = class {
29
29
  export {
30
30
  RPCHandler
31
31
  };
32
- //# sourceMappingURL=chunk-GBEB77SU.js.map
32
+ //# sourceMappingURL=chunk-MBMXGUNI.js.map
@@ -62,8 +62,50 @@ function middlewareOutputFn(output) {
62
62
  }
63
63
 
64
64
  // src/procedure-client.ts
65
- import { createORPCErrorConstructorMap, ORPCError, validateORPCError, ValidationError } from "@orpc/contract";
65
+ import { ORPCError as ORPCError2 } from "@orpc/client";
66
+ import { ValidationError } from "@orpc/contract";
66
67
  import { intercept, toError, value } from "@orpc/shared";
68
+
69
+ // src/error.ts
70
+ import { fallbackORPCErrorStatus, ORPCError } from "@orpc/client";
71
+ function createORPCErrorConstructorMap(errors) {
72
+ const proxy = new Proxy(errors, {
73
+ get(target, code) {
74
+ if (typeof code !== "string") {
75
+ return Reflect.get(target, code);
76
+ }
77
+ const item = (...[options]) => {
78
+ const config = errors[code];
79
+ return new ORPCError(code, {
80
+ defined: Boolean(config),
81
+ status: config?.status,
82
+ message: options?.message ?? config?.message,
83
+ data: options?.data,
84
+ cause: options?.cause
85
+ });
86
+ };
87
+ return item;
88
+ }
89
+ });
90
+ return proxy;
91
+ }
92
+ async function validateORPCError(map, error) {
93
+ const { code, status, message, data, cause, defined } = error;
94
+ const config = map?.[error.code];
95
+ if (!config || fallbackORPCErrorStatus(error.code, config.status) !== error.status) {
96
+ return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
97
+ }
98
+ if (!config.data) {
99
+ return defined ? error : new ORPCError(code, { defined: true, status, message, data, cause });
100
+ }
101
+ const validated = await config.data["~standard"].validate(error.data);
102
+ if (validated.issues) {
103
+ return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
104
+ }
105
+ return new ORPCError(code, { defined: true, status, message, data: validated.value, cause });
106
+ }
107
+
108
+ // src/procedure-client.ts
67
109
  function createProcedureClient(lazyableProcedure, ...[options]) {
68
110
  return async (...[input, callerOptions]) => {
69
111
  const path = options?.path ?? [];
@@ -81,12 +123,13 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
81
123
  errors,
82
124
  path,
83
125
  procedure,
84
- signal: callerOptions?.signal
126
+ signal: callerOptions?.signal,
127
+ lastEventId: callerOptions?.lastEventId
85
128
  },
86
129
  (interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
87
130
  );
88
131
  } catch (e) {
89
- if (!(e instanceof ORPCError)) {
132
+ if (!(e instanceof ORPCError2)) {
90
133
  throw toError(e);
91
134
  }
92
135
  const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
@@ -101,7 +144,7 @@ async function validateInput(procedure, input) {
101
144
  }
102
145
  const result = await schema["~standard"].validate(input);
103
146
  if (result.issues) {
104
- throw new ORPCError("BAD_REQUEST", {
147
+ throw new ORPCError2("BAD_REQUEST", {
105
148
  message: "Input validation failed",
106
149
  data: {
107
150
  issues: result.issues
@@ -118,7 +161,7 @@ async function validateOutput(procedure, output) {
118
161
  }
119
162
  const result = await schema["~standard"].validate(output);
120
163
  if (result.issues) {
121
- throw new ORPCError("INTERNAL_SERVER_ERROR", {
164
+ throw new ORPCError2("INTERNAL_SERVER_ERROR", {
122
165
  message: "Output validation failed",
123
166
  cause: new ValidationError({ message: "Output validation failed", issues: result.issues })
124
167
  });
@@ -375,4 +418,4 @@ export {
375
418
  convertPathToHttpPath,
376
419
  createContractedProcedure
377
420
  };
378
- //# sourceMappingURL=chunk-XP6YRLY2.js.map
421
+ //# sourceMappingURL=chunk-MHVECKBC.js.map
@@ -6,27 +6,27 @@ import {
6
6
  getRouterChild,
7
7
  isProcedure,
8
8
  unlazy
9
- } from "./chunk-XP6YRLY2.js";
9
+ } from "./chunk-MHVECKBC.js";
10
10
  import {
11
11
  CompositePlugin
12
- } from "./chunk-XI6WGCB3.js";
12
+ } from "./chunk-TXHKQO7N.js";
13
13
 
14
14
  // src/adapters/standard/handler.ts
15
- import { ORPCError, toORPCError } from "@orpc/contract";
15
+ import { ORPCError, toORPCError } from "@orpc/client";
16
16
  import { intercept, trim } from "@orpc/shared";
17
17
  var StandardHandler = class {
18
18
  constructor(router, matcher, codec, options = {}) {
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,16 +47,16 @@ 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;
59
- const output = await client(input, { signal: request.signal });
58
+ const lastEventId = Array.isArray(request.headers["last-event-id"]) ? request.headers["last-event-id"].at(-1) : request.headers["last-event-id"];
59
+ const output = await client(input, { signal: request.signal, lastEventId });
60
60
  const response = this.codec.encode(output, match.procedure);
61
61
  return {
62
62
  matched: true,
@@ -80,157 +80,16 @@ var StandardHandler = class {
80
80
  }
81
81
  };
82
82
 
83
- // src/adapters/standard/rpc-serializer.ts
84
- import { findDeepMatches, isObject, set } from "@orpc/shared";
85
- var RPCSerializer = class {
86
- serialize(data) {
87
- if (data === void 0) {
88
- return void 0;
89
- }
90
- if (data instanceof Blob) {
91
- return data;
92
- }
93
- const serializedJSON = serializeRPCJson(data);
94
- const { maps, values: blobs } = findDeepMatches((v) => v instanceof Blob, serializedJSON.json);
95
- if (blobs.length === 0) {
96
- return serializedJSON;
97
- }
98
- const form = new FormData();
99
- form.set("data", JSON.stringify(serializedJSON));
100
- form.set("maps", JSON.stringify(maps));
101
- for (const i in blobs) {
102
- form.set(i, blobs[i]);
103
- }
104
- return form;
105
- }
106
- deserialize(serialized) {
107
- if (serialized === void 0) {
108
- return void 0;
109
- }
110
- if (serialized instanceof Blob) {
111
- return serialized;
112
- }
113
- if (!(serialized instanceof FormData)) {
114
- return deserializeRPCJson(serialized);
115
- }
116
- const data = JSON.parse(serialized.get("data"));
117
- const maps = JSON.parse(serialized.get("maps"));
118
- for (const i in maps) {
119
- data.json = set(data.json, maps[i], serialized.get(i));
120
- }
121
- return deserializeRPCJson(data);
122
- }
123
- };
124
- function serializeRPCJson(value, segments = [], meta = []) {
125
- if (typeof value === "bigint") {
126
- meta.push(["bigint", segments]);
127
- return { json: value.toString(), meta };
128
- }
129
- if (value instanceof Date) {
130
- meta.push(["date", segments]);
131
- const data = Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
132
- return { json: data, meta };
133
- }
134
- if (Number.isNaN(value)) {
135
- meta.push(["nan", segments]);
136
- return { json: "NaN", meta };
137
- }
138
- if (value instanceof RegExp) {
139
- meta.push(["regexp", segments]);
140
- return { json: value.toString(), meta };
141
- }
142
- if (value instanceof URL) {
143
- meta.push(["url", segments]);
144
- return { json: value.toString(), meta };
145
- }
146
- if (isObject(value)) {
147
- const json = {};
148
- for (const k in value) {
149
- json[k] = serializeRPCJson(value[k], [...segments, k], meta).json;
150
- }
151
- return { json, meta };
152
- }
153
- if (Array.isArray(value)) {
154
- const json = value.map((v, i) => {
155
- if (v === void 0) {
156
- meta.push(["undefined", [...segments, i]]);
157
- return null;
158
- }
159
- return serializeRPCJson(v, [...segments, i], meta).json;
160
- });
161
- return { json, meta };
162
- }
163
- if (value instanceof Set) {
164
- const result = serializeRPCJson(Array.from(value), segments, meta);
165
- meta.push(["set", segments]);
166
- return result;
167
- }
168
- if (value instanceof Map) {
169
- const result = serializeRPCJson(Array.from(value.entries()), segments, meta);
170
- meta.push(["map", segments]);
171
- return result;
172
- }
173
- return { json: value, meta };
174
- }
175
- function deserializeRPCJson({
176
- json,
177
- meta
178
- }) {
179
- if (meta.length === 0) {
180
- return json;
181
- }
182
- const ref = { data: json };
183
- for (const [type, segments] of meta) {
184
- let currentRef = ref;
185
- let preSegment = "data";
186
- for (let i = 0; i < segments.length; i++) {
187
- currentRef = currentRef[preSegment];
188
- preSegment = segments[i];
189
- }
190
- switch (type) {
191
- case "nan":
192
- currentRef[preSegment] = Number.NaN;
193
- break;
194
- case "bigint":
195
- currentRef[preSegment] = BigInt(currentRef[preSegment]);
196
- break;
197
- case "date":
198
- currentRef[preSegment] = new Date(currentRef[preSegment]);
199
- break;
200
- case "regexp": {
201
- const [, pattern, flags] = currentRef[preSegment].match(/^\/(.*)\/([a-z]*)$/);
202
- currentRef[preSegment] = new RegExp(pattern, flags);
203
- break;
204
- }
205
- case "url":
206
- currentRef[preSegment] = new URL(currentRef[preSegment]);
207
- break;
208
- case "undefined":
209
- currentRef[preSegment] = void 0;
210
- break;
211
- case "map":
212
- currentRef[preSegment] = new Map(currentRef[preSegment]);
213
- break;
214
- case "set":
215
- currentRef[preSegment] = new Set(currentRef[preSegment]);
216
- break;
217
- /* v8 ignore next 3 */
218
- default: {
219
- const _expected = type;
220
- }
221
- }
222
- }
223
- return ref.data;
224
- }
225
-
226
83
  // src/adapters/standard/rpc-codec.ts
84
+ import { RPCSerializer } from "@orpc/client/rpc";
85
+ import { parseEmptyableJSON } from "@orpc/shared";
227
86
  var RPCCodec = class {
228
87
  serializer;
229
88
  constructor(options = {}) {
230
89
  this.serializer = options.serializer ?? new RPCSerializer();
231
90
  }
232
91
  async decode(request, _params, _procedure) {
233
- const serialized = request.method === "GET" ? JSON.parse(request.url.searchParams.getAll("data").at(-1)) : await request.body();
92
+ const serialized = request.method === "GET" ? parseEmptyableJSON(request.url.searchParams.getAll("data").at(-1)) : await request.body();
234
93
  return this.serializer.deserialize(serialized);
235
94
  }
236
95
  encode(output, _procedure) {
@@ -317,9 +176,7 @@ var RPCMatcher = class {
317
176
 
318
177
  export {
319
178
  StandardHandler,
320
- RPCSerializer,
321
- serializeRPCJson,
322
179
  RPCCodec,
323
180
  RPCMatcher
324
181
  };
325
- //# sourceMappingURL=chunk-GBL3M2PB.js.map
182
+ //# sourceMappingURL=chunk-NTHCS5CK.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-TXHKQO7N.js.map
package/dist/fetch.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  RPCHandler
3
- } from "./chunk-GBEB77SU.js";
4
- import "./chunk-GBL3M2PB.js";
5
- import "./chunk-XP6YRLY2.js";
6
- import "./chunk-XI6WGCB3.js";
3
+ } from "./chunk-MBMXGUNI.js";
4
+ import "./chunk-NTHCS5CK.js";
5
+ import "./chunk-MHVECKBC.js";
6
+ import "./chunk-TXHKQO7N.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-GBEB77SU.js";
4
- import "./chunk-GBL3M2PB.js";
5
- import "./chunk-XP6YRLY2.js";
6
- import "./chunk-XI6WGCB3.js";
3
+ } from "./chunk-MBMXGUNI.js";
4
+ import "./chunk-NTHCS5CK.js";
5
+ import "./chunk-MHVECKBC.js";
6
+ import "./chunk-TXHKQO7N.js";
7
7
 
8
8
  // src/adapters/hono/middleware.ts
9
9
  import { value } from "@orpc/shared";
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  middlewareOutputFn,
22
22
  setRouterContract,
23
23
  unlazy
24
- } from "./chunk-XP6YRLY2.js";
24
+ } from "./chunk-MHVECKBC.js";
25
25
 
26
26
  // src/builder.ts
27
27
  import { mergeErrorMap as mergeErrorMap2, mergeMeta as mergeMeta2, mergePrefix, mergeRoute as mergeRoute2, mergeTags } from "@orpc/contract";
@@ -50,10 +50,14 @@ function decorateMiddleware(middleware) {
50
50
  decorated.concat = (concatMiddleware, mapInput) => {
51
51
  const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
52
52
  const concatted = decorateMiddleware((options, input, output, ...rest) => {
53
- const next = async (...[nextOptions]) => {
54
- return mapped({ ...options, context: { ...nextOptions?.context, ...options.context } }, input, output, ...rest);
55
- };
56
- const merged = middleware({ ...options, next }, input, output, ...rest);
53
+ const merged = middleware({
54
+ ...options,
55
+ next: (...[nextOptions1]) => mapped({
56
+ ...options,
57
+ context: { ...options.context, ...nextOptions1?.context },
58
+ next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
59
+ }, input, output, ...rest)
60
+ }, input, output, ...rest);
57
61
  return merged;
58
62
  });
59
63
  return concatted;
@@ -357,8 +361,10 @@ function createRouterClient(router, ...rest) {
357
361
  }
358
362
 
359
363
  // src/index.ts
360
- import { isDefinedError, ORPCError, safe, type, ValidationError } from "@orpc/contract";
364
+ import { isDefinedError, ORPCError, safe } from "@orpc/client";
365
+ import { eventIterator, type, ValidationError } from "@orpc/contract";
361
366
  import { onError, onFinish, onStart, onSuccess } from "@orpc/shared";
367
+ import { getEventMeta, withEventMeta } from "@orpc/standard-server";
362
368
  export {
363
369
  Builder,
364
370
  DecoratedProcedure,
@@ -378,8 +384,10 @@ export {
378
384
  deepSetLazyRouterPrefix,
379
385
  eachAllContractProcedure,
380
386
  eachContractProcedure,
387
+ eventIterator,
381
388
  fallbackConfig,
382
389
  flatLazy,
390
+ getEventMeta,
383
391
  getLazyRouterPrefix,
384
392
  getRouterChild,
385
393
  getRouterContract,
@@ -399,6 +407,7 @@ export {
399
407
  safe,
400
408
  setRouterContract,
401
409
  type,
402
- unlazy
410
+ unlazy,
411
+ withEventMeta
403
412
  };
404
413
  //# sourceMappingURL=index.js.map
package/dist/next.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  RPCHandler
3
- } from "./chunk-GBEB77SU.js";
4
- import "./chunk-GBL3M2PB.js";
5
- import "./chunk-XP6YRLY2.js";
6
- import "./chunk-XI6WGCB3.js";
3
+ } from "./chunk-MBMXGUNI.js";
4
+ import "./chunk-NTHCS5CK.js";
5
+ import "./chunk-MHVECKBC.js";
6
+ import "./chunk-TXHKQO7N.js";
7
7
 
8
8
  // src/adapters/next/serve.ts
9
9
  import { value } from "@orpc/shared";
package/dist/node.js CHANGED
@@ -2,12 +2,12 @@ import {
2
2
  RPCCodec,
3
3
  RPCMatcher,
4
4
  StandardHandler
5
- } from "./chunk-GBL3M2PB.js";
6
- import "./chunk-XP6YRLY2.js";
7
- import "./chunk-XI6WGCB3.js";
5
+ } from "./chunk-NTHCS5CK.js";
6
+ import "./chunk-MHVECKBC.js";
7
+ import "./chunk-TXHKQO7N.js";
8
8
 
9
9
  // src/adapters/node/rpc-handler.ts
10
- import { sendStandardResponse, toStandardRequest } from "@orpc/server-standard-node";
10
+ import { sendStandardResponse, toStandardRequest } from "@orpc/standard-server-node";
11
11
  var RPCHandler = class {
12
12
  standardHandler;
13
13
  constructor(router, options) {
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-TXHKQO7N.js";
6
6
  export {
7
7
  CORSPlugin,
8
8
  CompositePlugin,
@@ -1,9 +1,9 @@
1
- import type { ErrorMap, HTTPPath, Meta, Schema } from '@orpc/contract';
2
- import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
1
+ import type { ErrorFromErrorMap, HTTPPath, Meta, Schema, SchemaOutput } from '@orpc/contract';
3
2
  import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
+ import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
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;
@@ -2,6 +2,5 @@ export * from './handler';
2
2
  export * from './rpc-codec';
3
3
  export * from './rpc-handler';
4
4
  export * from './rpc-matcher';
5
- export * from './rpc-serializer';
6
5
  export * from './types';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,8 @@
1
- import type { ORPCError } from '@orpc/contract';
2
- import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
1
+ import type { ORPCError } from '@orpc/client';
2
+ import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
3
3
  import type { AnyProcedure } from '../../procedure';
4
4
  import type { StandardCodec, StandardParams } from './types';
5
- import { RPCSerializer } from './rpc-serializer';
5
+ import { RPCSerializer } from '@orpc/client/rpc';
6
6
  export interface StandardCodecOptions {
7
7
  serializer?: RPCSerializer;
8
8
  }
@@ -1,5 +1,6 @@
1
- import type { HTTPPath, ORPCError } from '@orpc/contract';
2
- import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
1
+ import type { ORPCError } from '@orpc/client';
2
+ import type { HTTPPath } from '@orpc/contract';
3
+ import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
3
4
  import type { AnyProcedure } from '../../procedure';
4
5
  import type { AnyRouter } from '../../router';
5
6
  export type StandardParams = Record<string, string>;
@@ -1,6 +1,7 @@
1
- import type { ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
1
+ import type { ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
2
  import type { BuilderDef } from './builder';
3
3
  import type { ConflictContextGuard, Context, MergedContext } from './context';
4
+ import type { ORPCErrorConstructorMap } from './error';
4
5
  import type { FlattenLazy } from './lazy-utils';
5
6
  import type { MapInputMiddleware, Middleware } from './middleware';
6
7
  import type { ProcedureHandler } from './procedure';
@@ -1,6 +1,7 @@
1
- import type { ContractProcedureDef, ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
1
+ import type { ContractProcedureDef, ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
2
  import type { BuilderWithMiddlewares, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithOutput, RouterBuilder } from './builder-variants';
3
3
  import type { ConflictContextGuard, Context, MergedContext } from './context';
4
+ import type { ORPCErrorConstructorMap } from './error';
4
5
  import type { FlattenLazy } from './lazy-utils';
5
6
  import type { AnyMiddleware, MapInputMiddleware, Middleware } from './middleware';
6
7
  import type { DecoratedMiddleware } from './middleware-decorated';
@@ -1,6 +1,5 @@
1
1
  import type { IsNever } from '@orpc/shared';
2
2
  export type Context = Record<string, any>;
3
- export type TypeInitialContext<T extends Context> = (type: T) => unknown;
4
3
  export type MergedContext<T extends Context, U extends Context> = T & U;
5
4
  export declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
6
5
  export type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
@@ -0,0 +1,12 @@
1
+ import type { ORPCErrorCode, ORPCErrorOptions } from '@orpc/client';
2
+ import type { ErrorMap, ErrorMapItem, SchemaInput } from '@orpc/contract';
3
+ import type { MaybeOptionalOptions } from '@orpc/shared';
4
+ import { ORPCError } from '@orpc/client';
5
+ export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
6
+ export type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
7
+ export type ORPCErrorConstructorMap<T extends ErrorMap> = {
8
+ [K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, SchemaInput<UInputSchema>> : never : never;
9
+ };
10
+ export declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
11
+ export declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
12
+ //# sourceMappingURL=error.d.ts.map
@@ -1,7 +1,9 @@
1
- import type { ClientContext, ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
1
+ import type { ClientContext, ClientRest } from '@orpc/client';
2
+ import type { ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
3
  import type { MaybeOptionalOptions } from '@orpc/shared';
3
4
  import type { BuilderDef } from './builder';
4
5
  import type { ConflictContextGuard, Context, MergedContext } from './context';
6
+ import type { ORPCErrorConstructorMap } from './error';
5
7
  import type { MapInputMiddleware, Middleware } from './middleware';
6
8
  import type { Procedure, ProcedureHandler } from './procedure';
7
9
  import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
@@ -1,5 +1,6 @@
1
- import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta, ORPCErrorConstructorMap } from '@orpc/contract';
1
+ import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta } from '@orpc/contract';
2
2
  import type { ConflictContextGuard, Context, MergedContext } from './context';
3
+ import type { ORPCErrorConstructorMap } from './error';
3
4
  import type { ProcedureImplementer } from './implementer-procedure';
4
5
  import type { FlattenLazy } from './lazy-utils';
5
6
  import type { Middleware } from './middleware';
@@ -1,5 +1,6 @@
1
- import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta, ORPCErrorConstructorMap } from '@orpc/contract';
1
+ import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta } from '@orpc/contract';
2
2
  import type { ConflictContextGuard, Context, MergedContext } from './context';
3
+ import type { ORPCErrorConstructorMap } from './error';
3
4
  import type { ProcedureImplementer } from './implementer-procedure';
4
5
  import type { ImplementerInternalWithMiddlewares } from './implementer-variants';
5
6
  import type { AnyMiddleware, Middleware } from './middleware';
@@ -18,6 +18,8 @@ export * from './router';
18
18
  export * from './router-accessible-lazy';
19
19
  export * from './router-client';
20
20
  export * from './utils';
21
- export { isDefinedError, ORPCError, safe, type, ValidationError } from '@orpc/contract';
21
+ export { isDefinedError, ORPCError, safe } from '@orpc/client';
22
+ export { eventIterator, type, ValidationError } from '@orpc/contract';
22
23
  export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
24
+ export { getEventMeta, withEventMeta } from '@orpc/standard-server';
23
25
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
- import type { Meta, ORPCErrorConstructorMap } from '@orpc/contract';
1
+ import type { Meta } from '@orpc/contract';
2
2
  import type { Context, MergedContext } from './context';
3
+ import type { ORPCErrorConstructorMap } from './error';
3
4
  import type { MapInputMiddleware, Middleware } from './middleware';
4
5
  export interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta> {
5
6
  concat<UOutContext extends Context, UInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>;
@@ -1,6 +1,7 @@
1
- import type { ErrorMap, Meta, ORPCErrorConstructorMap, Schema } from '@orpc/contract';
1
+ import type { ErrorMap, Meta, Schema } from '@orpc/contract';
2
2
  import type { MaybeOptionalOptions, Promisable } from '@orpc/shared';
3
3
  import type { Context } from './context';
4
+ import type { ORPCErrorConstructorMap } from './error';
4
5
  import type { Procedure } from './procedure';
5
6
  export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
6
7
  output: TOutput;
@@ -22,6 +23,7 @@ export interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorCo
22
23
  path: string[];
23
24
  procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
24
25
  signal?: AbortSignal;
26
+ lastEventId: string | undefined;
25
27
  next: MiddlewareNextFn<TInContext, TOutput>;
26
28
  errors: TErrorConstructorMap;
27
29
  }
@@ -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
@@ -1,8 +1,10 @@
1
- import type { Client, ClientContext, ErrorFromErrorMap, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
1
+ import type { Client, ClientContext } from '@orpc/client';
2
2
  import type { Interceptor, MaybeOptionalOptions, Value } from '@orpc/shared';
3
3
  import type { Context } from './context';
4
4
  import type { Lazyable } from './lazy';
5
5
  import type { Procedure } from './procedure';
6
+ import { type ErrorFromErrorMap, type ErrorMap, type Meta, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
7
+ import { type ORPCErrorConstructorMap } from './error';
6
8
  export type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
7
9
  export interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
8
10
  context: TInitialContext;
@@ -11,6 +13,7 @@ export interface ProcedureClientInterceptorOptions<TInitialContext extends Conte
11
13
  path: string[];
12
14
  procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
13
15
  signal?: AbortSignal;
16
+ lastEventId: string | undefined;
14
17
  }
15
18
  /**
16
19
  * Options for creating a procedure caller with comprehensive type safety
@@ -1,6 +1,8 @@
1
- import type { ClientContext, ClientRest, ErrorMap, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
1
+ import type { ClientContext, ClientRest } from '@orpc/client';
2
+ import type { ErrorMap, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
3
  import type { MaybeOptionalOptions } from '@orpc/shared';
3
4
  import type { ConflictContextGuard, Context, MergedContext } from './context';
5
+ import type { ORPCErrorConstructorMap } from './error';
4
6
  import type { MapInputMiddleware, Middleware } from './middleware';
5
7
  import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
6
8
  import { Procedure } from './procedure';
@@ -1,4 +1,5 @@
1
- import type { ClientPromiseResult, ErrorFromErrorMap, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
1
+ import type { ClientPromiseResult } from '@orpc/client';
2
+ import type { ErrorFromErrorMap, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
3
  import type { MaybeOptionalOptions } from '@orpc/shared';
3
4
  import type { Context } from './context';
4
5
  import type { Lazyable } from './lazy';
@@ -1,6 +1,7 @@
1
- import type { ContractProcedureDef, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
1
+ import type { ContractProcedureDef, ErrorMap, Meta, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
2
  import type { Promisable } from '@orpc/shared';
3
- import type { Context, TypeInitialContext } from './context';
3
+ import type { Context } from './context';
4
+ import type { ORPCErrorConstructorMap } from './error';
4
5
  import type { AnyMiddleware } from './middleware';
5
6
  export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
6
7
  context: TCurrentContext;
@@ -8,13 +9,14 @@ export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput
8
9
  path: string[];
9
10
  procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
10
11
  signal?: AbortSignal;
12
+ lastEventId: string | undefined;
11
13
  errors: TErrorConstructorMap;
12
14
  }
13
15
  export interface ProcedureHandler<TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
14
16
  (opt: ProcedureHandlerOptions<TCurrentContext, SchemaOutput<TInputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
15
17
  }
16
18
  export interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
17
- __initialContext?: TypeInitialContext<TInitialContext>;
19
+ __initialContext?: (type: TInitialContext) => unknown;
18
20
  middlewares: AnyMiddleware[];
19
21
  inputValidationIndex: number;
20
22
  outputValidationIndex: number;
@@ -1,10 +1,11 @@
1
- import type { ClientContext, ErrorMap, Meta } from '@orpc/contract';
1
+ import type { ClientContext } from '@orpc/client';
2
+ import type { ErrorMap, Meta } from '@orpc/contract';
2
3
  import type { MaybeOptionalOptions } from '@orpc/shared';
3
4
  import type { Lazy } from './lazy';
4
5
  import type { Procedure } from './procedure';
5
6
  import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
6
7
  import type { AnyRouter, InferRouterInitialContext } from './router';
7
- export type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext> = TRouter extends Lazy<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
8
+ export type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Lazy<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
8
9
  [K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
9
10
  };
10
11
  export declare function createRouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext>(router: TRouter | Lazy<undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<TRouter>, undefined, undefined, unknown, ErrorMap, Meta, TClientContext>>): RouterClient<TRouter, TClientContext>;
package/dist/standard.js CHANGED
@@ -1,17 +1,13 @@
1
1
  import {
2
2
  RPCCodec,
3
3
  RPCMatcher,
4
- RPCSerializer,
5
- StandardHandler,
6
- serializeRPCJson
7
- } from "./chunk-GBL3M2PB.js";
8
- import "./chunk-XP6YRLY2.js";
9
- import "./chunk-XI6WGCB3.js";
4
+ StandardHandler
5
+ } from "./chunk-NTHCS5CK.js";
6
+ import "./chunk-MHVECKBC.js";
7
+ import "./chunk-TXHKQO7N.js";
10
8
  export {
11
9
  RPCCodec,
12
10
  RPCMatcher,
13
- RPCSerializer,
14
- StandardHandler,
15
- serializeRPCJson
11
+ StandardHandler
16
12
  };
17
13
  //# sourceMappingURL=standard.js.map
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.9125edb",
4
+ "version": "0.0.0-next.92faaf9",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -63,11 +63,12 @@
63
63
  "next": ">=14.0.0"
64
64
  },
65
65
  "dependencies": {
66
- "@orpc/server-standard": "^0.0.0",
67
- "@orpc/server-standard-fetch": "^0.0.0",
68
- "@orpc/server-standard-node": "^0.0.0",
69
- "@orpc/contract": "0.0.0-next.9125edb",
70
- "@orpc/shared": "0.0.0-next.9125edb"
66
+ "@orpc/client": "0.0.0-next.92faaf9",
67
+ "@orpc/contract": "0.0.0-next.92faaf9",
68
+ "@orpc/standard-server": "0.0.0-next.92faaf9",
69
+ "@orpc/standard-server-fetch": "0.0.0-next.92faaf9",
70
+ "@orpc/shared": "0.0.0-next.92faaf9",
71
+ "@orpc/standard-server-node": "0.0.0-next.92faaf9"
71
72
  },
72
73
  "devDependencies": {
73
74
  "light-my-request": "^6.5.1"
@@ -1,16 +0,0 @@
1
- import type { Segment } from '@orpc/shared';
2
- export type RPCSerializedJsonMeta = ['bigint' | 'date' | 'nan' | 'undefined' | 'set' | 'map' | 'regexp' | 'url', Segment[]][];
3
- export type RPCSerialized = {
4
- json: unknown;
5
- meta: RPCSerializedJsonMeta;
6
- } | FormData | Blob | undefined;
7
- export type RPCSerializedFormDataMaps = Segment[][];
8
- export declare class RPCSerializer {
9
- serialize(data: unknown): RPCSerialized;
10
- deserialize(serialized: RPCSerialized): unknown;
11
- }
12
- export declare function serializeRPCJson(value: unknown, segments?: Segment[], meta?: RPCSerializedJsonMeta): {
13
- json: unknown;
14
- meta: RPCSerializedJsonMeta;
15
- };
16
- //# sourceMappingURL=rpc-serializer.d.ts.map