@orpc/openapi 0.0.0-next.f81b4a2 → 0.0.0-next.f8cfaa5

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/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { AnyContractProcedure, AnySchema, AnyContractRouter } from '@orpc/contract';
2
- import { OpenAPIV3_1 } from 'openapi-types';
3
- export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
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.dbQeFCUJ.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<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);
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: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
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, OpenAPIV3_1.MediaTypeObject>;
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, OpenAPIV3_1.MediaTypeObject>;
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'): OpenAPIV3_1.ParameterObject[];
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): OpenAPIV3_1.SchemaObject & object;
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 { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
131
- export type { ConditionalSchemaConverter, FileSchema, ObjectSchema, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter };
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 };