@orpc/openapi 0.0.0-next.e7ee5a9 → 0.0.0-next.e8524dc

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.
Files changed (36) hide show
  1. package/README.md +28 -20
  2. package/dist/adapters/aws-lambda/index.d.mts +17 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +17 -0
  4. package/dist/adapters/aws-lambda/index.mjs +18 -0
  5. package/dist/adapters/fetch/index.d.mts +12 -9
  6. package/dist/adapters/fetch/index.d.ts +12 -9
  7. package/dist/adapters/fetch/index.mjs +14 -6
  8. package/dist/adapters/node/index.d.mts +12 -9
  9. package/dist/adapters/node/index.d.ts +12 -9
  10. package/dist/adapters/node/index.mjs +9 -20
  11. package/dist/adapters/standard/index.d.mts +22 -11
  12. package/dist/adapters/standard/index.d.ts +22 -11
  13. package/dist/adapters/standard/index.mjs +5 -3
  14. package/dist/index.d.mts +96 -155
  15. package/dist/index.d.ts +96 -155
  16. package/dist/index.mjs +34 -654
  17. package/dist/plugins/index.d.mts +69 -0
  18. package/dist/plugins/index.d.ts +69 -0
  19. package/dist/plugins/index.mjs +108 -0
  20. package/dist/shared/openapi.B3hexduL.d.mts +101 -0
  21. package/dist/shared/openapi.B3hexduL.d.ts +101 -0
  22. package/dist/shared/{openapi.CDsfPHgw.mjs → openapi.C_UtQ8Us.mjs} +61 -30
  23. package/dist/shared/openapi.D3j94c9n.d.mts +12 -0
  24. package/dist/shared/openapi.D3j94c9n.d.ts +12 -0
  25. package/dist/shared/openapi.DrrBsJ0w.mjs +738 -0
  26. package/package.json +19 -22
  27. package/dist/adapters/hono/index.d.mts +0 -7
  28. package/dist/adapters/hono/index.d.ts +0 -7
  29. package/dist/adapters/hono/index.mjs +0 -10
  30. package/dist/adapters/next/index.d.mts +0 -7
  31. package/dist/adapters/next/index.d.ts +0 -7
  32. package/dist/adapters/next/index.mjs +0 -10
  33. package/dist/shared/openapi.BHG_gu5Z.mjs +0 -8
  34. package/dist/shared/openapi.D0VMNR6V.mjs +0 -25
  35. package/dist/shared/openapi.Dz_6xooR.d.mts +0 -7
  36. package/dist/shared/openapi.Dz_6xooR.d.ts +0 -7
package/dist/index.d.mts CHANGED
@@ -1,169 +1,110 @@
1
- import { AnyContractProcedure, Schema, ContractRouter, HTTPPath } from '@orpc/contract';
2
- import * as OpenAPI from 'openapi3-ts/oas31';
3
- export { OpenAPI };
4
- export { OpenApiBuilder } from 'openapi3-ts/oas31';
5
- import * as JSONSchema from 'json-schema-typed/draft-2020-12';
6
- export { JSONSchema };
7
- export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
8
- import { OpenAPIJsonSerializer } from '@orpc/openapi-client/standard';
9
- import { AnyRouter } from '@orpc/server';
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.B3hexduL.mjs';
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 = OpenAPI.OperationObject | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
12
- declare function setOperationExtender<T extends object>(o: T, extend: OverrideOperationValue): T;
13
- declare function getOperationExtender(o: object): OverrideOperationValue | undefined;
14
- declare function extendOperation(operation: OpenAPI.OperationObject, procedure: AnyContractProcedure): OpenAPI.OperationObject;
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ *
16
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
+ */
18
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
15
21
 
16
- type ObjectSchema = JSONSchema.JSONSchema & {
22
+ /**
23
+ * @internal
24
+ */
25
+ type ObjectSchema = JSONSchema & {
17
26
  type: 'object';
18
27
  } & object;
19
- type FileSchema = JSONSchema.JSONSchema & {
28
+ /**
29
+ * @internal
30
+ */
31
+ type FileSchema = JSONSchema & {
20
32
  type: 'string';
21
33
  contentMediaType: string;
22
34
  } & object;
23
- declare const NON_LOGIC_KEYWORDS: string[];
35
+ /**
36
+ * @internal
37
+ */
38
+ declare const LOGIC_KEYWORDS: string[];
24
39
 
25
- declare class SchemaUtils {
26
- isFileSchema(schema: JSONSchema.JSONSchema): schema is FileSchema;
27
- isObjectSchema(schema: JSONSchema.JSONSchema): schema is ObjectSchema;
28
- isAnySchema(schema: JSONSchema.JSONSchema): boolean;
29
- isUndefinableSchema(schema: JSONSchema.JSONSchema): boolean;
30
- separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
31
- filterSchemaBranches(schema: JSONSchema.JSONSchema, check: (schema: JSONSchema.JSONSchema) => boolean, matches?: JSONSchema.JSONSchema[]): [matches: JSONSchema.JSONSchema[], rest: JSONSchema.JSONSchema | undefined];
32
- }
33
- type PublicSchemaUtils = Pick<SchemaUtils, keyof SchemaUtils>;
40
+ /**
41
+ * @internal
42
+ */
43
+ declare function toOpenAPIPath(path: HTTPPath): string;
44
+ /**
45
+ * @internal
46
+ */
47
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
48
+ /**
49
+ * @internal
50
+ */
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
52
+ /**
53
+ * @internal
54
+ */
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
56
+ /**
57
+ * @internal
58
+ */
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
60
+ /**
61
+ * @internal
62
+ */
63
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
64
+ /**
65
+ * @internal
66
+ */
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
34
69
 
35
- declare class OpenAPIContentBuilder {
36
- private readonly schemaUtils;
37
- constructor(schemaUtils: PublicSchemaUtils);
38
- build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
39
- }
40
- type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
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>>;
41
71
 
42
- declare class OpenAPIPathParser {
43
- parseDynamicParams(path: string): {
44
- name: string;
45
- raw: string;
46
- }[];
47
- }
48
- type PublicOpenAPIPathParser = Pick<OpenAPIPathParser, keyof OpenAPIPathParser>;
49
-
50
- interface SchemaConvertOptions {
51
- strategy: 'input' | 'output';
52
- }
53
- interface SchemaConverter {
54
- condition(schema: Schema, options: SchemaConvertOptions): boolean;
55
- convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
56
- }
57
- declare class CompositeSchemaConverter implements SchemaConverter {
58
- private readonly converters;
59
- constructor(converters: SchemaConverter[]);
60
- condition(): boolean;
61
- convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
62
- }
63
-
64
- interface OpenAPIInputStructureParseResult {
65
- paramsSchema: ObjectSchema | undefined;
66
- querySchema: ObjectSchema | undefined;
67
- headersSchema: ObjectSchema | undefined;
68
- bodySchema: JSONSchema.JSONSchema | undefined;
69
- }
70
- declare class OpenAPIInputStructureParser {
71
- private readonly schemaConverter;
72
- private readonly schemaUtils;
73
- private readonly pathParser;
74
- constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
75
- parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
76
- private parseDetailedSchema;
77
- private parseCompactSchema;
78
- }
79
- type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
80
-
81
- interface OpenAPIOutputStructureParseResult {
82
- headersSchema: ObjectSchema | undefined;
83
- bodySchema: JSONSchema.JSONSchema | undefined;
84
- }
85
- declare class OpenAPIOutputStructureParser {
86
- private readonly schemaConverter;
87
- private readonly schemaUtils;
88
- constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
89
- parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
90
- private parseDetailedSchema;
91
- private parseCompactSchema;
92
- }
93
- type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
94
-
95
- declare class OpenAPIParametersBuilder {
96
- build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
97
- type: 'object';
98
- } & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
99
- buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
100
- type: 'object';
101
- } & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
102
- }
103
- type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
104
-
105
- type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
106
- interface OpenAPIGeneratorOptions {
107
- contentBuilder?: PublicOpenAPIContentBuilder;
108
- parametersBuilder?: PublicOpenAPIParametersBuilder;
109
- schemaConverters?: SchemaConverter[];
110
- schemaUtils?: PublicSchemaUtils;
111
- jsonSerializer?: OpenAPIJsonSerializer;
112
- pathParser?: PublicOpenAPIPathParser;
113
- inputStructureParser?: PublicOpenAPIInputStructureParser;
114
- outputStructureParser?: PublicOpenAPIOutputStructureParser;
115
- /**
116
- * Throw error when you missing define tag definition on OpenAPI root tags
117
- *
118
- * Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
119
- * Because OpenAPI root tags is missing 'bar' tag
120
- *
121
- * @default false
122
- */
123
- considerMissingTagDefinitionAsError?: boolean;
124
- /**
125
- * Weather ignore procedures that has no path defined.
126
- *
127
- * @default false
128
- */
129
- ignoreUndefinedPathProcedures?: boolean;
130
- /**
131
- * What to do when we found an error with our router
132
- *
133
- * @default 'throw'
134
- */
135
- errorHandlerStrategy?: ErrorHandlerStrategy;
136
- /**
137
- * Strict error response
138
- *
139
- * @default true
140
- */
141
- strictErrorResponses?: boolean;
142
- }
143
- declare class OpenAPIGenerator {
144
- private readonly contentBuilder;
145
- private readonly parametersBuilder;
146
- private readonly schemaConverter;
147
- private readonly schemaUtils;
148
- private readonly jsonSerializer;
149
- private readonly pathParser;
150
- private readonly inputStructureParser;
151
- private readonly outputStructureParser;
152
- private readonly errorHandlerStrategy;
153
- private readonly ignoreUndefinedPathProcedures;
154
- private readonly considerMissingTagDefinitionAsError;
155
- private readonly strictErrorResponses;
156
- constructor(options?: OpenAPIGeneratorOptions);
157
- generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
158
- }
159
-
160
- declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
161
- declare function toOpenAPI31RoutePattern(path: HTTPPath): string;
162
-
163
- /** unnoq */
72
+ /**
73
+ *@internal
74
+ */
75
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
76
+ /**
77
+ * @internal
78
+ */
79
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
80
+ /**
81
+ * @internal
82
+ */
83
+ declare function isAnySchema(schema: JSONSchema): boolean;
84
+ /**
85
+ * @internal
86
+ */
87
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
88
+ /**
89
+ * @internal
90
+ */
91
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
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;
164
104
 
165
105
  declare const oo: {
166
- spec: typeof setOperationExtender;
106
+ spec: typeof customOpenAPIOperation;
167
107
  };
168
108
 
169
- export { CompositeSchemaConverter, type FileSchema, NON_LOGIC_KEYWORDS, type ObjectSchema, OpenAPIContentBuilder, OpenAPIGenerator, type OpenAPIGeneratorOptions, OpenAPIParametersBuilder, OpenAPIPathParser, type OverrideOperationValue, type PublicOpenAPIContentBuilder, type PublicOpenAPIParametersBuilder, type PublicOpenAPIPathParser, type PublicSchemaUtils, type SchemaConvertOptions, type SchemaConverter, SchemaUtils, extendOperation, getOperationExtender, oo, setOperationExtender, standardizeHTTPPath, toOpenAPI31RoutePattern };
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 };
package/dist/index.d.ts CHANGED
@@ -1,169 +1,110 @@
1
- import { AnyContractProcedure, Schema, ContractRouter, HTTPPath } from '@orpc/contract';
2
- import * as OpenAPI from 'openapi3-ts/oas31';
3
- export { OpenAPI };
4
- export { OpenApiBuilder } from 'openapi3-ts/oas31';
5
- import * as JSONSchema from 'json-schema-typed/draft-2020-12';
6
- export { JSONSchema };
7
- export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
8
- import { OpenAPIJsonSerializer } from '@orpc/openapi-client/standard';
9
- import { AnyRouter } from '@orpc/server';
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.B3hexduL.js';
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 = OpenAPI.OperationObject | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
12
- declare function setOperationExtender<T extends object>(o: T, extend: OverrideOperationValue): T;
13
- declare function getOperationExtender(o: object): OverrideOperationValue | undefined;
14
- declare function extendOperation(operation: OpenAPI.OperationObject, procedure: AnyContractProcedure): OpenAPI.OperationObject;
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ *
16
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
+ */
18
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
20
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
15
21
 
16
- type ObjectSchema = JSONSchema.JSONSchema & {
22
+ /**
23
+ * @internal
24
+ */
25
+ type ObjectSchema = JSONSchema & {
17
26
  type: 'object';
18
27
  } & object;
19
- type FileSchema = JSONSchema.JSONSchema & {
28
+ /**
29
+ * @internal
30
+ */
31
+ type FileSchema = JSONSchema & {
20
32
  type: 'string';
21
33
  contentMediaType: string;
22
34
  } & object;
23
- declare const NON_LOGIC_KEYWORDS: string[];
35
+ /**
36
+ * @internal
37
+ */
38
+ declare const LOGIC_KEYWORDS: string[];
24
39
 
25
- declare class SchemaUtils {
26
- isFileSchema(schema: JSONSchema.JSONSchema): schema is FileSchema;
27
- isObjectSchema(schema: JSONSchema.JSONSchema): schema is ObjectSchema;
28
- isAnySchema(schema: JSONSchema.JSONSchema): boolean;
29
- isUndefinableSchema(schema: JSONSchema.JSONSchema): boolean;
30
- separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
31
- filterSchemaBranches(schema: JSONSchema.JSONSchema, check: (schema: JSONSchema.JSONSchema) => boolean, matches?: JSONSchema.JSONSchema[]): [matches: JSONSchema.JSONSchema[], rest: JSONSchema.JSONSchema | undefined];
32
- }
33
- type PublicSchemaUtils = Pick<SchemaUtils, keyof SchemaUtils>;
40
+ /**
41
+ * @internal
42
+ */
43
+ declare function toOpenAPIPath(path: HTTPPath): string;
44
+ /**
45
+ * @internal
46
+ */
47
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
48
+ /**
49
+ * @internal
50
+ */
51
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
52
+ /**
53
+ * @internal
54
+ */
55
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
56
+ /**
57
+ * @internal
58
+ */
59
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
60
+ /**
61
+ * @internal
62
+ */
63
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
64
+ /**
65
+ * @internal
66
+ */
67
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
34
69
 
35
- declare class OpenAPIContentBuilder {
36
- private readonly schemaUtils;
37
- constructor(schemaUtils: PublicSchemaUtils);
38
- build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
39
- }
40
- type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
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>>;
41
71
 
42
- declare class OpenAPIPathParser {
43
- parseDynamicParams(path: string): {
44
- name: string;
45
- raw: string;
46
- }[];
47
- }
48
- type PublicOpenAPIPathParser = Pick<OpenAPIPathParser, keyof OpenAPIPathParser>;
49
-
50
- interface SchemaConvertOptions {
51
- strategy: 'input' | 'output';
52
- }
53
- interface SchemaConverter {
54
- condition(schema: Schema, options: SchemaConvertOptions): boolean;
55
- convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
56
- }
57
- declare class CompositeSchemaConverter implements SchemaConverter {
58
- private readonly converters;
59
- constructor(converters: SchemaConverter[]);
60
- condition(): boolean;
61
- convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
62
- }
63
-
64
- interface OpenAPIInputStructureParseResult {
65
- paramsSchema: ObjectSchema | undefined;
66
- querySchema: ObjectSchema | undefined;
67
- headersSchema: ObjectSchema | undefined;
68
- bodySchema: JSONSchema.JSONSchema | undefined;
69
- }
70
- declare class OpenAPIInputStructureParser {
71
- private readonly schemaConverter;
72
- private readonly schemaUtils;
73
- private readonly pathParser;
74
- constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
75
- parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
76
- private parseDetailedSchema;
77
- private parseCompactSchema;
78
- }
79
- type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
80
-
81
- interface OpenAPIOutputStructureParseResult {
82
- headersSchema: ObjectSchema | undefined;
83
- bodySchema: JSONSchema.JSONSchema | undefined;
84
- }
85
- declare class OpenAPIOutputStructureParser {
86
- private readonly schemaConverter;
87
- private readonly schemaUtils;
88
- constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
89
- parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
90
- private parseDetailedSchema;
91
- private parseCompactSchema;
92
- }
93
- type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
94
-
95
- declare class OpenAPIParametersBuilder {
96
- build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
97
- type: 'object';
98
- } & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
99
- buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
100
- type: 'object';
101
- } & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
102
- }
103
- type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
104
-
105
- type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
106
- interface OpenAPIGeneratorOptions {
107
- contentBuilder?: PublicOpenAPIContentBuilder;
108
- parametersBuilder?: PublicOpenAPIParametersBuilder;
109
- schemaConverters?: SchemaConverter[];
110
- schemaUtils?: PublicSchemaUtils;
111
- jsonSerializer?: OpenAPIJsonSerializer;
112
- pathParser?: PublicOpenAPIPathParser;
113
- inputStructureParser?: PublicOpenAPIInputStructureParser;
114
- outputStructureParser?: PublicOpenAPIOutputStructureParser;
115
- /**
116
- * Throw error when you missing define tag definition on OpenAPI root tags
117
- *
118
- * Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
119
- * Because OpenAPI root tags is missing 'bar' tag
120
- *
121
- * @default false
122
- */
123
- considerMissingTagDefinitionAsError?: boolean;
124
- /**
125
- * Weather ignore procedures that has no path defined.
126
- *
127
- * @default false
128
- */
129
- ignoreUndefinedPathProcedures?: boolean;
130
- /**
131
- * What to do when we found an error with our router
132
- *
133
- * @default 'throw'
134
- */
135
- errorHandlerStrategy?: ErrorHandlerStrategy;
136
- /**
137
- * Strict error response
138
- *
139
- * @default true
140
- */
141
- strictErrorResponses?: boolean;
142
- }
143
- declare class OpenAPIGenerator {
144
- private readonly contentBuilder;
145
- private readonly parametersBuilder;
146
- private readonly schemaConverter;
147
- private readonly schemaUtils;
148
- private readonly jsonSerializer;
149
- private readonly pathParser;
150
- private readonly inputStructureParser;
151
- private readonly outputStructureParser;
152
- private readonly errorHandlerStrategy;
153
- private readonly ignoreUndefinedPathProcedures;
154
- private readonly considerMissingTagDefinitionAsError;
155
- private readonly strictErrorResponses;
156
- constructor(options?: OpenAPIGeneratorOptions);
157
- generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
158
- }
159
-
160
- declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
161
- declare function toOpenAPI31RoutePattern(path: HTTPPath): string;
162
-
163
- /** unnoq */
72
+ /**
73
+ *@internal
74
+ */
75
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
76
+ /**
77
+ * @internal
78
+ */
79
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
80
+ /**
81
+ * @internal
82
+ */
83
+ declare function isAnySchema(schema: JSONSchema): boolean;
84
+ /**
85
+ * @internal
86
+ */
87
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
88
+ /**
89
+ * @internal
90
+ */
91
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
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;
164
104
 
165
105
  declare const oo: {
166
- spec: typeof setOperationExtender;
106
+ spec: typeof customOpenAPIOperation;
167
107
  };
168
108
 
169
- export { CompositeSchemaConverter, type FileSchema, NON_LOGIC_KEYWORDS, type ObjectSchema, OpenAPIContentBuilder, OpenAPIGenerator, type OpenAPIGeneratorOptions, OpenAPIParametersBuilder, OpenAPIPathParser, type OverrideOperationValue, type PublicOpenAPIContentBuilder, type PublicOpenAPIParametersBuilder, type PublicOpenAPIPathParser, type PublicSchemaUtils, type SchemaConvertOptions, type SchemaConverter, SchemaUtils, extendOperation, getOperationExtender, oo, setOperationExtender, standardizeHTTPPath, toOpenAPI31RoutePattern };
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 };