@orpc/server 2.0.0-beta.43 → 2.0.0-beta.45
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 +56 -57
- package/dist/adapters/aws-lambda/index.mjs +2 -2
- package/dist/adapters/crossws/index.mjs +2 -2
- package/dist/adapters/fastify/index.mjs +2 -2
- package/dist/adapters/fetch/index.d.mts +2 -2
- package/dist/adapters/fetch/index.d.ts +2 -2
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/message-port/index.d.mts +1 -1
- package/dist/adapters/message-port/index.d.ts +1 -1
- package/dist/adapters/message-port/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +10 -8
- package/dist/adapters/standard/index.d.ts +10 -8
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/helpers/index.d.mts +2 -1
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.mjs +3 -9
- package/dist/index.d.mts +14 -7
- package/dist/index.d.ts +14 -7
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.d.mts +64 -55
- package/dist/plugins/index.d.ts +64 -55
- package/dist/plugins/index.mjs +232 -146
- package/dist/shared/{server.BllfVJLm.d.mts → server.B4hFgqPr.d.mts} +2 -2
- package/dist/shared/{server.BEdOJs6S.d.mts → server.BWhT-63L.d.mts} +5 -5
- package/dist/shared/{server.BEdOJs6S.d.ts → server.BWhT-63L.d.ts} +5 -5
- package/dist/shared/{server.CVO0hWyj.d.mts → server.BYNQ06wN.d.ts} +5 -5
- package/dist/shared/{server.BgvqVW_v.mjs → server.BcxD3fmU.mjs} +15 -3
- package/dist/shared/{server.COfbQ0D8.d.ts → server.CI0qiBzm.d.ts} +2 -2
- package/dist/shared/{server.DFEuNUt4.d.ts → server.CO_upro1.d.ts} +3 -3
- package/dist/shared/{server.DZeVx8K9.d.ts → server.DcDZdSrg.d.ts} +1 -1
- package/dist/shared/{server.UG_xdTub.d.mts → server.DgcwQ-Wr.d.mts} +3 -3
- package/dist/shared/{server.B1ecixZJ.mjs → server.Kbq-C85k.mjs} +7 -20
- package/dist/shared/{server.DJNkZPfD.d.ts → server.TVSii8T9.d.mts} +5 -5
- package/dist/shared/{server.DD1roZl9.d.mts → server.TjEHK8V3.d.mts} +1 -1
- package/package.json +15 -15
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
2
|
import { StandardLazyRequest } from '@standard-server/core';
|
|
3
|
-
import { C as Context } from './server.
|
|
4
|
-
import { a as StandardHandlerHandleOptions } from './server.
|
|
3
|
+
import { C as Context } from './server.BWhT-63L.mjs';
|
|
4
|
+
import { a as StandardHandlerHandleOptions } from './server.TVSii8T9.mjs';
|
|
5
5
|
|
|
6
6
|
type FriendlyStandardHandlerHandleOptions<T extends Context> = Omit<StandardHandlerHandleOptions<T>, 'context'> & (object extends T ? {
|
|
7
|
-
context?: Value<Promisable<T>, [request: StandardLazyRequest]
|
|
7
|
+
context?: Value<Promisable<T>, [request: StandardLazyRequest]> | undefined;
|
|
8
8
|
} : {
|
|
9
9
|
context: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
10
10
|
});
|
|
@@ -2,7 +2,7 @@ import { ORPCError, toORPCError, RPCSerializer, COMMON_ERROR_STATUS_MAP } from '
|
|
|
2
2
|
import { sortPlugins, toArray, matchesHttpPathPrefix, value, intercept, getTracer, runWithSpan, ORPC_NAME, isAsyncIteratorObject, override, traceAsyncIterator, traceReadableStream, recordSpanError, wrapAsyncIterator, toTracingException, wrapReadableStream, pathToHttpPath, normalizeHttpPath, parseEmptyableJSON, getOwn } from '@orpc/shared';
|
|
3
3
|
import { flattenStandardHeader, parseStandardUrl, ErrorEvent } from '@standard-server/core';
|
|
4
4
|
import { c as createProcedureClient, u as unlazy, P as Procedure } from './server.FEqy7Hrj.mjs';
|
|
5
|
-
import { w as walkProcedureContractsSync,
|
|
5
|
+
import { w as walkProcedureContractsSync, r as resolveContractProcedure, D as DEFAULT_SUCCESS_STATUS, a as DEFAULT_ERROR_STATUS } from './server.BcxD3fmU.mjs';
|
|
6
6
|
|
|
7
7
|
class CompositeStandardHandlerPlugin {
|
|
8
8
|
name = "~composite";
|
|
@@ -191,6 +191,8 @@ class RPCMatcher {
|
|
|
191
191
|
rootRouter;
|
|
192
192
|
tree = /* @__PURE__ */ new Map();
|
|
193
193
|
pendingLazyRouters = /* @__PURE__ */ new Map();
|
|
194
|
+
/** segment count of the deepest pending key, never lowered so it stays an upper bound */
|
|
195
|
+
maxPendingLazyRouterDepth = 0;
|
|
194
196
|
constructor(router, options = {}) {
|
|
195
197
|
this.filter = options.filter ?? true;
|
|
196
198
|
const allowMethods = options.allowMethods ?? RPC_DEFAULT_ALLOW_METHODS;
|
|
@@ -216,6 +218,7 @@ class RPCMatcher {
|
|
|
216
218
|
}, path);
|
|
217
219
|
for (const result of lazyResults) {
|
|
218
220
|
this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
|
|
221
|
+
this.maxPendingLazyRouterDepth = Math.max(this.maxPendingLazyRouterDepth, result.path.length);
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
async match(method, pathname, prefix) {
|
|
@@ -270,22 +273,12 @@ class RPCMatcher {
|
|
|
270
273
|
return;
|
|
271
274
|
}
|
|
272
275
|
let slashIndex = 0;
|
|
273
|
-
|
|
274
|
-
const nextSlashIndex = pathname.indexOf("/", slashIndex + 1);
|
|
275
|
-
const httpPathPrefix = nextSlashIndex === -1 ? pathname : pathname.slice(0, nextSlashIndex);
|
|
276
|
-
if (this.pendingLazyRouters.has(httpPathPrefix)) {
|
|
277
|
-
return this.loadPendingLazyRouters(pathname, slashIndex);
|
|
278
|
-
}
|
|
279
|
-
slashIndex = nextSlashIndex;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
async loadPendingLazyRouters(pathname, slashIndex) {
|
|
283
|
-
while (slashIndex !== -1) {
|
|
276
|
+
for (let depth = 1; slashIndex !== -1 && depth <= this.maxPendingLazyRouterDepth; depth++) {
|
|
284
277
|
const nextSlashIndex = pathname.indexOf("/", slashIndex + 1);
|
|
285
278
|
const httpPathPrefix = nextSlashIndex === -1 ? pathname : pathname.slice(0, nextSlashIndex);
|
|
286
279
|
const pending = this.pendingLazyRouters.get(httpPathPrefix);
|
|
287
280
|
if (pending !== void 0) {
|
|
288
|
-
|
|
281
|
+
return this.loadPendingLazyRouter(httpPathPrefix, pending).then(() => this.resolvePendingLazyRouters(pathname));
|
|
289
282
|
}
|
|
290
283
|
slashIndex = nextSlashIndex;
|
|
291
284
|
}
|
|
@@ -305,13 +298,7 @@ class RPCMatcher {
|
|
|
305
298
|
this.pendingLazyRouters.delete(httpPathPrefix);
|
|
306
299
|
}
|
|
307
300
|
async resolveProcedure(entry) {
|
|
308
|
-
|
|
309
|
-
if (!(maybeProcedure instanceof Procedure)) {
|
|
310
|
-
throw new TypeError(
|
|
311
|
-
`[Contract-First] Missing or invalid implementation for procedure at path: "${entry.path.join(".")}". Ensure the procedure is correctly implemented and matches its contract.`
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
entry.procedure = createContractProcedure(maybeProcedure, entry.contract);
|
|
301
|
+
entry.procedure = await resolveContractProcedure(this.rootRouter, entry.contract, entry.path);
|
|
315
302
|
return entry.procedure;
|
|
316
303
|
}
|
|
317
304
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyORPCError } from '@orpc/client';
|
|
2
2
|
import { OrderablePlugin, Value, Promisable, Interceptor } from '@orpc/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/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.BWhT-63L.mjs';
|
|
5
5
|
import { Schema, ErrorMap } from '@orpc/contract';
|
|
6
6
|
|
|
7
7
|
interface StandardHandlerPlugin<T extends Context> extends OrderablePlugin {
|
|
@@ -73,19 +73,19 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
|
73
73
|
* - batch plugins - separate one request into multiple and call multiple next
|
|
74
74
|
* - openapi spec plugin - to intercept a request and early response
|
|
75
75
|
*/
|
|
76
|
-
routingInterceptors?: StandardHandlerRoutingInterceptor<TContext>[];
|
|
76
|
+
routingInterceptors?: StandardHandlerRoutingInterceptor<TContext>[] | undefined;
|
|
77
77
|
/**
|
|
78
78
|
* interceptor run after routing and before error handler,
|
|
79
79
|
* useful for error handling, logging, metrics, etc.
|
|
80
80
|
*/
|
|
81
|
-
interceptors?: StandardHandlerInterceptor<TContext>[];
|
|
81
|
+
interceptors?: StandardHandlerInterceptor<TContext>[] | undefined;
|
|
82
82
|
/**
|
|
83
83
|
*
|
|
84
84
|
* ClientInterceptor equivalent with createRouterClient.interceptors / createProcedure.interceptors
|
|
85
85
|
* useful for error handling, logging, metrics, etc. (not counting encoding/decoding)
|
|
86
86
|
*/
|
|
87
|
-
clientInterceptors?: ProcedureClientInterceptor<TContext, Schema<unknown>, ErrorMap>[];
|
|
88
|
-
plugins?: StandardHandlerPlugin<TContext>[];
|
|
87
|
+
clientInterceptors?: ProcedureClientInterceptor<TContext, Schema<unknown>, ErrorMap>[] | undefined;
|
|
88
|
+
plugins?: StandardHandlerPlugin<TContext>[] | undefined;
|
|
89
89
|
}
|
|
90
90
|
declare class StandardHandler<T extends Context> {
|
|
91
91
|
private readonly codec;
|
|
@@ -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.BWhT-63L.mjs';
|
|
3
3
|
|
|
4
4
|
type Router<TInitialContext extends Context> = Procedure<TInitialContext, 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.45",
|
|
5
5
|
"description": "Build typesafe APIs with oRPC: RPC and OpenAPI support, middleware, and adapters for Node.js, Bun, Deno, Fetch, Fastify, WebSocket, AWS Lambda, and more",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -117,23 +117,23 @@
|
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@orpc/client": "2.0.0-beta.
|
|
121
|
-
"@orpc/contract": "2.0.0-beta.
|
|
122
|
-
"@orpc/shared": "2.0.0-beta.
|
|
123
|
-
"@standard-server/aws-lambda": "~0.
|
|
124
|
-
"@standard-server/core": "~0.
|
|
125
|
-
"@standard-server/fastify": "~0.
|
|
126
|
-
"@standard-server/fetch": "~0.
|
|
127
|
-
"@standard-server/node": "~0.
|
|
128
|
-
"@standard-server/peer": "~0.
|
|
120
|
+
"@orpc/client": "2.0.0-beta.45",
|
|
121
|
+
"@orpc/contract": "2.0.0-beta.45",
|
|
122
|
+
"@orpc/shared": "2.0.0-beta.45",
|
|
123
|
+
"@standard-server/aws-lambda": "~0.11.0",
|
|
124
|
+
"@standard-server/core": "~0.11.0",
|
|
125
|
+
"@standard-server/fastify": "~0.11.0",
|
|
126
|
+
"@standard-server/fetch": "~0.11.0",
|
|
127
|
+
"@standard-server/node": "~0.11.0",
|
|
128
|
+
"@standard-server/peer": "~0.11.0",
|
|
129
129
|
"cookie": "^2.0.1"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
|
-
"crossws": "^0.4.
|
|
133
|
-
"fastify": "^5.12.
|
|
134
|
-
"supertest": "^7.
|
|
135
|
-
"ws": "^8.
|
|
136
|
-
"zod": "^4.
|
|
132
|
+
"crossws": "^0.4.15",
|
|
133
|
+
"fastify": "^5.12.7",
|
|
134
|
+
"supertest": "^7.3.1",
|
|
135
|
+
"ws": "^8.22.0",
|
|
136
|
+
"zod": "^4.6.7"
|
|
137
137
|
},
|
|
138
138
|
"scripts": {
|
|
139
139
|
"type:check": "tsc -b"
|