@orpc/openapi 0.0.0-next.3d10c98 → 0.0.0-next.3d4bea8

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.BfNjg7j9.js';
9
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
5
+ import { JSONSchema } from '@orpc/interop/json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/interop/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,10 @@ 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
+ 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
71
 
104
72
  /**
105
73
  *@internal
@@ -122,10 +90,21 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
122
90
  */
123
91
  declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
124
92
  declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
93
+ /**
94
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
95
+ * recursively expands it into an array of its constituent, non-union base schemas.
96
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
97
+ */
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;
125
104
 
126
105
  declare const oo: {
127
106
  spec: typeof customOpenAPIOperation;
128
107
  };
129
108
 
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 };
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 };
110
+ export type { FileSchema, ObjectSchema, OverrideOperationValue };