@orpc/server 0.0.0-next.7b151dd → 0.0.0-next.7b2677a
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 +2 -1
- package/dist/adapters/aws-lambda/index.mjs +2 -2
- package/dist/adapters/bun-ws/index.mjs +2 -2
- package/dist/adapters/crossws/index.mjs +2 -2
- package/dist/adapters/fetch/index.d.mts +49 -4
- package/dist/adapters/fetch/index.d.ts +49 -4
- package/dist/adapters/fetch/index.mjs +73 -3
- package/dist/adapters/message-port/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +25 -4
- package/dist/adapters/node/index.d.ts +25 -4
- package/dist/adapters/node/index.mjs +68 -12
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/adapters/ws/index.mjs +2 -2
- package/dist/hibernation/index.d.mts +9 -9
- package/dist/hibernation/index.d.ts +9 -9
- package/dist/hibernation/index.mjs +8 -8
- package/dist/index.mjs +3 -3
- package/dist/plugins/index.mjs +2 -2
- package/dist/shared/{server.CQr6WNc2.mjs → server.7jWaIryJ.mjs} +19 -11
- package/dist/shared/{server.BohymmQ6.mjs → server.BHZCyRuJ.mjs} +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
32
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
33
|
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
34
|
-
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
|
|
34
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
35
35
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
36
36
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
37
37
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -54,6 +54,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
54
54
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
55
55
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
56
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
57
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
57
58
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
58
59
|
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
59
60
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
@@ -7,9 +7,9 @@ import '@orpc/standard-server-fetch';
|
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import { S as StrictGetMethodPlugin } from '../../shared/server.BW-nUGgA.mjs';
|
|
9
9
|
import '@orpc/contract';
|
|
10
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
10
|
+
import { b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
11
11
|
import '@orpc/client/standard';
|
|
12
|
-
import '../../shared/server.
|
|
12
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
13
13
|
|
|
14
14
|
class AwsLambdaHandler {
|
|
15
15
|
constructor(standardHandler, options = {}) {
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
11
11
|
|
|
12
12
|
class BunWsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
11
11
|
|
|
12
12
|
class experimental_CrosswsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -57,14 +57,59 @@ declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T
|
|
|
57
57
|
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* This plugin is heavily inspired by the [Hono Compression Plugin](https://github.com/honojs/hono/blob/main/src/middleware/compress/index.ts)
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
|
|
65
|
+
interface CompressionPluginOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The compression schemes to use for response compression.
|
|
68
|
+
* Schemes are prioritized by their order in this array and
|
|
69
|
+
* only applied if the client supports them.
|
|
70
|
+
*
|
|
71
|
+
* @default ['gzip', 'deflate']
|
|
72
|
+
*/
|
|
73
|
+
encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
|
|
74
|
+
/**
|
|
75
|
+
* The minimum response size in bytes required to trigger compression.
|
|
76
|
+
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
77
|
+
* If the response size cannot be determined, compression will still be applied.
|
|
78
|
+
*
|
|
79
|
+
* @default 1024 (1KB)
|
|
80
|
+
*/
|
|
81
|
+
threshold?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Override the default content-type filter used to determine which responses should be compressed.
|
|
84
|
+
*
|
|
85
|
+
* @warning [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) responses are never compressed, regardless of this filter's return value.
|
|
86
|
+
* @default only responses with compressible content types are compressed.
|
|
87
|
+
*/
|
|
88
|
+
filter?: (request: Request, response: Response) => boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The Compression Plugin adds response compression to the Fetch Server.
|
|
92
|
+
* Build on top of [CompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)
|
|
93
|
+
* You might need to polyfill it if your environment does not support it.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/compression Compression Plugin Docs}
|
|
96
|
+
*/
|
|
97
|
+
declare class CompressionPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
98
|
+
private readonly encodings;
|
|
99
|
+
private readonly threshold;
|
|
100
|
+
private readonly filter;
|
|
101
|
+
constructor(options?: CompressionPluginOptions);
|
|
102
|
+
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardRPCHandlerOptions<T>, 'plugins'> {
|
|
61
106
|
/**
|
|
62
107
|
* Enables or disables the StrictGetMethodPlugin.
|
|
63
108
|
*
|
|
64
109
|
* @default true
|
|
65
110
|
*/
|
|
66
111
|
strictGetMethodPluginEnabled?: boolean;
|
|
67
|
-
}
|
|
112
|
+
}
|
|
68
113
|
/**
|
|
69
114
|
* RPC Handler for Fetch Server
|
|
70
115
|
*
|
|
@@ -75,5 +120,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
|
75
120
|
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
76
121
|
}
|
|
77
122
|
|
|
78
|
-
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
|
79
|
-
export type { BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
|
|
123
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, CompressionPlugin, FetchHandler, RPCHandler };
|
|
124
|
+
export type { BodyLimitPluginOptions, CompressionPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
|
|
@@ -57,14 +57,59 @@ declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T
|
|
|
57
57
|
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* This plugin is heavily inspired by the [Hono Compression Plugin](https://github.com/honojs/hono/blob/main/src/middleware/compress/index.ts)
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
|
|
65
|
+
interface CompressionPluginOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The compression schemes to use for response compression.
|
|
68
|
+
* Schemes are prioritized by their order in this array and
|
|
69
|
+
* only applied if the client supports them.
|
|
70
|
+
*
|
|
71
|
+
* @default ['gzip', 'deflate']
|
|
72
|
+
*/
|
|
73
|
+
encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
|
|
74
|
+
/**
|
|
75
|
+
* The minimum response size in bytes required to trigger compression.
|
|
76
|
+
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
77
|
+
* If the response size cannot be determined, compression will still be applied.
|
|
78
|
+
*
|
|
79
|
+
* @default 1024 (1KB)
|
|
80
|
+
*/
|
|
81
|
+
threshold?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Override the default content-type filter used to determine which responses should be compressed.
|
|
84
|
+
*
|
|
85
|
+
* @warning [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) responses are never compressed, regardless of this filter's return value.
|
|
86
|
+
* @default only responses with compressible content types are compressed.
|
|
87
|
+
*/
|
|
88
|
+
filter?: (request: Request, response: Response) => boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The Compression Plugin adds response compression to the Fetch Server.
|
|
92
|
+
* Build on top of [CompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)
|
|
93
|
+
* You might need to polyfill it if your environment does not support it.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/compression Compression Plugin Docs}
|
|
96
|
+
*/
|
|
97
|
+
declare class CompressionPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
98
|
+
private readonly encodings;
|
|
99
|
+
private readonly threshold;
|
|
100
|
+
private readonly filter;
|
|
101
|
+
constructor(options?: CompressionPluginOptions);
|
|
102
|
+
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardRPCHandlerOptions<T>, 'plugins'> {
|
|
61
106
|
/**
|
|
62
107
|
* Enables or disables the StrictGetMethodPlugin.
|
|
63
108
|
*
|
|
64
109
|
* @default true
|
|
65
110
|
*/
|
|
66
111
|
strictGetMethodPluginEnabled?: boolean;
|
|
67
|
-
}
|
|
112
|
+
}
|
|
68
113
|
/**
|
|
69
114
|
* RPC Handler for Fetch Server
|
|
70
115
|
*
|
|
@@ -75,5 +120,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
|
75
120
|
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
76
121
|
}
|
|
77
122
|
|
|
78
|
-
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
|
79
|
-
export type { BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
|
|
123
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, CompressionPlugin, FetchHandler, RPCHandler };
|
|
124
|
+
export type { BodyLimitPluginOptions, CompressionPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
|
|
@@ -4,11 +4,11 @@ import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fe
|
|
|
4
4
|
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '@orpc/standard-server/batch';
|
|
10
10
|
import { S as StrictGetMethodPlugin } from '../../shared/server.BW-nUGgA.mjs';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
12
12
|
|
|
13
13
|
class BodyLimitPlugin {
|
|
14
14
|
maxBodySize;
|
|
@@ -56,6 +56,76 @@ class BodyLimitPlugin {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const ORDERED_SUPPORTED_ENCODINGS = ["gzip", "deflate"];
|
|
60
|
+
class CompressionPlugin {
|
|
61
|
+
encodings;
|
|
62
|
+
threshold;
|
|
63
|
+
filter;
|
|
64
|
+
constructor(options = {}) {
|
|
65
|
+
this.encodings = options.encodings ?? ORDERED_SUPPORTED_ENCODINGS;
|
|
66
|
+
this.threshold = options.threshold ?? 1024;
|
|
67
|
+
this.filter = (request, response) => {
|
|
68
|
+
const hasContentDisposition = response.headers.has("content-disposition");
|
|
69
|
+
const contentType = response.headers.get("content-type");
|
|
70
|
+
if (!hasContentDisposition && contentType?.startsWith("text/event-stream")) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return options.filter ? options.filter(request, response) : isCompressibleContentType(contentType);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
initRuntimeAdapter(options) {
|
|
77
|
+
options.adapterInterceptors ??= [];
|
|
78
|
+
options.adapterInterceptors.unshift(async (options2) => {
|
|
79
|
+
const result = await options2.next();
|
|
80
|
+
if (!result.matched) {
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
const response = result.response;
|
|
84
|
+
if (response.headers.has("content-encoding") || response.headers.has("transfer-encoding") || isNoTransformCacheControl(response.headers.get("cache-control"))) {
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
const contentLength = response.headers.get("content-length");
|
|
88
|
+
if (contentLength && Number(contentLength) < this.threshold) {
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
const acceptEncoding = options2.request.headers.get("accept-encoding")?.split(",").map((enc) => enc.trim().split(";")[0]);
|
|
92
|
+
const encoding = this.encodings.find((enc) => acceptEncoding?.includes(enc));
|
|
93
|
+
if (!response.body || encoding === void 0) {
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
if (!this.filter(options2.request, response)) {
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
const compressedBody = response.body.pipeThrough(new CompressionStream(encoding));
|
|
100
|
+
const compressedHeaders = new Headers(response.headers);
|
|
101
|
+
compressedHeaders.delete("content-length");
|
|
102
|
+
compressedHeaders.set("content-encoding", encoding);
|
|
103
|
+
return {
|
|
104
|
+
...result,
|
|
105
|
+
response: new Response(compressedBody, {
|
|
106
|
+
status: response.status,
|
|
107
|
+
statusText: response.statusText,
|
|
108
|
+
headers: compressedHeaders
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
115
|
+
function isCompressibleContentType(contentType) {
|
|
116
|
+
if (contentType === null) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return COMPRESSIBLE_CONTENT_TYPE_REGEX.test(contentType);
|
|
120
|
+
}
|
|
121
|
+
const CACHE_CONTROL_NO_TRANSFORM_REGEX = /(?:^|,)\s*no-transform\s*(?:,|$)/i;
|
|
122
|
+
function isNoTransformCacheControl(cacheControl) {
|
|
123
|
+
if (cacheControl === null) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return CACHE_CONTROL_NO_TRANSFORM_REGEX.test(cacheControl);
|
|
127
|
+
}
|
|
128
|
+
|
|
59
129
|
class CompositeFetchHandlerPlugin extends CompositeStandardHandlerPlugin {
|
|
60
130
|
initRuntimeAdapter(options) {
|
|
61
131
|
for (const plugin of this.plugins) {
|
|
@@ -107,4 +177,4 @@ class RPCHandler extends FetchHandler {
|
|
|
107
177
|
}
|
|
108
178
|
}
|
|
109
179
|
|
|
110
|
-
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
|
180
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, CompressionPlugin, FetchHandler, RPCHandler };
|
|
@@ -5,10 +5,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/standard-server';
|
|
7
7
|
import '@orpc/contract';
|
|
8
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
8
|
+
import { b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
9
9
|
import '@orpc/client/standard';
|
|
10
10
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
12
12
|
|
|
13
13
|
class MessagePortHandler {
|
|
14
14
|
constructor(standardHandler) {
|
|
@@ -3,6 +3,7 @@ import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
3
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
|
4
4
|
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.gqRxT-yN.mjs';
|
|
5
5
|
import { F as FriendlyStandardHandleOptions } from '../../shared/server.BEFBl-Cb.mjs';
|
|
6
|
+
import compression from '@orpc/interop/compression';
|
|
6
7
|
import { S as StandardRPCHandlerOptions } from '../../shared/server.BU4WI18A.mjs';
|
|
7
8
|
import '@orpc/client';
|
|
8
9
|
import '@orpc/contract';
|
|
@@ -56,14 +57,34 @@ declare class BodyLimitPlugin<T extends Context> implements NodeHttpHandlerPlugi
|
|
|
56
57
|
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
interface CompressionPluginOptions extends compression.CompressionOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Override the default content-type filter used to determine which responses should be compressed.
|
|
63
|
+
*
|
|
64
|
+
* @warning [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) responses are never compressed, regardless of this filter's return value.
|
|
65
|
+
* @default only responses with compressible content types are compressed.
|
|
66
|
+
*/
|
|
67
|
+
filter?: (req: NodeHttpRequest, res: NodeHttpResponse) => boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The Compression Plugin adds response compression to the Node.js HTTP Server.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/compression Compression Plugin Docs}
|
|
73
|
+
*/
|
|
74
|
+
declare class CompressionPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
75
|
+
private readonly compressionHandler;
|
|
76
|
+
constructor(options?: CompressionPluginOptions);
|
|
77
|
+
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, Omit<StandardRPCHandlerOptions<T>, 'plugins'> {
|
|
60
81
|
/**
|
|
61
82
|
* Enables or disables the StrictGetMethodPlugin.
|
|
62
83
|
*
|
|
63
84
|
* @default true
|
|
64
85
|
*/
|
|
65
86
|
strictGetMethodPluginEnabled?: boolean;
|
|
66
|
-
}
|
|
87
|
+
}
|
|
67
88
|
/**
|
|
68
89
|
* RPC Handler for Node.js HTTP Server
|
|
69
90
|
*
|
|
@@ -74,5 +95,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
|
74
95
|
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
75
96
|
}
|
|
76
97
|
|
|
77
|
-
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
|
78
|
-
export type { BodyLimitPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin, RPCHandlerOptions };
|
|
98
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, CompressionPlugin, NodeHttpHandler, RPCHandler };
|
|
99
|
+
export type { BodyLimitPluginOptions, CompressionPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin, RPCHandlerOptions };
|
|
@@ -3,6 +3,7 @@ import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
3
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
|
4
4
|
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.Bmh5xd4n.js';
|
|
5
5
|
import { F as FriendlyStandardHandleOptions } from '../../shared/server.B7b2w3_i.js';
|
|
6
|
+
import compression from '@orpc/interop/compression';
|
|
6
7
|
import { S as StandardRPCHandlerOptions } from '../../shared/server.D0H-iaY3.js';
|
|
7
8
|
import '@orpc/client';
|
|
8
9
|
import '@orpc/contract';
|
|
@@ -56,14 +57,34 @@ declare class BodyLimitPlugin<T extends Context> implements NodeHttpHandlerPlugi
|
|
|
56
57
|
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
interface CompressionPluginOptions extends compression.CompressionOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Override the default content-type filter used to determine which responses should be compressed.
|
|
63
|
+
*
|
|
64
|
+
* @warning [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) responses are never compressed, regardless of this filter's return value.
|
|
65
|
+
* @default only responses with compressible content types are compressed.
|
|
66
|
+
*/
|
|
67
|
+
filter?: (req: NodeHttpRequest, res: NodeHttpResponse) => boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The Compression Plugin adds response compression to the Node.js HTTP Server.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/compression Compression Plugin Docs}
|
|
73
|
+
*/
|
|
74
|
+
declare class CompressionPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
75
|
+
private readonly compressionHandler;
|
|
76
|
+
constructor(options?: CompressionPluginOptions);
|
|
77
|
+
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, Omit<StandardRPCHandlerOptions<T>, 'plugins'> {
|
|
60
81
|
/**
|
|
61
82
|
* Enables or disables the StrictGetMethodPlugin.
|
|
62
83
|
*
|
|
63
84
|
* @default true
|
|
64
85
|
*/
|
|
65
86
|
strictGetMethodPluginEnabled?: boolean;
|
|
66
|
-
}
|
|
87
|
+
}
|
|
67
88
|
/**
|
|
68
89
|
* RPC Handler for Node.js HTTP Server
|
|
69
90
|
*
|
|
@@ -74,5 +95,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
|
74
95
|
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
75
96
|
}
|
|
76
97
|
|
|
77
|
-
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
|
78
|
-
export type { BodyLimitPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin, RPCHandlerOptions };
|
|
98
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, CompressionPlugin, NodeHttpHandler, RPCHandler };
|
|
99
|
+
export type { BodyLimitPluginOptions, CompressionPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin, RPCHandlerOptions };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { ORPCError } from '@orpc/client';
|
|
2
|
-
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { once, toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
+
import compression from '@orpc/interop/compression';
|
|
3
4
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
|
4
5
|
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
5
6
|
import '@orpc/standard-server';
|
|
6
7
|
import '@orpc/contract';
|
|
7
|
-
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.
|
|
8
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
8
9
|
import '@orpc/client/standard';
|
|
9
10
|
import '@orpc/standard-server/batch';
|
|
10
11
|
import '@orpc/standard-server-fetch';
|
|
11
12
|
import { S as StrictGetMethodPlugin } from '../../shared/server.BW-nUGgA.mjs';
|
|
12
|
-
import '../../shared/server.
|
|
13
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
13
14
|
|
|
14
15
|
class BodyLimitPlugin {
|
|
15
16
|
maxBodySize;
|
|
@@ -19,14 +20,12 @@ class BodyLimitPlugin {
|
|
|
19
20
|
initRuntimeAdapter(options) {
|
|
20
21
|
options.adapterInterceptors ??= [];
|
|
21
22
|
options.adapterInterceptors.push(async (options2) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!isHeaderChecked && Number(options2.request.headers["content-length"]) > this.maxBodySize) {
|
|
23
|
+
const checkHeader = once(() => {
|
|
24
|
+
if (Number(options2.request.headers["content-length"]) > this.maxBodySize) {
|
|
25
25
|
throw new ORPCError("PAYLOAD_TOO_LARGE");
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const originalEmit = options2.request.emit.bind(options2.request);
|
|
27
|
+
});
|
|
28
|
+
const originalEmit = options2.request.emit;
|
|
30
29
|
let currentBodySize = 0;
|
|
31
30
|
options2.request.emit = (event, ...args) => {
|
|
32
31
|
if (event === "data") {
|
|
@@ -36,9 +35,66 @@ class BodyLimitPlugin {
|
|
|
36
35
|
throw new ORPCError("PAYLOAD_TOO_LARGE");
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
return originalEmit(event, ...args);
|
|
38
|
+
return originalEmit.call(options2.request, event, ...args);
|
|
40
39
|
};
|
|
41
|
-
|
|
40
|
+
try {
|
|
41
|
+
return await options2.next(options2);
|
|
42
|
+
} finally {
|
|
43
|
+
options2.request.emit = originalEmit;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class CompressionPlugin {
|
|
50
|
+
compressionHandler;
|
|
51
|
+
constructor(options = {}) {
|
|
52
|
+
this.compressionHandler = compression({
|
|
53
|
+
...options,
|
|
54
|
+
filter: (req, res) => {
|
|
55
|
+
const hasContentDisposition = res.hasHeader("content-disposition");
|
|
56
|
+
const contentType = res.getHeader("content-type")?.toString();
|
|
57
|
+
if (!hasContentDisposition && contentType?.startsWith("text/event-stream")) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return options.filter ? options.filter(req, res) : compression.filter(req, res);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
initRuntimeAdapter(options) {
|
|
65
|
+
options.adapterInterceptors ??= [];
|
|
66
|
+
options.adapterInterceptors.unshift(async (options2) => {
|
|
67
|
+
let resolve;
|
|
68
|
+
let reject;
|
|
69
|
+
const promise = new Promise((res, rej) => {
|
|
70
|
+
resolve = res;
|
|
71
|
+
reject = rej;
|
|
72
|
+
});
|
|
73
|
+
const originalWrite = options2.response.write;
|
|
74
|
+
const originalEnd = options2.response.end;
|
|
75
|
+
const originalOn = options2.response.on;
|
|
76
|
+
this.compressionHandler(
|
|
77
|
+
options2.request,
|
|
78
|
+
options2.response,
|
|
79
|
+
async (err) => {
|
|
80
|
+
if (err) {
|
|
81
|
+
reject(err);
|
|
82
|
+
} else {
|
|
83
|
+
try {
|
|
84
|
+
resolve(await options2.next());
|
|
85
|
+
} catch (error) {
|
|
86
|
+
reject(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
try {
|
|
92
|
+
return await promise;
|
|
93
|
+
} finally {
|
|
94
|
+
options2.response.write = originalWrite;
|
|
95
|
+
options2.response.end = originalEnd;
|
|
96
|
+
options2.response.on = originalOn;
|
|
97
|
+
}
|
|
42
98
|
});
|
|
43
99
|
}
|
|
44
100
|
}
|
|
@@ -93,4 +149,4 @@ class RPCHandler extends NodeHttpHandler {
|
|
|
93
149
|
}
|
|
94
150
|
}
|
|
95
151
|
|
|
96
|
-
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
|
152
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, CompressionPlugin, NodeHttpHandler, RPCHandler };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.
|
|
1
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.BHZCyRuJ.mjs';
|
|
2
2
|
export { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
3
3
|
import '@orpc/client/standard';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/shared';
|
|
6
6
|
import '@orpc/standard-server';
|
|
7
|
-
import '../../shared/server.
|
|
7
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
8
8
|
import '@orpc/contract';
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
11
11
|
|
|
12
12
|
class WebsocketHandler {
|
|
13
13
|
#peers = /* @__PURE__ */ new WeakMap();
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.BHZCyRuJ.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.7jWaIryJ.mjs';
|
|
11
11
|
|
|
12
12
|
class WsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
|
2
2
|
import { g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.gqRxT-yN.mjs';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { HibernationEventIterator } from '@orpc/standard-server';
|
|
4
|
+
export { HibernationEventIterator, HibernationEventIteratorCallback } from '@orpc/standard-server';
|
|
5
5
|
import { C as Context, R as Router } from '../shared/server.CYNGeoCm.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
import '@orpc/shared';
|
|
9
9
|
|
|
10
|
-
interface
|
|
10
|
+
interface EncodeHibernationRPCEventOptions extends StandardRPCJsonSerializerOptions {
|
|
11
11
|
/**
|
|
12
12
|
* The type of event, each type corresponds a different operation
|
|
13
13
|
*
|
|
@@ -24,21 +24,21 @@ interface experimental_EncodeHibernationRPCEventOptions extends StandardRPCJsonS
|
|
|
24
24
|
*
|
|
25
25
|
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
|
26
26
|
*/
|
|
27
|
-
declare function
|
|
27
|
+
declare function encodeHibernationRPCEvent(id: string, payload: unknown, options?: EncodeHibernationRPCEventOptions): string;
|
|
28
28
|
|
|
29
|
-
interface
|
|
30
|
-
iterator?:
|
|
29
|
+
interface HibernationPluginContext {
|
|
30
|
+
iterator?: HibernationEventIterator<any>;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Enable Hibernation APIs
|
|
34
34
|
*
|
|
35
35
|
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
|
36
36
|
*/
|
|
37
|
-
declare class
|
|
37
|
+
declare class HibernationPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
38
38
|
readonly CONTEXT_SYMBOL: symbol;
|
|
39
39
|
order: number;
|
|
40
40
|
init(options: StandardHandlerOptions<T>, _router: Router<any, T>): void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export {
|
|
44
|
-
export type {
|
|
43
|
+
export { HibernationPlugin, encodeHibernationRPCEvent };
|
|
44
|
+
export type { EncodeHibernationRPCEventOptions, HibernationPluginContext };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
|
2
2
|
import { g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.Bmh5xd4n.js';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { HibernationEventIterator } from '@orpc/standard-server';
|
|
4
|
+
export { HibernationEventIterator, HibernationEventIteratorCallback } from '@orpc/standard-server';
|
|
5
5
|
import { C as Context, R as Router } from '../shared/server.CYNGeoCm.js';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
import '@orpc/shared';
|
|
9
9
|
|
|
10
|
-
interface
|
|
10
|
+
interface EncodeHibernationRPCEventOptions extends StandardRPCJsonSerializerOptions {
|
|
11
11
|
/**
|
|
12
12
|
* The type of event, each type corresponds a different operation
|
|
13
13
|
*
|
|
@@ -24,21 +24,21 @@ interface experimental_EncodeHibernationRPCEventOptions extends StandardRPCJsonS
|
|
|
24
24
|
*
|
|
25
25
|
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
|
26
26
|
*/
|
|
27
|
-
declare function
|
|
27
|
+
declare function encodeHibernationRPCEvent(id: string, payload: unknown, options?: EncodeHibernationRPCEventOptions): string;
|
|
28
28
|
|
|
29
|
-
interface
|
|
30
|
-
iterator?:
|
|
29
|
+
interface HibernationPluginContext {
|
|
30
|
+
iterator?: HibernationEventIterator<any>;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Enable Hibernation APIs
|
|
34
34
|
*
|
|
35
35
|
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
|
36
36
|
*/
|
|
37
|
-
declare class
|
|
37
|
+
declare class HibernationPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
38
38
|
readonly CONTEXT_SYMBOL: symbol;
|
|
39
39
|
order: number;
|
|
40
40
|
init(options: StandardHandlerOptions<T>, _router: Router<any, T>): void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export {
|
|
44
|
-
export type {
|
|
43
|
+
export { HibernationPlugin, encodeHibernationRPCEvent };
|
|
44
|
+
export type { EncodeHibernationRPCEventOptions, HibernationPluginContext };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { toORPCError } from '@orpc/client';
|
|
2
2
|
import { StandardRPCJsonSerializer } from '@orpc/client/standard';
|
|
3
3
|
import { stringifyJSON } from '@orpc/shared';
|
|
4
|
-
import { getEventMeta,
|
|
5
|
-
export {
|
|
4
|
+
import { getEventMeta, HibernationEventIterator } from '@orpc/standard-server';
|
|
5
|
+
export { HibernationEventIterator } from '@orpc/standard-server';
|
|
6
6
|
import { MessageType } from '@orpc/standard-server-peer';
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function encodeHibernationRPCEvent(id, payload, options = {}) {
|
|
9
9
|
const { event = "message", ...rest } = options;
|
|
10
10
|
const serializer = new StandardRPCJsonSerializer(rest);
|
|
11
11
|
const data = event === "error" ? toORPCError(payload).toJSON() : payload;
|
|
@@ -21,7 +21,7 @@ function experimental_encodeHibernationRPCEvent(id, payload, options = {}) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
class
|
|
24
|
+
class HibernationPlugin {
|
|
25
25
|
CONTEXT_SYMBOL = Symbol("ORPC_HIBERNATION_CONTEXT");
|
|
26
26
|
order = 2e6;
|
|
27
27
|
// make sure execute after the batch plugin
|
|
@@ -33,8 +33,8 @@ class experimental_HibernationPlugin {
|
|
|
33
33
|
const result = await options2.next({
|
|
34
34
|
...options2,
|
|
35
35
|
context: {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
...options2.context,
|
|
37
|
+
[this.CONTEXT_SYMBOL]: hibernationContext
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
if (!result.matched || !hibernationContext.iterator) {
|
|
@@ -54,7 +54,7 @@ class experimental_HibernationPlugin {
|
|
|
54
54
|
throw new TypeError("[HibernationPlugin] Hibernation context has been corrupted or modified by another plugin or interceptor");
|
|
55
55
|
}
|
|
56
56
|
const output = await options2.next();
|
|
57
|
-
if (output instanceof
|
|
57
|
+
if (output instanceof HibernationEventIterator) {
|
|
58
58
|
hibernationContext.iterator = output;
|
|
59
59
|
}
|
|
60
60
|
return output;
|
|
@@ -62,4 +62,4 @@ class experimental_HibernationPlugin {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export {
|
|
65
|
+
export { HibernationPlugin, encodeHibernationRPCEvent };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter, fallbackContractConfig } from '@orpc/contract';
|
|
2
2
|
export { ValidationError, eventIterator, type } from '@orpc/contract';
|
|
3
|
-
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, u as unlazy, g as getRouter, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure } from './shared/server.
|
|
4
|
-
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, w as resolveContractProcedures, t as traverseContractProcedures, x as unlazyRouter, v as validateORPCError } from './shared/server.
|
|
3
|
+
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, u as unlazy, g as getRouter, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure } from './shared/server.7jWaIryJ.mjs';
|
|
4
|
+
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, w as resolveContractProcedures, t as traverseContractProcedures, x as unlazyRouter, v as validateORPCError } from './shared/server.7jWaIryJ.mjs';
|
|
5
5
|
import { toORPCError } from '@orpc/client';
|
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
|
7
7
|
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
@@ -21,7 +21,7 @@ function fallbackConfig(key, value) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function decorateMiddleware(middleware) {
|
|
24
|
-
const decorated = (...args) => middleware(...args);
|
|
24
|
+
const decorated = ((...args) => middleware(...args));
|
|
25
25
|
decorated.mapInput = (mapInput) => {
|
|
26
26
|
const mapped = decorateMiddleware(
|
|
27
27
|
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -83,7 +83,7 @@ class BatchHandlerPlugin {
|
|
|
83
83
|
status,
|
|
84
84
|
headers,
|
|
85
85
|
mode,
|
|
86
|
-
body: async function* () {
|
|
86
|
+
body: (async function* () {
|
|
87
87
|
const promises = [...responses];
|
|
88
88
|
while (true) {
|
|
89
89
|
const handling = promises.filter((p) => p !== void 0);
|
|
@@ -94,7 +94,7 @@ class BatchHandlerPlugin {
|
|
|
94
94
|
promises[result.index] = void 0;
|
|
95
95
|
yield result;
|
|
96
96
|
}
|
|
97
|
-
}()
|
|
97
|
+
})()
|
|
98
98
|
});
|
|
99
99
|
return {
|
|
100
100
|
matched: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
|
|
2
2
|
import { resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, asyncIteratorWithSpan } from '@orpc/shared';
|
|
3
|
-
import { fallbackORPCErrorStatus,
|
|
4
|
-
import {
|
|
3
|
+
import { ORPCError, fallbackORPCErrorStatus, mapEventIterator } from '@orpc/client';
|
|
4
|
+
import { HibernationEventIterator } from '@orpc/standard-server';
|
|
5
5
|
|
|
6
6
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
7
7
|
function lazy(loader, meta = {}) {
|
|
@@ -116,6 +116,12 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
116
116
|
const clientContext = callerOptions?.context ?? {};
|
|
117
117
|
const context = await value(options.context ?? {}, clientContext);
|
|
118
118
|
const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
|
|
119
|
+
const validateError = async (e) => {
|
|
120
|
+
if (e instanceof ORPCError) {
|
|
121
|
+
return await validateORPCError(procedure["~orpc"].errorMap, e);
|
|
122
|
+
}
|
|
123
|
+
return e;
|
|
124
|
+
};
|
|
119
125
|
try {
|
|
120
126
|
const output = await runWithSpan(
|
|
121
127
|
{ name: "call_procedure", signal: callerOptions?.signal },
|
|
@@ -138,21 +144,23 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
138
144
|
}
|
|
139
145
|
);
|
|
140
146
|
if (isAsyncIteratorObject(output)) {
|
|
141
|
-
if (output instanceof
|
|
147
|
+
if (output instanceof HibernationEventIterator) {
|
|
142
148
|
return output;
|
|
143
149
|
}
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
return mapEventIterator(
|
|
151
|
+
asyncIteratorWithSpan(
|
|
152
|
+
{ name: "consume_event_iterator_output", signal: callerOptions?.signal },
|
|
153
|
+
output
|
|
154
|
+
),
|
|
155
|
+
{
|
|
156
|
+
value: (v) => v,
|
|
157
|
+
error: (e) => validateError(e)
|
|
158
|
+
}
|
|
147
159
|
);
|
|
148
160
|
}
|
|
149
161
|
return output;
|
|
150
162
|
} catch (e) {
|
|
151
|
-
|
|
152
|
-
throw e;
|
|
153
|
-
}
|
|
154
|
-
const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
|
|
155
|
-
throw validated;
|
|
163
|
+
throw await validateError(e);
|
|
156
164
|
}
|
|
157
165
|
};
|
|
158
166
|
}
|
|
@@ -2,7 +2,7 @@ import { toHttpPath, StandardRPCJsonSerializer, StandardRPCSerializer } from '@o
|
|
|
2
2
|
import { ORPCError, toORPCError } from '@orpc/client';
|
|
3
3
|
import { toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, parseEmptyableJSON, NullProtoObj, value } from '@orpc/shared';
|
|
4
4
|
import { flattenHeader } from '@orpc/standard-server';
|
|
5
|
-
import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.
|
|
5
|
+
import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.7jWaIryJ.mjs';
|
|
6
6
|
|
|
7
7
|
class CompositeStandardHandlerPlugin {
|
|
8
8
|
plugins;
|
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.
|
|
4
|
+
"version": "0.0.0-next.7b2677a",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -102,19 +102,20 @@
|
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
104
|
"cookie": "^1.0.2",
|
|
105
|
-
"@orpc/contract": "0.0.0-next.
|
|
106
|
-
"@orpc/client": "0.0.0-next.
|
|
107
|
-
"@orpc/
|
|
108
|
-
"@orpc/
|
|
109
|
-
"@orpc/standard-server
|
|
110
|
-
"@orpc/standard-server-
|
|
111
|
-
"@orpc/standard-server-
|
|
112
|
-
"@orpc/standard-server-
|
|
105
|
+
"@orpc/contract": "0.0.0-next.7b2677a",
|
|
106
|
+
"@orpc/client": "0.0.0-next.7b2677a",
|
|
107
|
+
"@orpc/interop": "0.0.0-next.7b2677a",
|
|
108
|
+
"@orpc/shared": "0.0.0-next.7b2677a",
|
|
109
|
+
"@orpc/standard-server": "0.0.0-next.7b2677a",
|
|
110
|
+
"@orpc/standard-server-aws-lambda": "0.0.0-next.7b2677a",
|
|
111
|
+
"@orpc/standard-server-peer": "0.0.0-next.7b2677a",
|
|
112
|
+
"@orpc/standard-server-node": "0.0.0-next.7b2677a",
|
|
113
|
+
"@orpc/standard-server-fetch": "0.0.0-next.7b2677a"
|
|
113
114
|
},
|
|
114
115
|
"devDependencies": {
|
|
115
116
|
"@types/ws": "^8.18.1",
|
|
116
117
|
"crossws": "^0.4.1",
|
|
117
|
-
"next": "^15.
|
|
118
|
+
"next": "^15.5.0",
|
|
118
119
|
"supertest": "^7.1.4",
|
|
119
120
|
"ws": "^8.18.3"
|
|
120
121
|
},
|