@orpc/openapi 2.0.0-beta.42 → 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.d.mts +1 -1
- package/dist/adapters/aws-lambda/index.d.ts +1 -1
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fastify/index.d.mts +1 -1
- package/dist/adapters/fastify/index.d.ts +1 -1
- package/dist/adapters/fastify/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.d.ts +1 -1
- package/dist/adapters/fetch/index.mjs +4 -4
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +2 -2
- package/dist/adapters/standard/index.d.ts +2 -2
- package/dist/adapters/standard/index.mjs +4 -4
- package/dist/helpers/index.mjs +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +47 -27
- package/dist/shared/{openapi.CkzUS83v.d.ts → openapi.1UQkZGBs.d.ts} +1 -1
- package/dist/shared/{openapi.BDiBd3_k.d.mts → openapi.BSLqRCwO.d.mts} +1 -1
- package/dist/shared/{openapi.Cg9h6jpm.d.mts → openapi.BVt3NPfo.d.mts} +1 -1
- package/dist/shared/{openapi.D326pNzT.mjs → openapi.DdjvA5Xo.mjs} +8 -8
- package/dist/shared/{openapi.C2LayTNZ.d.mts → openapi.DjGhiceP.d.mts} +10 -11
- package/dist/shared/{openapi.C2LayTNZ.d.ts → openapi.DjGhiceP.d.ts} +10 -11
- package/dist/shared/{openapi.BJRea9Uu.mjs → openapi.DjMM672U.mjs} +18 -16
- package/dist/shared/openapi.DtEVcxuW.mjs +149 -0
- package/dist/shared/{openapi.Bu_PfTtX.mjs → openapi.PXVenYpE.mjs} +1 -1
- package/dist/shared/{openapi.D0yWs-uW.d.ts → openapi.aoP0G_Bv.d.ts} +1 -1
- package/package.json +13 -13
- package/dist/shared/openapi.B2G-HeFn.mjs +0 -123
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
|
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.DjGhiceP.mjs';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.DjGhiceP.js';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
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';
|
|
7
7
|
import '@standard-server/core';
|
|
8
|
-
import '../../shared/openapi.
|
|
9
|
-
import '../../shared/openapi.
|
|
8
|
+
import '../../shared/openapi.PXVenYpE.mjs';
|
|
9
|
+
import '../../shared/openapi.DtEVcxuW.mjs';
|
|
10
10
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
11
11
|
import 'rou3';
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.DjGhiceP.mjs';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.DjGhiceP.js';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
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';
|
|
7
7
|
import '@standard-server/core';
|
|
8
|
-
import '../../shared/openapi.
|
|
9
|
-
import '../../shared/openapi.
|
|
8
|
+
import '../../shared/openapi.PXVenYpE.mjs';
|
|
9
|
+
import '../../shared/openapi.DtEVcxuW.mjs';
|
|
10
10
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
11
11
|
import 'rou3';
|
|
12
12
|
|
|
@@ -9,7 +9,7 @@ import { RouterContract } from '@orpc/contract';
|
|
|
9
9
|
import { OpenAPILinkCodecOptions } from '../standard/index.mjs';
|
|
10
10
|
import '@orpc/shared';
|
|
11
11
|
import '@standard-server/core';
|
|
12
|
-
import '../../shared/openapi.
|
|
12
|
+
import '../../shared/openapi.DjGhiceP.mjs';
|
|
13
13
|
|
|
14
14
|
interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
15
15
|
}
|
|
@@ -9,7 +9,7 @@ import { RouterContract } from '@orpc/contract';
|
|
|
9
9
|
import { OpenAPILinkCodecOptions } from '../standard/index.js';
|
|
10
10
|
import '@orpc/shared';
|
|
11
11
|
import '@standard-server/core';
|
|
12
|
-
import '../../shared/openapi.
|
|
12
|
+
import '../../shared/openapi.DjGhiceP.js';
|
|
13
13
|
|
|
14
14
|
interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
15
15
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
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';
|
|
10
10
|
import '@standard-server/core';
|
|
11
|
-
import '../../shared/openapi.
|
|
12
|
-
import '../../shared/openapi.
|
|
11
|
+
import '../../shared/openapi.PXVenYpE.mjs';
|
|
12
|
+
import '../../shared/openapi.DtEVcxuW.mjs';
|
|
13
13
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
14
14
|
import 'rou3';
|
|
15
15
|
import '@orpc/contract';
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.DjGhiceP.mjs';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.DjGhiceP.js';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
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';
|
|
7
7
|
import '@standard-server/core';
|
|
8
|
-
import '../../shared/openapi.
|
|
9
|
-
import '../../shared/openapi.
|
|
8
|
+
import '../../shared/openapi.PXVenYpE.mjs';
|
|
9
|
+
import '../../shared/openapi.DtEVcxuW.mjs';
|
|
10
10
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
11
11
|
import 'rou3';
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
2
|
-
export { a as OpenAPILinkCodec, O as OpenAPILinkCodecOptions } from '../../shared/openapi.
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.BSLqRCwO.mjs';
|
|
2
|
+
export { a as OpenAPILinkCodec, O as OpenAPILinkCodecOptions } from '../../shared/openapi.BVt3NPfo.mjs';
|
|
3
3
|
import { StandardHeaders } from '@standard-server/core';
|
|
4
4
|
import { OpenAPISerializer } from '../../index.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
2
|
-
export { a as OpenAPILinkCodec, O as OpenAPILinkCodecOptions } from '../../shared/openapi.
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.1UQkZGBs.js';
|
|
2
|
+
export { a as OpenAPILinkCodec, O as OpenAPILinkCodecOptions } from '../../shared/openapi.aoP0G_Bv.js';
|
|
3
3
|
import { StandardHeaders } from '@standard-server/core';
|
|
4
4
|
import { OpenAPISerializer } from '../../index.js';
|
|
5
5
|
import '@orpc/client';
|
|
@@ -1,11 +1,11 @@
|
|
|
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';
|
|
6
6
|
import '@standard-server/core';
|
|
7
|
-
import '../../shared/openapi.
|
|
8
|
-
import '../../shared/openapi.
|
|
7
|
+
import '../../shared/openapi.PXVenYpE.mjs';
|
|
8
|
+
import '../../shared/openapi.DtEVcxuW.mjs';
|
|
9
9
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
10
10
|
import 'rou3';
|
|
11
11
|
import '@orpc/contract';
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isSchemaIssue } from '@orpc/contract';
|
|
2
2
|
import { isTypescriptObject } from '@orpc/shared';
|
|
3
|
-
import { B as BracketNotationSerializer } from '../shared/openapi.
|
|
3
|
+
import { B as BracketNotationSerializer } from '../shared/openapi.DtEVcxuW.mjs';
|
|
4
4
|
|
|
5
5
|
function parseFormData(form) {
|
|
6
6
|
const serializer = new BracketNotationSerializer();
|
|
@@ -30,7 +30,7 @@ function getIssueMessage(error, path) {
|
|
|
30
30
|
if (path.endsWith("[]") && issuePath.replace(/\[(?:0|[1-9]\d*)\]$/, "[]") === path) {
|
|
31
31
|
return issue.message;
|
|
32
32
|
}
|
|
33
|
-
if (path === "" &&
|
|
33
|
+
if (path === "" && /^(?:0|[1-9]\d*)$/.test(issuePath)) {
|
|
34
34
|
return issue.message;
|
|
35
35
|
}
|
|
36
36
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OpenAPISerializer } from './shared/openapi.
|
|
2
|
-
export { B as BracketNotationSerializeResult, a as BracketNotationSerializer, b as BracketNotationSerializerOptions, c as OpenAPIJsonSerialization, d as OpenAPIJsonSerializer, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.
|
|
1
|
+
import { O as OpenAPISerializer } from './shared/openapi.DjGhiceP.mjs';
|
|
2
|
+
export { B as BracketNotationSerializeResult, a as BracketNotationSerializer, b as BracketNotationSerializerOptions, c as OpenAPIJsonSerialization, d as OpenAPIJsonSerializer, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.DjGhiceP.mjs';
|
|
3
3
|
import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
5
|
import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OpenAPISerializer } from './shared/openapi.
|
|
2
|
-
export { B as BracketNotationSerializeResult, a as BracketNotationSerializer, b as BracketNotationSerializerOptions, c as OpenAPIJsonSerialization, d as OpenAPIJsonSerializer, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.
|
|
1
|
+
import { O as OpenAPISerializer } from './shared/openapi.DjGhiceP.js';
|
|
2
|
+
export { B as BracketNotationSerializeResult, a as BracketNotationSerializer, b as BracketNotationSerializerOptions, c as OpenAPIJsonSerialization, d as OpenAPIJsonSerializer, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.DjGhiceP.js';
|
|
3
3
|
import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
5
|
import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { B as BracketNotationSerializer } from './shared/openapi.
|
|
1
|
+
export { B as BracketNotationSerializer } from './shared/openapi.DtEVcxuW.mjs';
|
|
2
2
|
import { createContractClientFactory, getAsyncIteratorObjectSchemaDetails, ProcedureContract, resolveMetaPlugins } from '@orpc/contract';
|
|
3
|
-
import { D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, c as DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE, i as isBodylessMethod, O as OpenAPISerializer, g as getDynamicPathParams } from './shared/openapi.
|
|
4
|
-
export { d as OpenAPIJsonSerializer } from './shared/openapi.
|
|
3
|
+
import { D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, c as DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE, i as isBodylessMethod, O as OpenAPISerializer, g as getDynamicPathParams } from './shared/openapi.PXVenYpE.mjs';
|
|
4
|
+
export { d as OpenAPIJsonSerializer } from './shared/openapi.PXVenYpE.mjs';
|
|
5
5
|
import { g as getOpenAPIMeta, o as openapi } from './shared/openapi.B9PQzqBn.mjs';
|
|
6
6
|
import { downgradeSpecV32ToV31, downgradeSpecV31ToV30 } from '@openapi-spec/downgrader';
|
|
7
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);
|
|
@@ -457,33 +454,56 @@ function extractDetailedResponseParts(schema, defaultStatus) {
|
|
|
457
454
|
);
|
|
458
455
|
}
|
|
459
456
|
const statusSchema = entries.find(([name]) => name === "status")?.[1];
|
|
460
|
-
|
|
457
|
+
const statuses = statusSchema === void 0 ? /* @__PURE__ */ new Map([[defaultStatus, void 0]]) : extractDetailedStatuses(statusSchema);
|
|
458
|
+
if (!statuses) {
|
|
461
459
|
throw new OpenAPIGeneratorError(
|
|
462
460
|
`invalid "status" field in the detailed output schema.
|
|
463
|
-
Expected:
|
|
461
|
+
Expected: literal integers below 400 (const, enum, or a union of them)
|
|
464
462
|
Received: ${stringifyJSON(statusSchema)}`
|
|
465
463
|
);
|
|
466
464
|
}
|
|
467
|
-
const status = (statusSchema?.const || void 0) ?? defaultStatus;
|
|
468
|
-
let parts = partsByStatus.get(status);
|
|
469
|
-
if (!parts) {
|
|
470
|
-
parts = { descriptions: [], bodies: [], headers: [] };
|
|
471
|
-
partsByStatus.set(status, parts);
|
|
472
|
-
}
|
|
473
|
-
if (statusSchema?.description !== void 0) {
|
|
474
|
-
parts.descriptions.push(statusSchema.description);
|
|
475
|
-
}
|
|
476
465
|
const headersSchema = entries.find(([name]) => name === "headers")?.[1];
|
|
477
|
-
if (headersSchema !== void 0) {
|
|
478
|
-
parts.headers.push(headersSchema);
|
|
479
|
-
}
|
|
480
466
|
const bodySchema = entries.find(([name]) => name === "body")?.[1];
|
|
481
|
-
|
|
482
|
-
parts.
|
|
467
|
+
for (const [status, description] of statuses) {
|
|
468
|
+
let parts = partsByStatus.get(status);
|
|
469
|
+
if (!parts) {
|
|
470
|
+
parts = { descriptions: [], bodies: [], headers: [] };
|
|
471
|
+
partsByStatus.set(status, parts);
|
|
472
|
+
}
|
|
473
|
+
if (description !== void 0) {
|
|
474
|
+
parts.descriptions.push(description);
|
|
475
|
+
}
|
|
476
|
+
if (headersSchema !== void 0) {
|
|
477
|
+
parts.headers.push(headersSchema);
|
|
478
|
+
}
|
|
479
|
+
if (bodySchema !== void 0) {
|
|
480
|
+
parts.bodies.push(bodySchema);
|
|
481
|
+
}
|
|
483
482
|
}
|
|
484
483
|
}
|
|
485
484
|
return partsByStatus;
|
|
486
485
|
}
|
|
486
|
+
function extractDetailedStatuses(schema) {
|
|
487
|
+
const statuses = /* @__PURE__ */ new Map();
|
|
488
|
+
for (const member of flattenJsonUnionSchema(schema)) {
|
|
489
|
+
if (typeof member !== "object") {
|
|
490
|
+
return void 0;
|
|
491
|
+
}
|
|
492
|
+
const values = member.const !== void 0 ? [member.const] : member.enum;
|
|
493
|
+
if (!values?.length) {
|
|
494
|
+
return void 0;
|
|
495
|
+
}
|
|
496
|
+
for (const value2 of values) {
|
|
497
|
+
if (!Number.isInteger(value2) || value2 >= 400) {
|
|
498
|
+
return void 0;
|
|
499
|
+
}
|
|
500
|
+
if (!statuses.has(value2)) {
|
|
501
|
+
statuses.set(value2, member.description);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return statuses.size ? statuses : void 0;
|
|
506
|
+
}
|
|
487
507
|
function buildErrorResponse(ctx, operation, def) {
|
|
488
508
|
const definitionsByStatus = /* @__PURE__ */ new Map();
|
|
489
509
|
for (const code of Object.keys(def.errorMap)) {
|
|
@@ -4,7 +4,7 @@ import { StandardHandlerCodec, ResolvedStandardHandlerHandleOptions, StandardHan
|
|
|
4
4
|
import { Value, Public, Promisable } from '@orpc/shared';
|
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
|
|
6
6
|
import { AnyProcedureContract } from '@orpc/contract';
|
|
7
|
-
import { O as OpenAPISerializer } from './openapi.
|
|
7
|
+
import { O as OpenAPISerializer } from './openapi.DjGhiceP.js';
|
|
8
8
|
|
|
9
9
|
interface OpenAPIMatcherOptions {
|
|
10
10
|
/**
|
|
@@ -4,7 +4,7 @@ import { StandardHandlerCodec, ResolvedStandardHandlerHandleOptions, StandardHan
|
|
|
4
4
|
import { Value, Public, Promisable } from '@orpc/shared';
|
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
|
|
6
6
|
import { AnyProcedureContract } from '@orpc/contract';
|
|
7
|
-
import { O as OpenAPISerializer } from './openapi.
|
|
7
|
+
import { O as OpenAPISerializer } from './openapi.DjGhiceP.mjs';
|
|
8
8
|
|
|
9
9
|
interface OpenAPIMatcherOptions {
|
|
10
10
|
/**
|
|
@@ -3,7 +3,7 @@ import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/clien
|
|
|
3
3
|
import { RouterContract } from '@orpc/contract';
|
|
4
4
|
import { Value, Promisable, Public } from '@orpc/shared';
|
|
5
5
|
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
|
|
6
|
-
import { O as OpenAPISerializer } from './openapi.
|
|
6
|
+
import { O as OpenAPISerializer } from './openapi.DjGhiceP.mjs';
|
|
7
7
|
|
|
8
8
|
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
9
9
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
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';
|
|
5
5
|
import { mergeStandardHeaders, parseStandardUrl } from '@standard-server/core';
|
|
6
6
|
import { toStandardHeaders } from '@standard-server/fetch';
|
|
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.
|
|
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 } : {
|
|
@@ -4,22 +4,21 @@ import { Segment } from '@orpc/shared';
|
|
|
4
4
|
type BracketNotationSerializeResult = [string, unknown][];
|
|
5
5
|
interface BracketNotationSerializerOptions {
|
|
6
6
|
/**
|
|
7
|
-
* Maximum explicit array
|
|
8
|
-
*
|
|
7
|
+
* Maximum number of empty slots that explicit array indexes may leave in total during deserialization
|
|
8
|
+
* (e.g., `a[0]=x&a[3]=y` leaves 2). An index that would exceed it turns its array into an object
|
|
9
|
+
* instead (e.g., `?arr[5000]=x` becomes `{ arr: { 5000: 'x' } }`).
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* efficiently, downstream code may inadvertently densify them - creating millions of
|
|
13
|
-
* undefined slots and exhausting memory.
|
|
11
|
+
* Empty slots take memory (a lone `?arr[999]=x` takes ~12KB in V8), and code iterating an array walks
|
|
12
|
+
* every one of them, so this keeps both in line with the input.
|
|
14
13
|
*
|
|
15
|
-
* NOTE:
|
|
14
|
+
* NOTE: Append-style notation (e.g., `arr[]`) never leaves empty slots.
|
|
16
15
|
*
|
|
17
|
-
* @default
|
|
16
|
+
* @default 1_000
|
|
18
17
|
*/
|
|
19
|
-
|
|
18
|
+
maxDeserializingEmptySlots?: number;
|
|
20
19
|
}
|
|
21
20
|
declare class BracketNotationSerializer {
|
|
22
|
-
private readonly
|
|
21
|
+
private readonly maxDeserializingEmptySlots;
|
|
23
22
|
constructor(options?: BracketNotationSerializerOptions);
|
|
24
23
|
serialize(data: unknown): BracketNotationSerializeResult;
|
|
25
24
|
private internalSerialize;
|
|
@@ -125,7 +124,7 @@ interface OpenAPISerializerSerializeOptions {
|
|
|
125
124
|
}
|
|
126
125
|
interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions {
|
|
127
126
|
/**
|
|
128
|
-
* Options for bracket notation serializer, like
|
|
127
|
+
* Options for bracket notation serializer, like maxDeserializingEmptySlots
|
|
129
128
|
*/
|
|
130
129
|
bracketNotation?: BracketNotationSerializerOptions | undefined;
|
|
131
130
|
/**
|
|
@@ -4,22 +4,21 @@ import { Segment } from '@orpc/shared';
|
|
|
4
4
|
type BracketNotationSerializeResult = [string, unknown][];
|
|
5
5
|
interface BracketNotationSerializerOptions {
|
|
6
6
|
/**
|
|
7
|
-
* Maximum explicit array
|
|
8
|
-
*
|
|
7
|
+
* Maximum number of empty slots that explicit array indexes may leave in total during deserialization
|
|
8
|
+
* (e.g., `a[0]=x&a[3]=y` leaves 2). An index that would exceed it turns its array into an object
|
|
9
|
+
* instead (e.g., `?arr[5000]=x` becomes `{ arr: { 5000: 'x' } }`).
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* efficiently, downstream code may inadvertently densify them - creating millions of
|
|
13
|
-
* undefined slots and exhausting memory.
|
|
11
|
+
* Empty slots take memory (a lone `?arr[999]=x` takes ~12KB in V8), and code iterating an array walks
|
|
12
|
+
* every one of them, so this keeps both in line with the input.
|
|
14
13
|
*
|
|
15
|
-
* NOTE:
|
|
14
|
+
* NOTE: Append-style notation (e.g., `arr[]`) never leaves empty slots.
|
|
16
15
|
*
|
|
17
|
-
* @default
|
|
16
|
+
* @default 1_000
|
|
18
17
|
*/
|
|
19
|
-
|
|
18
|
+
maxDeserializingEmptySlots?: number;
|
|
20
19
|
}
|
|
21
20
|
declare class BracketNotationSerializer {
|
|
22
|
-
private readonly
|
|
21
|
+
private readonly maxDeserializingEmptySlots;
|
|
23
22
|
constructor(options?: BracketNotationSerializerOptions);
|
|
24
23
|
serialize(data: unknown): BracketNotationSerializeResult;
|
|
25
24
|
private internalSerialize;
|
|
@@ -125,7 +124,7 @@ interface OpenAPISerializerSerializeOptions {
|
|
|
125
124
|
}
|
|
126
125
|
interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions {
|
|
127
126
|
/**
|
|
128
|
-
* Options for bracket notation serializer, like
|
|
127
|
+
* Options for bracket notation serializer, like maxDeserializingEmptySlots
|
|
129
128
|
*/
|
|
130
129
|
bracketNotation?: BracketNotationSerializerOptions | undefined;
|
|
131
130
|
/**
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
2
2
|
import { walkProcedureContractsSync, unlazy, getRouter, Procedure, createContractProcedure, DEFAULT_SUCCESS_STATUS, DEFAULT_ERROR_STATUS } from '@orpc/server';
|
|
3
|
-
import { value, pathToHttpPath, mergeHttpPath,
|
|
3
|
+
import { value, pathToHttpPath, mergeHttpPath, safeDecodeURIComponent, safeEncodeURIComponent, setOwn, NullProtoObj, isTypescriptObject, isPlainObject, stringifyJSON, getOwn, parseEmptyableJSON } from '@orpc/shared';
|
|
4
4
|
import { parseStandardUrl } from '@standard-server/core';
|
|
5
|
-
import { D as DEFAULT_OPENAPI_METHOD, g as getDynamicPathParams, O as OpenAPISerializer, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.
|
|
5
|
+
import { D as DEFAULT_OPENAPI_METHOD, g as getDynamicPathParams, O as OpenAPISerializer, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.PXVenYpE.mjs';
|
|
6
6
|
import { g as getOpenAPIMeta } from './openapi.B9PQzqBn.mjs';
|
|
7
7
|
import { createRouter, addRoute, findRoute, findAllRoutes, routeToRegExp } from 'rou3';
|
|
8
8
|
|
|
9
|
+
const ROU3_RAW_CHARS = String.raw`\w!$&'()*+,\-.:;=@[\\\]|~`;
|
|
10
|
+
const NORMALIZABLE_PATHNAME_REGEX = new RegExp(`[^${ROU3_RAW_CHARS}/]`);
|
|
11
|
+
const ROU3_ENCODED_SEGMENT_TEXT_REGEX = new RegExp(`[^${ROU3_RAW_CHARS}]+`, "g");
|
|
9
12
|
class OpenAPIMatcher {
|
|
10
13
|
filter;
|
|
11
14
|
rootRouter;
|
|
@@ -68,19 +71,12 @@ class OpenAPIMatcher {
|
|
|
68
71
|
return void 0;
|
|
69
72
|
}
|
|
70
73
|
}
|
|
74
|
+
pathname = normalizeRou3Path(pathname);
|
|
71
75
|
const loading = this.resolvePendingLazyRouters(pathname);
|
|
72
76
|
if (loading !== void 0) {
|
|
73
77
|
await loading;
|
|
74
78
|
}
|
|
75
|
-
|
|
76
|
-
if (match === void 0 && pathname.includes("%")) {
|
|
77
|
-
const normalizedPathname = normalizeHttpPath(pathname);
|
|
78
|
-
const normalizedLoading = this.resolvePendingLazyRouters(normalizedPathname);
|
|
79
|
-
if (normalizedLoading !== void 0) {
|
|
80
|
-
await normalizedLoading;
|
|
81
|
-
}
|
|
82
|
-
match = this.findMatch(method, normalizedPathname);
|
|
83
|
-
}
|
|
79
|
+
const match = this.findMatch(method, pathname);
|
|
84
80
|
if (match === void 0) {
|
|
85
81
|
return void 0;
|
|
86
82
|
}
|
|
@@ -140,7 +136,7 @@ class OpenAPIMatcher {
|
|
|
140
136
|
function toRou3Route(path) {
|
|
141
137
|
const dynamicParams = getDynamicPathParams(path);
|
|
142
138
|
if (!dynamicParams) {
|
|
143
|
-
return { pattern:
|
|
139
|
+
return { pattern: toRou3Literal(path) };
|
|
144
140
|
}
|
|
145
141
|
let pattern = "";
|
|
146
142
|
let literalStart = 0;
|
|
@@ -149,7 +145,7 @@ function toRou3Route(path) {
|
|
|
149
145
|
for (const param of dynamicParams) {
|
|
150
146
|
const key = `p${params.length}`;
|
|
151
147
|
params.push([key, param.parameterName]);
|
|
152
|
-
pattern +=
|
|
148
|
+
pattern += toRou3Literal(path.slice(literalStart, param.startIndex));
|
|
153
149
|
literalStart = param.startIndex + param.segment.length;
|
|
154
150
|
if (param.allowsSlash) {
|
|
155
151
|
if (catchAllKey !== void 0) {
|
|
@@ -161,12 +157,18 @@ function toRou3Route(path) {
|
|
|
161
157
|
pattern += `:${key}`;
|
|
162
158
|
}
|
|
163
159
|
}
|
|
164
|
-
pattern +=
|
|
160
|
+
pattern += toRou3Literal(path.slice(literalStart));
|
|
165
161
|
return { pattern, params, catchAllKey };
|
|
166
162
|
}
|
|
167
163
|
const ROU3_SYNTAX_REGEX = /[\\:*?+(){}]|(?<![^/])\.(?=\.?(?:\/|$))/g;
|
|
168
|
-
function
|
|
169
|
-
return text.replace(ROU3_SYNTAX_REGEX, "\\$&");
|
|
164
|
+
function toRou3Literal(text) {
|
|
165
|
+
return normalizeRou3Path(text).replace(ROU3_SYNTAX_REGEX, "\\$&");
|
|
166
|
+
}
|
|
167
|
+
function normalizeRou3Path(path) {
|
|
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("/");
|
|
170
172
|
}
|
|
171
173
|
function toRou3PrefixMatcher(prefix) {
|
|
172
174
|
const catchAll = getDynamicPathParams(prefix)?.find((param) => param.allowsSlash);
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { isPlainObject, NullProtoObj, getOwn, setOwn } from '@orpc/shared';
|
|
2
|
+
|
|
3
|
+
class BracketNotationSerializer {
|
|
4
|
+
maxDeserializingEmptySlots;
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.maxDeserializingEmptySlots = options.maxDeserializingEmptySlots ?? 1e3;
|
|
7
|
+
}
|
|
8
|
+
serialize(data) {
|
|
9
|
+
const result = [];
|
|
10
|
+
this.internalSerialize(data, "", true, result);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
internalSerialize(data, path, isRoot, result) {
|
|
14
|
+
if (Array.isArray(data)) {
|
|
15
|
+
data.forEach((item, i) => {
|
|
16
|
+
this.internalSerialize(item, isRoot ? i.toString() : `${path}[${i}]`, false, result);
|
|
17
|
+
});
|
|
18
|
+
} else if (isPlainObject(data)) {
|
|
19
|
+
for (const key of Object.keys(data)) {
|
|
20
|
+
this.internalSerialize(data[key], isRoot ? key : `${path}[${key}]`, false, result);
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
result.push([path, data]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
deserialize(serialized) {
|
|
27
|
+
let arrayPushStyles;
|
|
28
|
+
const root = new NullProtoObj();
|
|
29
|
+
let emptySlotsLeft = this.maxDeserializingEmptySlots;
|
|
30
|
+
for (const [path, value] of serialized) {
|
|
31
|
+
const segments = this.parsePath(path);
|
|
32
|
+
let currentRef = root;
|
|
33
|
+
let nextSegment = segments[0];
|
|
34
|
+
for (let i = 1; i < segments.length; i++) {
|
|
35
|
+
const segment = segments[i];
|
|
36
|
+
const isLast = i === segments.length - 1;
|
|
37
|
+
const existing = getOwn(currentRef, nextSegment);
|
|
38
|
+
let child = existing;
|
|
39
|
+
let key = segment;
|
|
40
|
+
if (Array.isArray(child) || !isPlainObject(child)) {
|
|
41
|
+
const isArray = Array.isArray(child);
|
|
42
|
+
const isPushStyle = isArray && !!arrayPushStyles?.has(child);
|
|
43
|
+
const length = isArray ? child.length : 0;
|
|
44
|
+
const index = internalToArrayIndex(segment);
|
|
45
|
+
const emptySlots = index === void 0 ? 0 : Math.max(0, index - length);
|
|
46
|
+
const canBeArray = segment === "" ? isLast && (isPushStyle || length === 0) : index !== void 0 && !(isLast && isPushStyle) && emptySlots <= emptySlotsLeft;
|
|
47
|
+
if (canBeArray) {
|
|
48
|
+
emptySlotsLeft -= emptySlots;
|
|
49
|
+
child = isArray ? child : [];
|
|
50
|
+
key = index ?? segment;
|
|
51
|
+
} else if (isArray) {
|
|
52
|
+
arrayPushStyles?.delete(child);
|
|
53
|
+
child = isPushStyle ? internalPushStyleArrayToObject(child) : internalArrayToObject(child);
|
|
54
|
+
} else {
|
|
55
|
+
child = new NullProtoObj();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (child !== existing) {
|
|
59
|
+
internalSetOwn(currentRef, nextSegment, child);
|
|
60
|
+
}
|
|
61
|
+
currentRef = child;
|
|
62
|
+
nextSegment = key;
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(currentRef) && nextSegment === "") {
|
|
65
|
+
arrayPushStyles ??= /* @__PURE__ */ new WeakSet();
|
|
66
|
+
arrayPushStyles.add(currentRef);
|
|
67
|
+
currentRef.push(value);
|
|
68
|
+
} else if (Object.hasOwn(currentRef, nextSegment)) {
|
|
69
|
+
const current = currentRef[nextSegment];
|
|
70
|
+
if (Array.isArray(current)) {
|
|
71
|
+
current.push(value);
|
|
72
|
+
} else {
|
|
73
|
+
internalSetOwn(currentRef, nextSegment, [current, value]);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
internalSetOwn(currentRef, nextSegment, value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return root;
|
|
80
|
+
}
|
|
81
|
+
stringifyPath(segments) {
|
|
82
|
+
if (segments.length === 0) {
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
let result = segments[0].toString();
|
|
86
|
+
for (let i = 1; i < segments.length; i++) {
|
|
87
|
+
result += `[${segments[i]}]`;
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
parsePath(path) {
|
|
92
|
+
const start = path.indexOf("[");
|
|
93
|
+
if (start === -1 || path[path.length - 1] !== "]") {
|
|
94
|
+
return [path];
|
|
95
|
+
}
|
|
96
|
+
const segments = [path.slice(0, start)];
|
|
97
|
+
let from = start + 1;
|
|
98
|
+
let to = path.indexOf("][", from);
|
|
99
|
+
while (to !== -1) {
|
|
100
|
+
segments.push(path.slice(from, to));
|
|
101
|
+
from = to + 2;
|
|
102
|
+
to = path.indexOf("][", from);
|
|
103
|
+
}
|
|
104
|
+
segments.push(path.slice(from, -1));
|
|
105
|
+
return segments;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const MAX_ARRAY_INDEX = 2 ** 32 - 2;
|
|
109
|
+
function internalToArrayIndex(key) {
|
|
110
|
+
if (key.length === 0 || key.length > 10) {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
let index = key.charCodeAt(0) - 48;
|
|
114
|
+
if (index < 0 || index > 9 || index === 0 && key.length > 1) {
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
for (let i = 1; i < key.length; i++) {
|
|
118
|
+
const digit = key.charCodeAt(i) - 48;
|
|
119
|
+
if (digit < 0 || digit > 9) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
index = index * 10 + digit;
|
|
123
|
+
}
|
|
124
|
+
return index <= MAX_ARRAY_INDEX ? index : void 0;
|
|
125
|
+
}
|
|
126
|
+
function internalArrayToObject(array) {
|
|
127
|
+
const obj = new NullProtoObj();
|
|
128
|
+
array.forEach((item, i) => {
|
|
129
|
+
obj[i] = item;
|
|
130
|
+
});
|
|
131
|
+
return obj;
|
|
132
|
+
}
|
|
133
|
+
function internalPushStyleArrayToObject(array) {
|
|
134
|
+
const obj = new NullProtoObj();
|
|
135
|
+
obj[""] = array.length === 1 ? array[0] : array;
|
|
136
|
+
return obj;
|
|
137
|
+
}
|
|
138
|
+
function internalSetOwn(container, key, value) {
|
|
139
|
+
if (typeof key === "string" && container instanceof NullProtoObj) {
|
|
140
|
+
const index = internalToArrayIndex(key);
|
|
141
|
+
if (index !== void 0 && index !== 0 && !Object.hasOwn(container, index - 1) && !Object.hasOwn(container, MAX_ARRAY_INDEX)) {
|
|
142
|
+
container[MAX_ARRAY_INDEX] = void 0;
|
|
143
|
+
delete container[MAX_ARRAY_INDEX];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
setOwn(container, key, value);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { BracketNotationSerializer as B };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { wrapAsyncIteratorPreservingEventMeta, toORPCError, isORPCErrorJson, createORPCErrorFromJson } from '@orpc/client';
|
|
2
2
|
import { isPlainObject, NullProtoObj, copyOnWrite, isAsyncIteratorObject } from '@orpc/shared';
|
|
3
3
|
import { ErrorEvent } from '@standard-server/core';
|
|
4
|
-
import { B as BracketNotationSerializer } from './openapi.
|
|
4
|
+
import { B as BracketNotationSerializer } from './openapi.DtEVcxuW.mjs';
|
|
5
5
|
|
|
6
6
|
const DEFAULT_OPENAPI_METHOD = "POST";
|
|
7
7
|
const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
@@ -3,7 +3,7 @@ import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/clien
|
|
|
3
3
|
import { RouterContract } from '@orpc/contract';
|
|
4
4
|
import { Value, Promisable, Public } from '@orpc/shared';
|
|
5
5
|
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
|
|
6
|
-
import { O as OpenAPISerializer } from './openapi.
|
|
6
|
+
import { O as OpenAPISerializer } from './openapi.DjGhiceP.js';
|
|
7
7
|
|
|
8
8
|
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
9
9
|
/**
|
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"
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { isPlainObject, NullProtoObj, getOwn, setOwn } from '@orpc/shared';
|
|
2
|
-
|
|
3
|
-
class BracketNotationSerializer {
|
|
4
|
-
maxExplicitDeserializingArrayIndex;
|
|
5
|
-
constructor(options = {}) {
|
|
6
|
-
this.maxExplicitDeserializingArrayIndex = options.maxExplicitDeserializingArrayIndex ?? 999;
|
|
7
|
-
}
|
|
8
|
-
serialize(data) {
|
|
9
|
-
const result = [];
|
|
10
|
-
this.internalSerialize(data, "", true, result);
|
|
11
|
-
return result;
|
|
12
|
-
}
|
|
13
|
-
internalSerialize(data, path, isRoot, result) {
|
|
14
|
-
if (Array.isArray(data)) {
|
|
15
|
-
data.forEach((item, i) => {
|
|
16
|
-
this.internalSerialize(item, isRoot ? i.toString() : `${path}[${i}]`, false, result);
|
|
17
|
-
});
|
|
18
|
-
} else if (isPlainObject(data)) {
|
|
19
|
-
for (const key of Object.keys(data)) {
|
|
20
|
-
this.internalSerialize(data[key], isRoot ? key : `${path}[${key}]`, false, result);
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
result.push([path, data]);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
deserialize(serialized) {
|
|
27
|
-
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
28
|
-
const root = new NullProtoObj();
|
|
29
|
-
for (const [path, value] of serialized) {
|
|
30
|
-
const segments = this.parsePath(path);
|
|
31
|
-
let currentRef = root;
|
|
32
|
-
let nextSegment = segments[0];
|
|
33
|
-
for (let i = 1; i < segments.length; i++) {
|
|
34
|
-
const segment = segments[i];
|
|
35
|
-
const isLast = i === segments.length - 1;
|
|
36
|
-
const existing = getOwn(currentRef, nextSegment);
|
|
37
|
-
let child = existing;
|
|
38
|
-
if (!Array.isArray(child) && !isPlainObject(child)) {
|
|
39
|
-
child = [];
|
|
40
|
-
}
|
|
41
|
-
if (Array.isArray(child)) {
|
|
42
|
-
const isPushStyle = arrayPushStyles.has(child);
|
|
43
|
-
const canStayArray = segment === "" ? isLast && (isPushStyle || child.length === 0) : internalIsValidArrayIndex(segment, this.maxExplicitDeserializingArrayIndex) && !(isLast && isPushStyle);
|
|
44
|
-
if (!canStayArray) {
|
|
45
|
-
arrayPushStyles.delete(child);
|
|
46
|
-
child = isPushStyle ? internalPushStyleArrayToObject(child) : internalArrayToObject(child);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (child !== existing) {
|
|
50
|
-
setOwn(currentRef, nextSegment, child);
|
|
51
|
-
}
|
|
52
|
-
currentRef = child;
|
|
53
|
-
nextSegment = segment;
|
|
54
|
-
}
|
|
55
|
-
if (Array.isArray(currentRef) && nextSegment === "") {
|
|
56
|
-
arrayPushStyles.add(currentRef);
|
|
57
|
-
currentRef.push(value);
|
|
58
|
-
} else if (Object.hasOwn(currentRef, nextSegment)) {
|
|
59
|
-
const current = currentRef[nextSegment];
|
|
60
|
-
if (Array.isArray(current)) {
|
|
61
|
-
current.push(value);
|
|
62
|
-
} else {
|
|
63
|
-
setOwn(currentRef, nextSegment, [current, value]);
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
setOwn(currentRef, nextSegment, value);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return root;
|
|
70
|
-
}
|
|
71
|
-
stringifyPath(segments) {
|
|
72
|
-
if (segments.length === 0) {
|
|
73
|
-
return "";
|
|
74
|
-
}
|
|
75
|
-
let result = segments[0].toString();
|
|
76
|
-
for (let i = 1; i < segments.length; i++) {
|
|
77
|
-
result += `[${segments[i]}]`;
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
parsePath(path) {
|
|
82
|
-
const segments = [];
|
|
83
|
-
let inBrackets = false;
|
|
84
|
-
let currentSegment = "";
|
|
85
|
-
for (let i = 0; i < path.length; i++) {
|
|
86
|
-
const char = path[i];
|
|
87
|
-
const nextChar = path[i + 1];
|
|
88
|
-
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
|
|
89
|
-
if (nextChar === void 0) {
|
|
90
|
-
inBrackets = false;
|
|
91
|
-
}
|
|
92
|
-
segments.push(currentSegment);
|
|
93
|
-
currentSegment = "";
|
|
94
|
-
i++;
|
|
95
|
-
} else if (segments.length === 0 && char === "[") {
|
|
96
|
-
inBrackets = true;
|
|
97
|
-
segments.push(currentSegment);
|
|
98
|
-
currentSegment = "";
|
|
99
|
-
} else {
|
|
100
|
-
currentSegment += char;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return inBrackets || segments.length === 0 ? [path] : segments;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
|
|
107
|
-
function internalIsValidArrayIndex(value, maxIndex) {
|
|
108
|
-
return INTEGER_PATTERN.test(value) && Number(value) <= maxIndex;
|
|
109
|
-
}
|
|
110
|
-
function internalArrayToObject(array) {
|
|
111
|
-
const obj = new NullProtoObj();
|
|
112
|
-
array.forEach((item, i) => {
|
|
113
|
-
obj[i] = item;
|
|
114
|
-
});
|
|
115
|
-
return obj;
|
|
116
|
-
}
|
|
117
|
-
function internalPushStyleArrayToObject(array) {
|
|
118
|
-
const obj = new NullProtoObj();
|
|
119
|
-
obj[""] = array.length === 1 ? array[0] : array;
|
|
120
|
-
return obj;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export { BracketNotationSerializer as B };
|