@orpc/openapi 0.0.0-next.f56d2b3 → 0.0.0-next.f635909

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.
Files changed (62) hide show
  1. package/README.md +100 -0
  2. package/dist/adapters/fetch/index.d.mts +17 -0
  3. package/dist/adapters/fetch/index.d.ts +17 -0
  4. package/dist/adapters/fetch/index.mjs +17 -0
  5. package/dist/adapters/node/index.d.mts +17 -0
  6. package/dist/adapters/node/index.d.ts +17 -0
  7. package/dist/adapters/node/index.mjs +17 -0
  8. package/dist/adapters/standard/index.d.mts +34 -0
  9. package/dist/adapters/standard/index.d.ts +34 -0
  10. package/dist/adapters/standard/index.mjs +8 -0
  11. package/dist/index.d.mts +96 -0
  12. package/dist/index.d.ts +96 -0
  13. package/dist/index.mjs +15 -0
  14. package/dist/plugins/index.d.mts +70 -0
  15. package/dist/plugins/index.d.ts +70 -0
  16. package/dist/plugins/index.mjs +97 -0
  17. package/dist/shared/openapi.D3j94c9n.d.mts +12 -0
  18. package/dist/shared/openapi.D3j94c9n.d.ts +12 -0
  19. package/dist/shared/openapi.DP97kr00.d.mts +47 -0
  20. package/dist/shared/openapi.DP97kr00.d.ts +47 -0
  21. package/dist/shared/openapi.fMEQd3Yd.mjs +544 -0
  22. package/dist/shared/openapi.p5tsmBXx.mjs +158 -0
  23. package/package.json +29 -38
  24. package/dist/chunk-Q2LSK6YZ.js +0 -102
  25. package/dist/chunk-SOVQ5ARD.js +0 -650
  26. package/dist/chunk-VFGNQS5W.js +0 -25
  27. package/dist/fetch.js +0 -34
  28. package/dist/hono.js +0 -34
  29. package/dist/index.js +0 -546
  30. package/dist/next.js +0 -34
  31. package/dist/node.js +0 -46
  32. package/dist/src/adapters/fetch/bracket-notation.d.ts +0 -84
  33. package/dist/src/adapters/fetch/index.d.ts +0 -10
  34. package/dist/src/adapters/fetch/input-structure-compact.d.ts +0 -6
  35. package/dist/src/adapters/fetch/input-structure-detailed.d.ts +0 -11
  36. package/dist/src/adapters/fetch/openapi-handler-server.d.ts +0 -7
  37. package/dist/src/adapters/fetch/openapi-handler-serverless.d.ts +0 -7
  38. package/dist/src/adapters/fetch/openapi-handler.d.ts +0 -32
  39. package/dist/src/adapters/fetch/openapi-payload-codec.d.ts +0 -15
  40. package/dist/src/adapters/fetch/openapi-procedure-matcher.d.ts +0 -19
  41. package/dist/src/adapters/fetch/schema-coercer.d.ts +0 -10
  42. package/dist/src/adapters/hono/index.d.ts +0 -2
  43. package/dist/src/adapters/next/index.d.ts +0 -2
  44. package/dist/src/adapters/node/index.d.ts +0 -5
  45. package/dist/src/adapters/node/openapi-handler-server.d.ts +0 -7
  46. package/dist/src/adapters/node/openapi-handler-serverless.d.ts +0 -7
  47. package/dist/src/adapters/node/openapi-handler.d.ts +0 -11
  48. package/dist/src/adapters/node/types.d.ts +0 -2
  49. package/dist/src/index.d.ts +0 -12
  50. package/dist/src/json-serializer.d.ts +0 -5
  51. package/dist/src/openapi-content-builder.d.ts +0 -10
  52. package/dist/src/openapi-error.d.ts +0 -3
  53. package/dist/src/openapi-generator.d.ts +0 -67
  54. package/dist/src/openapi-input-structure-parser.d.ts +0 -22
  55. package/dist/src/openapi-output-structure-parser.d.ts +0 -18
  56. package/dist/src/openapi-parameters-builder.d.ts +0 -12
  57. package/dist/src/openapi-path-parser.d.ts +0 -8
  58. package/dist/src/openapi.d.ts +0 -3
  59. package/dist/src/schema-converter.d.ts +0 -16
  60. package/dist/src/schema-utils.d.ts +0 -11
  61. package/dist/src/schema.d.ts +0 -12
  62. package/dist/src/utils.d.ts +0 -18
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ <div align="center">
2
+ <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
3
+ </div>
4
+
5
+ <h1></h1>
6
+
7
+ <div align="center">
8
+ <a href="https://codecov.io/gh/unnoq/orpc">
9
+ <img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@orpc/openapi">
12
+ <img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fopenapi?logo=npm" />
13
+ </a>
14
+ <a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
15
+ <img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
16
+ </a>
17
+ <a href="https://discord.gg/TXEbwRBvQn">
18
+ <img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
19
+ </a>
20
+ </div>
21
+
22
+ <h3 align="center">Typesafe APIs Made Simple 🪄</h3>
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
25
+
26
+ ---
27
+
28
+ ## Highlights
29
+
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.
42
+
43
+ ## Documentation
44
+
45
+ You can find the full documentation [here](https://orpc.unnoq.com).
46
+
47
+ ## Packages
48
+
49
+ - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
50
+ - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
51
+ - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
52
+ - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
53
+ - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
54
+ - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
55
+ - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
56
+ - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
57
+ - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
58
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
59
+ - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
60
+ - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
61
+ - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
62
+
63
+ ## `@orpc/openapi`
64
+
65
+ Generate OpenAPI specs and handle OpenAPI requests. Read the [documentation](https://orpc.unnoq.com/docs/openapi/getting-started) for more information.
66
+
67
+ ```ts
68
+ import { createServer } from 'node:http'
69
+ import { OpenAPIHandler } from '@orpc/openapi/node'
70
+ import { CORSPlugin } from '@orpc/server/plugins'
71
+
72
+ const handler = new OpenAPIHandler(router, {
73
+ plugins: [new CORSPlugin()]
74
+ })
75
+
76
+ const server = createServer(async (req, res) => {
77
+ const result = await handler.handle(req, res, {
78
+ context: { headers: req.headers }
79
+ })
80
+
81
+ if (!result.matched) {
82
+ res.statusCode = 404
83
+ res.end('No procedure matched')
84
+ }
85
+ })
86
+
87
+ server.listen(3000, '127.0.0.1', () => console.log('Listening on 127.0.0.1:3000'))
88
+ ```
89
+
90
+ ## Sponsors
91
+
92
+ <p align="center">
93
+ <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
94
+ <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
95
+ </a>
96
+ </p>
97
+
98
+ ## License
99
+
100
+ Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
@@ -0,0 +1,17 @@
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';
4
+ import '@orpc/openapi-client/standard';
5
+ import '@orpc/server/standard';
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
+ */
13
+ declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
14
+ constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
15
+ }
16
+
17
+ export { OpenAPIHandler };
@@ -0,0 +1,17 @@
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';
4
+ import '@orpc/openapi-client/standard';
5
+ import '@orpc/server/standard';
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
+ */
13
+ declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
14
+ constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
15
+ }
16
+
17
+ export { OpenAPIHandler };
@@ -0,0 +1,17 @@
1
+ import { FetchHandler } from '@orpc/server/fetch';
2
+ import '@orpc/contract';
3
+ import '@orpc/shared';
4
+ import { a as StandardOpenAPIHandler } from '../../shared/openapi.p5tsmBXx.mjs';
5
+ import '@orpc/client/standard';
6
+ import '@orpc/server';
7
+ import 'rou3';
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 };
@@ -0,0 +1,17 @@
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';
4
+ import '@orpc/openapi-client/standard';
5
+ import '@orpc/server/standard';
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
+ */
13
+ declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
14
+ constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
15
+ }
16
+
17
+ export { OpenAPIHandler };
@@ -0,0 +1,17 @@
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';
4
+ import '@orpc/openapi-client/standard';
5
+ import '@orpc/server/standard';
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
+ */
13
+ declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
14
+ constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
15
+ }
16
+
17
+ export { OpenAPIHandler };
@@ -0,0 +1,17 @@
1
+ import { NodeHttpHandler } from '@orpc/server/node';
2
+ import '@orpc/contract';
3
+ import '@orpc/shared';
4
+ import { a as StandardOpenAPIHandler } from '../../shared/openapi.p5tsmBXx.mjs';
5
+ import '@orpc/client/standard';
6
+ import '@orpc/server';
7
+ import 'rou3';
8
+ import '@orpc/openapi-client/standard';
9
+ import '@orpc/server/standard';
10
+
11
+ class OpenAPIHandler extends NodeHttpHandler {
12
+ constructor(router, options = {}) {
13
+ super(new StandardOpenAPIHandler(router, options), options);
14
+ }
15
+ }
16
+
17
+ export { OpenAPIHandler };
@@ -0,0 +1,34 @@
1
+ import { ORPCError, HTTPPath } from '@orpc/client';
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';
5
+ import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
6
+ export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
7
+
8
+ declare class StandardOpenAPICodec implements StandardCodec {
9
+ private readonly serializer;
10
+ constructor(serializer: StandardOpenAPISerializer);
11
+ decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
12
+ encode(output: unknown, procedure: AnyProcedure): StandardResponse;
13
+ encodeError(error: ORPCError<any, any>): StandardResponse;
14
+ }
15
+
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
+ /**
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 };
@@ -0,0 +1,34 @@
1
+ import { ORPCError, HTTPPath } from '@orpc/client';
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';
5
+ import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
6
+ export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
7
+
8
+ declare class StandardOpenAPICodec implements StandardCodec {
9
+ private readonly serializer;
10
+ constructor(serializer: StandardOpenAPISerializer);
11
+ decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
12
+ encode(output: unknown, procedure: AnyProcedure): StandardResponse;
13
+ encodeError(error: ORPCError<any, any>): StandardResponse;
14
+ }
15
+
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
+ /**
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 };
@@ -0,0 +1,8 @@
1
+ export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.p5tsmBXx.mjs';
2
+ import '@orpc/openapi-client/standard';
3
+ import '@orpc/server/standard';
4
+ import '@orpc/contract';
5
+ import '@orpc/shared';
6
+ import '@orpc/client/standard';
7
+ import '@orpc/server';
8
+ import 'rou3';
@@ -0,0 +1,96 @@
1
+ import { AnyContractProcedure } from '@orpc/contract';
2
+ import { OpenAPIV3_1 } from 'openapi-types';
3
+ export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
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
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
7
+ export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
8
+ import '@orpc/openapi-client/standard';
9
+ import '@orpc/server';
10
+ import '@orpc/shared';
11
+
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
+ */
18
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
21
+
22
+ /**
23
+ * @internal
24
+ */
25
+ type ObjectSchema = JSONSchema & {
26
+ type: 'object';
27
+ } & object;
28
+ /**
29
+ * @internal
30
+ */
31
+ type FileSchema = JSONSchema & {
32
+ type: 'string';
33
+ contentMediaType: string;
34
+ } & object;
35
+ /**
36
+ * @internal
37
+ */
38
+ declare const LOGIC_KEYWORDS: string[];
39
+
40
+ /**
41
+ * @internal
42
+ */
43
+ declare function toOpenAPIPath(path: HTTPPath): string;
44
+ /**
45
+ * @internal
46
+ */
47
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
48
+ /**
49
+ * @internal
50
+ */
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
52
+ /**
53
+ * @internal
54
+ */
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
56
+ /**
57
+ * @internal
58
+ */
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
60
+ /**
61
+ * @internal
62
+ */
63
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
64
+ /**
65
+ * @internal
66
+ */
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
68
+
69
+ /**
70
+ *@internal
71
+ */
72
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
73
+ /**
74
+ * @internal
75
+ */
76
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
77
+ /**
78
+ * @internal
79
+ */
80
+ declare function isAnySchema(schema: JSONSchema): boolean;
81
+ /**
82
+ * @internal
83
+ */
84
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
85
+ /**
86
+ * @internal
87
+ */
88
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
89
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
90
+
91
+ declare const oo: {
92
+ spec: typeof customOpenAPIOperation;
93
+ };
94
+
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 };
@@ -0,0 +1,96 @@
1
+ import { AnyContractProcedure } from '@orpc/contract';
2
+ import { OpenAPIV3_1 } from 'openapi-types';
3
+ export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
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
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
7
+ export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
8
+ import '@orpc/openapi-client/standard';
9
+ import '@orpc/server';
10
+ import '@orpc/shared';
11
+
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
+ */
18
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
21
+
22
+ /**
23
+ * @internal
24
+ */
25
+ type ObjectSchema = JSONSchema & {
26
+ type: 'object';
27
+ } & object;
28
+ /**
29
+ * @internal
30
+ */
31
+ type FileSchema = JSONSchema & {
32
+ type: 'string';
33
+ contentMediaType: string;
34
+ } & object;
35
+ /**
36
+ * @internal
37
+ */
38
+ declare const LOGIC_KEYWORDS: string[];
39
+
40
+ /**
41
+ * @internal
42
+ */
43
+ declare function toOpenAPIPath(path: HTTPPath): string;
44
+ /**
45
+ * @internal
46
+ */
47
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
48
+ /**
49
+ * @internal
50
+ */
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
52
+ /**
53
+ * @internal
54
+ */
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
56
+ /**
57
+ * @internal
58
+ */
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
60
+ /**
61
+ * @internal
62
+ */
63
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
64
+ /**
65
+ * @internal
66
+ */
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
68
+
69
+ /**
70
+ *@internal
71
+ */
72
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
73
+ /**
74
+ * @internal
75
+ */
76
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
77
+ /**
78
+ * @internal
79
+ */
80
+ declare function isAnySchema(schema: JSONSchema): boolean;
81
+ /**
82
+ * @internal
83
+ */
84
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
85
+ /**
86
+ * @internal
87
+ */
88
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
89
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
90
+
91
+ declare const oo: {
92
+ spec: typeof customOpenAPIOperation;
93
+ };
94
+
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.mjs ADDED
@@ -0,0 +1,15 @@
1
+ import { c as customOpenAPIOperation } from './shared/openapi.fMEQd3Yd.mjs';
2
+ export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, s as separateObjectSchema, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.fMEQd3Yd.mjs';
3
+ export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
4
+ import '@orpc/client';
5
+ import '@orpc/client/standard';
6
+ import '@orpc/contract';
7
+ import '@orpc/openapi-client/standard';
8
+ import '@orpc/server';
9
+ import '@orpc/shared';
10
+
11
+ const oo = {
12
+ spec: customOpenAPIOperation
13
+ };
14
+
15
+ export { customOpenAPIOperation, oo };
@@ -0,0 +1,70 @@
1
+ import { Context, HTTPPath, Router } from '@orpc/server';
2
+ import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
3
+ import { Value } from '@orpc/shared';
4
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DP97kr00.mjs';
5
+ import '@orpc/contract';
6
+ import '@orpc/openapi-client/standard';
7
+ import 'openapi-types';
8
+ import 'json-schema-typed/draft-2020-12';
9
+
10
+ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGeneratorOptions {
11
+ /**
12
+ * Options to pass to the OpenAPI generate.
13
+ *
14
+ */
15
+ specGenerateOptions?: Value<OpenAPIGeneratorGenerateOptions, [StandardHandlerInterceptorOptions<T>]>;
16
+ /**
17
+ * The URL path at which to serve the OpenAPI JSON.
18
+ *
19
+ * @default '/spec.json'
20
+ */
21
+ specPath?: HTTPPath;
22
+ /**
23
+ * The URL path at which to serve the API reference UI.
24
+ *
25
+ * @default '/'
26
+ */
27
+ docsPath?: HTTPPath;
28
+ /**
29
+ * The document title for the API reference UI.
30
+ *
31
+ * @default 'API Reference'
32
+ */
33
+ docsTitle?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
34
+ /**
35
+ * Arbitrary configuration object for the UI.
36
+ */
37
+ docsConfig?: Value<object, [StandardHandlerInterceptorOptions<T>]>;
38
+ /**
39
+ * HTML to inject into the <head> of the docs page.
40
+ *
41
+ * @default ''
42
+ */
43
+ docsHead?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
44
+ /**
45
+ * URL of the external script bundle for the reference UI.
46
+ *
47
+ * @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'
48
+ */
49
+ docsScriptUrl?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
50
+ /**
51
+ * Override function to generate the full HTML for the docs page.
52
+ */
53
+ renderDocsHtml?: (specUrl: string, title: string, head: string, scriptUrl: string, config: object | undefined) => string;
54
+ }
55
+ declare class OpenAPIReferencePlugin<T extends Context> implements StandardHandlerPlugin<T> {
56
+ private readonly generator;
57
+ private readonly specGenerateOptions;
58
+ private readonly specPath;
59
+ private readonly docsPath;
60
+ private readonly docsTitle;
61
+ private readonly docsHead;
62
+ private readonly docsScriptUrl;
63
+ private readonly docsConfig;
64
+ private readonly renderDocsHtml;
65
+ constructor(options?: OpenAPIReferencePluginOptions<T>);
66
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
67
+ }
68
+
69
+ export { OpenAPIReferencePlugin };
70
+ export type { OpenAPIReferencePluginOptions };
@@ -0,0 +1,70 @@
1
+ import { Context, HTTPPath, Router } from '@orpc/server';
2
+ import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
3
+ import { Value } from '@orpc/shared';
4
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DP97kr00.js';
5
+ import '@orpc/contract';
6
+ import '@orpc/openapi-client/standard';
7
+ import 'openapi-types';
8
+ import 'json-schema-typed/draft-2020-12';
9
+
10
+ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGeneratorOptions {
11
+ /**
12
+ * Options to pass to the OpenAPI generate.
13
+ *
14
+ */
15
+ specGenerateOptions?: Value<OpenAPIGeneratorGenerateOptions, [StandardHandlerInterceptorOptions<T>]>;
16
+ /**
17
+ * The URL path at which to serve the OpenAPI JSON.
18
+ *
19
+ * @default '/spec.json'
20
+ */
21
+ specPath?: HTTPPath;
22
+ /**
23
+ * The URL path at which to serve the API reference UI.
24
+ *
25
+ * @default '/'
26
+ */
27
+ docsPath?: HTTPPath;
28
+ /**
29
+ * The document title for the API reference UI.
30
+ *
31
+ * @default 'API Reference'
32
+ */
33
+ docsTitle?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
34
+ /**
35
+ * Arbitrary configuration object for the UI.
36
+ */
37
+ docsConfig?: Value<object, [StandardHandlerInterceptorOptions<T>]>;
38
+ /**
39
+ * HTML to inject into the <head> of the docs page.
40
+ *
41
+ * @default ''
42
+ */
43
+ docsHead?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
44
+ /**
45
+ * URL of the external script bundle for the reference UI.
46
+ *
47
+ * @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'
48
+ */
49
+ docsScriptUrl?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
50
+ /**
51
+ * Override function to generate the full HTML for the docs page.
52
+ */
53
+ renderDocsHtml?: (specUrl: string, title: string, head: string, scriptUrl: string, config: object | undefined) => string;
54
+ }
55
+ declare class OpenAPIReferencePlugin<T extends Context> implements StandardHandlerPlugin<T> {
56
+ private readonly generator;
57
+ private readonly specGenerateOptions;
58
+ private readonly specPath;
59
+ private readonly docsPath;
60
+ private readonly docsTitle;
61
+ private readonly docsHead;
62
+ private readonly docsScriptUrl;
63
+ private readonly docsConfig;
64
+ private readonly renderDocsHtml;
65
+ constructor(options?: OpenAPIReferencePluginOptions<T>);
66
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
67
+ }
68
+
69
+ export { OpenAPIReferencePlugin };
70
+ export type { OpenAPIReferencePluginOptions };