@orpc/openapi 0.0.0-next.e0f01a5 → 0.0.0-next.e27e0c1

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 CHANGED
@@ -17,32 +17,31 @@
17
17
  <a href="https://discord.gg/TXEbwRBvQn">
18
18
  <img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
19
19
  </a>
20
+ <a href="https://deepwiki.com/unnoq/orpc">
21
+ <img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
22
+ </a>
20
23
  </div>
21
24
 
22
25
  <h3 align="center">Typesafe APIs Made Simple 🪄</h3>
23
26
 
24
- **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards, ensuring a smooth and enjoyable developer experience.
27
+ **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
25
28
 
26
29
  ---
27
30
 
28
31
  ## Highlights
29
32
 
30
- - **End-to-End Type Safety 🔒**: Ensure complete type safety from inputs to outputs and errors, bridging server and client seamlessly.
31
- - **First-Class OpenAPI 📄**: Adheres to the OpenAPI standard out of the box, ensuring seamless integration and comprehensive API documentation.
32
- - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
- - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
- - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
- - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
- - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
- - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
- - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
39
- - **Native Types 📦**: Enjoy built-in support for Date, File, Blob, BigInt, URL and more with no extra setup.
40
- - **Lazy Router ⏱️**: Improve cold start times with our lazy routing feature.
41
- - **SSE & Streaming 📡**: Provides SSE and streaming features – perfect for real-time notifications and AI-powered streaming responses.
42
- - **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
43
- - **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
44
- - **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
45
- - **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
33
+ - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
34
+ - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
35
+ - **📝 Contract-First Development**: Optionally define your API contract before implementation.
36
+ - **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
37
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
38
+ - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
39
+ - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
40
+ - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
41
+ - **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
42
+ - **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
43
+ - **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
44
+ - **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
46
45
 
47
46
  ## Documentation
48
47
 
@@ -53,13 +52,14 @@ You can find the full documentation [here](https://orpc.unnoq.com).
53
52
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
54
53
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
55
54
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
55
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
56
+ - [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
57
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
56
58
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
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).
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).
59
+ - [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
60
+ - [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
61
61
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
62
- - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
62
+ - [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
63
63
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
64
64
  - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
65
65
  - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
@@ -0,0 +1,19 @@
1
+ import { Context, Router } from '@orpc/server';
2
+ import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
3
+ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.mjs';
4
+ import '@orpc/openapi-client/standard';
5
+ import '@orpc/server/standard';
6
+ import '@orpc/client';
7
+ import '@orpc/shared';
8
+
9
+ /**
10
+ * OpenAPI Handler for AWS Lambda.
11
+ *
12
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
13
+ * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
14
+ */
15
+ declare class OpenAPIHandler<T extends Context> extends AwsLambdaHandler<T> {
16
+ constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & AwsLambdaHandlerOptions>);
17
+ }
18
+
19
+ export { OpenAPIHandler };
@@ -0,0 +1,19 @@
1
+ import { Context, Router } from '@orpc/server';
2
+ import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
3
+ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.js';
4
+ import '@orpc/openapi-client/standard';
5
+ import '@orpc/server/standard';
6
+ import '@orpc/client';
7
+ import '@orpc/shared';
8
+
9
+ /**
10
+ * OpenAPI Handler for AWS Lambda.
11
+ *
12
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
13
+ * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
14
+ */
15
+ declare class OpenAPIHandler<T extends Context> extends AwsLambdaHandler<T> {
16
+ constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & AwsLambdaHandlerOptions>);
17
+ }
18
+
19
+ export { OpenAPIHandler };
@@ -0,0 +1,18 @@
1
+ import { AwsLambdaHandler } from '@orpc/server/aws-lambda';
2
+ import '@orpc/client';
3
+ import '@orpc/contract';
4
+ import '@orpc/shared';
5
+ import { a as StandardOpenAPIHandler } from '../../shared/openapi.BVXcB0u4.mjs';
6
+ import '@orpc/client/standard';
7
+ import '@orpc/server';
8
+ import 'rou3';
9
+ import '@orpc/openapi-client/standard';
10
+ import '@orpc/server/standard';
11
+
12
+ class OpenAPIHandler extends AwsLambdaHandler {
13
+ constructor(router, options = {}) {
14
+ super(new StandardOpenAPIHandler(router, options), options);
15
+ }
16
+ }
17
+
18
+ export { OpenAPIHandler };
@@ -1,11 +1,22 @@
1
1
  import { Context, Router } from '@orpc/server';
2
- import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
2
+ import { FetchHandlerOptions, FetchHandler } from '@orpc/server/fetch';
3
+ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.mjs';
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
+ import '@orpc/client';
7
+ import '@orpc/shared';
6
8
 
9
+ interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardOpenAPIHandlerOptions<T>, 'plugins'> {
10
+ }
11
+ /**
12
+ * OpenAPI Handler for Fetch Server
13
+ *
14
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
15
+ * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
16
+ */
7
17
  declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
8
- constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
18
+ constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
9
19
  }
10
20
 
11
21
  export { OpenAPIHandler };
22
+ export type { OpenAPIHandlerOptions };
@@ -1,11 +1,22 @@
1
1
  import { Context, Router } from '@orpc/server';
2
- import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
2
+ import { FetchHandlerOptions, FetchHandler } from '@orpc/server/fetch';
3
+ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.js';
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
+ import '@orpc/client';
7
+ import '@orpc/shared';
6
8
 
9
+ interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardOpenAPIHandlerOptions<T>, 'plugins'> {
10
+ }
11
+ /**
12
+ * OpenAPI Handler for Fetch Server
13
+ *
14
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
15
+ * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
16
+ */
7
17
  declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
8
- constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
18
+ constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
9
19
  }
10
20
 
11
21
  export { OpenAPIHandler };
22
+ export type { OpenAPIHandlerOptions };
@@ -1,7 +1,8 @@
1
1
  import { FetchHandler } from '@orpc/server/fetch';
2
+ import '@orpc/client';
2
3
  import '@orpc/contract';
3
4
  import '@orpc/shared';
4
- import { a as StandardOpenAPIHandler } from '../../shared/openapi.p5tsmBXx.mjs';
5
+ import { a as StandardOpenAPIHandler } from '../../shared/openapi.BVXcB0u4.mjs';
5
6
  import '@orpc/client/standard';
6
7
  import '@orpc/server';
7
8
  import 'rou3';
@@ -1,11 +1,22 @@
1
1
  import { Context, Router } from '@orpc/server';
2
- import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
2
+ import { NodeHttpHandlerOptions, NodeHttpHandler } from '@orpc/server/node';
3
+ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.mjs';
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
+ import '@orpc/client';
7
+ import '@orpc/shared';
6
8
 
9
+ interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, Omit<StandardOpenAPIHandlerOptions<T>, 'plugins'> {
10
+ }
11
+ /**
12
+ * OpenAPI Handler for Node Server
13
+ *
14
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
15
+ * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
16
+ */
7
17
  declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
8
- constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
18
+ constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
9
19
  }
10
20
 
11
21
  export { OpenAPIHandler };
22
+ export type { OpenAPIHandlerOptions };
@@ -1,11 +1,22 @@
1
1
  import { Context, Router } from '@orpc/server';
2
- import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
2
+ import { NodeHttpHandlerOptions, NodeHttpHandler } from '@orpc/server/node';
3
+ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.js';
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
+ import '@orpc/client';
7
+ import '@orpc/shared';
6
8
 
9
+ interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, Omit<StandardOpenAPIHandlerOptions<T>, 'plugins'> {
10
+ }
11
+ /**
12
+ * OpenAPI Handler for Node Server
13
+ *
14
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
15
+ * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
16
+ */
7
17
  declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
8
- constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
18
+ constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
9
19
  }
10
20
 
11
21
  export { OpenAPIHandler };
22
+ export type { OpenAPIHandlerOptions };
@@ -1,7 +1,8 @@
1
1
  import { NodeHttpHandler } from '@orpc/server/node';
2
+ import '@orpc/client';
2
3
  import '@orpc/contract';
3
4
  import '@orpc/shared';
4
- import { a as StandardOpenAPIHandler } from '../../shared/openapi.p5tsmBXx.mjs';
5
+ import { a as StandardOpenAPIHandler } from '../../shared/openapi.BVXcB0u4.mjs';
5
6
  import '@orpc/client/standard';
6
7
  import '@orpc/server';
7
8
  import 'rou3';
@@ -1,11 +1,13 @@
1
1
  import { ORPCError, HTTPPath } from '@orpc/client';
2
2
  import { StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
3
- import { AnyProcedure, AnyRouter } from '@orpc/server';
4
- import { StandardCodec, StandardParams, StandardMatcher, StandardMatchResult } from '@orpc/server/standard';
3
+ import { AnyProcedure } from '@orpc/server';
4
+ import { StandardCodec, StandardParams } from '@orpc/server/standard';
5
5
  import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
6
- export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
6
+ export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions, c as StandardOpenAPIMatcher, b as StandardOpenAPIMatcherOptions } from '../../shared/openapi.CQmjvnb0.mjs';
7
+ import '@orpc/shared';
7
8
 
8
9
  declare class StandardOpenAPICodec implements StandardCodec {
10
+ #private;
9
11
  private readonly serializer;
10
12
  constructor(serializer: StandardOpenAPISerializer);
11
13
  decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
@@ -13,13 +15,6 @@ declare class StandardOpenAPICodec implements StandardCodec {
13
15
  encodeError(error: ORPCError<any, any>): StandardResponse;
14
16
  }
15
17
 
16
- declare class StandardOpenAPIMatcher implements StandardMatcher {
17
- private readonly tree;
18
- private pendingRouters;
19
- init(router: AnyRouter, path?: readonly string[]): void;
20
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
21
- }
22
-
23
18
  /**
24
19
  * {@link https://github.com/unjs/rou3}
25
20
  *
@@ -31,4 +26,4 @@ declare function toRou3Pattern(path: HTTPPath): string;
31
26
  */
32
27
  declare function decodeParams(params: Record<string, string>): Record<string, string>;
33
28
 
34
- export { StandardOpenAPICodec, StandardOpenAPIMatcher, decodeParams, toRou3Pattern };
29
+ export { StandardOpenAPICodec, decodeParams, toRou3Pattern };
@@ -1,11 +1,13 @@
1
1
  import { ORPCError, HTTPPath } from '@orpc/client';
2
2
  import { StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
3
- import { AnyProcedure, AnyRouter } from '@orpc/server';
4
- import { StandardCodec, StandardParams, StandardMatcher, StandardMatchResult } from '@orpc/server/standard';
3
+ import { AnyProcedure } from '@orpc/server';
4
+ import { StandardCodec, StandardParams } from '@orpc/server/standard';
5
5
  import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
6
- export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
6
+ export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions, c as StandardOpenAPIMatcher, b as StandardOpenAPIMatcherOptions } from '../../shared/openapi.CQmjvnb0.js';
7
+ import '@orpc/shared';
7
8
 
8
9
  declare class StandardOpenAPICodec implements StandardCodec {
10
+ #private;
9
11
  private readonly serializer;
10
12
  constructor(serializer: StandardOpenAPISerializer);
11
13
  decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
@@ -13,13 +15,6 @@ declare class StandardOpenAPICodec implements StandardCodec {
13
15
  encodeError(error: ORPCError<any, any>): StandardResponse;
14
16
  }
15
17
 
16
- declare class StandardOpenAPIMatcher implements StandardMatcher {
17
- private readonly tree;
18
- private pendingRouters;
19
- init(router: AnyRouter, path?: readonly string[]): void;
20
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
21
- }
22
-
23
18
  /**
24
19
  * {@link https://github.com/unjs/rou3}
25
20
  *
@@ -31,4 +26,4 @@ declare function toRou3Pattern(path: HTTPPath): string;
31
26
  */
32
27
  declare function decodeParams(params: Record<string, string>): Record<string, string>;
33
28
 
34
- export { StandardOpenAPICodec, StandardOpenAPIMatcher, decodeParams, toRou3Pattern };
29
+ export { StandardOpenAPICodec, decodeParams, toRou3Pattern };
@@ -1,6 +1,7 @@
1
- export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.p5tsmBXx.mjs';
1
+ export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.BVXcB0u4.mjs';
2
2
  import '@orpc/openapi-client/standard';
3
3
  import '@orpc/server/standard';
4
+ import '@orpc/client';
4
5
  import '@orpc/contract';
5
6
  import '@orpc/shared';
6
7
  import '@orpc/client/standard';
package/dist/index.d.mts CHANGED
@@ -1,17 +1,23 @@
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';
5
- import { AnyRouter } from '@orpc/server';
6
- import { Promisable } from '@orpc/shared';
7
- import { JSONSchema } from 'json-schema-typed/draft-2020-12';
8
- export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
1
+ import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
2
+ export { OpenAPI } from '@orpc/contract';
3
+ export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.CfjfVeBJ.mjs';
9
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
5
+ import { JSONSchema } from '@orpc/interop/json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/interop/json-schema-typed/draft-2020-12';
7
+ import { JsonifiedClient } from '@orpc/openapi-client';
8
+ import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
9
+ import { MaybeOptionalOptions } from '@orpc/shared';
10
+ import '@orpc/openapi-client/standard';
10
11
 
11
- type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.OperationObject);
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ *
16
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
+ */
12
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
13
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
14
- declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
15
21
 
16
22
  /**
17
23
  * @internal
@@ -31,32 +37,6 @@ type FileSchema = JSONSchema & {
31
37
  */
32
38
  declare const LOGIC_KEYWORDS: string[];
33
39
 
34
- interface SchemaConvertOptions {
35
- strategy: 'input' | 'output';
36
- }
37
- interface SchemaConverter {
38
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
39
- }
40
- interface ConditionalSchemaConverter extends SchemaConverter {
41
- condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
42
- }
43
- declare class CompositeSchemaConverter implements SchemaConverter {
44
- private readonly converters;
45
- constructor(converters: ConditionalSchemaConverter[]);
46
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
47
- }
48
-
49
- interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
50
- schemaConverters?: ConditionalSchemaConverter[];
51
- }
52
- declare class OpenAPIGenerator {
53
- #private;
54
- private readonly serializer;
55
- private readonly converter;
56
- constructor(options?: OpenAPIGeneratorOptions);
57
- generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
58
- }
59
-
60
40
  /**
61
41
  * @internal
62
42
  */
@@ -68,15 +48,15 @@ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
68
48
  /**
69
49
  * @internal
70
50
  */
71
- declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
72
52
  /**
73
53
  * @internal
74
54
  */
75
- declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
76
56
  /**
77
57
  * @internal
78
58
  */
79
- declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
80
60
  /**
81
61
  * @internal
82
62
  */
@@ -84,7 +64,10 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
84
64
  /**
85
65
  * @internal
86
66
  */
87
- declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
69
+
70
+ declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
88
71
 
89
72
  /**
90
73
  *@internal
@@ -107,10 +90,21 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
107
90
  */
108
91
  declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
109
92
  declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
93
+ /**
94
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
95
+ * recursively expands it into an array of its constituent, non-union base schemas.
96
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
97
+ */
98
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
99
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
100
+ type: 'array';
101
+ items?: JSONSchema;
102
+ }];
103
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
110
104
 
111
105
  declare const oo: {
112
106
  spec: typeof customOpenAPIOperation;
113
107
  };
114
108
 
115
- export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
116
- export type { ConditionalSchemaConverter, FileSchema, ObjectSchema, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter };
109
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
110
+ export type { FileSchema, ObjectSchema, OverrideOperationValue };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,23 @@
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';
5
- import { AnyRouter } from '@orpc/server';
6
- import { Promisable } from '@orpc/shared';
7
- import { JSONSchema } from 'json-schema-typed/draft-2020-12';
8
- export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
1
+ import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
2
+ export { OpenAPI } from '@orpc/contract';
3
+ export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.CfjfVeBJ.js';
9
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
5
+ import { JSONSchema } from '@orpc/interop/json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/interop/json-schema-typed/draft-2020-12';
7
+ import { JsonifiedClient } from '@orpc/openapi-client';
8
+ import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
9
+ import { MaybeOptionalOptions } from '@orpc/shared';
10
+ import '@orpc/openapi-client/standard';
10
11
 
11
- type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.OperationObject);
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ *
16
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
+ */
12
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
13
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
14
- declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
15
21
 
16
22
  /**
17
23
  * @internal
@@ -31,32 +37,6 @@ type FileSchema = JSONSchema & {
31
37
  */
32
38
  declare const LOGIC_KEYWORDS: string[];
33
39
 
34
- interface SchemaConvertOptions {
35
- strategy: 'input' | 'output';
36
- }
37
- interface SchemaConverter {
38
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
39
- }
40
- interface ConditionalSchemaConverter extends SchemaConverter {
41
- condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
42
- }
43
- declare class CompositeSchemaConverter implements SchemaConverter {
44
- private readonly converters;
45
- constructor(converters: ConditionalSchemaConverter[]);
46
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
47
- }
48
-
49
- interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
50
- schemaConverters?: ConditionalSchemaConverter[];
51
- }
52
- declare class OpenAPIGenerator {
53
- #private;
54
- private readonly serializer;
55
- private readonly converter;
56
- constructor(options?: OpenAPIGeneratorOptions);
57
- generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
58
- }
59
-
60
40
  /**
61
41
  * @internal
62
42
  */
@@ -68,15 +48,15 @@ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
68
48
  /**
69
49
  * @internal
70
50
  */
71
- declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
72
52
  /**
73
53
  * @internal
74
54
  */
75
- declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
76
56
  /**
77
57
  * @internal
78
58
  */
79
- declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
80
60
  /**
81
61
  * @internal
82
62
  */
@@ -84,7 +64,10 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
84
64
  /**
85
65
  * @internal
86
66
  */
87
- declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
69
+
70
+ declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
88
71
 
89
72
  /**
90
73
  *@internal
@@ -107,10 +90,21 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
107
90
  */
108
91
  declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
109
92
  declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
93
+ /**
94
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
95
+ * recursively expands it into an array of its constituent, non-union base schemas.
96
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
97
+ */
98
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
99
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
100
+ type: 'array';
101
+ items?: JSONSchema;
102
+ }];
103
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
110
104
 
111
105
  declare const oo: {
112
106
  spec: typeof customOpenAPIOperation;
113
107
  };
114
108
 
115
- export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
116
- export type { ConditionalSchemaConverter, FileSchema, ObjectSchema, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter };
109
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
110
+ export type { FileSchema, ObjectSchema, OverrideOperationValue };