@orpc/openapi 0.0.0-next.fd13879 → 0.0.0-next.fd1ee2a

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
@@ -30,7 +30,7 @@
30
30
  - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
31
31
  - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
32
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.
33
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
34
34
  - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
35
35
  - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
36
36
  - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
@@ -49,14 +49,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
49
49
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
50
50
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
51
51
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
52
- - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
52
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
53
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
53
54
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
54
- - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
55
- - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
56
- - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
57
- - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
55
+ - [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
58
56
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
- - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
57
+ - [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
60
58
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
61
59
  - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
62
60
  - [@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.BkBlt1Qf.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,8 +1,10 @@
1
1
  import { Context, Router } from '@orpc/server';
2
2
  import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
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
 
7
9
  /**
8
10
  * OpenAPI Handler for Fetch Server
@@ -1,8 +1,10 @@
1
1
  import { Context, Router } from '@orpc/server';
2
2
  import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
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
 
7
9
  /**
8
10
  * OpenAPI Handler for Fetch Server
@@ -2,7 +2,7 @@ import { FetchHandler } from '@orpc/server/fetch';
2
2
  import '@orpc/client';
3
3
  import '@orpc/contract';
4
4
  import '@orpc/shared';
5
- import { a as StandardOpenAPIHandler } from '../../shared/openapi.C_UtQ8Us.mjs';
5
+ import { a as StandardOpenAPIHandler } from '../../shared/openapi.BkBlt1Qf.mjs';
6
6
  import '@orpc/client/standard';
7
7
  import '@orpc/server';
8
8
  import 'rou3';
@@ -1,8 +1,10 @@
1
1
  import { Context, Router } from '@orpc/server';
2
2
  import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
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
 
7
9
  /**
8
10
  * OpenAPI Handler for Node Server
@@ -1,8 +1,10 @@
1
1
  import { Context, Router } from '@orpc/server';
2
2
  import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
3
- import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
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
 
7
9
  /**
8
10
  * OpenAPI Handler for Node Server
@@ -2,7 +2,7 @@ import { NodeHttpHandler } from '@orpc/server/node';
2
2
  import '@orpc/client';
3
3
  import '@orpc/contract';
4
4
  import '@orpc/shared';
5
- import { a as StandardOpenAPIHandler } from '../../shared/openapi.C_UtQ8Us.mjs';
5
+ import { a as StandardOpenAPIHandler } from '../../shared/openapi.BkBlt1Qf.mjs';
6
6
  import '@orpc/client/standard';
7
7
  import '@orpc/server';
8
8
  import 'rou3';
@@ -1,9 +1,10 @@
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 {
9
10
  #private;
@@ -14,13 +15,6 @@ declare class StandardOpenAPICodec implements StandardCodec {
14
15
  encodeError(error: ORPCError<any, any>): StandardResponse;
15
16
  }
16
17
 
17
- declare class StandardOpenAPIMatcher implements StandardMatcher {
18
- private readonly tree;
19
- private pendingRouters;
20
- init(router: AnyRouter, path?: readonly string[]): void;
21
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
22
- }
23
-
24
18
  /**
25
19
  * {@link https://github.com/unjs/rou3}
26
20
  *
@@ -32,4 +26,4 @@ declare function toRou3Pattern(path: HTTPPath): string;
32
26
  */
33
27
  declare function decodeParams(params: Record<string, string>): Record<string, string>;
34
28
 
35
- export { StandardOpenAPICodec, StandardOpenAPIMatcher, decodeParams, toRou3Pattern };
29
+ export { StandardOpenAPICodec, decodeParams, toRou3Pattern };
@@ -1,9 +1,10 @@
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 {
9
10
  #private;
@@ -14,13 +15,6 @@ declare class StandardOpenAPICodec implements StandardCodec {
14
15
  encodeError(error: ORPCError<any, any>): StandardResponse;
15
16
  }
16
17
 
17
- declare class StandardOpenAPIMatcher implements StandardMatcher {
18
- private readonly tree;
19
- private pendingRouters;
20
- init(router: AnyRouter, path?: readonly string[]): void;
21
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
22
- }
23
-
24
18
  /**
25
19
  * {@link https://github.com/unjs/rou3}
26
20
  *
@@ -32,4 +26,4 @@ declare function toRou3Pattern(path: HTTPPath): string;
32
26
  */
33
27
  declare function decodeParams(params: Record<string, string>): Record<string, string>;
34
28
 
35
- export { StandardOpenAPICodec, StandardOpenAPIMatcher, decodeParams, toRou3Pattern };
29
+ export { StandardOpenAPICodec, decodeParams, toRou3Pattern };
@@ -1,4 +1,4 @@
1
- export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.C_UtQ8Us.mjs';
1
+ export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.BkBlt1Qf.mjs';
2
2
  import '@orpc/openapi-client/standard';
3
3
  import '@orpc/server/standard';
4
4
  import '@orpc/client';
package/dist/index.d.mts CHANGED
@@ -1,16 +1,15 @@
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.CwdCLgSU.mjs';
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.DPAN3GVs.mjs';
5
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
6
5
  import { JSONSchema } from 'json-schema-typed/draft-2020-12';
7
- export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
8
7
  import { JsonifiedClient } from '@orpc/openapi-client';
9
8
  import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
10
9
  import { MaybeOptionalOptions } from '@orpc/shared';
11
10
  import '@orpc/openapi-client/standard';
12
11
 
13
- 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);
14
13
  /**
15
14
  * Customize The Operation Object by proxy an error map item or a middleware.
16
15
  *
@@ -18,7 +17,7 @@ type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current:
18
17
  */
19
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
20
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
21
- declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
22
21
 
23
22
  /**
24
23
  * @internal
@@ -49,15 +48,15 @@ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
49
48
  /**
50
49
  * @internal
51
50
  */
52
- declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
53
52
  /**
54
53
  * @internal
55
54
  */
56
- 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>;
57
56
  /**
58
57
  * @internal
59
58
  */
60
- 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[];
61
60
  /**
62
61
  * @internal
63
62
  */
@@ -65,7 +64,8 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
65
64
  /**
66
65
  * @internal
67
66
  */
68
- 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
69
 
70
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>>;
71
71
 
@@ -96,10 +96,15 @@ declare function applySchemaOptionality(required: boolean, schema: JSONSchema):
96
96
  * If the schema is not a simple union or is a base type, it's returned as a single-element array.
97
97
  */
98
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;
99
104
 
100
105
  declare const oo: {
101
106
  spec: typeof customOpenAPIOperation;
102
107
  };
103
108
 
104
- export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
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 };
105
110
  export type { FileSchema, ObjectSchema, OverrideOperationValue };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,15 @@
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.CwdCLgSU.js';
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.DPAN3GVs.js';
5
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
6
5
  import { JSONSchema } from 'json-schema-typed/draft-2020-12';
7
- export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
8
7
  import { JsonifiedClient } from '@orpc/openapi-client';
9
8
  import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
10
9
  import { MaybeOptionalOptions } from '@orpc/shared';
11
10
  import '@orpc/openapi-client/standard';
12
11
 
13
- 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);
14
13
  /**
15
14
  * Customize The Operation Object by proxy an error map item or a middleware.
16
15
  *
@@ -18,7 +17,7 @@ type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current:
18
17
  */
19
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
20
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
21
- declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
22
21
 
23
22
  /**
24
23
  * @internal
@@ -49,15 +48,15 @@ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
49
48
  /**
50
49
  * @internal
51
50
  */
52
- declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
53
52
  /**
54
53
  * @internal
55
54
  */
56
- 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>;
57
56
  /**
58
57
  * @internal
59
58
  */
60
- 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[];
61
60
  /**
62
61
  * @internal
63
62
  */
@@ -65,7 +64,8 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
65
64
  /**
66
65
  * @internal
67
66
  */
68
- 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
69
 
70
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>>;
71
71
 
@@ -96,10 +96,15 @@ declare function applySchemaOptionality(required: boolean, schema: JSONSchema):
96
96
  * If the schema is not a simple union or is a base type, it's returned as a single-element array.
97
97
  */
98
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;
99
104
 
100
105
  declare const oo: {
101
106
  spec: typeof customOpenAPIOperation;
102
107
  };
103
108
 
104
- export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
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 };
105
110
  export type { FileSchema, ObjectSchema, OverrideOperationValue };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { c as customOpenAPIOperation } from './shared/openapi.PDTdnRIU.mjs';
2
- export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, o as expandUnionSchema, 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.PDTdnRIU.mjs';
1
+ import { c as customOpenAPIOperation } from './shared/openapi.BtoY8ZFF.mjs';
2
+ export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, p as expandArrayableSchema, o as expandUnionSchema, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, q as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, s as separateObjectSchema, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.BtoY8ZFF.mjs';
3
3
  import { createORPCErrorFromJson } from '@orpc/client';
4
4
  import { StandardOpenAPISerializer, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer } from '@orpc/openapi-client/standard';
5
5
  import { ORPCError, createRouterClient } from '@orpc/server';
6
6
  import { resolveMaybeOptionalOptions } from '@orpc/shared';
7
- export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
7
+ export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
8
8
  import '@orpc/client/standard';
9
9
  import '@orpc/contract';
10
10
 
@@ -1,9 +1,8 @@
1
+ import { OpenAPI } from '@orpc/contract';
1
2
  import { Context, HTTPPath, Router } from '@orpc/server';
2
3
  import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
3
- import { Value } from '@orpc/shared';
4
- import { OpenAPIV3_1 } from 'openapi-types';
5
- import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.CwdCLgSU.mjs';
6
- import '@orpc/contract';
4
+ import { Value, Promisable } from '@orpc/shared';
5
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DPAN3GVs.mjs';
7
6
  import '@orpc/openapi-client/standard';
8
7
  import 'json-schema-typed/draft-2020-12';
9
8
 
@@ -12,7 +11,7 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
12
11
  * Options to pass to the OpenAPI generate.
13
12
  *
14
13
  */
15
- specGenerateOptions?: Value<OpenAPIGeneratorGenerateOptions, [StandardHandlerInterceptorOptions<T>]>;
14
+ specGenerateOptions?: Value<Promisable<OpenAPIGeneratorGenerateOptions>, [StandardHandlerInterceptorOptions<T>]>;
16
15
  /**
17
16
  * The URL path at which to serve the OpenAPI JSON.
18
17
  *
@@ -30,27 +29,27 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
30
29
  *
31
30
  * @default 'API Reference'
32
31
  */
33
- docsTitle?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
32
+ docsTitle?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
34
33
  /**
35
34
  * Arbitrary configuration object for the UI.
36
35
  */
37
- docsConfig?: Value<Record<string, unknown>, [StandardHandlerInterceptorOptions<T>]>;
36
+ docsConfig?: Value<Promisable<Record<string, unknown>>, [StandardHandlerInterceptorOptions<T>]>;
38
37
  /**
39
38
  * HTML to inject into the <head> of the docs page.
40
39
  *
41
40
  * @default ''
42
41
  */
43
- docsHead?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
42
+ docsHead?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
44
43
  /**
45
44
  * URL of the external script bundle for the reference UI.
46
45
  *
47
46
  * @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'
48
47
  */
49
- docsScriptUrl?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
48
+ docsScriptUrl?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
50
49
  /**
51
50
  * Override function to generate the full HTML for the docs page.
52
51
  */
53
- renderDocsHtml?: (specUrl: string, title: string, head: string, scriptUrl: string, config: Record<string, unknown> | undefined, spec: OpenAPIV3_1.Document) => string;
52
+ renderDocsHtml?: (specUrl: string, title: string, head: string, scriptUrl: string, config: Record<string, unknown> | undefined, spec: OpenAPI.Document) => string;
54
53
  }
55
54
  declare class OpenAPIReferencePlugin<T extends Context> implements StandardHandlerPlugin<T> {
56
55
  private readonly generator;
@@ -1,9 +1,8 @@
1
+ import { OpenAPI } from '@orpc/contract';
1
2
  import { Context, HTTPPath, Router } from '@orpc/server';
2
3
  import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
3
- import { Value } from '@orpc/shared';
4
- import { OpenAPIV3_1 } from 'openapi-types';
5
- import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.CwdCLgSU.js';
6
- import '@orpc/contract';
4
+ import { Value, Promisable } from '@orpc/shared';
5
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DPAN3GVs.js';
7
6
  import '@orpc/openapi-client/standard';
8
7
  import 'json-schema-typed/draft-2020-12';
9
8
 
@@ -12,7 +11,7 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
12
11
  * Options to pass to the OpenAPI generate.
13
12
  *
14
13
  */
15
- specGenerateOptions?: Value<OpenAPIGeneratorGenerateOptions, [StandardHandlerInterceptorOptions<T>]>;
14
+ specGenerateOptions?: Value<Promisable<OpenAPIGeneratorGenerateOptions>, [StandardHandlerInterceptorOptions<T>]>;
16
15
  /**
17
16
  * The URL path at which to serve the OpenAPI JSON.
18
17
  *
@@ -30,27 +29,27 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
30
29
  *
31
30
  * @default 'API Reference'
32
31
  */
33
- docsTitle?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
32
+ docsTitle?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
34
33
  /**
35
34
  * Arbitrary configuration object for the UI.
36
35
  */
37
- docsConfig?: Value<Record<string, unknown>, [StandardHandlerInterceptorOptions<T>]>;
36
+ docsConfig?: Value<Promisable<Record<string, unknown>>, [StandardHandlerInterceptorOptions<T>]>;
38
37
  /**
39
38
  * HTML to inject into the <head> of the docs page.
40
39
  *
41
40
  * @default ''
42
41
  */
43
- docsHead?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
42
+ docsHead?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
44
43
  /**
45
44
  * URL of the external script bundle for the reference UI.
46
45
  *
47
46
  * @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'
48
47
  */
49
- docsScriptUrl?: Value<string, [StandardHandlerInterceptorOptions<T>]>;
48
+ docsScriptUrl?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
50
49
  /**
51
50
  * Override function to generate the full HTML for the docs page.
52
51
  */
53
- renderDocsHtml?: (specUrl: string, title: string, head: string, scriptUrl: string, config: Record<string, unknown> | undefined, spec: OpenAPIV3_1.Document) => string;
52
+ renderDocsHtml?: (specUrl: string, title: string, head: string, scriptUrl: string, config: Record<string, unknown> | undefined, spec: OpenAPI.Document) => string;
54
53
  }
55
54
  declare class OpenAPIReferencePlugin<T extends Context> implements StandardHandlerPlugin<T> {
56
55
  private readonly generator;
@@ -1,5 +1,5 @@
1
1
  import { stringifyJSON, once, value } from '@orpc/shared';
2
- import { O as OpenAPIGenerator } from '../shared/openapi.PDTdnRIU.mjs';
2
+ import { O as OpenAPIGenerator } from '../shared/openapi.BtoY8ZFF.mjs';
3
3
  import '@orpc/client';
4
4
  import '@orpc/client/standard';
5
5
  import '@orpc/contract';
@@ -2,7 +2,7 @@ import { standardizeHTTPPath, StandardOpenAPIJsonSerializer, StandardBracketNota
2
2
  import { StandardHandler } from '@orpc/server/standard';
3
3
  import { isORPCErrorStatus } from '@orpc/client';
4
4
  import { fallbackContractConfig } from '@orpc/contract';
5
- import { isObject, stringifyJSON } from '@orpc/shared';
5
+ import { isObject, stringifyJSON, value } from '@orpc/shared';
6
6
  import { toHttpPath } from '@orpc/client/standard';
7
7
  import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@orpc/server';
8
8
  import { createRouter, addRoute, findRoute } from 'rou3';
@@ -101,10 +101,18 @@ function decodeParams(params) {
101
101
  }
102
102
 
103
103
  class StandardOpenAPIMatcher {
104
+ filter;
104
105
  tree = createRouter();
105
106
  pendingRouters = [];
107
+ constructor(options = {}) {
108
+ this.filter = options.filter ?? true;
109
+ }
106
110
  init(router, path = []) {
107
- const laziedOptions = traverseContractProcedures({ router, path }, ({ path: path2, contract }) => {
111
+ const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
112
+ if (!value(this.filter, traverseOptions)) {
113
+ return;
114
+ }
115
+ const { path: path2, contract } = traverseOptions;
108
116
  const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
109
117
  const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
110
118
  if (isProcedure(contract)) {
@@ -168,9 +176,9 @@ class StandardOpenAPIMatcher {
168
176
  class StandardOpenAPIHandler extends StandardHandler {
169
177
  constructor(router, options) {
170
178
  const jsonSerializer = new StandardOpenAPIJsonSerializer(options);
171
- const bracketNotationSerializer = new StandardBracketNotationSerializer();
179
+ const bracketNotationSerializer = new StandardBracketNotationSerializer(options);
172
180
  const serializer = new StandardOpenAPISerializer(jsonSerializer, bracketNotationSerializer);
173
- const matcher = new StandardOpenAPIMatcher();
181
+ const matcher = new StandardOpenAPIMatcher(options);
174
182
  const codec = new StandardOpenAPICodec(serializer);
175
183
  super(router, matcher, codec, options);
176
184
  }