@orpc/openapi 0.0.0-next.f72e6b9 → 0.0.0-next.f779f69
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 +1 -0
- package/dist/adapters/aws-lambda/index.d.mts +17 -0
- package/dist/adapters/aws-lambda/index.d.ts +17 -0
- package/dist/adapters/aws-lambda/index.mjs +18 -0
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.d.ts +1 -1
- package/dist/adapters/fetch/index.mjs +2 -1
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +2 -1
- package/dist/adapters/standard/index.d.mts +1 -0
- package/dist/adapters/standard/index.d.ts +1 -0
- package/dist/adapters/standard/index.mjs +2 -1
- package/dist/index.d.mts +30 -52
- package/dist/index.d.ts +30 -52
- package/dist/index.mjs +31 -535
- package/dist/plugins/index.d.mts +69 -0
- package/dist/plugins/index.d.ts +69 -0
- package/dist/plugins/index.mjs +108 -0
- package/dist/shared/{openapi.p5tsmBXx.mjs → openapi.C_UtQ8Us.mjs} +27 -6
- package/dist/shared/openapi.DaYgbD_w.mjs +652 -0
- package/dist/shared/openapi.qZLdpE0a.d.mts +52 -0
- package/dist/shared/openapi.qZLdpE0a.d.ts +52 -0
- package/package.json +18 -9
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ 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
53
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
53
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).
|
|
54
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).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context, Router } from '@orpc/server';
|
|
2
|
+
import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
|
|
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 AWS Lambda.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
11
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
12
|
+
*/
|
|
13
|
+
declare class experimental_OpenAPIHandler<T extends Context> extends AwsLambdaHandler<T> {
|
|
14
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & AwsLambdaHandlerOptions>);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { experimental_OpenAPIHandler };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context, Router } from '@orpc/server';
|
|
2
|
+
import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
|
|
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 AWS Lambda.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
11
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
12
|
+
*/
|
|
13
|
+
declare class experimental_OpenAPIHandler<T extends Context> extends AwsLambdaHandler<T> {
|
|
14
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & AwsLambdaHandlerOptions>);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { experimental_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.C_UtQ8Us.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 experimental_OpenAPIHandler extends AwsLambdaHandler {
|
|
13
|
+
constructor(router, options = {}) {
|
|
14
|
+
super(new StandardOpenAPIHandler(router, options), options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { experimental_OpenAPIHandler };
|
|
@@ -8,7 +8,7 @@ import '@orpc/server/standard';
|
|
|
8
8
|
* OpenAPI Handler for Fetch Server
|
|
9
9
|
*
|
|
10
10
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
11
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
11
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
12
12
|
*/
|
|
13
13
|
declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
|
|
14
14
|
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
|
|
@@ -8,7 +8,7 @@ import '@orpc/server/standard';
|
|
|
8
8
|
* OpenAPI Handler for Fetch Server
|
|
9
9
|
*
|
|
10
10
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
11
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
11
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
12
12
|
*/
|
|
13
13
|
declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
|
|
14
14
|
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & FetchHandlerOptions<T>>);
|
|
@@ -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.
|
|
5
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.C_UtQ8Us.mjs';
|
|
5
6
|
import '@orpc/client/standard';
|
|
6
7
|
import '@orpc/server';
|
|
7
8
|
import 'rou3';
|
|
@@ -8,7 +8,7 @@ import '@orpc/server/standard';
|
|
|
8
8
|
* OpenAPI Handler for Node Server
|
|
9
9
|
*
|
|
10
10
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
11
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
11
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
12
12
|
*/
|
|
13
13
|
declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
14
14
|
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
|
@@ -8,7 +8,7 @@ import '@orpc/server/standard';
|
|
|
8
8
|
* OpenAPI Handler for Node Server
|
|
9
9
|
*
|
|
10
10
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
|
|
11
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
11
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
12
12
|
*/
|
|
13
13
|
declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
14
14
|
constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
|
@@ -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.
|
|
5
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.C_UtQ8Us.mjs';
|
|
5
6
|
import '@orpc/client/standard';
|
|
6
7
|
import '@orpc/server';
|
|
7
8
|
import 'rou3';
|
|
@@ -6,6 +6,7 @@ import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
|
6
6
|
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
|
|
7
7
|
|
|
8
8
|
declare class StandardOpenAPICodec implements StandardCodec {
|
|
9
|
+
#private;
|
|
9
10
|
private readonly serializer;
|
|
10
11
|
constructor(serializer: StandardOpenAPISerializer);
|
|
11
12
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
@@ -6,6 +6,7 @@ import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
|
6
6
|
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
|
|
7
7
|
|
|
8
8
|
declare class StandardOpenAPICodec implements StandardCodec {
|
|
9
|
+
#private;
|
|
9
10
|
private readonly serializer;
|
|
10
11
|
constructor(serializer: StandardOpenAPISerializer);
|
|
11
12
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.
|
|
1
|
+
export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.C_UtQ8Us.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,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
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 { d as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, S as SchemaConvertOptions, c as SchemaConverter } from './shared/openapi.qZLdpE0a.mjs';
|
|
9
4
|
import { HTTPPath, HTTPMethod } from '@orpc/client';
|
|
5
|
+
import { JSONSchema } 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';
|
|
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<
|
|
12
|
+
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
|
|
12
13
|
/**
|
|
13
14
|
* Customize The Operation Object by proxy an error map item or a middleware.
|
|
14
15
|
*
|
|
@@ -16,7 +17,7 @@ type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current:
|
|
|
16
17
|
*/
|
|
17
18
|
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
18
19
|
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
19
|
-
declare function applyCustomOpenAPIOperation(operation:
|
|
20
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @internal
|
|
@@ -36,42 +37,6 @@ type FileSchema = JSONSchema & {
|
|
|
36
37
|
*/
|
|
37
38
|
declare const LOGIC_KEYWORDS: string[];
|
|
38
39
|
|
|
39
|
-
interface SchemaConvertOptions {
|
|
40
|
-
strategy: 'input' | 'output';
|
|
41
|
-
}
|
|
42
|
-
interface SchemaConverter {
|
|
43
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
|
|
44
|
-
}
|
|
45
|
-
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
46
|
-
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
|
|
47
|
-
}
|
|
48
|
-
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
49
|
-
private readonly converters;
|
|
50
|
-
constructor(converters: ConditionalSchemaConverter[]);
|
|
51
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
|
|
55
|
-
schemaConverters?: ConditionalSchemaConverter[];
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
59
|
-
*
|
|
60
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
61
|
-
*/
|
|
62
|
-
declare class OpenAPIGenerator {
|
|
63
|
-
#private;
|
|
64
|
-
private readonly serializer;
|
|
65
|
-
private readonly converter;
|
|
66
|
-
constructor(options?: OpenAPIGeneratorOptions);
|
|
67
|
-
/**
|
|
68
|
-
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
69
|
-
*
|
|
70
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
71
|
-
*/
|
|
72
|
-
generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
40
|
/**
|
|
76
41
|
* @internal
|
|
77
42
|
*/
|
|
@@ -83,15 +48,15 @@ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
|
|
83
48
|
/**
|
|
84
49
|
* @internal
|
|
85
50
|
*/
|
|
86
|
-
declare function toOpenAPIContent(schema: JSONSchema): Record<string,
|
|
51
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
|
|
87
52
|
/**
|
|
88
53
|
* @internal
|
|
89
54
|
*/
|
|
90
|
-
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string,
|
|
55
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
|
|
91
56
|
/**
|
|
92
57
|
* @internal
|
|
93
58
|
*/
|
|
94
|
-
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'):
|
|
59
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
|
|
95
60
|
/**
|
|
96
61
|
* @internal
|
|
97
62
|
*/
|
|
@@ -99,7 +64,9 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
|
|
|
99
64
|
/**
|
|
100
65
|
* @internal
|
|
101
66
|
*/
|
|
102
|
-
declare function toOpenAPISchema(schema: JSONSchema):
|
|
67
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
|
|
68
|
+
|
|
69
|
+
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>>;
|
|
103
70
|
|
|
104
71
|
/**
|
|
105
72
|
*@internal
|
|
@@ -122,10 +89,21 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
|
|
|
122
89
|
*/
|
|
123
90
|
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
124
91
|
declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
|
|
92
|
+
/**
|
|
93
|
+
* Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
|
|
94
|
+
* recursively expands it into an array of its constituent, non-union base schemas.
|
|
95
|
+
* If the schema is not a simple union or is a base type, it's returned as a single-element array.
|
|
96
|
+
*/
|
|
97
|
+
declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
|
|
98
|
+
declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
|
|
99
|
+
type: 'array';
|
|
100
|
+
items?: JSONSchema;
|
|
101
|
+
}];
|
|
102
|
+
declare function isPrimitiveSchema(schema: JSONSchema): boolean;
|
|
125
103
|
|
|
126
104
|
declare const oo: {
|
|
127
105
|
spec: typeof customOpenAPIOperation;
|
|
128
106
|
};
|
|
129
107
|
|
|
130
|
-
export {
|
|
131
|
-
export type {
|
|
108
|
+
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
109
|
+
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
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 { d as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, S as SchemaConvertOptions, c as SchemaConverter } from './shared/openapi.qZLdpE0a.js';
|
|
9
4
|
import { HTTPPath, HTTPMethod } from '@orpc/client';
|
|
5
|
+
import { JSONSchema } 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';
|
|
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<
|
|
12
|
+
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
|
|
12
13
|
/**
|
|
13
14
|
* Customize The Operation Object by proxy an error map item or a middleware.
|
|
14
15
|
*
|
|
@@ -16,7 +17,7 @@ type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current:
|
|
|
16
17
|
*/
|
|
17
18
|
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
18
19
|
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
19
|
-
declare function applyCustomOpenAPIOperation(operation:
|
|
20
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @internal
|
|
@@ -36,42 +37,6 @@ type FileSchema = JSONSchema & {
|
|
|
36
37
|
*/
|
|
37
38
|
declare const LOGIC_KEYWORDS: string[];
|
|
38
39
|
|
|
39
|
-
interface SchemaConvertOptions {
|
|
40
|
-
strategy: 'input' | 'output';
|
|
41
|
-
}
|
|
42
|
-
interface SchemaConverter {
|
|
43
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
|
|
44
|
-
}
|
|
45
|
-
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
46
|
-
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
|
|
47
|
-
}
|
|
48
|
-
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
49
|
-
private readonly converters;
|
|
50
|
-
constructor(converters: ConditionalSchemaConverter[]);
|
|
51
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
|
|
55
|
-
schemaConverters?: ConditionalSchemaConverter[];
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
59
|
-
*
|
|
60
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
61
|
-
*/
|
|
62
|
-
declare class OpenAPIGenerator {
|
|
63
|
-
#private;
|
|
64
|
-
private readonly serializer;
|
|
65
|
-
private readonly converter;
|
|
66
|
-
constructor(options?: OpenAPIGeneratorOptions);
|
|
67
|
-
/**
|
|
68
|
-
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
69
|
-
*
|
|
70
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
71
|
-
*/
|
|
72
|
-
generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
40
|
/**
|
|
76
41
|
* @internal
|
|
77
42
|
*/
|
|
@@ -83,15 +48,15 @@ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
|
|
83
48
|
/**
|
|
84
49
|
* @internal
|
|
85
50
|
*/
|
|
86
|
-
declare function toOpenAPIContent(schema: JSONSchema): Record<string,
|
|
51
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
|
|
87
52
|
/**
|
|
88
53
|
* @internal
|
|
89
54
|
*/
|
|
90
|
-
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string,
|
|
55
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
|
|
91
56
|
/**
|
|
92
57
|
* @internal
|
|
93
58
|
*/
|
|
94
|
-
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'):
|
|
59
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
|
|
95
60
|
/**
|
|
96
61
|
* @internal
|
|
97
62
|
*/
|
|
@@ -99,7 +64,9 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
|
|
|
99
64
|
/**
|
|
100
65
|
* @internal
|
|
101
66
|
*/
|
|
102
|
-
declare function toOpenAPISchema(schema: JSONSchema):
|
|
67
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
|
|
68
|
+
|
|
69
|
+
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>>;
|
|
103
70
|
|
|
104
71
|
/**
|
|
105
72
|
*@internal
|
|
@@ -122,10 +89,21 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
|
|
|
122
89
|
*/
|
|
123
90
|
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
124
91
|
declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
|
|
92
|
+
/**
|
|
93
|
+
* Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
|
|
94
|
+
* recursively expands it into an array of its constituent, non-union base schemas.
|
|
95
|
+
* If the schema is not a simple union or is a base type, it's returned as a single-element array.
|
|
96
|
+
*/
|
|
97
|
+
declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
|
|
98
|
+
declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
|
|
99
|
+
type: 'array';
|
|
100
|
+
items?: JSONSchema;
|
|
101
|
+
}];
|
|
102
|
+
declare function isPrimitiveSchema(schema: JSONSchema): boolean;
|
|
125
103
|
|
|
126
104
|
declare const oo: {
|
|
127
105
|
spec: typeof customOpenAPIOperation;
|
|
128
106
|
};
|
|
129
107
|
|
|
130
|
-
export {
|
|
131
|
-
export type {
|
|
108
|
+
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
109
|
+
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|