@orpc/server 0.0.0-next.6acfc62 → 0.0.0-next.6c13765
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/dist/chunk-47YYO5JS.js +32 -0
- package/dist/chunk-77FU7QSO.js +181 -0
- package/dist/{chunk-NOA3GBJQ.js → chunk-MHVECKBC.js} +64 -23
- package/dist/{chunk-OWMUECGT.js → chunk-WQNNSBXW.js} +20 -11
- package/dist/fetch.js +6 -14
- package/dist/hono.js +7 -15
- package/dist/index.js +16 -7
- package/dist/next.js +6 -14
- package/dist/node.js +7 -151
- package/dist/plugins.js +1 -1
- package/dist/src/adapters/fetch/index.d.ts +0 -1
- package/dist/src/adapters/fetch/rpc-handler.d.ts +3 -2
- package/dist/src/adapters/fetch/types.d.ts +3 -2
- package/dist/src/adapters/hono/middleware.d.ts +2 -3
- package/dist/src/adapters/next/serve.d.ts +2 -3
- package/dist/src/adapters/node/index.d.ts +0 -1
- package/dist/src/adapters/node/rpc-handler.d.ts +3 -2
- package/dist/src/adapters/node/types.d.ts +3 -2
- package/dist/src/adapters/standard/handler.d.ts +15 -9
- package/dist/src/adapters/standard/index.d.ts +0 -1
- package/dist/src/adapters/standard/rpc-codec.d.ts +4 -3
- package/dist/src/adapters/standard/types.d.ts +3 -26
- package/dist/src/builder-variants.d.ts +2 -1
- package/dist/src/builder.d.ts +2 -1
- package/dist/src/context.d.ts +0 -1
- package/dist/src/error.d.ts +12 -0
- package/dist/src/implementer-procedure.d.ts +7 -4
- package/dist/src/implementer-variants.d.ts +2 -1
- package/dist/src/implementer.d.ts +2 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/middleware-decorated.d.ts +2 -1
- package/dist/src/middleware.d.ts +5 -4
- package/dist/src/plugins/cors.d.ts +2 -1
- package/dist/src/procedure-client.d.ts +21 -8
- package/dist/src/procedure-decorated.d.ts +7 -4
- package/dist/src/procedure-utils.d.ts +5 -3
- package/dist/src/procedure.d.ts +5 -3
- package/dist/src/router-client.d.ts +7 -17
- package/dist/src/router.d.ts +1 -0
- package/dist/standard.js +5 -9
- package/package.json +7 -4
- package/dist/chunk-JBPBLCBJ.js +0 -136
- package/dist/chunk-SUGWQSMQ.js +0 -308
- package/dist/src/adapters/fetch/utils.d.ts +0 -6
- package/dist/src/adapters/node/utils.d.ts +0 -5
- package/dist/src/adapters/standard/rpc-serializer.d.ts +0 -16
@@ -0,0 +1,32 @@
|
|
1
|
+
import {
|
2
|
+
RPCCodec,
|
3
|
+
RPCMatcher,
|
4
|
+
StandardHandler
|
5
|
+
} from "./chunk-77FU7QSO.js";
|
6
|
+
|
7
|
+
// src/adapters/fetch/rpc-handler.ts
|
8
|
+
import { toFetchResponse, toStandardRequest } from "@orpc/server-standard-fetch";
|
9
|
+
var RPCHandler = class {
|
10
|
+
standardHandler;
|
11
|
+
constructor(router, options) {
|
12
|
+
const matcher = options?.matcher ?? new RPCMatcher();
|
13
|
+
const codec = options?.codec ?? new RPCCodec();
|
14
|
+
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
15
|
+
}
|
16
|
+
async handle(request, ...rest) {
|
17
|
+
const standardRequest = toStandardRequest(request);
|
18
|
+
const result = await this.standardHandler.handle(standardRequest, ...rest);
|
19
|
+
if (!result.matched) {
|
20
|
+
return result;
|
21
|
+
}
|
22
|
+
return {
|
23
|
+
matched: true,
|
24
|
+
response: toFetchResponse(result.response)
|
25
|
+
};
|
26
|
+
}
|
27
|
+
};
|
28
|
+
|
29
|
+
export {
|
30
|
+
RPCHandler
|
31
|
+
};
|
32
|
+
//# sourceMappingURL=chunk-47YYO5JS.js.map
|
@@ -0,0 +1,181 @@
|
|
1
|
+
import {
|
2
|
+
convertPathToHttpPath,
|
3
|
+
createContractedProcedure,
|
4
|
+
createProcedureClient,
|
5
|
+
eachContractProcedure,
|
6
|
+
getRouterChild,
|
7
|
+
isProcedure,
|
8
|
+
unlazy
|
9
|
+
} from "./chunk-MHVECKBC.js";
|
10
|
+
import {
|
11
|
+
CompositePlugin
|
12
|
+
} from "./chunk-WQNNSBXW.js";
|
13
|
+
|
14
|
+
// src/adapters/standard/handler.ts
|
15
|
+
import { ORPCError, toORPCError } from "@orpc/client";
|
16
|
+
import { intercept, trim } from "@orpc/shared";
|
17
|
+
var StandardHandler = class {
|
18
|
+
constructor(router, matcher, codec, options = {}) {
|
19
|
+
this.matcher = matcher;
|
20
|
+
this.codec = codec;
|
21
|
+
this.options = options;
|
22
|
+
this.plugin = new CompositePlugin(options.plugins);
|
23
|
+
this.plugin.init(this.options);
|
24
|
+
this.matcher.init(router);
|
25
|
+
}
|
26
|
+
plugin;
|
27
|
+
handle(request, ...[options]) {
|
28
|
+
return intercept(
|
29
|
+
this.options.rootInterceptors ?? [],
|
30
|
+
{
|
31
|
+
request,
|
32
|
+
...options,
|
33
|
+
context: options?.context ?? {}
|
34
|
+
// context is optional only when all fields are optional so we can safely force it to have a context
|
35
|
+
},
|
36
|
+
async (interceptorOptions) => {
|
37
|
+
let isDecoding = false;
|
38
|
+
try {
|
39
|
+
return await intercept(
|
40
|
+
this.options.interceptors ?? [],
|
41
|
+
interceptorOptions,
|
42
|
+
async (interceptorOptions2) => {
|
43
|
+
const method = interceptorOptions2.request.method;
|
44
|
+
const url = interceptorOptions2.request.url;
|
45
|
+
const pathname = `/${trim(url.pathname.replace(interceptorOptions2.prefix ?? "", ""), "/")}`;
|
46
|
+
const match = await this.matcher.match(method, pathname);
|
47
|
+
if (!match) {
|
48
|
+
return { matched: false, response: void 0 };
|
49
|
+
}
|
50
|
+
const client = createProcedureClient(match.procedure, {
|
51
|
+
context: interceptorOptions2.context,
|
52
|
+
path: match.path,
|
53
|
+
interceptors: this.options.clientInterceptors
|
54
|
+
});
|
55
|
+
isDecoding = true;
|
56
|
+
const input = await this.codec.decode(request, match.params, match.procedure);
|
57
|
+
isDecoding = false;
|
58
|
+
const lastEventId = Array.isArray(request.headers["last-event-id"]) ? request.headers["last-event-id"].at(-1) : request.headers["last-event-id"];
|
59
|
+
const output = await client(input, { signal: request.signal, lastEventId });
|
60
|
+
const response = this.codec.encode(output, match.procedure);
|
61
|
+
return {
|
62
|
+
matched: true,
|
63
|
+
response
|
64
|
+
};
|
65
|
+
}
|
66
|
+
);
|
67
|
+
} catch (e) {
|
68
|
+
const error = isDecoding ? new ORPCError("BAD_REQUEST", {
|
69
|
+
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
70
|
+
cause: e
|
71
|
+
}) : toORPCError(e);
|
72
|
+
const response = this.codec.encodeError(error);
|
73
|
+
return {
|
74
|
+
matched: true,
|
75
|
+
response
|
76
|
+
};
|
77
|
+
}
|
78
|
+
}
|
79
|
+
);
|
80
|
+
}
|
81
|
+
};
|
82
|
+
|
83
|
+
// src/adapters/standard/rpc-codec.ts
|
84
|
+
import { RPCSerializer } from "@orpc/client/rpc";
|
85
|
+
var RPCCodec = class {
|
86
|
+
serializer;
|
87
|
+
constructor(options = {}) {
|
88
|
+
this.serializer = options.serializer ?? new RPCSerializer();
|
89
|
+
}
|
90
|
+
async decode(request, _params, _procedure) {
|
91
|
+
const serialized = request.method === "GET" ? JSON.parse(request.url.searchParams.getAll("data").at(-1)) : await request.body();
|
92
|
+
return this.serializer.deserialize(serialized);
|
93
|
+
}
|
94
|
+
encode(output, _procedure) {
|
95
|
+
return {
|
96
|
+
status: 200,
|
97
|
+
headers: {},
|
98
|
+
body: this.serializer.serialize(output)
|
99
|
+
};
|
100
|
+
}
|
101
|
+
encodeError(error) {
|
102
|
+
return {
|
103
|
+
status: error.status,
|
104
|
+
headers: {},
|
105
|
+
body: this.serializer.serialize(error.toJSON())
|
106
|
+
};
|
107
|
+
}
|
108
|
+
};
|
109
|
+
|
110
|
+
// src/adapters/standard/rpc-matcher.ts
|
111
|
+
var RPCMatcher = class {
|
112
|
+
tree = {};
|
113
|
+
pendingRouters = [];
|
114
|
+
init(router, path = []) {
|
115
|
+
const laziedOptions = eachContractProcedure({
|
116
|
+
router,
|
117
|
+
path
|
118
|
+
}, ({ path: path2, contract }) => {
|
119
|
+
const httpPath = convertPathToHttpPath(path2);
|
120
|
+
if (isProcedure(contract)) {
|
121
|
+
this.tree[httpPath] = {
|
122
|
+
path: path2,
|
123
|
+
contract,
|
124
|
+
procedure: contract,
|
125
|
+
// this mean dev not used contract-first so we can used contract as procedure directly
|
126
|
+
router
|
127
|
+
};
|
128
|
+
} else {
|
129
|
+
this.tree[httpPath] = {
|
130
|
+
path: path2,
|
131
|
+
contract,
|
132
|
+
procedure: void 0,
|
133
|
+
router
|
134
|
+
};
|
135
|
+
}
|
136
|
+
});
|
137
|
+
this.pendingRouters.push(...laziedOptions.map((option) => ({
|
138
|
+
...option,
|
139
|
+
httpPathPrefix: convertPathToHttpPath(option.path)
|
140
|
+
})));
|
141
|
+
}
|
142
|
+
async match(_method, pathname) {
|
143
|
+
if (this.pendingRouters.length) {
|
144
|
+
const newPendingRouters = [];
|
145
|
+
for (const pendingRouter of this.pendingRouters) {
|
146
|
+
if (pathname.startsWith(pendingRouter.httpPathPrefix)) {
|
147
|
+
const { default: router } = await unlazy(pendingRouter.lazied);
|
148
|
+
this.init(router, pendingRouter.path);
|
149
|
+
} else {
|
150
|
+
newPendingRouters.push(pendingRouter);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
this.pendingRouters = newPendingRouters;
|
154
|
+
}
|
155
|
+
const match = this.tree[pathname];
|
156
|
+
if (!match) {
|
157
|
+
return void 0;
|
158
|
+
}
|
159
|
+
if (!match.procedure) {
|
160
|
+
const { default: maybeProcedure } = await unlazy(getRouterChild(match.router, ...match.path));
|
161
|
+
if (!isProcedure(maybeProcedure)) {
|
162
|
+
throw new Error(`
|
163
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${convertPathToHttpPath(match.path)}.
|
164
|
+
Ensure that the procedure is correctly defined and matches the expected contract.
|
165
|
+
`);
|
166
|
+
}
|
167
|
+
match.procedure = createContractedProcedure(match.contract, maybeProcedure);
|
168
|
+
}
|
169
|
+
return {
|
170
|
+
path: match.path,
|
171
|
+
procedure: match.procedure
|
172
|
+
};
|
173
|
+
}
|
174
|
+
};
|
175
|
+
|
176
|
+
export {
|
177
|
+
StandardHandler,
|
178
|
+
RPCCodec,
|
179
|
+
RPCMatcher
|
180
|
+
};
|
181
|
+
//# sourceMappingURL=chunk-77FU7QSO.js.map
|
@@ -62,33 +62,74 @@ function middlewareOutputFn(output) {
|
|
62
62
|
}
|
63
63
|
|
64
64
|
// src/procedure-client.ts
|
65
|
-
import {
|
66
|
-
import {
|
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
|
+
function createORPCErrorConstructorMap(errors) {
|
72
|
+
const proxy = new Proxy(errors, {
|
73
|
+
get(target, code) {
|
74
|
+
if (typeof code !== "string") {
|
75
|
+
return Reflect.get(target, code);
|
76
|
+
}
|
77
|
+
const item = (...[options]) => {
|
78
|
+
const config = errors[code];
|
79
|
+
return new ORPCError(code, {
|
80
|
+
defined: Boolean(config),
|
81
|
+
status: config?.status,
|
82
|
+
message: options?.message ?? config?.message,
|
83
|
+
data: options?.data,
|
84
|
+
cause: options?.cause
|
85
|
+
});
|
86
|
+
};
|
87
|
+
return item;
|
88
|
+
}
|
89
|
+
});
|
90
|
+
return proxy;
|
91
|
+
}
|
92
|
+
async function validateORPCError(map, error) {
|
93
|
+
const { code, status, message, data, cause, defined } = error;
|
94
|
+
const config = map?.[error.code];
|
95
|
+
if (!config || fallbackORPCErrorStatus(error.code, config.status) !== error.status) {
|
96
|
+
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
|
97
|
+
}
|
98
|
+
if (!config.data) {
|
99
|
+
return defined ? error : new ORPCError(code, { defined: true, status, message, data, cause });
|
100
|
+
}
|
101
|
+
const validated = await config.data["~standard"].validate(error.data);
|
102
|
+
if (validated.issues) {
|
103
|
+
return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
|
104
|
+
}
|
105
|
+
return new ORPCError(code, { defined: true, status, message, data: validated.value, cause });
|
106
|
+
}
|
107
|
+
|
108
|
+
// src/procedure-client.ts
|
67
109
|
function createProcedureClient(lazyableProcedure, ...[options]) {
|
68
110
|
return async (...[input, callerOptions]) => {
|
69
111
|
const path = options?.path ?? [];
|
70
112
|
const { default: procedure } = await unlazy(lazyableProcedure);
|
71
|
-
const
|
113
|
+
const clientContext = callerOptions?.context ?? {};
|
114
|
+
const context = await value(options?.context ?? {}, clientContext);
|
72
115
|
const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
|
73
|
-
const executeOptions = {
|
74
|
-
input,
|
75
|
-
context,
|
76
|
-
errors,
|
77
|
-
path,
|
78
|
-
procedure,
|
79
|
-
signal: callerOptions?.signal
|
80
|
-
};
|
81
116
|
try {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
117
|
+
return await intercept(
|
118
|
+
options?.interceptors ?? [],
|
119
|
+
{
|
120
|
+
context,
|
121
|
+
input,
|
122
|
+
// input only optional when it undefinable so we can safely cast it
|
123
|
+
errors,
|
124
|
+
path,
|
125
|
+
procedure,
|
126
|
+
signal: callerOptions?.signal,
|
127
|
+
lastEventId: callerOptions?.lastEventId
|
128
|
+
},
|
129
|
+
(interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
|
130
|
+
);
|
90
131
|
} catch (e) {
|
91
|
-
if (!(e instanceof
|
132
|
+
if (!(e instanceof ORPCError2)) {
|
92
133
|
throw toError(e);
|
93
134
|
}
|
94
135
|
const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
|
@@ -103,7 +144,7 @@ async function validateInput(procedure, input) {
|
|
103
144
|
}
|
104
145
|
const result = await schema["~standard"].validate(input);
|
105
146
|
if (result.issues) {
|
106
|
-
throw new
|
147
|
+
throw new ORPCError2("BAD_REQUEST", {
|
107
148
|
message: "Input validation failed",
|
108
149
|
data: {
|
109
150
|
issues: result.issues
|
@@ -120,7 +161,7 @@ async function validateOutput(procedure, output) {
|
|
120
161
|
}
|
121
162
|
const result = await schema["~standard"].validate(output);
|
122
163
|
if (result.issues) {
|
123
|
-
throw new
|
164
|
+
throw new ORPCError2("INTERNAL_SERVER_ERROR", {
|
124
165
|
message: "Output validation failed",
|
125
166
|
cause: new ValidationError({ message: "Output validation failed", issues: result.issues })
|
126
167
|
});
|
@@ -377,4 +418,4 @@ export {
|
|
377
418
|
convertPathToHttpPath,
|
378
419
|
createContractedProcedure
|
379
420
|
};
|
380
|
-
//# sourceMappingURL=chunk-
|
421
|
+
//# sourceMappingURL=chunk-MHVECKBC.js.map
|
@@ -16,7 +16,7 @@ var CORSPlugin = class {
|
|
16
16
|
options;
|
17
17
|
constructor(options) {
|
18
18
|
const defaults = {
|
19
|
-
origin:
|
19
|
+
origin: (origin) => origin,
|
20
20
|
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"]
|
21
21
|
};
|
22
22
|
this.options = {
|
@@ -25,8 +25,8 @@ var CORSPlugin = class {
|
|
25
25
|
};
|
26
26
|
}
|
27
27
|
init(options) {
|
28
|
-
options.
|
29
|
-
options.
|
28
|
+
options.rootInterceptors ??= [];
|
29
|
+
options.rootInterceptors.unshift(async (interceptorOptions) => {
|
30
30
|
if (interceptorOptions.request.method === "OPTIONS") {
|
31
31
|
const resHeaders = {};
|
32
32
|
if (this.options.maxAge !== void 0) {
|
@@ -52,7 +52,7 @@ var CORSPlugin = class {
|
|
52
52
|
}
|
53
53
|
return interceptorOptions.next();
|
54
54
|
});
|
55
|
-
options.
|
55
|
+
options.rootInterceptors.unshift(async (interceptorOptions) => {
|
56
56
|
const result = await interceptorOptions.next();
|
57
57
|
if (!result.matched) {
|
58
58
|
return result;
|
@@ -60,12 +60,21 @@ var CORSPlugin = class {
|
|
60
60
|
const origin = Array.isArray(interceptorOptions.request.headers.origin) ? interceptorOptions.request.headers.origin.join(",") : interceptorOptions.request.headers.origin || "";
|
61
61
|
const allowedOrigin = await value(this.options.origin, origin, interceptorOptions);
|
62
62
|
const allowedOriginArr = Array.isArray(allowedOrigin) ? allowedOrigin : [allowedOrigin];
|
63
|
-
if (allowedOriginArr.includes(
|
64
|
-
result.response.headers["access-control-allow-origin"] =
|
65
|
-
}
|
66
|
-
|
63
|
+
if (allowedOriginArr.includes("*")) {
|
64
|
+
result.response.headers["access-control-allow-origin"] = "*";
|
65
|
+
} else {
|
66
|
+
if (allowedOriginArr.includes(origin)) {
|
67
|
+
result.response.headers["access-control-allow-origin"] = origin;
|
68
|
+
}
|
67
69
|
result.response.headers.vary = interceptorOptions.request.headers.vary ?? "origin";
|
68
70
|
}
|
71
|
+
const allowedTimingOrigin = await value(this.options.timingOrigin, origin, interceptorOptions);
|
72
|
+
const allowedTimingOriginArr = Array.isArray(allowedTimingOrigin) ? allowedTimingOrigin : [allowedTimingOrigin];
|
73
|
+
if (allowedTimingOriginArr.includes("*")) {
|
74
|
+
result.response.headers["timing-allow-origin"] = "*";
|
75
|
+
} else if (allowedTimingOriginArr.includes(origin)) {
|
76
|
+
result.response.headers["timing-allow-origin"] = origin;
|
77
|
+
}
|
69
78
|
if (this.options.credentials) {
|
70
79
|
result.response.headers["access-control-allow-credentials"] = "true";
|
71
80
|
}
|
@@ -80,8 +89,8 @@ var CORSPlugin = class {
|
|
80
89
|
// src/plugins/response-headers.ts
|
81
90
|
var ResponseHeadersPlugin = class {
|
82
91
|
init(options) {
|
83
|
-
options.
|
84
|
-
options.
|
92
|
+
options.rootInterceptors ??= [];
|
93
|
+
options.rootInterceptors.push(async (interceptorOptions) => {
|
85
94
|
const headers = new Headers();
|
86
95
|
interceptorOptions.context.resHeaders = headers;
|
87
96
|
const result = await interceptorOptions.next();
|
@@ -108,4 +117,4 @@ export {
|
|
108
117
|
CORSPlugin,
|
109
118
|
ResponseHeadersPlugin
|
110
119
|
};
|
111
|
-
//# sourceMappingURL=chunk-
|
120
|
+
//# sourceMappingURL=chunk-WQNNSBXW.js.map
|
package/dist/fetch.js
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
import {
|
2
|
-
RPCHandler
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
} from "./chunk-JBPBLCBJ.js";
|
8
|
-
import "./chunk-SUGWQSMQ.js";
|
9
|
-
import "./chunk-NOA3GBJQ.js";
|
10
|
-
import "./chunk-OWMUECGT.js";
|
2
|
+
RPCHandler
|
3
|
+
} from "./chunk-47YYO5JS.js";
|
4
|
+
import "./chunk-77FU7QSO.js";
|
5
|
+
import "./chunk-MHVECKBC.js";
|
6
|
+
import "./chunk-WQNNSBXW.js";
|
11
7
|
export {
|
12
|
-
RPCHandler
|
13
|
-
fetchReToStandardBody,
|
14
|
-
fetchRequestToStandardRequest,
|
15
|
-
standardBodyToFetchBody,
|
16
|
-
standardResponseToFetchResponse
|
8
|
+
RPCHandler
|
17
9
|
};
|
18
10
|
//# sourceMappingURL=fetch.js.map
|
package/dist/hono.js
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
import {
|
2
|
-
RPCHandler
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
} from "./chunk-JBPBLCBJ.js";
|
8
|
-
import "./chunk-SUGWQSMQ.js";
|
9
|
-
import "./chunk-NOA3GBJQ.js";
|
10
|
-
import "./chunk-OWMUECGT.js";
|
2
|
+
RPCHandler
|
3
|
+
} from "./chunk-47YYO5JS.js";
|
4
|
+
import "./chunk-77FU7QSO.js";
|
5
|
+
import "./chunk-MHVECKBC.js";
|
6
|
+
import "./chunk-WQNNSBXW.js";
|
11
7
|
|
12
8
|
// src/adapters/hono/middleware.ts
|
13
9
|
import { value } from "@orpc/shared";
|
@@ -26,17 +22,13 @@ function createMiddleware(handler, ...[options]) {
|
|
26
22
|
const context = await value(options?.context ?? {}, c);
|
27
23
|
const { matched, response } = await handler.handle(request, { ...options, context });
|
28
24
|
if (matched) {
|
29
|
-
return c.
|
25
|
+
return c.newResponse(response.body, response);
|
30
26
|
}
|
31
27
|
await next();
|
32
28
|
};
|
33
29
|
}
|
34
30
|
export {
|
35
31
|
RPCHandler,
|
36
|
-
createMiddleware
|
37
|
-
fetchReToStandardBody,
|
38
|
-
fetchRequestToStandardRequest,
|
39
|
-
standardBodyToFetchBody,
|
40
|
-
standardResponseToFetchResponse
|
32
|
+
createMiddleware
|
41
33
|
};
|
42
34
|
//# sourceMappingURL=hono.js.map
|
package/dist/index.js
CHANGED
@@ -21,7 +21,7 @@ import {
|
|
21
21
|
middlewareOutputFn,
|
22
22
|
setRouterContract,
|
23
23
|
unlazy
|
24
|
-
} from "./chunk-
|
24
|
+
} from "./chunk-MHVECKBC.js";
|
25
25
|
|
26
26
|
// src/builder.ts
|
27
27
|
import { mergeErrorMap as mergeErrorMap2, mergeMeta as mergeMeta2, mergePrefix, mergeRoute as mergeRoute2, mergeTags } from "@orpc/contract";
|
@@ -50,10 +50,14 @@ function decorateMiddleware(middleware) {
|
|
50
50
|
decorated.concat = (concatMiddleware, mapInput) => {
|
51
51
|
const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
|
52
52
|
const concatted = decorateMiddleware((options, input, output, ...rest) => {
|
53
|
-
const
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
const merged = middleware({
|
54
|
+
...options,
|
55
|
+
next: (...[nextOptions1]) => mapped({
|
56
|
+
...options,
|
57
|
+
context: { ...options.context, ...nextOptions1?.context },
|
58
|
+
next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
|
59
|
+
}, input, output, ...rest)
|
60
|
+
}, input, output, ...rest);
|
57
61
|
return merged;
|
58
62
|
});
|
59
63
|
return concatted;
|
@@ -357,7 +361,9 @@ function createRouterClient(router, ...rest) {
|
|
357
361
|
}
|
358
362
|
|
359
363
|
// src/index.ts
|
360
|
-
import { isDefinedError, ORPCError, safe
|
364
|
+
import { isDefinedError, ORPCError, safe } from "@orpc/client";
|
365
|
+
import { eventIterator, type, ValidationError } from "@orpc/contract";
|
366
|
+
import { getEventMeta, withEventMeta } from "@orpc/server-standard";
|
361
367
|
import { onError, onFinish, onStart, onSuccess } from "@orpc/shared";
|
362
368
|
export {
|
363
369
|
Builder,
|
@@ -378,8 +384,10 @@ export {
|
|
378
384
|
deepSetLazyRouterPrefix,
|
379
385
|
eachAllContractProcedure,
|
380
386
|
eachContractProcedure,
|
387
|
+
eventIterator,
|
381
388
|
fallbackConfig,
|
382
389
|
flatLazy,
|
390
|
+
getEventMeta,
|
383
391
|
getLazyRouterPrefix,
|
384
392
|
getRouterChild,
|
385
393
|
getRouterContract,
|
@@ -399,6 +407,7 @@ export {
|
|
399
407
|
safe,
|
400
408
|
setRouterContract,
|
401
409
|
type,
|
402
|
-
unlazy
|
410
|
+
unlazy,
|
411
|
+
withEventMeta
|
403
412
|
};
|
404
413
|
//# sourceMappingURL=index.js.map
|
package/dist/next.js
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
import {
|
2
|
-
RPCHandler
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
} from "./chunk-JBPBLCBJ.js";
|
8
|
-
import "./chunk-SUGWQSMQ.js";
|
9
|
-
import "./chunk-NOA3GBJQ.js";
|
10
|
-
import "./chunk-OWMUECGT.js";
|
2
|
+
RPCHandler
|
3
|
+
} from "./chunk-47YYO5JS.js";
|
4
|
+
import "./chunk-77FU7QSO.js";
|
5
|
+
import "./chunk-MHVECKBC.js";
|
6
|
+
import "./chunk-WQNNSBXW.js";
|
11
7
|
|
12
8
|
// src/adapters/next/serve.ts
|
13
9
|
import { value } from "@orpc/shared";
|
@@ -30,10 +26,6 @@ function serve(handler, ...[options]) {
|
|
30
26
|
}
|
31
27
|
export {
|
32
28
|
RPCHandler,
|
33
|
-
|
34
|
-
fetchRequestToStandardRequest,
|
35
|
-
serve,
|
36
|
-
standardBodyToFetchBody,
|
37
|
-
standardResponseToFetchResponse
|
29
|
+
serve
|
38
30
|
};
|
39
31
|
//# sourceMappingURL=next.js.map
|