@orpc/server 0.0.0-next.93e6063 → 0.0.0-next.9486ab5
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 +14 -1
- package/dist/adapters/fetch/index.d.mts +38 -11
- package/dist/adapters/fetch/index.d.ts +38 -11
- package/dist/adapters/fetch/index.mjs +6 -6
- package/dist/adapters/hono/index.d.mts +6 -4
- package/dist/adapters/hono/index.d.ts +6 -4
- package/dist/adapters/hono/index.mjs +6 -6
- package/dist/adapters/next/index.d.mts +6 -4
- package/dist/adapters/next/index.d.ts +6 -4
- package/dist/adapters/next/index.mjs +6 -6
- package/dist/adapters/node/index.d.mts +40 -22
- package/dist/adapters/node/index.d.ts +40 -22
- package/dist/adapters/node/index.mjs +77 -22
- package/dist/adapters/standard/index.d.mts +12 -15
- package/dist/adapters/standard/index.d.ts +12 -15
- package/dist/adapters/standard/index.mjs +2 -3
- package/dist/index.d.mts +156 -120
- package/dist/index.d.ts +156 -120
- package/dist/index.mjs +78 -48
- package/dist/plugins/index.d.mts +15 -16
- package/dist/plugins/index.d.ts +15 -16
- package/dist/plugins/index.mjs +10 -6
- package/dist/shared/server.89QkKw3a.d.mts +10 -0
- package/dist/shared/server.B1S3zwuw.d.mts +8 -0
- package/dist/shared/server.BMkFIQUb.d.mts +66 -0
- package/dist/shared/server.BT0gne12.d.ts +8 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/{server.V6zT5iYQ.mjs → server.CjWkNG6l.mjs} +151 -160
- package/dist/shared/server.D0YVcfZk.d.mts +143 -0
- package/dist/shared/server.D0YVcfZk.d.ts +143 -0
- package/dist/shared/{server.BBGuTxHE.mjs → server.D9QduY95.mjs} +43 -45
- package/dist/shared/server.Et1O6Bm7.mjs +98 -0
- package/dist/shared/server.taqJyaMn.d.ts +10 -0
- package/dist/shared/server.ywWqDZgA.d.ts +66 -0
- package/package.json +8 -8
- package/dist/shared/server.B-ewprcf.d.ts +0 -77
- package/dist/shared/server.CA-o8cUY.d.mts +0 -9
- package/dist/shared/server.Cn9ybJtE.d.mts +0 -152
- package/dist/shared/server.Cn9ybJtE.d.ts +0 -152
- package/dist/shared/server.DJrh0Ceu.d.mts +0 -77
- package/dist/shared/server.DPQt9YYq.d.ts +0 -9
- package/dist/shared/server.KwueCzFr.mjs +0 -26
- package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
package/dist/index.mjs
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure } from '@orpc/contract';
|
1
|
+
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } from '@orpc/contract';
|
2
2
|
export { ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
-
import { P as Procedure,
|
4
|
-
export { L as
|
3
|
+
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure, g as getRouter } from './shared/server.CjWkNG6l.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, w as resolveContractProcedures, t as traverseContractProcedures, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.CjWkNG6l.mjs';
|
5
|
+
import { toORPCError } from '@orpc/client';
|
5
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
6
7
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
8
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
8
9
|
|
9
10
|
const DEFAULT_CONFIG = {
|
10
11
|
initialInputValidationIndex: 0,
|
11
|
-
initialOutputValidationIndex: 0
|
12
|
+
initialOutputValidationIndex: 0,
|
13
|
+
dedupeLeadingMiddlewares: true
|
12
14
|
};
|
13
15
|
function fallbackConfig(key, value) {
|
14
16
|
if (value === void 0) {
|
@@ -18,7 +20,7 @@ function fallbackConfig(key, value) {
|
|
18
20
|
}
|
19
21
|
|
20
22
|
function decorateMiddleware(middleware) {
|
21
|
-
const decorated = middleware;
|
23
|
+
const decorated = (...args) => middleware(...args);
|
22
24
|
decorated.mapInput = (mapInput) => {
|
23
25
|
const mapped = decorateMiddleware(
|
24
26
|
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
@@ -43,6 +45,17 @@ function decorateMiddleware(middleware) {
|
|
43
45
|
return decorated;
|
44
46
|
}
|
45
47
|
|
48
|
+
function createActionableClient(client) {
|
49
|
+
const action = async (input) => {
|
50
|
+
try {
|
51
|
+
return [null, await client(input)];
|
52
|
+
} catch (error) {
|
53
|
+
return [toORPCError(error).toJSON(), void 0];
|
54
|
+
}
|
55
|
+
};
|
56
|
+
return action;
|
57
|
+
}
|
58
|
+
|
46
59
|
class DecoratedProcedure extends Procedure {
|
47
60
|
errors(errors) {
|
48
61
|
return new DecoratedProcedure({
|
@@ -73,16 +86,29 @@ class DecoratedProcedure extends Procedure {
|
|
73
86
|
* Make this procedure callable (works like a function while still being a procedure).
|
74
87
|
*/
|
75
88
|
callable(...rest) {
|
76
|
-
|
77
|
-
|
78
|
-
|
89
|
+
const client = createProcedureClient(this, ...rest);
|
90
|
+
return new Proxy(client, {
|
91
|
+
get: (target, key) => {
|
92
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
93
|
+
},
|
94
|
+
has: (target, key) => {
|
95
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
96
|
+
}
|
79
97
|
});
|
80
98
|
}
|
81
99
|
/**
|
82
|
-
* Make this procedure compatible with server action
|
100
|
+
* Make this procedure compatible with server action.
|
83
101
|
*/
|
84
102
|
actionable(...rest) {
|
85
|
-
|
103
|
+
const action = createActionableClient(createProcedureClient(this, ...rest));
|
104
|
+
return new Proxy(action, {
|
105
|
+
get: (target, key) => {
|
106
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
107
|
+
},
|
108
|
+
has: (target, key) => {
|
109
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
110
|
+
}
|
111
|
+
});
|
86
112
|
}
|
87
113
|
}
|
88
114
|
|
@@ -100,6 +126,7 @@ class Builder {
|
|
100
126
|
return new Builder({
|
101
127
|
...this["~orpc"],
|
102
128
|
config,
|
129
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares),
|
103
130
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", config.initialInputValidationIndex) + inputValidationCount,
|
104
131
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config.initialOutputValidationIndex) + outputValidationCount
|
105
132
|
});
|
@@ -133,6 +160,12 @@ class Builder {
|
|
133
160
|
route: initialRoute
|
134
161
|
});
|
135
162
|
}
|
163
|
+
$input(initialInputSchema) {
|
164
|
+
return new Builder({
|
165
|
+
...this["~orpc"],
|
166
|
+
inputSchema: initialInputSchema
|
167
|
+
});
|
168
|
+
}
|
136
169
|
middleware(middleware) {
|
137
170
|
return decorateMiddleware(middleware);
|
138
171
|
}
|
@@ -194,10 +227,10 @@ class Builder {
|
|
194
227
|
});
|
195
228
|
}
|
196
229
|
router(router) {
|
197
|
-
return
|
230
|
+
return enhanceRouter(router, this["~orpc"]);
|
198
231
|
}
|
199
232
|
lazy(loader) {
|
200
|
-
return
|
233
|
+
return enhanceRouter(lazy(loader), this["~orpc"]);
|
201
234
|
}
|
202
235
|
}
|
203
236
|
const os = new Builder({
|
@@ -205,17 +238,12 @@ const os = new Builder({
|
|
205
238
|
route: {},
|
206
239
|
meta: {},
|
207
240
|
errorMap: {},
|
208
|
-
inputSchema: void 0,
|
209
|
-
outputSchema: void 0,
|
210
241
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex"),
|
211
242
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex"),
|
212
|
-
middlewares: []
|
243
|
+
middlewares: [],
|
244
|
+
dedupeLeadingMiddlewares: true
|
213
245
|
});
|
214
246
|
|
215
|
-
function mergeContext(context, other) {
|
216
|
-
return { ...context, ...other };
|
217
|
-
}
|
218
|
-
|
219
247
|
function implementerInternal(contract, config, middlewares) {
|
220
248
|
if (isContractProcedure(contract)) {
|
221
249
|
const impl2 = new Builder({
|
@@ -223,12 +251,16 @@ function implementerInternal(contract, config, middlewares) {
|
|
223
251
|
config,
|
224
252
|
middlewares,
|
225
253
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", config?.initialInputValidationIndex) + middlewares.length,
|
226
|
-
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length
|
254
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length,
|
255
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
227
256
|
});
|
228
257
|
return impl2;
|
229
258
|
}
|
230
259
|
const impl = new Proxy(contract, {
|
231
260
|
get: (target, key) => {
|
261
|
+
if (typeof key !== "string") {
|
262
|
+
return Reflect.get(target, key);
|
263
|
+
}
|
232
264
|
let method;
|
233
265
|
if (key === "middleware") {
|
234
266
|
method = (mid) => decorateMiddleware(mid);
|
@@ -242,23 +274,29 @@ function implementerInternal(contract, config, middlewares) {
|
|
242
274
|
};
|
243
275
|
} else if (key === "router") {
|
244
276
|
method = (router) => {
|
245
|
-
const adapted =
|
277
|
+
const adapted = enhanceRouter(router, {
|
246
278
|
middlewares,
|
247
|
-
errorMap: {}
|
279
|
+
errorMap: {},
|
280
|
+
prefix: void 0,
|
281
|
+
tags: void 0,
|
282
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
248
283
|
});
|
249
|
-
return
|
284
|
+
return setHiddenRouterContract(adapted, contract);
|
250
285
|
};
|
251
286
|
} else if (key === "lazy") {
|
252
287
|
method = (loader) => {
|
253
|
-
const adapted =
|
288
|
+
const adapted = enhanceRouter(lazy(loader), {
|
254
289
|
middlewares,
|
255
|
-
errorMap: {}
|
290
|
+
errorMap: {},
|
291
|
+
prefix: void 0,
|
292
|
+
tags: void 0,
|
293
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
256
294
|
});
|
257
|
-
return
|
295
|
+
return setHiddenRouterContract(adapted, contract);
|
258
296
|
};
|
259
297
|
}
|
260
|
-
const next =
|
261
|
-
if (!next
|
298
|
+
const next = getContractRouter(target, [key]);
|
299
|
+
if (!next) {
|
262
300
|
return method ?? next;
|
263
301
|
}
|
264
302
|
const nextImpl = implementerInternal(next, config, middlewares);
|
@@ -285,42 +323,34 @@ function implement(contract, config = {}) {
|
|
285
323
|
method = (config2) => implement(contract, config2);
|
286
324
|
}
|
287
325
|
const next = Reflect.get(target, key);
|
288
|
-
if (!next || typeof next !== "function" && typeof next !== "object") {
|
289
|
-
return method
|
290
|
-
}
|
291
|
-
if (method) {
|
292
|
-
return new Proxy(method, {
|
293
|
-
get(_, key2) {
|
294
|
-
return Reflect.get(next, key2);
|
295
|
-
}
|
296
|
-
});
|
326
|
+
if (!method || !next || typeof next !== "function" && typeof next !== "object") {
|
327
|
+
return method || next;
|
297
328
|
}
|
298
|
-
return
|
329
|
+
return new Proxy(method, {
|
330
|
+
get(_, key2) {
|
331
|
+
return Reflect.get(next, key2);
|
332
|
+
}
|
333
|
+
});
|
299
334
|
}
|
300
335
|
});
|
301
336
|
return impl;
|
302
337
|
}
|
303
338
|
|
304
|
-
function
|
305
|
-
return createProcedureClient(procedure, ...rest)(input);
|
306
|
-
}
|
307
|
-
|
308
|
-
function createRouterClient(router, ...rest) {
|
339
|
+
function createRouterClient(router, ...[options]) {
|
309
340
|
if (isProcedure(router)) {
|
310
|
-
const caller = createProcedureClient(router,
|
341
|
+
const caller = createProcedureClient(router, options);
|
311
342
|
return caller;
|
312
343
|
}
|
313
|
-
const procedureCaller = isLazy(router) ? createProcedureClient(
|
344
|
+
const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
|
314
345
|
const recursive = new Proxy(procedureCaller, {
|
315
346
|
get(target, key) {
|
316
347
|
if (typeof key !== "string") {
|
317
348
|
return Reflect.get(target, key);
|
318
349
|
}
|
319
|
-
const next =
|
350
|
+
const next = getRouter(router, [key]);
|
320
351
|
if (!next) {
|
321
352
|
return Reflect.get(target, key);
|
322
353
|
}
|
323
|
-
const [options] = rest;
|
324
354
|
return createRouterClient(next, {
|
325
355
|
...options,
|
326
356
|
path: [...options?.path ?? [], key]
|
@@ -330,4 +360,4 @@ function createRouterClient(router, ...rest) {
|
|
330
360
|
return recursive;
|
331
361
|
}
|
332
362
|
|
333
|
-
export { Builder, DecoratedProcedure, Procedure,
|
363
|
+
export { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,31 +1,30 @@
|
|
1
|
-
import {
|
2
|
-
export { C as CompositePlugin } from '../shared/server.DJrh0Ceu.mjs';
|
1
|
+
import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.BMkFIQUb.mjs';
|
3
2
|
import { Value } from '@orpc/shared';
|
4
|
-
import { C as Context } from '../shared/server.
|
3
|
+
import { C as Context } from '../shared/server.D0YVcfZk.mjs';
|
4
|
+
import '@orpc/client';
|
5
5
|
import '@orpc/contract';
|
6
6
|
import '@orpc/standard-server';
|
7
|
-
import '@orpc/client';
|
8
7
|
|
9
|
-
interface CORSOptions<
|
10
|
-
origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<
|
11
|
-
timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<
|
12
|
-
allowMethods?: string[];
|
13
|
-
allowHeaders?: string[];
|
8
|
+
interface CORSOptions<T extends Context> {
|
9
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
10
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
11
|
+
allowMethods?: readonly string[];
|
12
|
+
allowHeaders?: readonly string[];
|
14
13
|
maxAge?: number;
|
15
14
|
credentials?: boolean;
|
16
|
-
exposeHeaders?: string[];
|
15
|
+
exposeHeaders?: readonly string[];
|
17
16
|
}
|
18
|
-
declare class CORSPlugin<
|
17
|
+
declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
19
18
|
private readonly options;
|
20
|
-
constructor(options?:
|
21
|
-
init(options: StandardHandlerOptions<
|
19
|
+
constructor(options?: CORSOptions<T>);
|
20
|
+
init(options: StandardHandlerOptions<T>): void;
|
22
21
|
}
|
23
22
|
|
24
23
|
interface ResponseHeadersPluginContext {
|
25
24
|
resHeaders?: Headers;
|
26
25
|
}
|
27
|
-
declare class ResponseHeadersPlugin<
|
28
|
-
init(options: StandardHandlerOptions<
|
26
|
+
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
27
|
+
init(options: StandardHandlerOptions<T>): void;
|
29
28
|
}
|
30
29
|
|
31
|
-
export { type CORSOptions, CORSPlugin,
|
30
|
+
export { type CORSOptions, CORSPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,31 +1,30 @@
|
|
1
|
-
import {
|
2
|
-
export { C as CompositePlugin } from '../shared/server.B-ewprcf.js';
|
1
|
+
import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.ywWqDZgA.js';
|
3
2
|
import { Value } from '@orpc/shared';
|
4
|
-
import { C as Context } from '../shared/server.
|
3
|
+
import { C as Context } from '../shared/server.D0YVcfZk.js';
|
4
|
+
import '@orpc/client';
|
5
5
|
import '@orpc/contract';
|
6
6
|
import '@orpc/standard-server';
|
7
|
-
import '@orpc/client';
|
8
7
|
|
9
|
-
interface CORSOptions<
|
10
|
-
origin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<
|
11
|
-
timingOrigin?: Value<string | string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<
|
12
|
-
allowMethods?: string[];
|
13
|
-
allowHeaders?: string[];
|
8
|
+
interface CORSOptions<T extends Context> {
|
9
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
10
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
11
|
+
allowMethods?: readonly string[];
|
12
|
+
allowHeaders?: readonly string[];
|
14
13
|
maxAge?: number;
|
15
14
|
credentials?: boolean;
|
16
|
-
exposeHeaders?: string[];
|
15
|
+
exposeHeaders?: readonly string[];
|
17
16
|
}
|
18
|
-
declare class CORSPlugin<
|
17
|
+
declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
19
18
|
private readonly options;
|
20
|
-
constructor(options?:
|
21
|
-
init(options: StandardHandlerOptions<
|
19
|
+
constructor(options?: CORSOptions<T>);
|
20
|
+
init(options: StandardHandlerOptions<T>): void;
|
22
21
|
}
|
23
22
|
|
24
23
|
interface ResponseHeadersPluginContext {
|
25
24
|
resHeaders?: Headers;
|
26
25
|
}
|
27
|
-
declare class ResponseHeadersPlugin<
|
28
|
-
init(options: StandardHandlerOptions<
|
26
|
+
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
27
|
+
init(options: StandardHandlerOptions<T>): void;
|
29
28
|
}
|
30
29
|
|
31
|
-
export { type CORSOptions, CORSPlugin,
|
30
|
+
export { type CORSOptions, CORSPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
|
package/dist/plugins/index.mjs
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
export { C as CompositePlugin } from '../shared/server.Q6ZmnTgO.mjs';
|
2
1
|
import { value } from '@orpc/shared';
|
3
2
|
|
4
3
|
class CORSPlugin {
|
5
4
|
options;
|
6
|
-
constructor(options) {
|
5
|
+
constructor(options = {}) {
|
7
6
|
const defaults = {
|
8
7
|
origin: (origin) => origin,
|
9
8
|
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"]
|
@@ -79,14 +78,19 @@ class ResponseHeadersPlugin {
|
|
79
78
|
init(options) {
|
80
79
|
options.rootInterceptors ??= [];
|
81
80
|
options.rootInterceptors.push(async (interceptorOptions) => {
|
82
|
-
const
|
83
|
-
|
84
|
-
|
81
|
+
const resHeaders = interceptorOptions.context.resHeaders ?? new Headers();
|
82
|
+
const result = await interceptorOptions.next({
|
83
|
+
...interceptorOptions,
|
84
|
+
context: {
|
85
|
+
...interceptorOptions.context,
|
86
|
+
resHeaders
|
87
|
+
}
|
88
|
+
});
|
85
89
|
if (!result.matched) {
|
86
90
|
return result;
|
87
91
|
}
|
88
92
|
const responseHeaders = result.response.headers;
|
89
|
-
for (const [key, value] of
|
93
|
+
for (const [key, value] of resHeaders) {
|
90
94
|
if (Array.isArray(responseHeaders[key])) {
|
91
95
|
responseHeaders[key].push(value);
|
92
96
|
} else if (responseHeaders[key] !== void 0) {
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { C as Context } from './server.D0YVcfZk.mjs';
|
2
|
+
import { S as StandardHandleOptions } from './server.BMkFIQUb.mjs';
|
3
|
+
|
4
|
+
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
5
|
+
context?: T;
|
6
|
+
} : {
|
7
|
+
context: T;
|
8
|
+
});
|
9
|
+
|
10
|
+
export type { FriendlyStandardHandleOptions as F };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
+
import { C as Context } from './server.D0YVcfZk.mjs';
|
3
|
+
import { a as StandardHandlerOptions } from './server.BMkFIQUb.mjs';
|
4
|
+
|
5
|
+
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
+
}
|
7
|
+
|
8
|
+
export type { StandardRPCHandlerOptions as S };
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { HTTPPath, ORPCError } from '@orpc/client';
|
2
|
+
import { AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
|
3
|
+
import { Interceptor } from '@orpc/shared';
|
4
|
+
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
5
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.D0YVcfZk.mjs';
|
6
|
+
|
7
|
+
type StandardParams = Record<string, string>;
|
8
|
+
type StandardMatchResult = {
|
9
|
+
path: readonly string[];
|
10
|
+
procedure: AnyProcedure;
|
11
|
+
params?: StandardParams;
|
12
|
+
} | undefined;
|
13
|
+
interface StandardMatcher {
|
14
|
+
init(router: AnyRouter): void;
|
15
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
16
|
+
}
|
17
|
+
interface StandardCodec {
|
18
|
+
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
19
|
+
encodeError(error: ORPCError<any, any>): StandardResponse;
|
20
|
+
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
21
|
+
}
|
22
|
+
|
23
|
+
interface StandardHandleOptions<T extends Context> {
|
24
|
+
prefix?: HTTPPath;
|
25
|
+
context: T;
|
26
|
+
}
|
27
|
+
type StandardHandleResult = {
|
28
|
+
matched: true;
|
29
|
+
response: StandardResponse;
|
30
|
+
} | {
|
31
|
+
matched: false;
|
32
|
+
response: undefined;
|
33
|
+
};
|
34
|
+
interface StandardHandlerPlugin<TContext extends Context> {
|
35
|
+
init?(options: StandardHandlerOptions<TContext>): void;
|
36
|
+
}
|
37
|
+
interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
38
|
+
request: StandardLazyRequest;
|
39
|
+
}
|
40
|
+
interface StandardHandlerOptions<TContext extends Context> {
|
41
|
+
plugins?: StandardHandlerPlugin<TContext>[];
|
42
|
+
/**
|
43
|
+
* Interceptors at the request level, helpful when you want catch errors
|
44
|
+
*/
|
45
|
+
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
46
|
+
/**
|
47
|
+
* Interceptors at the root level, helpful when you want override the request/response
|
48
|
+
*/
|
49
|
+
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
50
|
+
/**
|
51
|
+
*
|
52
|
+
* Interceptors for procedure client.
|
53
|
+
*/
|
54
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
55
|
+
}
|
56
|
+
declare class StandardHandler<T extends Context> {
|
57
|
+
private readonly matcher;
|
58
|
+
private readonly codec;
|
59
|
+
private readonly interceptors;
|
60
|
+
private readonly clientInterceptors;
|
61
|
+
private readonly rootInterceptors;
|
62
|
+
constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
|
63
|
+
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
64
|
+
}
|
65
|
+
|
66
|
+
export { type StandardHandleOptions as S, type StandardHandlerOptions as a, type StandardHandlerInterceptorOptions as b, type StandardHandlerPlugin as c, type StandardCodec as d, type StandardParams as e, type StandardMatcher as f, type StandardMatchResult as g, type StandardHandleResult as h, StandardHandler as i };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
+
import { C as Context } from './server.D0YVcfZk.js';
|
3
|
+
import { a as StandardHandlerOptions } from './server.ywWqDZgA.js';
|
4
|
+
|
5
|
+
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
+
}
|
7
|
+
|
8
|
+
export type { StandardRPCHandlerOptions as S };
|