@orpc/server 2.0.0-beta.34 → 2.0.0-beta.36
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 +30 -20
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/crossws/index.d.mts +2 -2
- package/dist/adapters/crossws/index.d.ts +2 -2
- package/dist/adapters/crossws/index.mjs +5 -4
- package/dist/adapters/fastify/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.d.ts +1 -1
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/message-port/index.d.mts +3 -3
- package/dist/adapters/message-port/index.d.ts +3 -3
- package/dist/adapters/message-port/index.mjs +5 -4
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +91 -17
- package/dist/adapters/standard/index.d.ts +91 -17
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/standard-peer/index.d.mts +4 -9
- package/dist/adapters/standard-peer/index.d.ts +4 -9
- package/dist/adapters/standard-peer/index.mjs +10 -2
- package/dist/adapters/websocket/index.d.mts +3 -3
- package/dist/adapters/websocket/index.d.ts +3 -3
- package/dist/adapters/websocket/index.mjs +5 -4
- package/dist/extensions/callable.mjs +2 -2
- package/dist/index.mjs +7 -9
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/index.mjs +3 -3
- package/dist/shared/{server.BNfuzVqH.mjs → server.24nXyhbl.mjs} +1 -1
- package/dist/shared/{server.BrURRtO7.d.mts → server.B5K1CViq.d.mts} +21 -10
- package/dist/shared/{server.gXC5UaAH.mjs → server.BynNaBBA.mjs} +8 -10
- package/dist/shared/{server.CGQ3M7fX.d.mts → server.C7xllBNN.d.mts} +1 -1
- package/dist/shared/server.CFqSIFnT.d.mts +14 -0
- package/dist/shared/{server.D23TTT5i.d.ts → server.Cxranw-8.d.ts} +21 -10
- package/dist/shared/{server.C-hqoApz.d.ts → server.D0dr-F8u.d.ts} +1 -1
- package/dist/shared/{server.CDOFCg6A.mjs → server.Djb_ebJT.mjs} +3 -4
- package/dist/shared/server.RRVK1xTV.d.ts +14 -0
- package/dist/shared/{server.ozO1TILY.mjs → server.vUIzQiOP.mjs} +82 -21
- package/package.json +4 -4
- package/dist/shared/server.ByvwIMbH.d.mts +0 -91
- package/dist/shared/server.CAmrY_mX.d.ts +0 -91
- package/dist/shared/server.CX4vUnDk.mjs +0 -11
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { Value, Promisable } from '@orpc/shared';
|
|
2
1
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
|
|
3
2
|
import { Context } from '../../index.js';
|
|
4
|
-
import {
|
|
3
|
+
import { StandardHandler } from '../standard/index.js';
|
|
4
|
+
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
+
import '@orpc/shared';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
context?: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
10
|
-
} : {
|
|
11
|
-
context: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
12
|
-
});
|
|
13
|
-
declare function createStandardPeerRequestHandler<T extends Context>(handler: StandardHandler<T>, options: StandardPeerRequestHandlerOptions<T>): (request: StandardLazyRequest) => Promise<StandardResponse>;
|
|
9
|
+
declare function createStandardPeerRequestHandler<T extends Context>(handler: StandardHandler<T>, options: FriendlyStandardHandlerHandleOptions<T>): (request: StandardLazyRequest) => Promise<StandardResponse>;
|
|
14
10
|
|
|
15
11
|
export { createStandardPeerRequestHandler };
|
|
16
|
-
export type { StandardPeerRequestHandlerOptions };
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
|
|
2
|
+
|
|
3
|
+
function createStandardPeerRequestHandler(handler, options) {
|
|
4
|
+
return async (request) => {
|
|
5
|
+
const { response } = await handler.handle(request, resolveFriendlyStandardHandlerHandleOptions(options));
|
|
6
|
+
return response ?? { status: 404, headers: {}, body: "No procedure matched" };
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { createStandardPeerRequestHandler };
|
|
@@ -2,7 +2,7 @@ import { Arrayable, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
2
2
|
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
3
3
|
import { Context } from '../../index.mjs';
|
|
4
4
|
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
6
6
|
import { Router } from '../../index.mjs';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
8
8
|
import '@orpc/client';
|
|
@@ -44,7 +44,7 @@ declare class WebSocketHandler<T extends Context> {
|
|
|
44
44
|
* @param ws The WebSocket instance. Use the same instance for all messages.
|
|
45
45
|
* @param data The received message. Binary data should already be loaded (not a `Blob`).
|
|
46
46
|
*/
|
|
47
|
-
message(ws: WebSocketLike, data: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>, ...rest: MaybeOptionalOptions<
|
|
47
|
+
message(ws: WebSocketLike, data: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<{
|
|
48
48
|
matched: boolean;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
@@ -58,7 +58,7 @@ declare class WebSocketHandler<T extends Context> {
|
|
|
58
58
|
*
|
|
59
59
|
* Prefer this over calling `.message()` and `.close()` manually.
|
|
60
60
|
*/
|
|
61
|
-
upgrade(ws: Pick<WebSocket, 'send' | 'addEventListener' | 'removeEventListener'>, ...rest: MaybeOptionalOptions<
|
|
61
|
+
upgrade(ws: Pick<WebSocket, 'send' | 'addEventListener' | 'removeEventListener'>, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): void;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, WebSocketHandlerOptions<T> {
|
|
@@ -2,7 +2,7 @@ import { Arrayable, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
2
2
|
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
3
3
|
import { Context } from '../../index.js';
|
|
4
4
|
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
6
6
|
import { Router } from '../../index.js';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
8
8
|
import '@orpc/client';
|
|
@@ -44,7 +44,7 @@ declare class WebSocketHandler<T extends Context> {
|
|
|
44
44
|
* @param ws The WebSocket instance. Use the same instance for all messages.
|
|
45
45
|
* @param data The received message. Binary data should already be loaded (not a `Blob`).
|
|
46
46
|
*/
|
|
47
|
-
message(ws: WebSocketLike, data: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>, ...rest: MaybeOptionalOptions<
|
|
47
|
+
message(ws: WebSocketLike, data: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<{
|
|
48
48
|
matched: boolean;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
@@ -58,7 +58,7 @@ declare class WebSocketHandler<T extends Context> {
|
|
|
58
58
|
*
|
|
59
59
|
* Prefer this over calling `.message()` and `.close()` manually.
|
|
60
60
|
*/
|
|
61
|
-
upgrade(ws: Pick<WebSocket, 'send' | 'addEventListener' | 'removeEventListener'>, ...rest: MaybeOptionalOptions<
|
|
61
|
+
upgrade(ws: Pick<WebSocket, 'send' | 'addEventListener' | 'removeEventListener'>, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): void;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, WebSocketHandlerOptions<T> {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { toStringOrBytes, resolveMaybeOptionalOptions, sequential, loadBytes } from '@orpc/shared';
|
|
2
2
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage } from '@standard-server/peer';
|
|
3
|
-
import {
|
|
4
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
3
|
+
import { createStandardPeerRequestHandler } from '../standard-peer/index.mjs';
|
|
4
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.vUIzQiOP.mjs';
|
|
5
|
+
import '../../shared/server.W91HSRkE.mjs';
|
|
5
6
|
import '@orpc/client';
|
|
6
7
|
import '@standard-server/core';
|
|
7
|
-
import '../../shared/server.
|
|
8
|
+
import '../../shared/server.Djb_ebJT.mjs';
|
|
8
9
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.BynNaBBA.mjs';
|
|
10
11
|
|
|
11
12
|
class WebSocketHandler {
|
|
12
13
|
constructor(handler, options = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createProcedureClient } from '../shared/server.
|
|
2
|
-
import { D as DecoratedProcedure } from '../shared/server.
|
|
1
|
+
import { c as createProcedureClient } from '../shared/server.Djb_ebJT.mjs';
|
|
2
|
+
import { D as DecoratedProcedure } from '../shared/server.24nXyhbl.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/contract';
|
|
5
5
|
import '@orpc/shared';
|
package/dist/index.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import { mergeErrorMap, resolveMetaPlugins, getHiddenMetaPlugins, ProcedureContr
|
|
|
2
2
|
export { ValidationError, asyncIteratorObject, defineMeta, error, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
3
3
|
import { toArray, bindMethods, isTypescriptObject, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
5
|
-
import { L as Lazy, P as Procedure, c as createProcedureClient } from './shared/server.
|
|
6
|
-
export { u as unlazy } from './shared/server.
|
|
7
|
-
import { D as DecoratedProcedure } from './shared/server.
|
|
8
|
-
import { b as augmentRouter, d as augmentImplementedRouter, e as withHiddenRouterContract, f as createGuardedProcedureLazy, g as getRouter } from './shared/server.
|
|
9
|
-
export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS, h as call, c as createContractProcedure, i as getHiddenRouterContract, u as unlazyRouter, j as walkProcedureContractsAsync, w as walkProcedureContractsSync } from './shared/server.
|
|
5
|
+
import { L as Lazy, P as Procedure, c as createProcedureClient } from './shared/server.Djb_ebJT.mjs';
|
|
6
|
+
export { u as unlazy } from './shared/server.Djb_ebJT.mjs';
|
|
7
|
+
import { D as DecoratedProcedure } from './shared/server.24nXyhbl.mjs';
|
|
8
|
+
import { b as augmentRouter, d as augmentImplementedRouter, e as withHiddenRouterContract, f as createGuardedProcedureLazy, g as getRouter } from './shared/server.BynNaBBA.mjs';
|
|
9
|
+
export { a as DEFAULT_ERROR_STATUS, D as DEFAULT_SUCCESS_STATUS, h as call, c as createContractProcedure, i as getHiddenRouterContract, u as unlazyRouter, j as walkProcedureContractsAsync, w as walkProcedureContractsSync } from './shared/server.BynNaBBA.mjs';
|
|
10
10
|
import { RECURSIVE_CLIENT_UNWRAP_KEYS } from '@orpc/client';
|
|
11
11
|
export { COMMON_ERROR_STATUS_MAP, ORPCError, RPCJsonSerializer, RPCSerializer, cloneORPCError, isDefinedError, safe, toORPCError } from '@orpc/client';
|
|
12
12
|
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
@@ -388,13 +388,11 @@ function createRouterImplementerInternal(contract, config, middlewares) {
|
|
|
388
388
|
});
|
|
389
389
|
}
|
|
390
390
|
const implementer = {};
|
|
391
|
-
for (const key
|
|
392
|
-
const child = contract[key];
|
|
391
|
+
for (const [key, child] of Object.entries(contract)) {
|
|
393
392
|
implementer[key] = createRouterImplementerInternal(child, config, middlewares);
|
|
394
393
|
}
|
|
395
394
|
const shared = bindMethods(SharedRouterImplementer.create(contract, config, middlewares));
|
|
396
|
-
for (const key
|
|
397
|
-
const method = shared[key];
|
|
395
|
+
for (const [key, method] of Object.entries(shared)) {
|
|
398
396
|
if (key in implementer) {
|
|
399
397
|
const child = implementer[key];
|
|
400
398
|
implementer[key] = new Proxy(method, {
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { Value, Promisable, ThrowableError } from '@orpc/shared';
|
|
|
2
2
|
import { StandardLazyRequest, StandardHeaders, StandardMethod } from '@standard-server/core';
|
|
3
3
|
import { Context } from '../index.mjs';
|
|
4
4
|
import { StandardHandlerPlugin, StandardHandlerRoutingInterceptorOptions, StandardHandlerOptions, StandardHandlerInterceptorOptions } from '../adapters/standard/index.mjs';
|
|
5
|
-
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.
|
|
5
|
+
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.C7xllBNN.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
|
|
@@ -76,7 +76,7 @@ interface BatchHandlerPluginOptions<T extends Context> {
|
|
|
76
76
|
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
77
77
|
name: string;
|
|
78
78
|
/**
|
|
79
|
-
* Run batch interceptors
|
|
79
|
+
* Run batch interceptors inside the tracing interceptors
|
|
80
80
|
* so each subrequest gets its own span instead of sharing one batch-level span.
|
|
81
81
|
*/
|
|
82
82
|
after: string[];
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Value, Promisable, ThrowableError } from '@orpc/shared';
|
|
|
2
2
|
import { StandardLazyRequest, StandardHeaders, StandardMethod } from '@standard-server/core';
|
|
3
3
|
import { Context } from '../index.js';
|
|
4
4
|
import { StandardHandlerPlugin, StandardHandlerRoutingInterceptorOptions, StandardHandlerOptions, StandardHandlerInterceptorOptions } from '../adapters/standard/index.js';
|
|
5
|
-
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.
|
|
5
|
+
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.D0dr-F8u.js';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
|
|
@@ -76,7 +76,7 @@ interface BatchHandlerPluginOptions<T extends Context> {
|
|
|
76
76
|
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
77
77
|
name: string;
|
|
78
78
|
/**
|
|
79
|
-
* Run batch interceptors
|
|
79
|
+
* Run batch interceptors inside the tracing interceptors
|
|
80
80
|
* so each subrequest gets its own span instead of sharing one batch-level span.
|
|
81
81
|
*/
|
|
82
82
|
after: string[];
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -9,10 +9,10 @@ const BATCH_CONTENT_TYPE = "application/vnd.orpc.batch";
|
|
|
9
9
|
class BatchHandlerPlugin {
|
|
10
10
|
name = "~batch";
|
|
11
11
|
/**
|
|
12
|
-
* Run batch interceptors
|
|
12
|
+
* Run batch interceptors inside the tracing interceptors
|
|
13
13
|
* so each subrequest gets its own span instead of sharing one batch-level span.
|
|
14
14
|
*/
|
|
15
|
-
after = ["~
|
|
15
|
+
after = ["~tracing"];
|
|
16
16
|
maxSize;
|
|
17
17
|
mapSubrequest;
|
|
18
18
|
successStatus;
|
|
@@ -217,7 +217,7 @@ class CORSHandlerPlugin {
|
|
|
217
217
|
* - Run CORS interceptors before batch interceptors so headers are applied to
|
|
218
218
|
* the actual response rather than sub-responses.
|
|
219
219
|
*/
|
|
220
|
-
after = ["~
|
|
220
|
+
after = ["~tracing", "~batch"];
|
|
221
221
|
constructor(options = {}) {
|
|
222
222
|
const defaults = {
|
|
223
223
|
origin: "*",
|
|
@@ -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.Djb_ebJT.mjs';
|
|
3
3
|
|
|
4
4
|
class DecoratedProcedure extends Procedure {
|
|
5
5
|
meta(...plugins) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyORPCError } from '@orpc/client';
|
|
2
|
-
import { OrderablePlugin,
|
|
2
|
+
import { OrderablePlugin, Value, Promisable, Interceptor } from '@orpc/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
|
|
4
4
|
import { C as Context, c as ProcedureClientInterceptor, A as AnyProcedure } from './server.BsujoJoF.mjs';
|
|
5
5
|
import { Schema, ErrorMap } from '@orpc/contract';
|
|
@@ -36,6 +36,17 @@ declare class CompositeStandardHandlerPlugin<T extends Context> implements Stand
|
|
|
36
36
|
|
|
37
37
|
interface StandardHandlerHandleOptions<T extends Context> {
|
|
38
38
|
prefix?: `/${string}` | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The initial context, or a function (sync or async) that receives the request and returns it.
|
|
41
|
+
* The function only runs once the request passes the prefix check.
|
|
42
|
+
*/
|
|
43
|
+
context: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `StandardHandlerHandleOptions` after the context has been resolved,
|
|
47
|
+
* this is what interceptors and codecs receive.
|
|
48
|
+
*/
|
|
49
|
+
interface ResolvedStandardHandlerHandleOptions<T extends Context> extends Omit<StandardHandlerHandleOptions<T>, 'context'> {
|
|
39
50
|
context: T;
|
|
40
51
|
}
|
|
41
52
|
type StandardHandlerHandleResult = {
|
|
@@ -45,11 +56,11 @@ type StandardHandlerHandleResult = {
|
|
|
45
56
|
matched: false;
|
|
46
57
|
response?: undefined;
|
|
47
58
|
};
|
|
48
|
-
interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandlerCodecResolvedProcedure,
|
|
59
|
+
interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandlerCodecResolvedProcedure, ResolvedStandardHandlerHandleOptions<T> {
|
|
49
60
|
request: StandardLazyRequest;
|
|
50
61
|
}
|
|
51
62
|
type StandardHandlerInterceptor<T extends Context> = Interceptor<StandardHandlerInterceptorOptions<T>, Promise<StandardResponse>>;
|
|
52
|
-
interface StandardHandlerRoutingInterceptorOptions<T extends Context> extends
|
|
63
|
+
interface StandardHandlerRoutingInterceptorOptions<T extends Context> extends ResolvedStandardHandlerHandleOptions<T> {
|
|
53
64
|
request: StandardLazyRequest;
|
|
54
65
|
}
|
|
55
66
|
type StandardHandlerRoutingInterceptor<T extends Context> = Interceptor<StandardHandlerRoutingInterceptorOptions<T>, Promise<StandardHandlerHandleResult>>;
|
|
@@ -82,9 +93,9 @@ declare class StandardHandler<T extends Context> {
|
|
|
82
93
|
private readonly interceptors;
|
|
83
94
|
private readonly clientInterceptors;
|
|
84
95
|
constructor(codec: StandardHandlerCodec<T>, options: StandardHandlerOptions<T>);
|
|
85
|
-
handle(request: StandardLazyRequest,
|
|
96
|
+
handle(request: StandardLazyRequest, options: StandardHandlerHandleOptions<T>): Promise<StandardHandlerHandleResult>;
|
|
86
97
|
}
|
|
87
|
-
declare class
|
|
98
|
+
declare class TracingHandlerPlugin implements StandardHandlerPlugin<any> {
|
|
88
99
|
name: string;
|
|
89
100
|
init(options: StandardHandlerOptions<any>): StandardHandlerOptions<any>;
|
|
90
101
|
}
|
|
@@ -95,10 +106,10 @@ interface StandardHandlerCodecResolvedProcedure {
|
|
|
95
106
|
decodeInput: () => Promise<unknown>;
|
|
96
107
|
}
|
|
97
108
|
interface StandardHandlerCodec<T extends Context> {
|
|
98
|
-
resolveProcedure(request: StandardLazyRequest, options:
|
|
99
|
-
encodeOutput(output: unknown, procedure: AnyProcedure, path: string[], options:
|
|
100
|
-
encodeError(error: AnyORPCError, procedure: AnyProcedure, path: string[], options:
|
|
109
|
+
resolveProcedure(request: StandardLazyRequest, options: ResolvedStandardHandlerHandleOptions<T>): Promisable<StandardHandlerCodecResolvedProcedure | undefined>;
|
|
110
|
+
encodeOutput(output: unknown, procedure: AnyProcedure, path: string[], options: ResolvedStandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
111
|
+
encodeError(error: AnyORPCError, procedure: AnyProcedure, path: string[], options: ResolvedStandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
101
112
|
}
|
|
102
113
|
|
|
103
|
-
export { CompositeStandardHandlerPlugin as C,
|
|
104
|
-
export type {
|
|
114
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as S, TracingHandlerPlugin as T };
|
|
115
|
+
export type { ResolvedStandardHandlerHandleOptions as R, StandardHandlerHandleOptions as a, StandardHandlerPlugin as b, StandardHandlerOptions as c, StandardHandlerRoutingInterceptorOptions as d, StandardHandlerInterceptorOptions as e, StandardHandlerCodec as f, StandardHandlerCodecResolvedProcedure as g, StandardHandlerHandleResult as h, StandardHandlerInterceptor as i, StandardHandlerRoutingInterceptor as j };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createProcedureClient, P as Procedure, L as Lazy, u as unlazy } from './server.
|
|
1
|
+
import { c as createProcedureClient, P as Procedure, L as Lazy, u as unlazy } from './server.Djb_ebJT.mjs';
|
|
2
2
|
import { resolveMetaPlugins, mergeErrorMap, ProcedureContract } from '@orpc/contract';
|
|
3
3
|
import { omit, isTypescriptObject } from '@orpc/shared';
|
|
4
4
|
|
|
@@ -93,8 +93,8 @@ function augmentRouter(router, options) {
|
|
|
93
93
|
return router;
|
|
94
94
|
}
|
|
95
95
|
const enhanced = {};
|
|
96
|
-
for (const key
|
|
97
|
-
enhanced[key] = augmentRouter(
|
|
96
|
+
for (const [key, child] of Object.entries(router)) {
|
|
97
|
+
enhanced[key] = augmentRouter(child, options);
|
|
98
98
|
}
|
|
99
99
|
return enhanced;
|
|
100
100
|
}
|
|
@@ -125,8 +125,8 @@ function augmentImplementedRouter(router, options) {
|
|
|
125
125
|
return router;
|
|
126
126
|
}
|
|
127
127
|
const enhanced = {};
|
|
128
|
-
for (const key
|
|
129
|
-
enhanced[key] = augmentImplementedRouter(
|
|
128
|
+
for (const [key, child] of Object.entries(router)) {
|
|
129
|
+
enhanced[key] = augmentImplementedRouter(child, options);
|
|
130
130
|
}
|
|
131
131
|
return enhanced;
|
|
132
132
|
}
|
|
@@ -177,8 +177,7 @@ function walkProcedureContractsSyncInternal(router, callback, path, lazyResults)
|
|
|
177
177
|
if (!isTypescriptObject(router)) {
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
|
-
for (const key
|
|
181
|
-
const value = router[key];
|
|
180
|
+
for (const [key, value] of Object.entries(router)) {
|
|
182
181
|
path.push(key);
|
|
183
182
|
if (value instanceof Lazy) {
|
|
184
183
|
lazyResults.push({ router: value, path: path.slice() });
|
|
@@ -200,8 +199,7 @@ async function walkProcedureContractsAsync(router, callback, path = []) {
|
|
|
200
199
|
if (!isTypescriptObject(router)) {
|
|
201
200
|
return;
|
|
202
201
|
}
|
|
203
|
-
for (const key
|
|
204
|
-
const value = router[key];
|
|
202
|
+
for (const [key, value] of Object.entries(router)) {
|
|
205
203
|
if (value instanceof Lazy) {
|
|
206
204
|
const { default: router2 } = await unlazy(value);
|
|
207
205
|
await walkProcedureContractsAsync(router2, callback, [...path, key]);
|
|
@@ -218,7 +216,7 @@ async function unlazyRouter(router) {
|
|
|
218
216
|
return router;
|
|
219
217
|
}
|
|
220
218
|
const unlazied = {};
|
|
221
|
-
for (const key
|
|
219
|
+
for (const key of Object.keys(router)) {
|
|
222
220
|
const item = router[key];
|
|
223
221
|
const { default: unlaziedRouter } = await unlazy(item);
|
|
224
222
|
unlazied[key] = await unlazyRouter(unlaziedRouter);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as Context } from './server.BsujoJoF.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { b as StandardHandlerPlugin, c as StandardHandlerOptions } from './server.B5K1CViq.mjs';
|
|
3
3
|
|
|
4
4
|
interface RequestLimitHandlerPluginOptions {
|
|
5
5
|
/**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
+
import { StandardLazyRequest } from '@standard-server/core';
|
|
3
|
+
import { C as Context } from './server.BsujoJoF.mjs';
|
|
4
|
+
import { a as StandardHandlerHandleOptions } from './server.B5K1CViq.mjs';
|
|
5
|
+
|
|
6
|
+
type FriendlyStandardHandlerHandleOptions<T extends Context> = Omit<StandardHandlerHandleOptions<T>, 'context'> & (object extends T ? {
|
|
7
|
+
context?: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
8
|
+
} : {
|
|
9
|
+
context: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
10
|
+
});
|
|
11
|
+
declare function resolveFriendlyStandardHandlerHandleOptions<T extends Context>(options: FriendlyStandardHandlerHandleOptions<T>): StandardHandlerHandleOptions<T>;
|
|
12
|
+
|
|
13
|
+
export { resolveFriendlyStandardHandlerHandleOptions as r };
|
|
14
|
+
export type { FriendlyStandardHandlerHandleOptions as F };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyORPCError } from '@orpc/client';
|
|
2
|
-
import { OrderablePlugin,
|
|
2
|
+
import { OrderablePlugin, Value, Promisable, Interceptor } from '@orpc/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
|
|
4
4
|
import { C as Context, c as ProcedureClientInterceptor, A as AnyProcedure } from './server.BsujoJoF.js';
|
|
5
5
|
import { Schema, ErrorMap } from '@orpc/contract';
|
|
@@ -36,6 +36,17 @@ declare class CompositeStandardHandlerPlugin<T extends Context> implements Stand
|
|
|
36
36
|
|
|
37
37
|
interface StandardHandlerHandleOptions<T extends Context> {
|
|
38
38
|
prefix?: `/${string}` | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The initial context, or a function (sync or async) that receives the request and returns it.
|
|
41
|
+
* The function only runs once the request passes the prefix check.
|
|
42
|
+
*/
|
|
43
|
+
context: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `StandardHandlerHandleOptions` after the context has been resolved,
|
|
47
|
+
* this is what interceptors and codecs receive.
|
|
48
|
+
*/
|
|
49
|
+
interface ResolvedStandardHandlerHandleOptions<T extends Context> extends Omit<StandardHandlerHandleOptions<T>, 'context'> {
|
|
39
50
|
context: T;
|
|
40
51
|
}
|
|
41
52
|
type StandardHandlerHandleResult = {
|
|
@@ -45,11 +56,11 @@ type StandardHandlerHandleResult = {
|
|
|
45
56
|
matched: false;
|
|
46
57
|
response?: undefined;
|
|
47
58
|
};
|
|
48
|
-
interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandlerCodecResolvedProcedure,
|
|
59
|
+
interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandlerCodecResolvedProcedure, ResolvedStandardHandlerHandleOptions<T> {
|
|
49
60
|
request: StandardLazyRequest;
|
|
50
61
|
}
|
|
51
62
|
type StandardHandlerInterceptor<T extends Context> = Interceptor<StandardHandlerInterceptorOptions<T>, Promise<StandardResponse>>;
|
|
52
|
-
interface StandardHandlerRoutingInterceptorOptions<T extends Context> extends
|
|
63
|
+
interface StandardHandlerRoutingInterceptorOptions<T extends Context> extends ResolvedStandardHandlerHandleOptions<T> {
|
|
53
64
|
request: StandardLazyRequest;
|
|
54
65
|
}
|
|
55
66
|
type StandardHandlerRoutingInterceptor<T extends Context> = Interceptor<StandardHandlerRoutingInterceptorOptions<T>, Promise<StandardHandlerHandleResult>>;
|
|
@@ -82,9 +93,9 @@ declare class StandardHandler<T extends Context> {
|
|
|
82
93
|
private readonly interceptors;
|
|
83
94
|
private readonly clientInterceptors;
|
|
84
95
|
constructor(codec: StandardHandlerCodec<T>, options: StandardHandlerOptions<T>);
|
|
85
|
-
handle(request: StandardLazyRequest,
|
|
96
|
+
handle(request: StandardLazyRequest, options: StandardHandlerHandleOptions<T>): Promise<StandardHandlerHandleResult>;
|
|
86
97
|
}
|
|
87
|
-
declare class
|
|
98
|
+
declare class TracingHandlerPlugin implements StandardHandlerPlugin<any> {
|
|
88
99
|
name: string;
|
|
89
100
|
init(options: StandardHandlerOptions<any>): StandardHandlerOptions<any>;
|
|
90
101
|
}
|
|
@@ -95,10 +106,10 @@ interface StandardHandlerCodecResolvedProcedure {
|
|
|
95
106
|
decodeInput: () => Promise<unknown>;
|
|
96
107
|
}
|
|
97
108
|
interface StandardHandlerCodec<T extends Context> {
|
|
98
|
-
resolveProcedure(request: StandardLazyRequest, options:
|
|
99
|
-
encodeOutput(output: unknown, procedure: AnyProcedure, path: string[], options:
|
|
100
|
-
encodeError(error: AnyORPCError, procedure: AnyProcedure, path: string[], options:
|
|
109
|
+
resolveProcedure(request: StandardLazyRequest, options: ResolvedStandardHandlerHandleOptions<T>): Promisable<StandardHandlerCodecResolvedProcedure | undefined>;
|
|
110
|
+
encodeOutput(output: unknown, procedure: AnyProcedure, path: string[], options: ResolvedStandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
111
|
+
encodeError(error: AnyORPCError, procedure: AnyProcedure, path: string[], options: ResolvedStandardHandlerHandleOptions<T>): Promisable<StandardResponse>;
|
|
101
112
|
}
|
|
102
113
|
|
|
103
|
-
export { CompositeStandardHandlerPlugin as C,
|
|
104
|
-
export type {
|
|
114
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as S, TracingHandlerPlugin as T };
|
|
115
|
+
export type { ResolvedStandardHandlerHandleOptions as R, StandardHandlerHandleOptions as a, StandardHandlerPlugin as b, StandardHandlerOptions as c, StandardHandlerRoutingInterceptorOptions as d, StandardHandlerInterceptorOptions as e, StandardHandlerCodec as f, StandardHandlerCodecResolvedProcedure as g, StandardHandlerHandleResult as h, StandardHandlerInterceptor as i, StandardHandlerRoutingInterceptor as j };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as Context } from './server.BsujoJoF.js';
|
|
2
|
-
import {
|
|
2
|
+
import { b as StandardHandlerPlugin, c as StandardHandlerOptions } from './server.Cxranw-8.js';
|
|
3
3
|
|
|
4
4
|
interface RequestLimitHandlerPluginOptions {
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { wrapAsyncIteratorPreservingEventMeta, ORPCError } from '@orpc/client';
|
|
2
2
|
import { createORPCErrorConstructorMap, reconcileORPCError, ValidationError, ProcedureContract } from '@orpc/contract';
|
|
3
|
-
import { getConstructor, isTypescriptObject, resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, override, traceAsyncIterator, traceReadableStream, isPlainObject, mergeTwoLevels } from '@orpc/shared';
|
|
3
|
+
import { getConstructor, isTypescriptObject, resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, override, getTracer, traceAsyncIterator, traceReadableStream, isPlainObject, mergeTwoLevels } from '@orpc/shared';
|
|
4
4
|
|
|
5
5
|
class Lazy {
|
|
6
6
|
"~orpc";
|
|
@@ -59,11 +59,10 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
59
59
|
});
|
|
60
60
|
if (isAsyncIteratorObject(output)) {
|
|
61
61
|
return override(output, wrapAsyncIteratorPreservingEventMeta(
|
|
62
|
-
traceAsyncIterator("consume_async_iterator_object_output", output),
|
|
62
|
+
getTracer() ? traceAsyncIterator("consume_async_iterator_object_output", output) : output,
|
|
63
63
|
{ mapError: reconcileError }
|
|
64
64
|
));
|
|
65
|
-
}
|
|
66
|
-
if (output instanceof ReadableStream) {
|
|
65
|
+
} else if (getTracer() && output instanceof ReadableStream) {
|
|
67
66
|
return override(output, traceReadableStream("consume_octet_stream_output", output));
|
|
68
67
|
}
|
|
69
68
|
return output;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
+
import { StandardLazyRequest } from '@standard-server/core';
|
|
3
|
+
import { C as Context } from './server.BsujoJoF.js';
|
|
4
|
+
import { a as StandardHandlerHandleOptions } from './server.Cxranw-8.js';
|
|
5
|
+
|
|
6
|
+
type FriendlyStandardHandlerHandleOptions<T extends Context> = Omit<StandardHandlerHandleOptions<T>, 'context'> & (object extends T ? {
|
|
7
|
+
context?: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
8
|
+
} : {
|
|
9
|
+
context: Value<Promisable<T>, [request: StandardLazyRequest]>;
|
|
10
|
+
});
|
|
11
|
+
declare function resolveFriendlyStandardHandlerHandleOptions<T extends Context>(options: FriendlyStandardHandlerHandleOptions<T>): StandardHandlerHandleOptions<T>;
|
|
12
|
+
|
|
13
|
+
export { resolveFriendlyStandardHandlerHandleOptions as r };
|
|
14
|
+
export type { FriendlyStandardHandlerHandleOptions as F };
|