@orpc/openapi 1.0.0-beta.7 → 1.1.0

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
@@ -21,28 +21,24 @@
21
21
 
22
22
  <h3 align="center">Typesafe APIs Made Simple 🪄</h3>
23
23
 
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.
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
25
25
 
26
26
  ---
27
27
 
28
28
  ## Highlights
29
29
 
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.
30
+ - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
31
+ - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
32
+ - **📝 Contract-First Development**: Optionally define your API contract before implementation.
33
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
34
+ - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
35
+ - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
36
+ - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
37
+ - **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
38
+ - **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
39
+ - **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
40
+ - **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
41
+ - **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
46
42
 
47
43
  ## Documentation
48
44
 
@@ -4,6 +4,12 @@ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
6
 
7
+ /**
8
+ * OpenAPI Handler for Fetch Server
9
+ *
10
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
11
+ * @see {@link https://orpc.unnoq.com/docs/integrations/fetch-server Fetch Server Integration Docs}
12
+ */
7
13
  declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
8
14
  constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
9
15
  }
@@ -4,6 +4,12 @@ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
6
 
7
+ /**
8
+ * OpenAPI Handler for Fetch Server
9
+ *
10
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
11
+ * @see {@link https://orpc.unnoq.com/docs/integrations/fetch-server Fetch Server Integration Docs}
12
+ */
7
13
  declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
8
14
  constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
9
15
  }
@@ -4,6 +4,12 @@ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
6
 
7
+ /**
8
+ * OpenAPI Handler for Node Server
9
+ *
10
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
11
+ * @see {@link https://orpc.unnoq.com/docs/integrations/node Node Integration Docs}
12
+ */
7
13
  declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
8
14
  constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
9
15
  }
@@ -4,6 +4,12 @@ import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9
4
4
  import '@orpc/openapi-client/standard';
5
5
  import '@orpc/server/standard';
6
6
 
7
+ /**
8
+ * OpenAPI Handler for Node Server
9
+ *
10
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
11
+ * @see {@link https://orpc.unnoq.com/docs/integrations/node Node Integration Docs}
12
+ */
7
13
  declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
8
14
  constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
9
15
  }
package/dist/index.d.mts CHANGED
@@ -1,13 +1,20 @@
1
- import { AnyContractProcedure, AnySchema, AnyContractRouter } from '@orpc/contract';
1
+ import { AnyContractProcedure } from '@orpc/contract';
2
2
  import { OpenAPIV3_1 } from 'openapi-types';
3
3
  export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
4
- import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
5
- import { AnyRouter } from '@orpc/server';
4
+ export { d as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, S as SchemaConvertOptions, c as SchemaConverter } from './shared/openapi.DP97kr00.mjs';
5
+ import { HTTPPath, HTTPMethod } from '@orpc/client';
6
6
  import { JSONSchema } from 'json-schema-typed/draft-2020-12';
7
7
  export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
8
- import { HTTPPath, HTTPMethod } from '@orpc/client';
8
+ import '@orpc/openapi-client/standard';
9
+ import '@orpc/server';
10
+ import '@orpc/shared';
9
11
 
10
12
  type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.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
+ */
11
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
12
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
13
20
  declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
@@ -30,32 +37,6 @@ type FileSchema = JSONSchema & {
30
37
  */
31
38
  declare const LOGIC_KEYWORDS: string[];
32
39
 
33
- interface SchemaConvertOptions {
34
- strategy: 'input' | 'output';
35
- }
36
- interface SchemaConverter {
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;
41
- }
42
- declare class CompositeSchemaConverter implements SchemaConverter {
43
- private readonly converters;
44
- constructor(converters: ConditionalSchemaConverter[]);
45
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
46
- }
47
-
48
- interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
49
- schemaConverters?: ConditionalSchemaConverter[];
50
- }
51
- declare class OpenAPIGenerator {
52
- #private;
53
- private readonly serializer;
54
- private readonly converter;
55
- constructor(options?: OpenAPIGeneratorOptions);
56
- generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
57
- }
58
-
59
40
  /**
60
41
  * @internal
61
42
  */
@@ -111,5 +92,5 @@ declare const oo: {
111
92
  spec: typeof customOpenAPIOperation;
112
93
  };
113
94
 
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 };
95
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
96
+ export type { FileSchema, ObjectSchema, OverrideOperationValue };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,20 @@
1
- import { AnyContractProcedure, AnySchema, AnyContractRouter } from '@orpc/contract';
1
+ import { AnyContractProcedure } from '@orpc/contract';
2
2
  import { OpenAPIV3_1 } from 'openapi-types';
3
3
  export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
4
- import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
5
- import { AnyRouter } from '@orpc/server';
4
+ export { d as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, S as SchemaConvertOptions, c as SchemaConverter } from './shared/openapi.DP97kr00.js';
5
+ import { HTTPPath, HTTPMethod } from '@orpc/client';
6
6
  import { JSONSchema } from 'json-schema-typed/draft-2020-12';
7
7
  export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
8
- import { HTTPPath, HTTPMethod } from '@orpc/client';
8
+ import '@orpc/openapi-client/standard';
9
+ import '@orpc/server';
10
+ import '@orpc/shared';
9
11
 
10
12
  type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.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
+ */
11
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
12
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
13
20
  declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
@@ -30,32 +37,6 @@ type FileSchema = JSONSchema & {
30
37
  */
31
38
  declare const LOGIC_KEYWORDS: string[];
32
39
 
33
- interface SchemaConvertOptions {
34
- strategy: 'input' | 'output';
35
- }
36
- interface SchemaConverter {
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;
41
- }
42
- declare class CompositeSchemaConverter implements SchemaConverter {
43
- private readonly converters;
44
- constructor(converters: ConditionalSchemaConverter[]);
45
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
46
- }
47
-
48
- interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
49
- schemaConverters?: ConditionalSchemaConverter[];
50
- }
51
- declare class OpenAPIGenerator {
52
- #private;
53
- private readonly serializer;
54
- private readonly converter;
55
- constructor(options?: OpenAPIGeneratorOptions);
56
- generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
57
- }
58
-
59
40
  /**
60
41
  * @internal
61
42
  */
@@ -111,5 +92,5 @@ declare const oo: {
111
92
  spec: typeof customOpenAPIOperation;
112
93
  };
113
94
 
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 };
95
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
96
+ export type { FileSchema, ObjectSchema, OverrideOperationValue };