@orpc/openapi 2.0.0-beta.43 → 2.0.0-beta.44
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 +2 -10
- package/dist/adapters/aws-lambda/index.mjs +1 -1
- package/dist/adapters/fastify/index.mjs +1 -1
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/node/index.mjs +1 -1
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.mjs +5 -8
- package/dist/shared/{openapi.C6KG7fwg.mjs → openapi.DdjvA5Xo.mjs} +7 -7
- package/dist/shared/{openapi.DcQKf6ur.mjs → openapi.DjMM672U.mjs} +7 -12
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
18
18
|
</a>
|
|
19
19
|
<a href="https://deepwiki.com/middleapi/orpc">
|
|
20
|
-
<img src="https://
|
|
20
|
+
<img alt="Ask DeepWiki" src="https://img.shields.io/badge/Ask-DeepWiki-blue" />
|
|
21
21
|
</a>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
@@ -95,14 +95,6 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
95
95
|
</tr>
|
|
96
96
|
</table>
|
|
97
97
|
|
|
98
|
-
### Special Sponsors
|
|
99
|
-
|
|
100
|
-
<table>
|
|
101
|
-
<tr>
|
|
102
|
-
<td align="center"><a href="http://twitter.com/rauchg?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guillermo Rauch"><img src="https://avatars.githubusercontent.com/u/13041?u=1ee8d111657cdd02ff6d253df00978d17ee6d722&v=4" width="279" alt="Guillermo Rauch"/><br />Guillermo Rauch</a></td>
|
|
103
|
-
</tr>
|
|
104
|
-
</table>
|
|
105
|
-
|
|
106
98
|
### Premium Sponsors
|
|
107
99
|
|
|
108
100
|
<table>
|
|
@@ -178,7 +170,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
178
170
|
</tr>
|
|
179
171
|
</table>
|
|
180
172
|
|
|
181
|
-
With thanks to [
|
|
173
|
+
With thanks to [39 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
|
|
182
174
|
|
|
183
175
|
## References
|
|
184
176
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AwsLambdaHandler } from '@orpc/server/aws-lambda';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.DjMM672U.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FastifyHandler } from '@orpc/server/fastify';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.DjMM672U.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FetchHandler } from '@orpc/server/fetch';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.DjMM672U.mjs';
|
|
4
4
|
import { FetchLinkTransport } from '@orpc/client/fetch';
|
|
5
5
|
import { StandardLink } from '@orpc/client/standard';
|
|
6
|
-
import { O as OpenAPILinkCodec } from '../../shared/openapi.
|
|
6
|
+
import { O as OpenAPILinkCodec } from '../../shared/openapi.DdjvA5Xo.mjs';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/server';
|
|
9
9
|
import '@orpc/shared';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeHttpHandler } from '@orpc/server/node';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.DjMM672U.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher, s as serializeHeaders } from '../../shared/openapi.
|
|
2
|
-
export { O as OpenAPILinkCodec } from '../../shared/openapi.
|
|
1
|
+
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher, s as serializeHeaders } from '../../shared/openapi.DjMM672U.mjs';
|
|
2
|
+
export { O as OpenAPILinkCodec } from '../../shared/openapi.DdjvA5Xo.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/server';
|
|
5
5
|
import '@orpc/shared';
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
|
8
8
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
9
9
|
import { encodeJsonPointerSegment, ensureJsonSchemaObject, mapJsonSchemaRefs, decodeJsonPointerSegment, isUnconstrainedSchema, combineJsonSchemasWithComposition, extractJsonObjectSchemaEntries, combineJsonObjectSchemaEntries, flattenJsonUnionSchema, isJsonPrimitiveSchema, matchArrayableJsonSchema, isJsonFileSchema, DelegatingJsonSchemaConverter, StandardJsonSchemaConverter, hoistRecursiveRefToDef } from '@orpc/json-schema';
|
|
10
10
|
import { DEFAULT_SUCCESS_STATUS, DEFAULT_ERROR_STATUS, walkProcedureContractsAsync } from '@orpc/server';
|
|
11
|
-
import { setOwn, getOwn, isDeepEqual, value, findDeepMatches,
|
|
11
|
+
import { setOwn, getOwn, isDeepEqual, isPlainObject, value, findDeepMatches, stringifyJSON, toArray, clone, pathToHttpPath, mergeHttpPath, isTypescriptObject } from '@orpc/shared';
|
|
12
12
|
import '@standard-server/core';
|
|
13
13
|
|
|
14
14
|
function createContractJsonifiedClientFactory(link, options = {}) {
|
|
@@ -127,17 +127,14 @@ function componentNameCandidate(preferredName, direction, attempt) {
|
|
|
127
127
|
function definedKeysOf(object) {
|
|
128
128
|
return Object.keys(object).filter((key) => object[key] !== void 0).sort();
|
|
129
129
|
}
|
|
130
|
+
function isSchemaContainer(value) {
|
|
131
|
+
return Array.isArray(value) || isPlainObject(value);
|
|
132
|
+
}
|
|
130
133
|
function areSchemasEquivalentForReuse(candidate, existing, ctx) {
|
|
131
134
|
if (candidate === existing) {
|
|
132
135
|
return true;
|
|
133
136
|
}
|
|
134
|
-
if (
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
if (candidate === null || existing === null) {
|
|
138
|
-
return candidate === existing;
|
|
139
|
-
}
|
|
140
|
-
if (typeof candidate !== "object" || typeof existing !== "object") {
|
|
137
|
+
if (!isSchemaContainer(candidate) || !isSchemaContainer(existing)) {
|
|
141
138
|
return isDeepEqual(candidate, existing);
|
|
142
139
|
}
|
|
143
140
|
const seenExisting = ctx.visited.get(candidate);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MalformedResponseError, isORPCErrorJson, createORPCErrorFromJson } from '@orpc/client';
|
|
2
2
|
import { getRouterContract, ProcedureContract } from '@orpc/contract';
|
|
3
3
|
import { unlazy } from '@orpc/server';
|
|
4
4
|
import { value, pathToHttpPath, mergeHttpPath, isTypescriptObject, stringifyJSON, safeEncodeURIComponent } from '@orpc/shared';
|
|
@@ -6,7 +6,7 @@ import { mergeStandardHeaders, parseStandardUrl } from '@standard-server/core';
|
|
|
6
6
|
import { toStandardHeaders } from '@standard-server/fetch';
|
|
7
7
|
import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, g as getDynamicPathParams, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.PXVenYpE.mjs';
|
|
8
8
|
import { g as getOpenAPIMeta } from './openapi.B9PQzqBn.mjs';
|
|
9
|
-
import { s as serializeHeaders } from './openapi.
|
|
9
|
+
import { s as serializeHeaders } from './openapi.DjMM672U.mjs';
|
|
10
10
|
|
|
11
11
|
const END_SLASH_REGEX = /\/$/;
|
|
12
12
|
const DOT_SEGMENT_REGEX = /(?:^|\/)\.{1,2}(?:\/|$)/;
|
|
@@ -149,6 +149,9 @@ class OpenAPILinkCodec {
|
|
|
149
149
|
if (DOT_SEGMENT_REGEX.test(encoded)) {
|
|
150
150
|
throw new TypeError(`Path param "${param.parameterName}" cannot contain "." or ".." segments in call to procedure (${path.join(".")}).`);
|
|
151
151
|
}
|
|
152
|
+
if (encoded.startsWith("/")) {
|
|
153
|
+
encoded = `%2F${encoded.slice(1)}`;
|
|
154
|
+
}
|
|
152
155
|
return encoded;
|
|
153
156
|
}
|
|
154
157
|
serializeQueryString(data, queryStyles) {
|
|
@@ -254,7 +257,7 @@ class OpenAPILinkCodec {
|
|
|
254
257
|
try {
|
|
255
258
|
return this.serializer.deserialize(body);
|
|
256
259
|
} catch (error) {
|
|
257
|
-
throw
|
|
260
|
+
throw new MalformedResponseError({
|
|
258
261
|
message: "Invalid OpenAPI response format.",
|
|
259
262
|
response: { status: response.status, headers: response.headers, body },
|
|
260
263
|
cause: error
|
|
@@ -269,10 +272,7 @@ class OpenAPILinkCodec {
|
|
|
269
272
|
if (isORPCErrorJson(deserialized)) {
|
|
270
273
|
return { kind: "error", error: createORPCErrorFromJson(deserialized) };
|
|
271
274
|
}
|
|
272
|
-
|
|
273
|
-
kind: "error",
|
|
274
|
-
error: createORPCErrorFromMalformedResponse({ response: { headers: response.headers, status: response.status, body } })
|
|
275
|
-
};
|
|
275
|
+
throw new MalformedResponseError({ response: { headers: response.headers, status: response.status, body } });
|
|
276
276
|
}
|
|
277
277
|
const outputStructure = meta?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
|
|
278
278
|
return outputStructure === "compact" ? { kind: "output", output: deserialized } : {
|
|
@@ -71,19 +71,12 @@ class OpenAPIMatcher {
|
|
|
71
71
|
return void 0;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
pathname = normalizeRou3Path(pathname);
|
|
74
75
|
const loading = this.resolvePendingLazyRouters(pathname);
|
|
75
76
|
if (loading !== void 0) {
|
|
76
77
|
await loading;
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
if (match === void 0 && NORMALIZABLE_PATHNAME_REGEX.test(pathname)) {
|
|
80
|
-
const normalizedPathname = normalizeRou3Path(pathname);
|
|
81
|
-
const normalizedLoading = this.resolvePendingLazyRouters(normalizedPathname);
|
|
82
|
-
if (normalizedLoading !== void 0) {
|
|
83
|
-
await normalizedLoading;
|
|
84
|
-
}
|
|
85
|
-
match = this.findMatch(method, normalizedPathname);
|
|
86
|
-
}
|
|
79
|
+
const match = this.findMatch(method, pathname);
|
|
87
80
|
if (match === void 0) {
|
|
88
81
|
return void 0;
|
|
89
82
|
}
|
|
@@ -169,11 +162,13 @@ function toRou3Route(path) {
|
|
|
169
162
|
}
|
|
170
163
|
const ROU3_SYNTAX_REGEX = /[\\:*?+(){}]|(?<![^/])\.(?=\.?(?:\/|$))/g;
|
|
171
164
|
function toRou3Literal(text) {
|
|
172
|
-
|
|
173
|
-
return normalized.replace(ROU3_SYNTAX_REGEX, "\\$&");
|
|
165
|
+
return normalizeRou3Path(text).replace(ROU3_SYNTAX_REGEX, "\\$&");
|
|
174
166
|
}
|
|
175
167
|
function normalizeRou3Path(path) {
|
|
176
|
-
|
|
168
|
+
if (!NORMALIZABLE_PATHNAME_REGEX.test(path)) {
|
|
169
|
+
return path;
|
|
170
|
+
}
|
|
171
|
+
return path.split("/").map((segment) => NORMALIZABLE_PATHNAME_REGEX.test(segment) ? safeDecodeURIComponent(segment).replace(ROU3_ENCODED_SEGMENT_TEXT_REGEX, safeEncodeURIComponent) : segment).join("/");
|
|
177
172
|
}
|
|
178
173
|
function toRou3PrefixMatcher(prefix) {
|
|
179
174
|
const catchAll = getDynamicPathParams(prefix)?.find((param) => param.allowsSlash);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.44",
|
|
5
5
|
"description": "Generate OpenAPI specs from oRPC routers and serve OpenAPI-compliant APIs with end-to-end type safety",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -99,22 +99,22 @@
|
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"@openapi-spec/downgrader": "~0.3.0",
|
|
101
101
|
"@openapi-spec/types": "~0.3.0",
|
|
102
|
-
"@orpc/client": "2.0.0-beta.
|
|
103
|
-
"@orpc/contract": "2.0.0-beta.
|
|
104
|
-
"@orpc/json-schema": "2.0.0-beta.
|
|
105
|
-
"@orpc/server": "2.0.0-beta.
|
|
106
|
-
"@orpc/shared": "2.0.0-beta.
|
|
107
|
-
"@standard-server/core": "~0.10.
|
|
108
|
-
"@standard-server/fetch": "~0.10.
|
|
102
|
+
"@orpc/client": "2.0.0-beta.44",
|
|
103
|
+
"@orpc/contract": "2.0.0-beta.44",
|
|
104
|
+
"@orpc/json-schema": "2.0.0-beta.44",
|
|
105
|
+
"@orpc/server": "2.0.0-beta.44",
|
|
106
|
+
"@orpc/shared": "2.0.0-beta.44",
|
|
107
|
+
"@standard-server/core": "~0.10.3",
|
|
108
|
+
"@standard-server/fetch": "~0.10.3",
|
|
109
109
|
"rou3": "^1.0.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@scalar/api-reference": "^1.
|
|
113
|
-
"@standard-server/aws-lambda": "~0.10.
|
|
112
|
+
"@scalar/api-reference": "^1.73.1",
|
|
113
|
+
"@standard-server/aws-lambda": "~0.10.3",
|
|
114
114
|
"@types/swagger-ui": "^5.32.0",
|
|
115
|
-
"fastify": "^5.12.
|
|
116
|
-
"swagger-ui": "^5.
|
|
117
|
-
"zod": "^4.5
|
|
115
|
+
"fastify": "^5.12.5",
|
|
116
|
+
"swagger-ui": "^5.33.1",
|
|
117
|
+
"zod": "^4.6.5"
|
|
118
118
|
},
|
|
119
119
|
"scripts": {
|
|
120
120
|
"type:check": "tsc -b"
|