@orpc/openapi 0.0.0-next.f710cd7 → 0.0.0-next.f724c58
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 +14 -10
- package/dist/adapters/aws-lambda/index.d.mts +20 -0
- package/dist/adapters/aws-lambda/index.d.ts +20 -0
- package/dist/adapters/aws-lambda/index.mjs +18 -0
- package/dist/adapters/fastify/index.d.mts +23 -0
- package/dist/adapters/fastify/index.d.ts +23 -0
- package/dist/adapters/fastify/index.mjs +18 -0
- package/dist/adapters/fetch/index.d.mts +11 -5
- package/dist/adapters/fetch/index.d.ts +11 -5
- package/dist/adapters/fetch/index.mjs +2 -1
- package/dist/adapters/node/index.d.mts +11 -5
- package/dist/adapters/node/index.d.ts +11 -5
- package/dist/adapters/node/index.mjs +2 -1
- package/dist/adapters/standard/index.d.mts +8 -22
- package/dist/adapters/standard/index.d.ts +8 -22
- package/dist/adapters/standard/index.mjs +2 -1
- package/dist/index.d.mts +38 -53
- package/dist/index.d.ts +38 -53
- package/dist/index.mjs +31 -535
- package/dist/plugins/index.d.mts +84 -0
- package/dist/plugins/index.d.ts +84 -0
- package/dist/plugins/index.mjs +148 -0
- package/dist/shared/openapi.BGy4N6eR.d.mts +120 -0
- package/dist/shared/openapi.BGy4N6eR.d.ts +120 -0
- package/dist/shared/openapi.CoREqFh3.mjs +853 -0
- package/dist/shared/{openapi.p5tsmBXx.mjs → openapi.DIt-Z9W1.mjs} +45 -13
- package/dist/shared/openapi.DwaweYRb.d.mts +54 -0
- package/dist/shared/openapi.DwaweYRb.d.ts +54 -0
- package/package.json +28 -12
- package/dist/shared/openapi.D3j94c9n.d.mts +0 -12
- package/dist/shared/openapi.D3j94c9n.d.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
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 { 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.BGy4N6eR.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
|
*
|
|
15
|
-
* @see {@link https://orpc.
|
|
16
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
|
|
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,16 @@ 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
|
+
declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
|
|
69
|
+
/**
|
|
70
|
+
* Simplifies composed object JSON Schemas (using anyOf, oneOf, allOf) by flattening nested compositions
|
|
71
|
+
*
|
|
72
|
+
* @warning The result is looser than the original schema and may not fully validate the same data.
|
|
73
|
+
*/
|
|
74
|
+
declare function simplifyComposedObjectJsonSchemasAndRefs(schema: JSONSchema, doc?: OpenAPI.Document): JSONSchema;
|
|
75
|
+
|
|
76
|
+
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
77
|
|
|
104
78
|
/**
|
|
105
79
|
*@internal
|
|
@@ -122,10 +96,21 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
|
|
|
122
96
|
*/
|
|
123
97
|
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
124
98
|
declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
|
|
99
|
+
/**
|
|
100
|
+
* Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
|
|
101
|
+
* recursively expands it into an array of its constituent, non-union base schemas.
|
|
102
|
+
* If the schema is not a simple union or is a base type, it's returned as a single-element array.
|
|
103
|
+
*/
|
|
104
|
+
declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
|
|
105
|
+
declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
|
|
106
|
+
type: 'array';
|
|
107
|
+
items?: JSONSchema;
|
|
108
|
+
}];
|
|
109
|
+
declare function isPrimitiveSchema(schema: JSONSchema): boolean;
|
|
125
110
|
|
|
126
111
|
declare const oo: {
|
|
127
112
|
spec: typeof customOpenAPIOperation;
|
|
128
113
|
};
|
|
129
114
|
|
|
130
|
-
export {
|
|
131
|
-
export type {
|
|
115
|
+
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, simplifyComposedObjectJsonSchemasAndRefs, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
116
|
+
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|