@orpc/openapi 0.0.0-next.b2e67f7 → 0.0.0-next.b355a2e
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 +41 -28
- package/dist/adapters/aws-lambda/index.d.mts +20 -0
- package/dist/adapters/aws-lambda/index.d.ts +20 -0
- package/dist/adapters/aws-lambda/index.mjs +18 -0
- package/dist/adapters/fastify/index.d.mts +23 -0
- package/dist/adapters/fastify/index.d.ts +23 -0
- package/dist/adapters/fastify/index.mjs +18 -0
- package/dist/adapters/fetch/index.d.mts +23 -0
- package/dist/adapters/fetch/index.d.ts +23 -0
- package/dist/adapters/fetch/index.mjs +18 -0
- package/dist/adapters/node/index.d.mts +23 -0
- package/dist/adapters/node/index.d.ts +23 -0
- package/dist/adapters/node/index.mjs +18 -0
- package/dist/adapters/standard/index.d.mts +20 -0
- package/dist/adapters/standard/index.d.ts +20 -0
- package/dist/adapters/standard/index.mjs +9 -0
- package/dist/index.d.mts +116 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.mjs +41 -0
- package/dist/plugins/index.d.mts +84 -0
- package/dist/plugins/index.d.ts +84 -0
- package/dist/plugins/index.mjs +148 -0
- package/dist/shared/openapi.BGy4N6eR.d.mts +120 -0
- package/dist/shared/openapi.BGy4N6eR.d.ts +120 -0
- package/dist/shared/openapi.CoREqFh3.mjs +853 -0
- package/dist/{chunk-LTTK3H5J.js → shared/openapi.DIt-Z9W1.mjs} +76 -43
- package/dist/shared/openapi.DwaweYRb.d.mts +54 -0
- package/dist/shared/openapi.DwaweYRb.d.ts +54 -0
- package/package.json +41 -42
- package/dist/chunk-PW7RAFQQ.js +0 -32
- package/dist/chunk-XGHV4TH3.js +0 -13
- package/dist/fetch.js +0 -9
- package/dist/hono.js +0 -9
- package/dist/index.js +0 -701
- package/dist/next.js +0 -9
- package/dist/node.js +0 -30
- package/dist/src/adapters/fetch/index.d.ts +0 -2
- package/dist/src/adapters/fetch/openapi-handler.d.ts +0 -11
- package/dist/src/adapters/hono/index.d.ts +0 -2
- package/dist/src/adapters/next/index.d.ts +0 -2
- package/dist/src/adapters/node/index.d.ts +0 -2
- package/dist/src/adapters/node/openapi-handler.d.ts +0 -11
- package/dist/src/adapters/standard/index.d.ts +0 -4
- package/dist/src/adapters/standard/openapi-codec.d.ts +0 -13
- package/dist/src/adapters/standard/openapi-handler.d.ts +0 -5
- package/dist/src/adapters/standard/openapi-matcher.d.ts +0 -10
- package/dist/src/index.d.ts +0 -16
- package/dist/src/openapi-content-builder.d.ts +0 -10
- package/dist/src/openapi-error.d.ts +0 -3
- package/dist/src/openapi-generator.d.ts +0 -67
- package/dist/src/openapi-input-structure-parser.d.ts +0 -22
- package/dist/src/openapi-operation-extender.d.ts +0 -7
- package/dist/src/openapi-output-structure-parser.d.ts +0 -18
- package/dist/src/openapi-parameters-builder.d.ts +0 -12
- package/dist/src/openapi-path-parser.d.ts +0 -8
- package/dist/src/openapi.d.ts +0 -3
- package/dist/src/schema-converter.d.ts +0 -16
- package/dist/src/schema-utils.d.ts +0 -11
- package/dist/src/schema.d.ts +0 -12
- package/dist/src/utils.d.ts +0 -4
- package/dist/standard.js +0 -10
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from
|
|
1
|
+
import { standardizeHTTPPath, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer, StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
+
import { isORPCErrorStatus } from '@orpc/client';
|
|
4
|
+
import { fallbackContractConfig } from '@orpc/contract';
|
|
5
|
+
import { isObject, stringifyJSON, tryDecodeURIComponent, value } from '@orpc/shared';
|
|
6
|
+
import { toHttpPath } from '@orpc/client/standard';
|
|
7
|
+
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@orpc/server';
|
|
8
|
+
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { fallbackContractConfig } from "@orpc/contract";
|
|
8
|
-
import { isObject } from "@orpc/shared";
|
|
9
|
-
var OpenAPICodec = class {
|
|
10
|
-
constructor(serializer = new OpenAPISerializer()) {
|
|
10
|
+
class StandardOpenAPICodec {
|
|
11
|
+
constructor(serializer, options = {}) {
|
|
11
12
|
this.serializer = serializer;
|
|
13
|
+
this.customErrorResponseBodyEncoder = options.customErrorResponseBodyEncoder;
|
|
12
14
|
}
|
|
15
|
+
customErrorResponseBodyEncoder;
|
|
13
16
|
async decode(request, params, procedure) {
|
|
14
17
|
const inputStructure = fallbackContractConfig("defaultInputStructure", procedure["~orpc"].route.inputStructure);
|
|
15
18
|
if (inputStructure === "compact") {
|
|
@@ -52,40 +55,69 @@ var OpenAPICodec = class {
|
|
|
52
55
|
body: this.serializer.serialize(output)
|
|
53
56
|
};
|
|
54
57
|
}
|
|
55
|
-
if (!
|
|
56
|
-
throw new Error(
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
if (!this.#isDetailedOutput(output)) {
|
|
59
|
+
throw new Error(`
|
|
60
|
+
Invalid "detailed" output structure:
|
|
61
|
+
\u2022 Expected an object with optional properties:
|
|
62
|
+
- status (number 200-399)
|
|
63
|
+
- headers (Record<string, string | string[]>)
|
|
64
|
+
- body (any)
|
|
65
|
+
\u2022 No extra keys allowed.
|
|
66
|
+
|
|
67
|
+
Actual value:
|
|
68
|
+
${stringifyJSON(output)}
|
|
69
|
+
`);
|
|
59
70
|
}
|
|
60
71
|
return {
|
|
61
|
-
status: successStatus,
|
|
72
|
+
status: output.status ?? successStatus,
|
|
62
73
|
headers: output.headers ?? {},
|
|
63
74
|
body: this.serializer.serialize(output.body)
|
|
64
75
|
};
|
|
65
76
|
}
|
|
66
77
|
encodeError(error) {
|
|
78
|
+
const body = this.customErrorResponseBodyEncoder?.(error) ?? error.toJSON();
|
|
67
79
|
return {
|
|
68
80
|
status: error.status,
|
|
69
81
|
headers: {},
|
|
70
|
-
body: this.serializer.serialize(
|
|
82
|
+
body: this.serializer.serialize(body, { outputFormat: "plain" })
|
|
71
83
|
};
|
|
72
84
|
}
|
|
73
|
-
|
|
85
|
+
#isDetailedOutput(output) {
|
|
86
|
+
if (!isObject(output)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (output.headers && !isObject(output.headers)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
74
98
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
function toRou3Pattern(path) {
|
|
100
|
+
return standardizeHTTPPath(path).replace(/\/\{\+([^}]+)\}/g, "/**:$1").replace(/\/\{([^}]+)\}/g, "/:$1");
|
|
101
|
+
}
|
|
102
|
+
function decodeParams(params) {
|
|
103
|
+
return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, tryDecodeURIComponent(value)]));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
class StandardOpenAPIMatcher {
|
|
107
|
+
filter;
|
|
80
108
|
tree = createRouter();
|
|
81
109
|
pendingRouters = [];
|
|
110
|
+
constructor(options = {}) {
|
|
111
|
+
this.filter = options.filter ?? true;
|
|
112
|
+
}
|
|
82
113
|
init(router, path = []) {
|
|
83
|
-
const laziedOptions =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const
|
|
114
|
+
const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
|
|
115
|
+
if (!value(this.filter, traverseOptions)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const { path: path2, contract } = traverseOptions;
|
|
119
|
+
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
120
|
+
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
|
89
121
|
if (isProcedure(contract)) {
|
|
90
122
|
addRoute(this.tree, method, httpPath, {
|
|
91
123
|
path: path2,
|
|
@@ -105,8 +137,8 @@ var OpenAPIMatcher = class {
|
|
|
105
137
|
});
|
|
106
138
|
this.pendingRouters.push(...laziedOptions.map((option) => ({
|
|
107
139
|
...option,
|
|
108
|
-
httpPathPrefix:
|
|
109
|
-
laziedPrefix:
|
|
140
|
+
httpPathPrefix: toHttpPath(option.path),
|
|
141
|
+
laziedPrefix: getLazyMeta(option.router).prefix
|
|
110
142
|
})));
|
|
111
143
|
}
|
|
112
144
|
async match(method, pathname) {
|
|
@@ -114,7 +146,7 @@ var OpenAPIMatcher = class {
|
|
|
114
146
|
const newPendingRouters = [];
|
|
115
147
|
for (const pendingRouter of this.pendingRouters) {
|
|
116
148
|
if (!pendingRouter.laziedPrefix || pathname.startsWith(pendingRouter.laziedPrefix) || pathname.startsWith(pendingRouter.httpPathPrefix)) {
|
|
117
|
-
const { default: router } = await unlazy(pendingRouter.
|
|
149
|
+
const { default: router } = await unlazy(pendingRouter.router);
|
|
118
150
|
this.init(router, pendingRouter.path);
|
|
119
151
|
} else {
|
|
120
152
|
newPendingRouters.push(pendingRouter);
|
|
@@ -127,14 +159,14 @@ var OpenAPIMatcher = class {
|
|
|
127
159
|
return void 0;
|
|
128
160
|
}
|
|
129
161
|
if (!match.data.procedure) {
|
|
130
|
-
const { default: maybeProcedure } = await unlazy(
|
|
162
|
+
const { default: maybeProcedure } = await unlazy(getRouter(match.data.router, match.data.path));
|
|
131
163
|
if (!isProcedure(maybeProcedure)) {
|
|
132
164
|
throw new Error(`
|
|
133
|
-
[Contract-First] Missing or invalid implementation for procedure at path: ${
|
|
165
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${toHttpPath(match.data.path)}.
|
|
134
166
|
Ensure that the procedure is correctly defined and matches the expected contract.
|
|
135
167
|
`);
|
|
136
168
|
}
|
|
137
|
-
match.data.procedure = createContractedProcedure(match.data.contract
|
|
169
|
+
match.data.procedure = createContractedProcedure(maybeProcedure, match.data.contract);
|
|
138
170
|
}
|
|
139
171
|
return {
|
|
140
172
|
path: match.data.path,
|
|
@@ -142,16 +174,17 @@ var OpenAPIMatcher = class {
|
|
|
142
174
|
params: match.params ? decodeParams(match.params) : void 0
|
|
143
175
|
};
|
|
144
176
|
}
|
|
145
|
-
};
|
|
146
|
-
function toRou3Pattern(path) {
|
|
147
|
-
return standardizeHTTPPath(path).replace(/\{\+([^}]+)\}/g, "**:$1").replace(/\{([^}]+)\}/g, ":$1");
|
|
148
177
|
}
|
|
149
|
-
|
|
150
|
-
|
|
178
|
+
|
|
179
|
+
class StandardOpenAPIHandler extends StandardHandler {
|
|
180
|
+
constructor(router, options) {
|
|
181
|
+
const jsonSerializer = new StandardOpenAPIJsonSerializer(options);
|
|
182
|
+
const bracketNotationSerializer = new StandardBracketNotationSerializer(options);
|
|
183
|
+
const serializer = new StandardOpenAPISerializer(jsonSerializer, bracketNotationSerializer);
|
|
184
|
+
const matcher = new StandardOpenAPIMatcher(options);
|
|
185
|
+
const codec = new StandardOpenAPICodec(serializer, options);
|
|
186
|
+
super(router, matcher, codec, options);
|
|
187
|
+
}
|
|
151
188
|
}
|
|
152
189
|
|
|
153
|
-
export {
|
|
154
|
-
OpenAPICodec,
|
|
155
|
-
OpenAPIMatcher
|
|
156
|
-
};
|
|
157
|
-
//# sourceMappingURL=chunk-LTTK3H5J.js.map
|
|
190
|
+
export { StandardOpenAPICodec as S, StandardOpenAPIHandler as a, StandardOpenAPIMatcher as b, decodeParams as d, toRou3Pattern as t };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { StandardOpenAPISerializer, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter, Context, Router } from '@orpc/server';
|
|
3
|
+
import { StandardCodec, StandardParams, StandardMatcher, StandardMatchResult, StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
|
4
|
+
import { ORPCError, HTTPPath } from '@orpc/client';
|
|
5
|
+
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
6
|
+
import { Value } from '@orpc/shared';
|
|
7
|
+
|
|
8
|
+
interface StandardOpenAPICodecOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Customize how an ORPC error is encoded into a response body.
|
|
11
|
+
* Use this if your API needs a different error output structure.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* - Return `null | undefined` to fallback to default behavior
|
|
15
|
+
*
|
|
16
|
+
* @default ((e) => e.toJSON())
|
|
17
|
+
*/
|
|
18
|
+
customErrorResponseBodyEncoder?: (error: ORPCError<any, any>) => unknown;
|
|
19
|
+
}
|
|
20
|
+
declare class StandardOpenAPICodec implements StandardCodec {
|
|
21
|
+
#private;
|
|
22
|
+
private readonly serializer;
|
|
23
|
+
private readonly customErrorResponseBodyEncoder;
|
|
24
|
+
constructor(serializer: StandardOpenAPISerializer, options?: StandardOpenAPICodecOptions);
|
|
25
|
+
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
26
|
+
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
27
|
+
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface StandardOpenAPIMatcherOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Filter procedures. Return `false` to exclude a procedure from matching.
|
|
33
|
+
*
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
|
37
|
+
}
|
|
38
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
|
39
|
+
private readonly filter;
|
|
40
|
+
private readonly tree;
|
|
41
|
+
private pendingRouters;
|
|
42
|
+
constructor(options?: StandardOpenAPIMatcherOptions);
|
|
43
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
|
44
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPIMatcherOptions, StandardOpenAPICodecOptions {
|
|
48
|
+
}
|
|
49
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
|
50
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { StandardOpenAPICodec as a, StandardOpenAPIHandler as c, StandardOpenAPIMatcher as e };
|
|
54
|
+
export type { StandardOpenAPICodecOptions as S, StandardOpenAPIHandlerOptions as b, StandardOpenAPIMatcherOptions as d };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { StandardOpenAPISerializer, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
|
2
|
+
import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter, Context, Router } from '@orpc/server';
|
|
3
|
+
import { StandardCodec, StandardParams, StandardMatcher, StandardMatchResult, StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
|
4
|
+
import { ORPCError, HTTPPath } from '@orpc/client';
|
|
5
|
+
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
6
|
+
import { Value } from '@orpc/shared';
|
|
7
|
+
|
|
8
|
+
interface StandardOpenAPICodecOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Customize how an ORPC error is encoded into a response body.
|
|
11
|
+
* Use this if your API needs a different error output structure.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* - Return `null | undefined` to fallback to default behavior
|
|
15
|
+
*
|
|
16
|
+
* @default ((e) => e.toJSON())
|
|
17
|
+
*/
|
|
18
|
+
customErrorResponseBodyEncoder?: (error: ORPCError<any, any>) => unknown;
|
|
19
|
+
}
|
|
20
|
+
declare class StandardOpenAPICodec implements StandardCodec {
|
|
21
|
+
#private;
|
|
22
|
+
private readonly serializer;
|
|
23
|
+
private readonly customErrorResponseBodyEncoder;
|
|
24
|
+
constructor(serializer: StandardOpenAPISerializer, options?: StandardOpenAPICodecOptions);
|
|
25
|
+
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
26
|
+
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
27
|
+
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface StandardOpenAPIMatcherOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Filter procedures. Return `false` to exclude a procedure from matching.
|
|
33
|
+
*
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
|
37
|
+
}
|
|
38
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
|
39
|
+
private readonly filter;
|
|
40
|
+
private readonly tree;
|
|
41
|
+
private pendingRouters;
|
|
42
|
+
constructor(options?: StandardOpenAPIMatcherOptions);
|
|
43
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
|
44
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPIMatcherOptions, StandardOpenAPICodecOptions {
|
|
48
|
+
}
|
|
49
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
|
50
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { StandardOpenAPICodec as a, StandardOpenAPIHandler as c, StandardOpenAPIMatcher as e };
|
|
54
|
+
export type { StandardOpenAPICodecOptions as S, StandardOpenAPIHandlerOptions as b, StandardOpenAPIMatcherOptions as d };
|
package/package.json
CHANGED
|
@@ -1,75 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.b355a2e",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/middleapi/orpc.git",
|
|
10
10
|
"directory": "packages/openapi"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
|
-
"unnoq",
|
|
14
13
|
"orpc"
|
|
15
14
|
],
|
|
16
15
|
"exports": {
|
|
17
16
|
".": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"import": "./dist/index.
|
|
20
|
-
"default": "./dist/index.
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"default": "./dist/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./plugins": {
|
|
22
|
+
"types": "./dist/plugins/index.d.mts",
|
|
23
|
+
"import": "./dist/plugins/index.mjs",
|
|
24
|
+
"default": "./dist/plugins/index.mjs"
|
|
21
25
|
},
|
|
22
26
|
"./standard": {
|
|
23
|
-
"types": "./dist/
|
|
24
|
-
"import": "./dist/standard.
|
|
25
|
-
"default": "./dist/standard.
|
|
27
|
+
"types": "./dist/adapters/standard/index.d.mts",
|
|
28
|
+
"import": "./dist/adapters/standard/index.mjs",
|
|
29
|
+
"default": "./dist/adapters/standard/index.mjs"
|
|
26
30
|
},
|
|
27
31
|
"./fetch": {
|
|
28
|
-
"types": "./dist/
|
|
29
|
-
"import": "./dist/fetch.
|
|
30
|
-
"default": "./dist/fetch.
|
|
31
|
-
},
|
|
32
|
-
"./hono": {
|
|
33
|
-
"types": "./dist/src/adapters/hono/index.d.ts",
|
|
34
|
-
"import": "./dist/hono.js",
|
|
35
|
-
"default": "./dist/hono.js"
|
|
36
|
-
},
|
|
37
|
-
"./next": {
|
|
38
|
-
"types": "./dist/src/adapters/next/index.d.ts",
|
|
39
|
-
"import": "./dist/next.js",
|
|
40
|
-
"default": "./dist/next.js"
|
|
32
|
+
"types": "./dist/adapters/fetch/index.d.mts",
|
|
33
|
+
"import": "./dist/adapters/fetch/index.mjs",
|
|
34
|
+
"default": "./dist/adapters/fetch/index.mjs"
|
|
41
35
|
},
|
|
42
36
|
"./node": {
|
|
43
|
-
"types": "./dist/
|
|
44
|
-
"import": "./dist/node.
|
|
45
|
-
"default": "./dist/node.
|
|
37
|
+
"types": "./dist/adapters/node/index.d.mts",
|
|
38
|
+
"import": "./dist/adapters/node/index.mjs",
|
|
39
|
+
"default": "./dist/adapters/node/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./fastify": {
|
|
42
|
+
"types": "./dist/adapters/fastify/index.d.mts",
|
|
43
|
+
"import": "./dist/adapters/fastify/index.mjs",
|
|
44
|
+
"default": "./dist/adapters/fastify/index.mjs"
|
|
46
45
|
},
|
|
47
|
-
"
|
|
48
|
-
"types": "./dist/
|
|
46
|
+
"./aws-lambda": {
|
|
47
|
+
"types": "./dist/adapters/aws-lambda/index.d.mts",
|
|
48
|
+
"import": "./dist/adapters/aws-lambda/index.mjs",
|
|
49
|
+
"default": "./dist/adapters/aws-lambda/index.mjs"
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
"files": [
|
|
52
|
-
"!**/*.map",
|
|
53
|
-
"!**/*.tsbuildinfo",
|
|
54
53
|
"dist"
|
|
55
54
|
],
|
|
56
55
|
"dependencies": {
|
|
57
|
-
"json-schema-typed": "^8.0.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"@orpc/
|
|
61
|
-
"@orpc/
|
|
62
|
-
"@orpc/
|
|
63
|
-
"@orpc/
|
|
64
|
-
"@orpc/
|
|
65
|
-
"@orpc/standard-server
|
|
66
|
-
"@orpc/standard-server-node": "0.0.0-next.b2e67f7"
|
|
56
|
+
"json-schema-typed": "^8.0.2",
|
|
57
|
+
"rou3": "^0.7.12",
|
|
58
|
+
"@orpc/client": "0.0.0-next.b355a2e",
|
|
59
|
+
"@orpc/contract": "0.0.0-next.b355a2e",
|
|
60
|
+
"@orpc/interop": "0.0.0-next.b355a2e",
|
|
61
|
+
"@orpc/openapi-client": "0.0.0-next.b355a2e",
|
|
62
|
+
"@orpc/server": "0.0.0-next.b355a2e",
|
|
63
|
+
"@orpc/shared": "0.0.0-next.b355a2e",
|
|
64
|
+
"@orpc/standard-server": "0.0.0-next.b355a2e"
|
|
67
65
|
},
|
|
68
66
|
"devDependencies": {
|
|
69
|
-
"
|
|
67
|
+
"fastify": "^5.7.4",
|
|
68
|
+
"zod": "^4.3.6"
|
|
70
69
|
},
|
|
71
70
|
"scripts": {
|
|
72
|
-
"build": "
|
|
71
|
+
"build": "unbuild",
|
|
73
72
|
"build:watch": "pnpm run build --watch",
|
|
74
73
|
"type:check": "tsc -b"
|
|
75
74
|
}
|
package/dist/chunk-PW7RAFQQ.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OpenAPICodec,
|
|
3
|
-
OpenAPIMatcher
|
|
4
|
-
} from "./chunk-LTTK3H5J.js";
|
|
5
|
-
|
|
6
|
-
// src/adapters/fetch/openapi-handler.ts
|
|
7
|
-
import { StandardHandler } from "@orpc/server/standard";
|
|
8
|
-
import { toFetchResponse, toStandardRequest } from "@orpc/standard-server-fetch";
|
|
9
|
-
var OpenAPIHandler = class {
|
|
10
|
-
standardHandler;
|
|
11
|
-
constructor(router, options) {
|
|
12
|
-
const matcher = options?.matcher ?? new OpenAPIMatcher();
|
|
13
|
-
const codec = options?.codec ?? new OpenAPICodec();
|
|
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
|
-
OpenAPIHandler
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=chunk-PW7RAFQQ.js.map
|
package/dist/chunk-XGHV4TH3.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// src/utils.ts
|
|
2
|
-
function standardizeHTTPPath(path) {
|
|
3
|
-
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
4
|
-
}
|
|
5
|
-
function toOpenAPI31RoutePattern(path) {
|
|
6
|
-
return standardizeHTTPPath(path).replace(/\{\+([^}]+)\}/g, "{$1}");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
standardizeHTTPPath,
|
|
11
|
-
toOpenAPI31RoutePattern
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chunk-XGHV4TH3.js.map
|
package/dist/fetch.js
DELETED