@orpc/server 0.0.0-next.346e220 → 0.0.0-next.34c9217
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.d.mts +5 -5
- package/dist/adapters/aws-lambda/index.d.ts +5 -5
- package/dist/adapters/aws-lambda/index.mjs +2 -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 +54 -9
- package/dist/adapters/fetch/index.d.ts +54 -9
- package/dist/adapters/fetch/index.mjs +73 -3
- 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 +30 -9
- package/dist/adapters/node/index.d.ts +30 -9
- package/dist/adapters/node/index.mjs +68 -12
- 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/hibernation/index.d.mts +2 -2
- package/dist/hibernation/index.d.ts +2 -2
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +4 -4
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.mjs +12 -10
- package/dist/shared/{server.CYNGeoCm.d.mts → server.B4BGqy3Y.d.mts} +2 -3
- package/dist/shared/{server.CYNGeoCm.d.ts → server.B4BGqy3Y.d.ts} +2 -3
- package/dist/shared/{server.D0H-iaY3.d.ts → server.COL12UTb.d.ts} +3 -3
- package/dist/shared/{server.BEFBl-Cb.d.mts → server.CVKCo60T.d.mts} +2 -2
- package/dist/shared/{server.B_fj3X5m.mjs → server.CaqDCZX1.mjs} +29 -28
- package/dist/shared/{server.jMTkVNIb.d.ts → server.Cb6yD7DZ.d.ts} +1 -1
- package/dist/shared/{server.BU4WI18A.d.mts → server.Ck-gOLzq.d.mts} +3 -3
- package/dist/shared/{server.gqRxT-yN.d.mts → server.DBCUJijK.d.mts} +1 -1
- package/dist/shared/{server.B7b2w3_i.d.ts → server.DNtJ-p60.d.ts} +2 -2
- package/dist/shared/{server.Bmh5xd4n.d.ts → server.DPIFWpxG.d.ts} +1 -1
- package/dist/shared/{server.DhJj-1X9.d.mts → server.DzV1hr3z.d.mts} +1 -1
- package/dist/shared/{server.CYRYFTxo.mjs → server.vzZSq5UM.mjs} +1 -1
- package/package.json +11 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
|
|
1
|
+
import { isContractProcedure, validateORPCError, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
|
|
2
2
|
import { resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, asyncIteratorWithSpan } from '@orpc/shared';
|
|
3
|
-
import {
|
|
3
|
+
import { ORPCError, mapEventIterator } from '@orpc/client';
|
|
4
4
|
import { HibernationEventIterator } from '@orpc/standard-server';
|
|
5
5
|
|
|
6
6
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
@@ -88,21 +88,6 @@ function createORPCErrorConstructorMap(errors) {
|
|
|
88
88
|
});
|
|
89
89
|
return proxy;
|
|
90
90
|
}
|
|
91
|
-
async function validateORPCError(map, error) {
|
|
92
|
-
const { code, status, message, data, cause, defined } = error;
|
|
93
|
-
const config = map?.[error.code];
|
|
94
|
-
if (!config || fallbackORPCErrorStatus(error.code, config.status) !== error.status) {
|
|
95
|
-
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
|
|
96
|
-
}
|
|
97
|
-
if (!config.data) {
|
|
98
|
-
return defined ? error : new ORPCError(code, { defined: true, status, message, data, cause });
|
|
99
|
-
}
|
|
100
|
-
const validated = await config.data["~standard"].validate(error.data);
|
|
101
|
-
if (validated.issues) {
|
|
102
|
-
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
|
|
103
|
-
}
|
|
104
|
-
return new ORPCError(code, { defined: true, status, message, data: validated.value, cause });
|
|
105
|
-
}
|
|
106
91
|
|
|
107
92
|
function middlewareOutputFn(output) {
|
|
108
93
|
return { output, context: {} };
|
|
@@ -116,6 +101,12 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
116
101
|
const clientContext = callerOptions?.context ?? {};
|
|
117
102
|
const context = await value(options.context ?? {}, clientContext);
|
|
118
103
|
const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
|
|
104
|
+
const validateError = async (e) => {
|
|
105
|
+
if (e instanceof ORPCError) {
|
|
106
|
+
return await validateORPCError(procedure["~orpc"].errorMap, e);
|
|
107
|
+
}
|
|
108
|
+
return e;
|
|
109
|
+
};
|
|
119
110
|
try {
|
|
120
111
|
const output = await runWithSpan(
|
|
121
112
|
{ name: "call_procedure", signal: callerOptions?.signal },
|
|
@@ -141,18 +132,20 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
141
132
|
if (output instanceof HibernationEventIterator) {
|
|
142
133
|
return output;
|
|
143
134
|
}
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
return mapEventIterator(
|
|
136
|
+
asyncIteratorWithSpan(
|
|
137
|
+
{ name: "consume_event_iterator_output", signal: callerOptions?.signal },
|
|
138
|
+
output
|
|
139
|
+
),
|
|
140
|
+
{
|
|
141
|
+
value: (v) => v,
|
|
142
|
+
error: (e) => validateError(e)
|
|
143
|
+
}
|
|
147
144
|
);
|
|
148
145
|
}
|
|
149
146
|
return output;
|
|
150
147
|
} catch (e) {
|
|
151
|
-
|
|
152
|
-
throw e;
|
|
153
|
-
}
|
|
154
|
-
const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
|
|
155
|
-
throw validated;
|
|
148
|
+
throw await validateError(e);
|
|
156
149
|
}
|
|
157
150
|
};
|
|
158
151
|
}
|
|
@@ -171,7 +164,11 @@ async function validateInput(procedure, input) {
|
|
|
171
164
|
data: {
|
|
172
165
|
issues: result.issues
|
|
173
166
|
},
|
|
174
|
-
cause: new ValidationError({
|
|
167
|
+
cause: new ValidationError({
|
|
168
|
+
message: "Input validation failed",
|
|
169
|
+
issues: result.issues,
|
|
170
|
+
data: input
|
|
171
|
+
})
|
|
175
172
|
});
|
|
176
173
|
}
|
|
177
174
|
return result.value;
|
|
@@ -190,7 +187,11 @@ async function validateOutput(procedure, output) {
|
|
|
190
187
|
if (result.issues) {
|
|
191
188
|
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
192
189
|
message: "Output validation failed",
|
|
193
|
-
cause: new ValidationError({
|
|
190
|
+
cause: new ValidationError({
|
|
191
|
+
message: "Output validation failed",
|
|
192
|
+
issues: result.issues,
|
|
193
|
+
data: output
|
|
194
|
+
})
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
197
|
return result.value;
|
|
@@ -405,4 +406,4 @@ function call(procedure, input, ...rest) {
|
|
|
405
406
|
return createProcedureClient(procedure, options)(input, options);
|
|
406
407
|
}
|
|
407
408
|
|
|
408
|
-
export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u,
|
|
409
|
+
export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, resolveContractProcedures as v, unlazyRouter as w };
|
|
@@ -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.B4BGqy3Y.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> & {
|
|
@@ -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.B4BGqy3Y.mjs';
|
|
3
|
+
import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.DBCUJijK.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.DzV1hr3z.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.B4BGqy3Y.mjs';
|
|
6
6
|
|
|
7
7
|
interface StandardHandlerPlugin<T extends Context> {
|
|
8
8
|
order?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Context } from './server.
|
|
2
|
-
import { b as StandardHandleOptions } from './server.
|
|
1
|
+
import { C as Context } from './server.B4BGqy3Y.js';
|
|
2
|
+
import { b as StandardHandleOptions } from './server.DPIFWpxG.js';
|
|
3
3
|
|
|
4
4
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
5
5
|
context?: T;
|
|
@@ -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.B4BGqy3Y.js';
|
|
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.B4BGqy3Y.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> & {
|
|
@@ -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.CaqDCZX1.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.34c9217",
|
|
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/client": "0.0.0-next.
|
|
106
|
-
"@orpc/
|
|
107
|
-
"@orpc/
|
|
108
|
-
"@orpc/
|
|
109
|
-
"@orpc/standard-server
|
|
110
|
-
"@orpc/standard-server-
|
|
111
|
-
"@orpc/standard-server-
|
|
112
|
-
"@orpc/standard-server-node": "0.0.0-next.
|
|
105
|
+
"@orpc/client": "0.0.0-next.34c9217",
|
|
106
|
+
"@orpc/interop": "0.0.0-next.34c9217",
|
|
107
|
+
"@orpc/contract": "0.0.0-next.34c9217",
|
|
108
|
+
"@orpc/shared": "0.0.0-next.34c9217",
|
|
109
|
+
"@orpc/standard-server": "0.0.0-next.34c9217",
|
|
110
|
+
"@orpc/standard-server-aws-lambda": "0.0.0-next.34c9217",
|
|
111
|
+
"@orpc/standard-server-fetch": "0.0.0-next.34c9217",
|
|
112
|
+
"@orpc/standard-server-node": "0.0.0-next.34c9217",
|
|
113
|
+
"@orpc/standard-server-peer": "0.0.0-next.34c9217"
|
|
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.2",
|
|
118
119
|
"supertest": "^7.1.4",
|
|
119
120
|
"ws": "^8.18.3"
|
|
120
121
|
},
|