@orpc/server 1.7.4 → 1.7.6
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/dist/adapters/aws-lambda/index.d.mts +5 -5
- package/dist/adapters/aws-lambda/index.d.ts +5 -5
- package/dist/adapters/aws-lambda/index.mjs +3 -2
- package/dist/adapters/bun-ws/index.d.mts +5 -5
- package/dist/adapters/bun-ws/index.d.ts +5 -5
- package/dist/adapters/bun-ws/index.mjs +2 -2
- package/dist/adapters/crossws/index.d.mts +5 -5
- package/dist/adapters/crossws/index.d.ts +5 -5
- package/dist/adapters/crossws/index.mjs +2 -2
- package/dist/adapters/fetch/index.d.mts +5 -5
- package/dist/adapters/fetch/index.d.ts +5 -5
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/message-port/index.d.mts +5 -5
- package/dist/adapters/message-port/index.d.ts +5 -5
- package/dist/adapters/message-port/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +5 -5
- package/dist/adapters/node/index.d.ts +5 -5
- package/dist/adapters/node/index.mjs +3 -2
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/standard-peer/index.d.mts +3 -3
- package/dist/adapters/standard-peer/index.d.ts +3 -3
- package/dist/adapters/websocket/index.d.mts +5 -5
- package/dist/adapters/websocket/index.d.ts +5 -5
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/adapters/ws/index.d.mts +5 -5
- package/dist/adapters/ws/index.d.ts +5 -5
- package/dist/adapters/ws/index.mjs +2 -2
- package/dist/helpers/index.d.mts +130 -0
- package/dist/helpers/index.d.ts +130 -0
- package/dist/helpers/index.mjs +182 -0
- package/dist/hibernation/index.d.mts +2 -2
- package/dist/hibernation/index.d.ts +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +5 -4
- package/dist/plugins/index.d.mts +17 -4
- package/dist/plugins/index.d.ts +17 -4
- package/dist/plugins/index.mjs +18 -1
- package/dist/shared/{server.mGrd7l1v.d.ts → server.B7b2w3_i.d.ts} +2 -2
- package/dist/shared/{server.VjZAmjFs.d.mts → server.BEFBl-Cb.d.mts} +2 -2
- package/dist/shared/{server.C-F_fMXW.d.mts → server.BU4WI18A.d.mts} +3 -3
- package/dist/shared/{server.BX8Iro5z.d.ts → server.Bmh5xd4n.d.ts} +1 -1
- package/dist/shared/{server.Aqc4pYFD.mjs → server.CIL9uKTN.mjs} +1 -1
- package/dist/shared/{server.CRejaM08.d.mts → server.CYNGeoCm.d.mts} +4 -2
- package/dist/shared/{server.CRejaM08.d.ts → server.CYNGeoCm.d.ts} +4 -2
- package/dist/shared/{server.CPC5w4d2.d.ts → server.D0H-iaY3.d.ts} +3 -3
- package/dist/shared/{server.DrG30u7a.d.mts → server.DhJj-1X9.d.mts} +1 -1
- package/dist/shared/{server.DLJzqnSX.mjs → server.NeumLVdS.mjs} +11 -9
- package/dist/shared/{server.De2J-WNx.d.mts → server.gqRxT-yN.d.mts} +1 -1
- package/dist/shared/{server.Bi2_bIHo.d.ts → server.jMTkVNIb.d.ts} +1 -1
- package/package.json +15 -9
@@ -1,9 +1,9 @@
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import { b as AnyRouter, C as Context, R as Router } from './server.
|
3
|
-
import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.
|
2
|
+
import { b as AnyRouter, C as Context, R as Router } from './server.CYNGeoCm.mjs';
|
3
|
+
import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.gqRxT-yN.mjs';
|
4
4
|
import { HTTPPath } from '@orpc/client';
|
5
5
|
import { Value } from '@orpc/shared';
|
6
|
-
import { T as TraverseContractProcedureCallbackOptions } from './server.
|
6
|
+
import { T as TraverseContractProcedureCallbackOptions } from './server.DhJj-1X9.mjs';
|
7
7
|
|
8
8
|
interface StandardRPCMatcherOptions {
|
9
9
|
/**
|
@@ -2,7 +2,7 @@ import { HTTPPath, ORPCError } from '@orpc/client';
|
|
2
2
|
import { Meta } from '@orpc/contract';
|
3
3
|
import { Interceptor } from '@orpc/shared';
|
4
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
5
|
-
import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.
|
5
|
+
import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.CYNGeoCm.js';
|
6
6
|
|
7
7
|
interface StandardHandlerPlugin<T extends Context> {
|
8
8
|
order?: number;
|
@@ -2,7 +2,7 @@ import { toHttpPath, StandardRPCJsonSerializer, StandardRPCSerializer } from '@o
|
|
2
2
|
import { ORPCError, toORPCError } from '@orpc/client';
|
3
3
|
import { toArray, intercept, 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.NeumLVdS.mjs';
|
6
6
|
|
7
7
|
class CompositeStandardHandlerPlugin {
|
8
8
|
plugins;
|
@@ -29,7 +29,9 @@ interface Lazy<T> {
|
|
29
29
|
}
|
30
30
|
type Lazyable<T> = T | Lazy<T>;
|
31
31
|
/**
|
32
|
-
*
|
32
|
+
* Creates a lazy-loaded item.
|
33
|
+
*
|
34
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazy(...)` instead.
|
33
35
|
*/
|
34
36
|
declare function lazy<T>(loader: () => Promise<{
|
35
37
|
default: T;
|
@@ -138,7 +140,7 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
|
|
138
140
|
*
|
139
141
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
140
142
|
*/
|
141
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...
|
143
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
142
144
|
|
143
145
|
/**
|
144
146
|
* Represents a router, which defines a hierarchical structure of procedures.
|
@@ -29,7 +29,9 @@ interface Lazy<T> {
|
|
29
29
|
}
|
30
30
|
type Lazyable<T> = T | Lazy<T>;
|
31
31
|
/**
|
32
|
-
*
|
32
|
+
* Creates a lazy-loaded item.
|
33
|
+
*
|
34
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazy(...)` instead.
|
33
35
|
*/
|
34
36
|
declare function lazy<T>(loader: () => Promise<{
|
35
37
|
default: T;
|
@@ -138,7 +140,7 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
|
|
138
140
|
*
|
139
141
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
140
142
|
*/
|
141
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...
|
143
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
142
144
|
|
143
145
|
/**
|
144
146
|
* Represents a router, which defines a hierarchical structure of procedures.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import { b as AnyRouter, C as Context, R as Router } from './server.
|
3
|
-
import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.
|
2
|
+
import { b as AnyRouter, C as Context, R as Router } from './server.CYNGeoCm.js';
|
3
|
+
import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.Bmh5xd4n.js';
|
4
4
|
import { HTTPPath } from '@orpc/client';
|
5
5
|
import { Value } from '@orpc/shared';
|
6
|
-
import { T as TraverseContractProcedureCallbackOptions } from './server.
|
6
|
+
import { T as TraverseContractProcedureCallbackOptions } from './server.jMTkVNIb.js';
|
7
7
|
|
8
8
|
interface StandardRPCMatcherOptions {
|
9
9
|
/**
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ErrorMap, EnhanceRouteOptions, MergedErrorMap, AnyContractRouter, AnyContractProcedure } from '@orpc/contract';
|
2
|
-
import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.
|
2
|
+
import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.CYNGeoCm.mjs';
|
3
3
|
|
4
4
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
5
5
|
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
|
2
|
-
import { value, intercept
|
2
|
+
import { resolveMaybeOptionalOptions, toArray, value, intercept } from '@orpc/shared';
|
3
3
|
import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
|
4
4
|
|
5
5
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
@@ -71,14 +71,15 @@ function createORPCErrorConstructorMap(errors) {
|
|
71
71
|
if (typeof code !== "string") {
|
72
72
|
return Reflect.get(target, code);
|
73
73
|
}
|
74
|
-
const item = (...
|
74
|
+
const item = (...rest) => {
|
75
|
+
const options = resolveMaybeOptionalOptions(rest);
|
75
76
|
const config = errors[code];
|
76
77
|
return new ORPCError(code, {
|
77
78
|
defined: Boolean(config),
|
78
79
|
status: config?.status,
|
79
|
-
message: options
|
80
|
-
data: options
|
81
|
-
cause: options
|
80
|
+
message: options.message ?? config?.message,
|
81
|
+
data: options.data,
|
82
|
+
cause: options.cause
|
82
83
|
});
|
83
84
|
};
|
84
85
|
return item;
|
@@ -106,16 +107,17 @@ function middlewareOutputFn(output) {
|
|
106
107
|
return { output, context: {} };
|
107
108
|
}
|
108
109
|
|
109
|
-
function createProcedureClient(lazyableProcedure, ...
|
110
|
+
function createProcedureClient(lazyableProcedure, ...rest) {
|
111
|
+
const options = resolveMaybeOptionalOptions(rest);
|
110
112
|
return async (...[input, callerOptions]) => {
|
111
|
-
const path = options
|
113
|
+
const path = toArray(options.path);
|
112
114
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
113
115
|
const clientContext = callerOptions?.context ?? {};
|
114
|
-
const context = await value(options
|
116
|
+
const context = await value(options.context ?? {}, clientContext);
|
115
117
|
const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
|
116
118
|
try {
|
117
119
|
return await intercept(
|
118
|
-
options
|
120
|
+
toArray(options.interceptors),
|
119
121
|
{
|
120
122
|
context,
|
121
123
|
input,
|
@@ -2,7 +2,7 @@ import { HTTPPath, ORPCError } from '@orpc/client';
|
|
2
2
|
import { Meta } from '@orpc/contract';
|
3
3
|
import { Interceptor } from '@orpc/shared';
|
4
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
5
|
-
import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.
|
5
|
+
import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.CYNGeoCm.mjs';
|
6
6
|
|
7
7
|
interface StandardHandlerPlugin<T extends Context> {
|
8
8
|
order?: number;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ErrorMap, EnhanceRouteOptions, MergedErrorMap, AnyContractRouter, AnyContractProcedure } from '@orpc/contract';
|
2
|
-
import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.
|
2
|
+
import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.CYNGeoCm.js';
|
3
3
|
|
4
4
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
5
5
|
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.7.
|
4
|
+
"version": "1.7.6",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -19,6 +19,11 @@
|
|
19
19
|
"import": "./dist/index.mjs",
|
20
20
|
"default": "./dist/index.mjs"
|
21
21
|
},
|
22
|
+
"./helpers": {
|
23
|
+
"types": "./dist/helpers/index.d.mts",
|
24
|
+
"import": "./dist/helpers/index.mjs",
|
25
|
+
"default": "./dist/helpers/index.mjs"
|
26
|
+
},
|
22
27
|
"./plugins": {
|
23
28
|
"types": "./dist/plugins/index.d.mts",
|
24
29
|
"import": "./dist/plugins/index.mjs",
|
@@ -96,14 +101,15 @@
|
|
96
101
|
}
|
97
102
|
},
|
98
103
|
"dependencies": {
|
99
|
-
"
|
100
|
-
"@orpc/
|
101
|
-
"@orpc/
|
102
|
-
"@orpc/standard-server
|
103
|
-
"@orpc/shared": "1.7.
|
104
|
-
"@orpc/standard-server-
|
105
|
-
"@orpc/standard-server-
|
106
|
-
"@orpc/standard-server-
|
104
|
+
"cookie": "^1.0.2",
|
105
|
+
"@orpc/client": "1.7.6",
|
106
|
+
"@orpc/contract": "1.7.6",
|
107
|
+
"@orpc/standard-server": "1.7.6",
|
108
|
+
"@orpc/shared": "1.7.6",
|
109
|
+
"@orpc/standard-server-aws-lambda": "1.7.6",
|
110
|
+
"@orpc/standard-server-fetch": "1.7.6",
|
111
|
+
"@orpc/standard-server-node": "1.7.6",
|
112
|
+
"@orpc/standard-server-peer": "1.7.6"
|
107
113
|
},
|
108
114
|
"devDependencies": {
|
109
115
|
"@types/ws": "^8.18.1",
|