@orpc/openapi 0.0.0-next.df024bb → 0.0.0-next.df486d6
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 +14 -1
- package/dist/adapters/fetch/index.d.mts +6 -9
- package/dist/adapters/fetch/index.d.ts +6 -9
- package/dist/adapters/fetch/index.mjs +13 -6
- package/dist/adapters/node/index.d.mts +6 -9
- package/dist/adapters/node/index.d.ts +6 -9
- package/dist/adapters/node/index.mjs +8 -22
- package/dist/adapters/standard/index.d.mts +19 -9
- package/dist/adapters/standard/index.d.ts +19 -9
- package/dist/adapters/standard/index.mjs +4 -3
- package/dist/index.d.mts +87 -141
- package/dist/index.d.ts +87 -141
- package/dist/index.mjs +435 -560
- package/dist/shared/openapi.D3j94c9n.d.mts +12 -0
- package/dist/shared/openapi.D3j94c9n.d.ts +12 -0
- package/dist/shared/{openapi.CDsfPHgw.mjs → openapi.p5tsmBXx.mjs} +34 -24
- package/package.json +9 -21
- package/dist/adapters/hono/index.d.mts +0 -7
- package/dist/adapters/hono/index.d.ts +0 -7
- package/dist/adapters/hono/index.mjs +0 -10
- package/dist/adapters/next/index.d.mts +0 -7
- package/dist/adapters/next/index.d.ts +0 -7
- package/dist/adapters/next/index.mjs +0 -10
- package/dist/shared/openapi.BHG_gu5Z.mjs +0 -8
- package/dist/shared/openapi.BcJH4F9P.mjs +0 -27
- package/dist/shared/openapi.Dz_6xooR.d.mts +0 -7
- package/dist/shared/openapi.Dz_6xooR.d.ts +0 -7
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
|
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
|
@@ -53,11 +53,16 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
53
53
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
54
54
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
56
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
57
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
|
57
58
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
59
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
60
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
58
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
59
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
60
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
61
66
|
|
|
62
67
|
## `@orpc/openapi`
|
|
63
68
|
|
|
@@ -86,6 +91,14 @@ const server = createServer(async (req, res) => {
|
|
|
86
91
|
server.listen(3000, '127.0.0.1', () => console.log('Listening on 127.0.0.1:3000'))
|
|
87
92
|
```
|
|
88
93
|
|
|
94
|
+
## Sponsors
|
|
95
|
+
|
|
96
|
+
<p align="center">
|
|
97
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
|
98
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
|
99
|
+
</a>
|
|
100
|
+
</p>
|
|
101
|
+
|
|
89
102
|
## License
|
|
90
103
|
|
|
91
104
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
|
-
import { FetchHandler,
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { O as OpenAPIHandlerOptions } from '../../shared/openapi.Dz_6xooR.mjs';
|
|
2
|
+
import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
|
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
|
|
4
|
+
import '@orpc/openapi-client/standard';
|
|
5
|
+
import '@orpc/server/standard';
|
|
7
6
|
|
|
8
|
-
declare class OpenAPIHandler<T extends Context>
|
|
9
|
-
|
|
10
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
11
|
-
handle(request: Request, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & ToFetchResponseOptions>): Promise<FetchHandleResult>;
|
|
7
|
+
declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
|
|
8
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
export { OpenAPIHandler };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
|
-
import { FetchHandler,
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { O as OpenAPIHandlerOptions } from '../../shared/openapi.Dz_6xooR.js';
|
|
2
|
+
import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
|
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
|
|
4
|
+
import '@orpc/openapi-client/standard';
|
|
5
|
+
import '@orpc/server/standard';
|
|
7
6
|
|
|
8
|
-
declare class OpenAPIHandler<T extends Context>
|
|
9
|
-
|
|
10
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
11
|
-
handle(request: Request, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & ToFetchResponseOptions>): Promise<FetchHandleResult>;
|
|
7
|
+
declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
|
|
8
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
export { OpenAPIHandler };
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import '@orpc/server/standard';
|
|
3
|
-
import '@orpc/standard-server-fetch';
|
|
4
|
-
import '../../shared/openapi.CDsfPHgw.mjs';
|
|
1
|
+
import { FetchHandler } from '@orpc/server/fetch';
|
|
5
2
|
import '@orpc/contract';
|
|
6
|
-
import '@orpc/openapi-client/standard';
|
|
7
3
|
import '@orpc/shared';
|
|
4
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.p5tsmBXx.mjs';
|
|
5
|
+
import '@orpc/client/standard';
|
|
8
6
|
import '@orpc/server';
|
|
9
7
|
import 'rou3';
|
|
10
|
-
import '
|
|
8
|
+
import '@orpc/openapi-client/standard';
|
|
9
|
+
import '@orpc/server/standard';
|
|
10
|
+
|
|
11
|
+
class OpenAPIHandler extends FetchHandler {
|
|
12
|
+
constructor(router, options = {}) {
|
|
13
|
+
super(new StandardOpenAPIHandler(router, options), options);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { OpenAPIHandler };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
|
-
import { NodeHttpHandler,
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { O as OpenAPIHandlerOptions } from '../../shared/openapi.Dz_6xooR.mjs';
|
|
2
|
+
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
|
|
4
|
+
import '@orpc/openapi-client/standard';
|
|
5
|
+
import '@orpc/server/standard';
|
|
7
6
|
|
|
8
|
-
declare class OpenAPIHandler<T extends Context>
|
|
9
|
-
|
|
10
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
11
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & SendStandardResponseOptions>): Promise<NodeHttpHandleResult>;
|
|
7
|
+
declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
8
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
export { OpenAPIHandler };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
|
-
import { NodeHttpHandler,
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { O as OpenAPIHandlerOptions } from '../../shared/openapi.Dz_6xooR.js';
|
|
2
|
+
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
|
|
4
|
+
import '@orpc/openapi-client/standard';
|
|
5
|
+
import '@orpc/server/standard';
|
|
7
6
|
|
|
8
|
-
declare class OpenAPIHandler<T extends Context>
|
|
9
|
-
|
|
10
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
11
|
-
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & SendStandardResponseOptions>): Promise<NodeHttpHandleResult>;
|
|
7
|
+
declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
8
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
export { OpenAPIHandler };
|
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
|
3
|
-
import { a as OpenAPIMatcher, O as OpenAPICodec } from '../../shared/openapi.CDsfPHgw.mjs';
|
|
1
|
+
import { NodeHttpHandler } from '@orpc/server/node';
|
|
4
2
|
import '@orpc/contract';
|
|
5
|
-
import '@orpc/openapi-client/standard';
|
|
6
3
|
import '@orpc/shared';
|
|
4
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.p5tsmBXx.mjs';
|
|
5
|
+
import '@orpc/client/standard';
|
|
7
6
|
import '@orpc/server';
|
|
8
7
|
import 'rou3';
|
|
9
|
-
import '
|
|
8
|
+
import '@orpc/openapi-client/standard';
|
|
9
|
+
import '@orpc/server/standard';
|
|
10
10
|
|
|
11
|
-
class OpenAPIHandler {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const matcher = options?.matcher ?? new OpenAPIMatcher();
|
|
15
|
-
const codec = options?.codec ?? new OpenAPICodec();
|
|
16
|
-
this.standardHandler = new StandardHandler(router, matcher, codec, { ...options });
|
|
17
|
-
}
|
|
18
|
-
async handle(req, res, ...[
|
|
19
|
-
options = {}
|
|
20
|
-
]) {
|
|
21
|
-
const standardRequest = toStandardLazyRequest(req, res);
|
|
22
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
|
23
|
-
if (!result.matched) {
|
|
24
|
-
return { matched: false };
|
|
25
|
-
}
|
|
26
|
-
await sendStandardResponse(res, result.response, options);
|
|
27
|
-
return { matched: true };
|
|
11
|
+
class OpenAPIHandler extends NodeHttpHandler {
|
|
12
|
+
constructor(router, options = {}) {
|
|
13
|
+
super(new StandardOpenAPIHandler(router, options), options);
|
|
28
14
|
}
|
|
29
15
|
}
|
|
30
16
|
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { ORPCError } from '@orpc/client';
|
|
1
|
+
import { ORPCError, HTTPPath } from '@orpc/client';
|
|
2
|
+
import { StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
|
|
2
3
|
import { AnyProcedure, AnyRouter } from '@orpc/server';
|
|
3
4
|
import { StandardCodec, StandardParams, StandardMatcher, StandardMatchResult } from '@orpc/server/standard';
|
|
4
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
5
|
-
|
|
6
|
-
export { O as OpenAPIHandlerOptions } from '../../shared/openapi.Dz_6xooR.mjs';
|
|
7
|
-
import { HTTPPath } from '@orpc/contract';
|
|
6
|
+
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
|
|
8
7
|
|
|
9
|
-
declare class
|
|
8
|
+
declare class StandardOpenAPICodec implements StandardCodec {
|
|
10
9
|
private readonly serializer;
|
|
11
|
-
constructor(serializer
|
|
10
|
+
constructor(serializer: StandardOpenAPISerializer);
|
|
12
11
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
13
12
|
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
14
13
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
declare class
|
|
16
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
|
18
17
|
private readonly tree;
|
|
19
18
|
private pendingRouters;
|
|
20
|
-
init(router: AnyRouter, path?: string[]): void;
|
|
19
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
|
21
20
|
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* {@link https://github.com/unjs/rou3}
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
declare function toRou3Pattern(path: HTTPPath): string;
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
|
33
|
+
|
|
34
|
+
export { StandardOpenAPICodec, StandardOpenAPIMatcher, decodeParams, toRou3Pattern };
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { ORPCError } from '@orpc/client';
|
|
1
|
+
import { ORPCError, HTTPPath } from '@orpc/client';
|
|
2
|
+
import { StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
|
|
2
3
|
import { AnyProcedure, AnyRouter } from '@orpc/server';
|
|
3
4
|
import { StandardCodec, StandardParams, StandardMatcher, StandardMatchResult } from '@orpc/server/standard';
|
|
4
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
5
|
-
|
|
6
|
-
export { O as OpenAPIHandlerOptions } from '../../shared/openapi.Dz_6xooR.js';
|
|
7
|
-
import { HTTPPath } from '@orpc/contract';
|
|
6
|
+
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
|
|
8
7
|
|
|
9
|
-
declare class
|
|
8
|
+
declare class StandardOpenAPICodec implements StandardCodec {
|
|
10
9
|
private readonly serializer;
|
|
11
|
-
constructor(serializer
|
|
10
|
+
constructor(serializer: StandardOpenAPISerializer);
|
|
12
11
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
13
12
|
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
14
13
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
declare class
|
|
16
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
|
18
17
|
private readonly tree;
|
|
19
18
|
private pendingRouters;
|
|
20
|
-
init(router: AnyRouter, path?: string[]): void;
|
|
19
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
|
21
20
|
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* {@link https://github.com/unjs/rou3}
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
declare function toRou3Pattern(path: HTTPPath): string;
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
|
33
|
+
|
|
34
|
+
export { StandardOpenAPICodec, StandardOpenAPIMatcher, decodeParams, toRou3Pattern };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import '@orpc/contract';
|
|
1
|
+
export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.p5tsmBXx.mjs';
|
|
3
2
|
import '@orpc/openapi-client/standard';
|
|
3
|
+
import '@orpc/server/standard';
|
|
4
|
+
import '@orpc/contract';
|
|
4
5
|
import '@orpc/shared';
|
|
6
|
+
import '@orpc/client/standard';
|
|
5
7
|
import '@orpc/server';
|
|
6
8
|
import 'rou3';
|
|
7
|
-
import '../../shared/openapi.BHG_gu5Z.mjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,169 +1,115 @@
|
|
|
1
|
-
import { AnyContractProcedure,
|
|
2
|
-
import
|
|
3
|
-
export { OpenAPI };
|
|
4
|
-
|
|
5
|
-
import * as JSONSchema from 'json-schema-typed/draft-2020-12';
|
|
6
|
-
export { JSONSchema };
|
|
7
|
-
export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
|
8
|
-
import { OpenAPIJsonSerializer } from '@orpc/openapi-client/standard';
|
|
1
|
+
import { AnyContractProcedure, AnySchema, AnyContractRouter } from '@orpc/contract';
|
|
2
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
3
|
+
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
4
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
|
9
5
|
import { AnyRouter } from '@orpc/server';
|
|
6
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
7
|
+
export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
|
8
|
+
import { HTTPPath, HTTPMethod } from '@orpc/client';
|
|
10
9
|
|
|
11
|
-
type OverrideOperationValue =
|
|
12
|
-
declare function
|
|
13
|
-
declare function
|
|
14
|
-
declare function
|
|
10
|
+
type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.OperationObject);
|
|
11
|
+
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
12
|
+
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
13
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
type ObjectSchema = JSONSchema & {
|
|
17
19
|
type: 'object';
|
|
18
20
|
} & object;
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
type FileSchema = JSONSchema & {
|
|
20
25
|
type: 'string';
|
|
21
26
|
contentMediaType: string;
|
|
22
27
|
} & object;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
isObjectSchema(schema: JSONSchema.JSONSchema): schema is ObjectSchema;
|
|
28
|
-
isAnySchema(schema: JSONSchema.JSONSchema): boolean;
|
|
29
|
-
isUndefinableSchema(schema: JSONSchema.JSONSchema): boolean;
|
|
30
|
-
separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
31
|
-
filterSchemaBranches(schema: JSONSchema.JSONSchema, check: (schema: JSONSchema.JSONSchema) => boolean, matches?: JSONSchema.JSONSchema[]): [matches: JSONSchema.JSONSchema[], rest: JSONSchema.JSONSchema | undefined];
|
|
32
|
-
}
|
|
33
|
-
type PublicSchemaUtils = Pick<SchemaUtils, keyof SchemaUtils>;
|
|
34
|
-
|
|
35
|
-
declare class OpenAPIContentBuilder {
|
|
36
|
-
private readonly schemaUtils;
|
|
37
|
-
constructor(schemaUtils: PublicSchemaUtils);
|
|
38
|
-
build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
|
|
39
|
-
}
|
|
40
|
-
type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
|
|
41
|
-
|
|
42
|
-
declare class OpenAPIPathParser {
|
|
43
|
-
parseDynamicParams(path: string): {
|
|
44
|
-
name: string;
|
|
45
|
-
raw: string;
|
|
46
|
-
}[];
|
|
47
|
-
}
|
|
48
|
-
type PublicOpenAPIPathParser = Pick<OpenAPIPathParser, keyof OpenAPIPathParser>;
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
declare const LOGIC_KEYWORDS: string[];
|
|
49
32
|
|
|
50
33
|
interface SchemaConvertOptions {
|
|
51
34
|
strategy: 'input' | 'output';
|
|
52
35
|
}
|
|
53
36
|
interface SchemaConverter {
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
|
|
38
|
+
}
|
|
39
|
+
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
40
|
+
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): boolean;
|
|
56
41
|
}
|
|
57
42
|
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
58
43
|
private readonly converters;
|
|
59
|
-
constructor(converters:
|
|
60
|
-
|
|
61
|
-
convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface OpenAPIInputStructureParseResult {
|
|
65
|
-
paramsSchema: ObjectSchema | undefined;
|
|
66
|
-
querySchema: ObjectSchema | undefined;
|
|
67
|
-
headersSchema: ObjectSchema | undefined;
|
|
68
|
-
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
69
|
-
}
|
|
70
|
-
declare class OpenAPIInputStructureParser {
|
|
71
|
-
private readonly schemaConverter;
|
|
72
|
-
private readonly schemaUtils;
|
|
73
|
-
private readonly pathParser;
|
|
74
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
|
|
75
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
|
|
76
|
-
private parseDetailedSchema;
|
|
77
|
-
private parseCompactSchema;
|
|
78
|
-
}
|
|
79
|
-
type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
|
|
80
|
-
|
|
81
|
-
interface OpenAPIOutputStructureParseResult {
|
|
82
|
-
headersSchema: ObjectSchema | undefined;
|
|
83
|
-
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
84
|
-
}
|
|
85
|
-
declare class OpenAPIOutputStructureParser {
|
|
86
|
-
private readonly schemaConverter;
|
|
87
|
-
private readonly schemaUtils;
|
|
88
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
|
|
89
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
|
|
90
|
-
private parseDetailedSchema;
|
|
91
|
-
private parseCompactSchema;
|
|
92
|
-
}
|
|
93
|
-
type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
|
|
94
|
-
|
|
95
|
-
declare class OpenAPIParametersBuilder {
|
|
96
|
-
build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
|
|
97
|
-
type: 'object';
|
|
98
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
|
|
99
|
-
buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
|
|
100
|
-
type: 'object';
|
|
101
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
|
|
44
|
+
constructor(converters: ConditionalSchemaConverter[]);
|
|
45
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
|
|
102
46
|
}
|
|
103
|
-
type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
|
104
47
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
contentBuilder?: PublicOpenAPIContentBuilder;
|
|
108
|
-
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
109
|
-
schemaConverters?: SchemaConverter[];
|
|
110
|
-
schemaUtils?: PublicSchemaUtils;
|
|
111
|
-
jsonSerializer?: OpenAPIJsonSerializer;
|
|
112
|
-
pathParser?: PublicOpenAPIPathParser;
|
|
113
|
-
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
114
|
-
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
115
|
-
/**
|
|
116
|
-
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
117
|
-
*
|
|
118
|
-
* Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
|
|
119
|
-
* Because OpenAPI root tags is missing 'bar' tag
|
|
120
|
-
*
|
|
121
|
-
* @default false
|
|
122
|
-
*/
|
|
123
|
-
considerMissingTagDefinitionAsError?: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Weather ignore procedures that has no path defined.
|
|
126
|
-
*
|
|
127
|
-
* @default false
|
|
128
|
-
*/
|
|
129
|
-
ignoreUndefinedPathProcedures?: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* What to do when we found an error with our router
|
|
132
|
-
*
|
|
133
|
-
* @default 'throw'
|
|
134
|
-
*/
|
|
135
|
-
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
136
|
-
/**
|
|
137
|
-
* Strict error response
|
|
138
|
-
*
|
|
139
|
-
* @default true
|
|
140
|
-
*/
|
|
141
|
-
strictErrorResponses?: boolean;
|
|
48
|
+
interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
|
|
49
|
+
schemaConverters?: ConditionalSchemaConverter[];
|
|
142
50
|
}
|
|
143
51
|
declare class OpenAPIGenerator {
|
|
144
|
-
private
|
|
145
|
-
private readonly
|
|
146
|
-
private readonly
|
|
147
|
-
private readonly schemaUtils;
|
|
148
|
-
private readonly jsonSerializer;
|
|
149
|
-
private readonly pathParser;
|
|
150
|
-
private readonly inputStructureParser;
|
|
151
|
-
private readonly outputStructureParser;
|
|
152
|
-
private readonly errorHandlerStrategy;
|
|
153
|
-
private readonly ignoreUndefinedPathProcedures;
|
|
154
|
-
private readonly considerMissingTagDefinitionAsError;
|
|
155
|
-
private readonly strictErrorResponses;
|
|
52
|
+
#private;
|
|
53
|
+
private readonly serializer;
|
|
54
|
+
private readonly converter;
|
|
156
55
|
constructor(options?: OpenAPIGeneratorOptions);
|
|
157
|
-
generate(router:
|
|
56
|
+
generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
|
|
158
57
|
}
|
|
159
58
|
|
|
160
|
-
|
|
161
|
-
|
|
59
|
+
/**
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
declare function toOpenAPIPath(path: HTTPPath): string;
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
|
|
162
87
|
|
|
163
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
*@internal
|
|
90
|
+
*/
|
|
91
|
+
declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
|
96
|
+
/**
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
declare function isAnySchema(schema: JSONSchema): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
104
|
+
/**
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
108
|
+
declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
|
|
164
109
|
|
|
165
110
|
declare const oo: {
|
|
166
|
-
spec: typeof
|
|
111
|
+
spec: typeof customOpenAPIOperation;
|
|
167
112
|
};
|
|
168
113
|
|
|
169
|
-
export { CompositeSchemaConverter,
|
|
114
|
+
export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
115
|
+
export type { ConditionalSchemaConverter, FileSchema, ObjectSchema, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter };
|