@orpc/server 0.43.0 → 0.44.0
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 +1 -1
- package/dist/adapters/fetch/index.d.mts +27 -0
- package/dist/adapters/fetch/index.d.ts +27 -0
- package/dist/adapters/fetch/index.mjs +9 -0
- package/dist/adapters/hono/index.d.mts +20 -0
- package/dist/adapters/hono/index.d.ts +20 -0
- package/dist/{hono.js → adapters/hono/index.mjs} +11 -13
- package/dist/adapters/next/index.d.mts +27 -0
- package/dist/adapters/next/index.d.ts +27 -0
- package/dist/{next.js → adapters/next/index.mjs} +11 -13
- package/dist/adapters/node/index.d.mts +35 -0
- package/dist/adapters/node/index.d.ts +35 -0
- package/dist/adapters/node/index.mjs +28 -0
- package/dist/adapters/standard/index.d.mts +29 -0
- package/dist/adapters/standard/index.d.ts +29 -0
- package/dist/adapters/standard/index.mjs +7 -0
- package/dist/index.d.mts +253 -0
- package/dist/index.d.ts +253 -0
- package/dist/{index.js → index.mjs} +33 -113
- package/dist/plugins/index.d.mts +31 -0
- package/dist/plugins/index.d.ts +31 -0
- package/dist/{chunk-TXHKQO7N.js → plugins/index.mjs} +11 -28
- package/dist/{chunk-TV5DRAST.js → shared/server.BBGuTxHE.mjs} +12 -31
- package/dist/shared/server.BqEaivV1.d.ts +9 -0
- package/dist/shared/server.CHpDfeOK.d.mts +77 -0
- package/dist/shared/server.CI7U5gRZ.d.mts +152 -0
- package/dist/shared/server.CI7U5gRZ.d.ts +152 -0
- package/dist/{chunk-WDY5PTME.js → shared/server.CUE4Aija.mjs} +8 -16
- package/dist/shared/server.DSZ2XY8G.d.ts +77 -0
- package/dist/shared/server.MnOqRlBp.d.mts +9 -0
- package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
- package/dist/{chunk-MHVECKBC.js → shared/server.V6zT5iYQ.mjs} +48 -90
- package/package.json +29 -34
- package/dist/fetch.js +0 -10
- package/dist/node.js +0 -31
- package/dist/plugins.js +0 -11
- package/dist/src/adapters/fetch/index.d.ts +0 -3
- package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/fetch/types.d.ts +0 -14
- package/dist/src/adapters/hono/index.d.ts +0 -3
- package/dist/src/adapters/hono/middleware.d.ts +0 -12
- package/dist/src/adapters/next/index.d.ts +0 -3
- package/dist/src/adapters/next/serve.d.ts +0 -19
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/node/types.d.ts +0 -22
- package/dist/src/adapters/standard/handler.d.ts +0 -53
- package/dist/src/adapters/standard/index.d.ts +0 -6
- package/dist/src/adapters/standard/rpc-codec.d.ts +0 -16
- package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
- package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
- package/dist/src/adapters/standard/types.d.ts +0 -21
- package/dist/src/builder-variants.d.ts +0 -75
- package/dist/src/builder.d.ts +0 -58
- package/dist/src/config.d.ts +0 -6
- package/dist/src/context.d.ts +0 -8
- package/dist/src/error.d.ts +0 -12
- package/dist/src/hidden.d.ts +0 -8
- package/dist/src/implementer-procedure.d.ts +0 -33
- package/dist/src/implementer-variants.d.ts +0 -18
- package/dist/src/implementer.d.ts +0 -29
- package/dist/src/index.d.ts +0 -25
- package/dist/src/lazy-utils.d.ts +0 -6
- package/dist/src/lazy.d.ts +0 -22
- package/dist/src/middleware-decorated.d.ts +0 -11
- package/dist/src/middleware-utils.d.ts +0 -5
- package/dist/src/middleware.d.ts +0 -38
- package/dist/src/plugins/base.d.ts +0 -11
- package/dist/src/plugins/cors.d.ts +0 -19
- package/dist/src/plugins/index.d.ts +0 -4
- package/dist/src/plugins/response-headers.d.ts +0 -10
- package/dist/src/procedure-client.d.ts +0 -33
- package/dist/src/procedure-decorated.d.ts +0 -24
- package/dist/src/procedure-utils.d.ts +0 -19
- package/dist/src/procedure.d.ts +0 -31
- package/dist/src/router-accessible-lazy.d.ts +0 -8
- package/dist/src/router-client.d.ts +0 -12
- package/dist/src/router.d.ts +0 -30
- package/dist/src/utils.d.ts +0 -24
- package/dist/standard.js +0 -13
@@ -1,5 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
|
2
|
+
import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, adaptRoute } from '@orpc/contract';
|
3
|
+
import { value, intercept, toError } from '@orpc/shared';
|
4
|
+
|
5
|
+
const LAZY_LOADER_SYMBOL = Symbol("ORPC_LAZY_LOADER");
|
3
6
|
function lazy(loader) {
|
4
7
|
return {
|
5
8
|
[LAZY_LOADER_SYMBOL]: loader
|
@@ -12,14 +15,12 @@ function unlazy(lazied) {
|
|
12
15
|
return isLazy(lazied) ? lazied[LAZY_LOADER_SYMBOL]() : Promise.resolve({ default: lazied });
|
13
16
|
}
|
14
17
|
|
15
|
-
|
16
|
-
import { isContractProcedure } from "@orpc/contract";
|
17
|
-
var Procedure = class {
|
18
|
+
class Procedure {
|
18
19
|
"~orpc";
|
19
20
|
constructor(def) {
|
20
21
|
this["~orpc"] = def;
|
21
22
|
}
|
22
|
-
}
|
23
|
+
}
|
23
24
|
function isProcedure(item) {
|
24
25
|
if (item instanceof Procedure) {
|
25
26
|
return true;
|
@@ -27,7 +28,6 @@ function isProcedure(item) {
|
|
27
28
|
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "inputValidationIndex" in item["~orpc"] && "outputValidationIndex" in item["~orpc"] && "handler" in item["~orpc"];
|
28
29
|
}
|
29
30
|
|
30
|
-
// src/lazy-utils.ts
|
31
31
|
function flatLazy(lazied) {
|
32
32
|
const flattenLoader = async () => {
|
33
33
|
let current = await unlazy(lazied);
|
@@ -56,18 +56,24 @@ function createLazyProcedureFormAnyLazy(lazied) {
|
|
56
56
|
return lazyProcedure;
|
57
57
|
}
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
function dedupeMiddlewares(compare, middlewares) {
|
60
|
+
let min = 0;
|
61
|
+
for (let i = 0; i < middlewares.length; i++) {
|
62
|
+
const index = compare.indexOf(middlewares[i], min);
|
63
|
+
if (index === -1) {
|
64
|
+
return middlewares.slice(i);
|
65
|
+
}
|
66
|
+
min = index + 1;
|
67
|
+
}
|
68
|
+
return [];
|
69
|
+
}
|
70
|
+
function mergeMiddlewares(first, second) {
|
71
|
+
return [...first, ...dedupeMiddlewares(first, second)];
|
72
|
+
}
|
73
|
+
function addMiddleware(middlewares, addition) {
|
74
|
+
return [...middlewares, addition];
|
62
75
|
}
|
63
76
|
|
64
|
-
// src/procedure-client.ts
|
65
|
-
import { ORPCError as ORPCError2 } from "@orpc/client";
|
66
|
-
import { ValidationError } from "@orpc/contract";
|
67
|
-
import { intercept, toError, value } from "@orpc/shared";
|
68
|
-
|
69
|
-
// src/error.ts
|
70
|
-
import { fallbackORPCErrorStatus, ORPCError } from "@orpc/client";
|
71
77
|
function createORPCErrorConstructorMap(errors) {
|
72
78
|
const proxy = new Proxy(errors, {
|
73
79
|
get(target, code) {
|
@@ -105,7 +111,10 @@ async function validateORPCError(map, error) {
|
|
105
111
|
return new ORPCError(code, { defined: true, status, message, data: validated.value, cause });
|
106
112
|
}
|
107
113
|
|
108
|
-
|
114
|
+
function middlewareOutputFn(output) {
|
115
|
+
return { output, context: {} };
|
116
|
+
}
|
117
|
+
|
109
118
|
function createProcedureClient(lazyableProcedure, ...[options]) {
|
110
119
|
return async (...[input, callerOptions]) => {
|
111
120
|
const path = options?.path ?? [];
|
@@ -129,7 +138,7 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
|
|
129
138
|
(interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
|
130
139
|
);
|
131
140
|
} catch (e) {
|
132
|
-
if (!(e instanceof
|
141
|
+
if (!(e instanceof ORPCError)) {
|
133
142
|
throw toError(e);
|
134
143
|
}
|
135
144
|
const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
|
@@ -144,7 +153,7 @@ async function validateInput(procedure, input) {
|
|
144
153
|
}
|
145
154
|
const result = await schema["~standard"].validate(input);
|
146
155
|
if (result.issues) {
|
147
|
-
throw new
|
156
|
+
throw new ORPCError("BAD_REQUEST", {
|
148
157
|
message: "Input validation failed",
|
149
158
|
data: {
|
150
159
|
issues: result.issues
|
@@ -161,7 +170,7 @@ async function validateOutput(procedure, output) {
|
|
161
170
|
}
|
162
171
|
const result = await schema["~standard"].validate(output);
|
163
172
|
if (result.issues) {
|
164
|
-
throw new
|
173
|
+
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
165
174
|
message: "Output validation failed",
|
166
175
|
cause: new ValidationError({ message: "Output validation failed", issues: result.issues })
|
167
176
|
});
|
@@ -196,8 +205,7 @@ async function executeProcedureInternal(procedure, options) {
|
|
196
205
|
return (await next({})).output;
|
197
206
|
}
|
198
207
|
|
199
|
-
|
200
|
-
var ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_ROUTER_CONTRACT");
|
208
|
+
const ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_ROUTER_CONTRACT");
|
201
209
|
function setRouterContract(obj, contract) {
|
202
210
|
return new Proxy(obj, {
|
203
211
|
get(target, key) {
|
@@ -211,7 +219,7 @@ function setRouterContract(obj, contract) {
|
|
211
219
|
function getRouterContract(obj) {
|
212
220
|
return obj[ROUTER_CONTRACT_SYMBOL];
|
213
221
|
}
|
214
|
-
|
222
|
+
const LAZY_ROUTER_PREFIX_SYMBOL = Symbol("ORPC_LAZY_ROUTER_PREFIX");
|
215
223
|
function deepSetLazyRouterPrefix(router, prefix) {
|
216
224
|
return new Proxy(router, {
|
217
225
|
get(target, key) {
|
@@ -230,29 +238,20 @@ function getLazyRouterPrefix(obj) {
|
|
230
238
|
return obj[LAZY_ROUTER_PREFIX_SYMBOL];
|
231
239
|
}
|
232
240
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
return middlewares.slice(i);
|
241
|
+
function createAccessibleLazyRouter(lazied) {
|
242
|
+
const flattenLazy = flatLazy(lazied);
|
243
|
+
const recursive = new Proxy(flattenLazy, {
|
244
|
+
get(target, key) {
|
245
|
+
if (typeof key !== "string") {
|
246
|
+
return Reflect.get(target, key);
|
247
|
+
}
|
248
|
+
const next = getRouterChild(flattenLazy, key);
|
249
|
+
return createAccessibleLazyRouter(next);
|
243
250
|
}
|
244
|
-
|
245
|
-
|
246
|
-
return [];
|
247
|
-
}
|
248
|
-
function mergeMiddlewares(first, second) {
|
249
|
-
return [...first, ...dedupeMiddlewares(first, second)];
|
250
|
-
}
|
251
|
-
function addMiddleware(middlewares, addition) {
|
252
|
-
return [...middlewares, addition];
|
251
|
+
});
|
252
|
+
return recursive;
|
253
253
|
}
|
254
254
|
|
255
|
-
// src/router.ts
|
256
255
|
function adaptRouter(router, options) {
|
257
256
|
if (isLazy(router)) {
|
258
257
|
const adapted2 = lazy(async () => {
|
@@ -316,23 +315,6 @@ function getRouterChild(router, ...path) {
|
|
316
315
|
return current;
|
317
316
|
}
|
318
317
|
|
319
|
-
// src/router-accessible-lazy.ts
|
320
|
-
function createAccessibleLazyRouter(lazied) {
|
321
|
-
const flattenLazy = flatLazy(lazied);
|
322
|
-
const recursive = new Proxy(flattenLazy, {
|
323
|
-
get(target, key) {
|
324
|
-
if (typeof key !== "string") {
|
325
|
-
return Reflect.get(target, key);
|
326
|
-
}
|
327
|
-
const next = getRouterChild(flattenLazy, key);
|
328
|
-
return createAccessibleLazyRouter(next);
|
329
|
-
}
|
330
|
-
});
|
331
|
-
return recursive;
|
332
|
-
}
|
333
|
-
|
334
|
-
// src/utils.ts
|
335
|
-
import { isContractProcedure as isContractProcedure2 } from "@orpc/contract";
|
336
318
|
function eachContractProcedure(options, callback, laziedOptions = []) {
|
337
319
|
const hiddenContract = getRouterContract(options.router);
|
338
320
|
if (hiddenContract) {
|
@@ -350,7 +332,7 @@ function eachContractProcedure(options, callback, laziedOptions = []) {
|
|
350
332
|
lazied: options.router,
|
351
333
|
path: options.path
|
352
334
|
});
|
353
|
-
} else if (
|
335
|
+
} else if (isContractProcedure(options.router)) {
|
354
336
|
callback({
|
355
337
|
contract: options.router,
|
356
338
|
path: options.path
|
@@ -373,10 +355,10 @@ async function eachAllContractProcedure(options, callback) {
|
|
373
355
|
const pending = [options];
|
374
356
|
for (const item of pending) {
|
375
357
|
const lazies = eachContractProcedure(item, callback);
|
376
|
-
for (const
|
377
|
-
const { default: router } = await unlazy(
|
358
|
+
for (const lazy of lazies) {
|
359
|
+
const { default: router } = await unlazy(lazy.lazied);
|
378
360
|
pending.push({
|
379
|
-
path:
|
361
|
+
path: lazy.path,
|
380
362
|
router
|
381
363
|
});
|
382
364
|
}
|
@@ -394,28 +376,4 @@ function createContractedProcedure(contract, procedure) {
|
|
394
376
|
});
|
395
377
|
}
|
396
378
|
|
397
|
-
export {
|
398
|
-
LAZY_LOADER_SYMBOL,
|
399
|
-
lazy,
|
400
|
-
isLazy,
|
401
|
-
unlazy,
|
402
|
-
Procedure,
|
403
|
-
isProcedure,
|
404
|
-
flatLazy,
|
405
|
-
createLazyProcedureFormAnyLazy,
|
406
|
-
addMiddleware,
|
407
|
-
middlewareOutputFn,
|
408
|
-
createProcedureClient,
|
409
|
-
setRouterContract,
|
410
|
-
getRouterContract,
|
411
|
-
deepSetLazyRouterPrefix,
|
412
|
-
getLazyRouterPrefix,
|
413
|
-
createAccessibleLazyRouter,
|
414
|
-
adaptRouter,
|
415
|
-
getRouterChild,
|
416
|
-
eachContractProcedure,
|
417
|
-
eachAllContractProcedure,
|
418
|
-
convertPathToHttpPath,
|
419
|
-
createContractedProcedure
|
420
|
-
};
|
421
|
-
//# sourceMappingURL=chunk-MHVECKBC.js.map
|
379
|
+
export { LAZY_LOADER_SYMBOL as L, Procedure as P, convertPathToHttpPath as a, createContractedProcedure as b, createProcedureClient as c, addMiddleware as d, eachContractProcedure as e, adaptRouter as f, getRouterChild as g, flatLazy as h, isProcedure as i, isLazy as j, createLazyProcedureFormAnyLazy as k, lazy as l, getRouterContract as m, deepSetLazyRouterPrefix as n, getLazyRouterPrefix as o, middlewareOutputFn as p, createAccessibleLazyRouter as q, eachAllContractProcedure as r, setRouterContract as s, unlazy as u };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.44.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -15,47 +15,42 @@
|
|
15
15
|
],
|
16
16
|
"exports": {
|
17
17
|
".": {
|
18
|
-
"types": "./dist/
|
19
|
-
"import": "./dist/index.
|
20
|
-
"default": "./dist/index.
|
18
|
+
"types": "./dist/index.d.mts",
|
19
|
+
"import": "./dist/index.mjs",
|
20
|
+
"default": "./dist/index.mjs"
|
21
21
|
},
|
22
22
|
"./plugins": {
|
23
|
-
"types": "./dist/
|
24
|
-
"import": "./dist/plugins.
|
25
|
-
"default": "./dist/plugins.
|
23
|
+
"types": "./dist/plugins/index.d.mts",
|
24
|
+
"import": "./dist/plugins/index.mjs",
|
25
|
+
"default": "./dist/plugins/index.mjs"
|
26
26
|
},
|
27
27
|
"./standard": {
|
28
|
-
"types": "./dist/
|
29
|
-
"import": "./dist/standard.
|
30
|
-
"default": "./dist/standard.
|
28
|
+
"types": "./dist/adapters/standard/index.d.mts",
|
29
|
+
"import": "./dist/adapters/standard/index.mjs",
|
30
|
+
"default": "./dist/adapters/standard/index.mjs"
|
31
31
|
},
|
32
32
|
"./fetch": {
|
33
|
-
"types": "./dist/
|
34
|
-
"import": "./dist/fetch.
|
35
|
-
"default": "./dist/fetch.
|
33
|
+
"types": "./dist/adapters/fetch/index.d.mts",
|
34
|
+
"import": "./dist/adapters/fetch/index.mjs",
|
35
|
+
"default": "./dist/adapters/fetch/index.mjs"
|
36
36
|
},
|
37
37
|
"./hono": {
|
38
|
-
"types": "./dist/
|
39
|
-
"import": "./dist/hono.
|
40
|
-
"default": "./dist/hono.
|
38
|
+
"types": "./dist/adapters/hono/index.d.mts",
|
39
|
+
"import": "./dist/adapters/hono/index.mjs",
|
40
|
+
"default": "./dist/adapters/hono/index.mjs"
|
41
41
|
},
|
42
42
|
"./next": {
|
43
|
-
"types": "./dist/
|
44
|
-
"import": "./dist/next.
|
45
|
-
"default": "./dist/next.
|
43
|
+
"types": "./dist/adapters/next/index.d.mts",
|
44
|
+
"import": "./dist/adapters/next/index.mjs",
|
45
|
+
"default": "./dist/adapters/next/index.mjs"
|
46
46
|
},
|
47
47
|
"./node": {
|
48
|
-
"types": "./dist/
|
49
|
-
"import": "./dist/node.
|
50
|
-
"default": "./dist/node.
|
51
|
-
},
|
52
|
-
"./🔒/*": {
|
53
|
-
"types": "./dist/src/*.d.ts"
|
48
|
+
"types": "./dist/adapters/node/index.d.mts",
|
49
|
+
"import": "./dist/adapters/node/index.mjs",
|
50
|
+
"default": "./dist/adapters/node/index.mjs"
|
54
51
|
}
|
55
52
|
},
|
56
53
|
"files": [
|
57
|
-
"!**/*.map",
|
58
|
-
"!**/*.tsbuildinfo",
|
59
54
|
"dist"
|
60
55
|
],
|
61
56
|
"peerDependencies": {
|
@@ -63,18 +58,18 @@
|
|
63
58
|
"next": ">=14.0.0"
|
64
59
|
},
|
65
60
|
"dependencies": {
|
66
|
-
"@orpc/client": "0.
|
67
|
-
"@orpc/
|
68
|
-
"@orpc/
|
69
|
-
"@orpc/standard-server
|
70
|
-
"@orpc/standard-server-
|
71
|
-
"@orpc/standard-server": "0.
|
61
|
+
"@orpc/client": "0.44.0",
|
62
|
+
"@orpc/contract": "0.44.0",
|
63
|
+
"@orpc/shared": "0.44.0",
|
64
|
+
"@orpc/standard-server": "0.44.0",
|
65
|
+
"@orpc/standard-server-fetch": "0.44.0",
|
66
|
+
"@orpc/standard-server-node": "0.44.0"
|
72
67
|
},
|
73
68
|
"devDependencies": {
|
74
69
|
"light-my-request": "^6.5.1"
|
75
70
|
},
|
76
71
|
"scripts": {
|
77
|
-
"build": "
|
72
|
+
"build": "unbuild",
|
78
73
|
"build:watch": "pnpm run build --watch",
|
79
74
|
"type:check": "tsc -b"
|
80
75
|
}
|
package/dist/fetch.js
DELETED
package/dist/node.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
RPCCodec,
|
3
|
-
RPCMatcher,
|
4
|
-
StandardHandler
|
5
|
-
} from "./chunk-TV5DRAST.js";
|
6
|
-
import "./chunk-MHVECKBC.js";
|
7
|
-
import "./chunk-TXHKQO7N.js";
|
8
|
-
|
9
|
-
// src/adapters/node/rpc-handler.ts
|
10
|
-
import { sendStandardResponse, toStandardRequest } from "@orpc/standard-server-node";
|
11
|
-
var RPCHandler = class {
|
12
|
-
standardHandler;
|
13
|
-
constructor(router, options) {
|
14
|
-
const codec = options?.codec ?? new RPCCodec();
|
15
|
-
const matcher = options?.matcher ?? new RPCMatcher();
|
16
|
-
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
17
|
-
}
|
18
|
-
async handle(req, res, ...rest) {
|
19
|
-
const standardRequest = toStandardRequest(req, res);
|
20
|
-
const result = await this.standardHandler.handle(standardRequest, ...rest);
|
21
|
-
if (!result.matched) {
|
22
|
-
return { matched: false };
|
23
|
-
}
|
24
|
-
await sendStandardResponse(res, result.response);
|
25
|
-
return { matched: true };
|
26
|
-
}
|
27
|
-
};
|
28
|
-
export {
|
29
|
-
RPCHandler
|
30
|
-
};
|
31
|
-
//# sourceMappingURL=node.js.map
|
package/dist/plugins.js
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import type { Context } from '../../context';
|
3
|
-
import type { Router } from '../../router';
|
4
|
-
import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
|
5
|
-
import type { FetchHandler, FetchHandleResult } from './types';
|
6
|
-
export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
|
7
|
-
private readonly standardHandler;
|
8
|
-
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
9
|
-
handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
10
|
-
}
|
11
|
-
//# sourceMappingURL=rpc-handler.d.ts.map
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import type { Context } from '../../context';
|
3
|
-
import type { StandardHandleOptions } from '../standard';
|
4
|
-
export type FetchHandleResult = {
|
5
|
-
matched: true;
|
6
|
-
response: Response;
|
7
|
-
} | {
|
8
|
-
matched: false;
|
9
|
-
response: undefined;
|
10
|
-
};
|
11
|
-
export interface FetchHandler<T extends Context> {
|
12
|
-
handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
13
|
-
}
|
14
|
-
//# sourceMappingURL=types.d.ts.map
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
2
|
-
import type { Context as HonoContext, MiddlewareHandler } from 'hono';
|
3
|
-
import type { Context } from '../../context';
|
4
|
-
import type { FetchHandler } from '../fetch';
|
5
|
-
import type { StandardHandleOptions } from '../standard';
|
6
|
-
export type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
7
|
-
context?: Value<T, [HonoContext]>;
|
8
|
-
} : {
|
9
|
-
context: Value<T, [HonoContext]>;
|
10
|
-
});
|
11
|
-
export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
12
|
-
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
2
|
-
import type { NextRequest } from 'next/server';
|
3
|
-
import type { Context } from '../../context';
|
4
|
-
import type { FetchHandler } from '../fetch';
|
5
|
-
import type { StandardHandleOptions } from '../standard';
|
6
|
-
export type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
7
|
-
context?: Value<T, [NextRequest]>;
|
8
|
-
} : {
|
9
|
-
context: Value<T, [NextRequest]>;
|
10
|
-
});
|
11
|
-
export interface ServeResult {
|
12
|
-
GET(req: NextRequest): Promise<Response>;
|
13
|
-
POST(req: NextRequest): Promise<Response>;
|
14
|
-
PUT(req: NextRequest): Promise<Response>;
|
15
|
-
PATCH(req: NextRequest): Promise<Response>;
|
16
|
-
DELETE(req: NextRequest): Promise<Response>;
|
17
|
-
}
|
18
|
-
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
19
|
-
//# sourceMappingURL=serve.d.ts.map
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import type { Context } from '../../context';
|
3
|
-
import type { Router } from '../../router';
|
4
|
-
import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
|
5
|
-
import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from './types';
|
6
|
-
export declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
|
7
|
-
private readonly standardHandler;
|
8
|
-
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
9
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
10
|
-
}
|
11
|
-
//# sourceMappingURL=rpc-handler.d.ts.map
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
3
|
-
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
4
|
-
import type { Context } from '../../context';
|
5
|
-
import type { StandardHandleOptions } from '../standard';
|
6
|
-
export type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
7
|
-
/**
|
8
|
-
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
9
|
-
* This is useful for `express.js` middleware.
|
10
|
-
*/
|
11
|
-
originalUrl?: string;
|
12
|
-
};
|
13
|
-
export type NodeHttpResponse = ServerResponse | Http2ServerResponse;
|
14
|
-
export type NodeHttpHandleResult = {
|
15
|
-
matched: true;
|
16
|
-
} | {
|
17
|
-
matched: false;
|
18
|
-
};
|
19
|
-
export interface NodeHttpHandler<T extends Context> {
|
20
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
21
|
-
}
|
22
|
-
//# sourceMappingURL=types.d.ts.map
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import type { ErrorFromErrorMap, HTTPPath, Meta, Schema, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
-
import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
|
4
|
-
import type { Context } from '../../context';
|
5
|
-
import type { Plugin } from '../../plugins';
|
6
|
-
import type { ProcedureClientInterceptorOptions } from '../../procedure-client';
|
7
|
-
import type { Router } from '../../router';
|
8
|
-
import type { StandardCodec, StandardMatcher } from './types';
|
9
|
-
export type StandardHandleOptions<T extends Context> = {
|
10
|
-
prefix?: HTTPPath;
|
11
|
-
} & (Record<never, never> extends T ? {
|
12
|
-
context?: T;
|
13
|
-
} : {
|
14
|
-
context: T;
|
15
|
-
});
|
16
|
-
export type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
|
17
|
-
context: T;
|
18
|
-
};
|
19
|
-
export type StandardHandleResult = {
|
20
|
-
matched: true;
|
21
|
-
response: StandardResponse;
|
22
|
-
} | {
|
23
|
-
matched: false;
|
24
|
-
response: undefined;
|
25
|
-
};
|
26
|
-
export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
|
27
|
-
request: StandardRequest;
|
28
|
-
};
|
29
|
-
export interface StandardHandlerOptions<TContext extends Context> {
|
30
|
-
plugins?: Plugin<TContext>[];
|
31
|
-
/**
|
32
|
-
* Interceptors at the request level, helpful when you want catch errors
|
33
|
-
*/
|
34
|
-
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
35
|
-
/**
|
36
|
-
* Interceptors at the root level, helpful when you want override the request/response
|
37
|
-
*/
|
38
|
-
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
39
|
-
/**
|
40
|
-
*
|
41
|
-
* Interceptors for procedure client.
|
42
|
-
*/
|
43
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Schema, Record<never, never>, Meta>, SchemaOutput<Schema, unknown>, ErrorFromErrorMap<Record<never, never>>>[];
|
44
|
-
}
|
45
|
-
export declare class StandardHandler<T extends Context> {
|
46
|
-
private readonly matcher;
|
47
|
-
private readonly codec;
|
48
|
-
private readonly options;
|
49
|
-
private readonly plugin;
|
50
|
-
constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
|
51
|
-
handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
|
52
|
-
}
|
53
|
-
//# sourceMappingURL=handler.d.ts.map
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { ORPCError } from '@orpc/client';
|
2
|
-
import type { AnyProcedure } from '../../procedure';
|
3
|
-
import type { StandardCodec, StandardParams } from './types';
|
4
|
-
import { RPCSerializer } from '@orpc/client/rpc';
|
5
|
-
import { type StandardRequest, type StandardResponse } from '@orpc/standard-server';
|
6
|
-
export interface StandardCodecOptions {
|
7
|
-
serializer?: RPCSerializer;
|
8
|
-
}
|
9
|
-
export declare class RPCCodec implements StandardCodec {
|
10
|
-
private readonly serializer;
|
11
|
-
constructor(options?: StandardCodecOptions);
|
12
|
-
decode(request: StandardRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
|
13
|
-
encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
|
14
|
-
encodeError(error: ORPCError<any, any>): StandardResponse;
|
15
|
-
}
|
16
|
-
//# sourceMappingURL=rpc-codec.d.ts.map
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { Context } from '../../context';
|
2
|
-
import type { StandardHandlerOptions } from './handler';
|
3
|
-
import type { StandardCodec, StandardMatcher } from './types';
|
4
|
-
export interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T> {
|
5
|
-
matcher?: StandardMatcher;
|
6
|
-
codec?: StandardCodec;
|
7
|
-
}
|
8
|
-
//# sourceMappingURL=rpc-handler.d.ts.map
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { HTTPPath } from '@orpc/contract';
|
2
|
-
import type { StandardMatcher, StandardMatchResult } from './types';
|
3
|
-
import { type AnyRouter } from '../../router';
|
4
|
-
export declare class RPCMatcher implements StandardMatcher {
|
5
|
-
private readonly tree;
|
6
|
-
private pendingRouters;
|
7
|
-
init(router: AnyRouter, path?: string[]): void;
|
8
|
-
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=rpc-matcher.d.ts.map
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import type { ORPCError } from '@orpc/client';
|
2
|
-
import type { HTTPPath } from '@orpc/contract';
|
3
|
-
import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
|
4
|
-
import type { AnyProcedure } from '../../procedure';
|
5
|
-
import type { AnyRouter } from '../../router';
|
6
|
-
export type StandardParams = Record<string, string>;
|
7
|
-
export type StandardMatchResult = {
|
8
|
-
path: string[];
|
9
|
-
procedure: AnyProcedure;
|
10
|
-
params?: StandardParams;
|
11
|
-
} | undefined;
|
12
|
-
export interface StandardMatcher {
|
13
|
-
init(router: AnyRouter): void;
|
14
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
15
|
-
}
|
16
|
-
export interface StandardCodec {
|
17
|
-
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
18
|
-
encodeError(error: ORPCError<any, any>): StandardResponse;
|
19
|
-
decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
20
|
-
}
|
21
|
-
//# sourceMappingURL=types.d.ts.map
|