@orpc/server 2.0.0-beta.2 → 2.0.0-beta.21
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 +32 -21
- package/dist/adapters/crossws/index.d.mts +11 -8
- package/dist/adapters/crossws/index.d.ts +11 -8
- package/dist/adapters/crossws/index.mjs +10 -7
- package/dist/adapters/fetch/index.d.mts +8 -56
- package/dist/adapters/fetch/index.d.ts +8 -56
- package/dist/adapters/fetch/index.mjs +6 -136
- package/dist/adapters/message-port/index.d.mts +11 -13
- package/dist/adapters/message-port/index.d.ts +11 -13
- package/dist/adapters/message-port/index.mjs +28 -32
- package/dist/adapters/node/index.d.mts +7 -37
- package/dist/adapters/node/index.d.ts +7 -37
- package/dist/adapters/node/index.mjs +6 -112
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/standard-peer/index.d.mts +2 -2
- package/dist/adapters/standard-peer/index.d.ts +2 -2
- package/dist/adapters/websocket/index.d.mts +36 -26
- package/dist/adapters/websocket/index.d.ts +36 -26
- package/dist/adapters/websocket/index.mjs +33 -25
- package/dist/extensions/callable.d.mts +1 -1
- package/dist/extensions/callable.d.ts +1 -1
- package/dist/extensions/callable.mjs +2 -2
- package/dist/helpers/index.d.mts +3 -3
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/index.mjs +13 -5
- package/dist/index.d.mts +19 -16
- package/dist/index.d.ts +19 -16
- package/dist/index.mjs +36 -22
- package/dist/plugins/index.d.mts +136 -5
- package/dist/plugins/index.d.ts +136 -5
- package/dist/plugins/index.mjs +394 -6
- package/dist/shared/{server.BsNNjG5J.d.mts → server.15O7oC1p.d.mts} +1 -1
- package/dist/shared/{server.B_U9y00a.d.mts → server.B4BnEWWm.d.mts} +6 -5
- package/dist/shared/{server.EOHJ3NJr.d.ts → server.BhsVw7m7.d.ts} +2 -2
- package/dist/shared/{server.BwHnWUuN.mjs → server.BoiFpNT7.mjs} +4 -2
- package/dist/shared/{server.GDpX6Df8.mjs → server.COPVXhDG.mjs} +3 -3
- package/dist/shared/{server.BL22TloH.d.mts → server.CcR4kgje.d.mts} +25 -3
- package/dist/shared/{server.BL22TloH.d.ts → server.CcR4kgje.d.ts} +25 -3
- package/dist/shared/{server.T9F3bzZx.d.ts → server.CnN50DHH.d.ts} +6 -5
- package/dist/shared/{server.CjOb6ItT.mjs → server.DBs0rrf9.mjs} +1 -1
- package/dist/shared/{server.BB_Ik9Ph.d.mts → server.DDFizwfU.d.mts} +2 -2
- package/dist/shared/{server.CrlKQucM.mjs → server.DofEOwf-.mjs} +11 -7
- package/dist/shared/{server.Pa0F03f_.d.ts → server.m3szVJGU.d.ts} +1 -1
- package/package.json +9 -10
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RPCSerializer, AnyORPCError } from '@orpc/client';
|
|
2
2
|
import { Value, Promisable } from '@orpc/shared';
|
|
3
3
|
import { StandardMethod, StandardLazyRequest, StandardResponse } from '@standardserver/core';
|
|
4
|
-
import { A as AnyProcedure, C as Context } from './server.
|
|
5
|
-
import { A as AnyRouter } from './server.
|
|
4
|
+
import { A as AnyProcedure, C as Context } from './server.CcR4kgje.js';
|
|
5
|
+
import { A as AnyRouter } from './server.m3szVJGU.js';
|
|
6
6
|
import { AnyProcedureContract } from '@orpc/contract';
|
|
7
|
-
import { b as StandardHandlerHandleOptions, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure } from './server.
|
|
7
|
+
import { b as StandardHandlerHandleOptions, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure } from './server.BhsVw7m7.js';
|
|
8
8
|
|
|
9
9
|
interface RPCMatcherOptions {
|
|
10
10
|
/**
|
|
@@ -38,14 +38,15 @@ interface RPCHandlerCodecOptions<T extends Context> extends RPCMatcherOptions {
|
|
|
38
38
|
/**
|
|
39
39
|
* Resolve HTTP status for encoded successful outputs.
|
|
40
40
|
*
|
|
41
|
-
* Value should be in range `
|
|
41
|
+
* Value should be in the `2xx` range and must be less than `400`.
|
|
42
42
|
* Return `undefined` or `null` to fallback to default
|
|
43
43
|
*
|
|
44
|
-
* @default
|
|
44
|
+
* @default DEFAULT_SUCCESS_STATUS (200)
|
|
45
45
|
*/
|
|
46
46
|
outputStatus?: Value<number | undefined | null, [output: unknown, procedure: AnyProcedure, path: string[], options: StandardHandlerHandleOptions<T>]>;
|
|
47
47
|
/**
|
|
48
48
|
* Mapping ORPCError Code -> HTTP Status Code
|
|
49
|
+
* The status code should be in the `4xx` or `5xx` range (must be greater than or equal to `400`).
|
|
49
50
|
*
|
|
50
51
|
* @default COMMON_ERROR_STATUS_MAP
|
|
51
52
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveMetaPlugins, mergeErrorMap, getHiddenMetaPlugins } from '@orpc/contract';
|
|
2
|
-
import { P as Procedure } from './server.
|
|
2
|
+
import { P as Procedure } from './server.DofEOwf-.mjs';
|
|
3
3
|
|
|
4
4
|
class DecoratedProcedure extends Procedure {
|
|
5
5
|
meta(...plugins) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyORPCError } from '@orpc/client';
|
|
2
2
|
import { OrderablePlugin, Interceptor, Promisable } from '@orpc/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@standardserver/core';
|
|
4
|
-
import { C as Context, c as ProcedureClientInterceptor, A as AnyProcedure } from './server.
|
|
4
|
+
import { C as Context, c as ProcedureClientInterceptor, A as AnyProcedure } from './server.CcR4kgje.mjs';
|
|
5
5
|
import { Schema, ErrorMap } from '@orpc/contract';
|
|
6
6
|
|
|
7
7
|
interface StandardHandlerPlugin<T extends Context> extends OrderablePlugin {
|
|
@@ -101,4 +101,4 @@ interface StandardHandlerCodec<T extends Context> {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export { CompositeStandardHandlerPlugin as C, OtelHandlerPlugin as O, StandardHandler as S };
|
|
104
|
-
export type { StandardHandlerOptions as a, StandardHandlerHandleOptions as b, StandardHandlerCodec as c, StandardHandlerCodecResolvedProcedure as d, StandardHandlerPlugin as e, StandardHandlerRoutingInterceptorOptions as f,
|
|
104
|
+
export type { StandardHandlerOptions as a, StandardHandlerHandleOptions as b, StandardHandlerCodec as c, StandardHandlerCodecResolvedProcedure as d, StandardHandlerPlugin as e, StandardHandlerRoutingInterceptorOptions as f, StandardHandlerInterceptorOptions as g, StandardHandlerHandleResult as h, StandardHandlerInterceptor as i, StandardHandlerRoutingInterceptor as j };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ORPCError,
|
|
1
|
+
import { ORPCError, wrapAsyncIteratorPreservingEventMeta, cloneORPCError } from '@orpc/client';
|
|
2
2
|
import { reconcileORPCError, ValidationError, ProcedureContract } from '@orpc/contract';
|
|
3
3
|
import { getOrBind, resolveMaybeOptionalOptions, getConstructor, isTypescriptObject, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, override, traceAsyncIterator, traceReadableStream } from '@orpc/shared';
|
|
4
4
|
|
|
@@ -84,8 +84,8 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
84
84
|
);
|
|
85
85
|
});
|
|
86
86
|
if (isAsyncIteratorObject(output)) {
|
|
87
|
-
return override(output,
|
|
88
|
-
traceAsyncIterator("
|
|
87
|
+
return override(output, wrapAsyncIteratorPreservingEventMeta(
|
|
88
|
+
traceAsyncIterator("consume_async_iterator_object_output", output),
|
|
89
89
|
{ mapError: reconcileError }
|
|
90
90
|
));
|
|
91
91
|
}
|
|
@@ -151,8 +151,10 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
151
151
|
let currentInput = input;
|
|
152
152
|
const startInputIndex = midIndex === 0 ? 0 : orderedMiddlewares[midIndex - 1].inputSchemasLengthAtUse ?? 0;
|
|
153
153
|
const endInputIndex = midIndex === orderedMiddlewares.length ? inputSchemas.length : orderedMiddlewares[midIndex].inputSchemasLengthAtUse ?? 0;
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
if (!procedure["~orpc"].disableInputValidation) {
|
|
155
|
+
for (let i = startInputIndex; i < endInputIndex; i++) {
|
|
156
|
+
currentInput = await validateInput(i, inputSchemas[i], currentInput);
|
|
157
|
+
}
|
|
156
158
|
}
|
|
157
159
|
let currentOutput;
|
|
158
160
|
let currentContext = context;
|
|
@@ -201,8 +203,10 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
201
203
|
}
|
|
202
204
|
const startOutputIndex = midIndex === 0 ? 0 : orderedMiddlewares[midIndex - 1].outputSchemasLengthAtUse ?? 0;
|
|
203
205
|
const endOutputIndex = midIndex === orderedMiddlewares.length ? outputSchemas.length : orderedMiddlewares[midIndex].outputSchemasLengthAtUse ?? 0;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
if (!procedure["~orpc"].disableOutputValidation) {
|
|
207
|
+
for (let i = endOutputIndex - 1; i >= startOutputIndex; i--) {
|
|
208
|
+
currentOutput = await validateOutput(i, outputSchemas[i], currentOutput);
|
|
209
|
+
}
|
|
206
210
|
}
|
|
207
211
|
return { output: currentOutput, context: currentContext };
|
|
208
212
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RouterContract, ProcedureContract, ORPCErrorFromErrorMap, ThrowableError, InferSchemaInput, InferSchemaOutput } from '@orpc/contract';
|
|
2
|
-
import { C as Context, a as Procedure, L as Lazyable, M as MergedContext } from './server.
|
|
2
|
+
import { C as Context, a as Procedure, L as Lazyable, M as MergedContext } from './server.CcR4kgje.js';
|
|
3
3
|
|
|
4
4
|
type Router<TInitialContext extends Context> = Procedure<TInitialContext, any, any, any, any, any> | {
|
|
5
5
|
[k: string]: Lazyable<Router<TInitialContext>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.21",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -85,15 +85,14 @@
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@standardserver/core": "^0.0
|
|
89
|
-
"@standardserver/fetch": "^0.0
|
|
90
|
-
"@standardserver/node": "^0.0
|
|
91
|
-
"@standardserver/peer": "^0.0
|
|
92
|
-
"cookie": "^
|
|
93
|
-
"@orpc/
|
|
94
|
-
"@orpc/
|
|
95
|
-
"@orpc/
|
|
96
|
-
"@orpc/client": "2.0.0-beta.2"
|
|
88
|
+
"@standardserver/core": "^0.5.0",
|
|
89
|
+
"@standardserver/fetch": "^0.5.0",
|
|
90
|
+
"@standardserver/node": "^0.5.0",
|
|
91
|
+
"@standardserver/peer": "^0.5.0",
|
|
92
|
+
"cookie": "^2.0.1",
|
|
93
|
+
"@orpc/client": "2.0.0-beta.21",
|
|
94
|
+
"@orpc/shared": "2.0.0-beta.21",
|
|
95
|
+
"@orpc/contract": "2.0.0-beta.21"
|
|
97
96
|
},
|
|
98
97
|
"devDependencies": {
|
|
99
98
|
"crossws": "^0.4.6",
|