@orpc/openapi 1.14.10 → 1.14.11
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 +52 -71
- package/dist/adapters/fetch/index.d.mts +20 -16
- package/dist/adapters/fetch/index.d.ts +20 -16
- package/dist/adapters/fetch/index.mjs +24 -8
- package/dist/adapters/node/index.d.mts +8 -13
- package/dist/adapters/node/index.d.ts +8 -13
- package/dist/adapters/node/index.mjs +10 -7
- package/dist/adapters/standard/index.d.mts +46 -16
- package/dist/adapters/standard/index.d.ts +46 -16
- package/dist/adapters/standard/index.mjs +9 -6
- package/dist/extensions/route.d.mts +43 -0
- package/dist/extensions/route.d.ts +43 -0
- package/dist/extensions/route.mjs +14 -0
- package/dist/helpers/index.d.mts +51 -0
- package/dist/helpers/index.d.ts +51 -0
- package/dist/helpers/index.mjs +39 -0
- package/dist/index.d.mts +117 -105
- package/dist/index.d.ts +117 -105
- package/dist/index.mjs +850 -32
- package/dist/plugins/index.d.mts +55 -51
- package/dist/plugins/index.d.ts +55 -51
- package/dist/plugins/index.mjs +147 -142
- package/dist/shared/openapi.B6hEbRyF.d.ts +83 -0
- package/dist/shared/openapi.B9PQzqBn.mjs +49 -0
- package/dist/shared/openapi.BOOA-bde.d.mts +142 -0
- package/dist/shared/openapi.BOOA-bde.d.ts +142 -0
- package/dist/shared/openapi.BafbB3uM.d.mts +83 -0
- package/dist/shared/openapi.Bt87OzTt.mjs +131 -0
- package/dist/shared/openapi.ByT4oUeY.d.mts +18 -0
- package/dist/shared/openapi.ByT4oUeY.d.ts +18 -0
- package/dist/shared/openapi.C-p_Q2lb.mjs +359 -0
- package/dist/shared/openapi.CVgUshDP.mjs +318 -0
- package/dist/shared/openapi.DNNo0V-l.d.ts +313 -0
- package/dist/shared/openapi.hg_rhZ4x.d.mts +313 -0
- package/dist/shared/openapi.zZH_UksW.mjs +278 -0
- package/package.json +46 -24
- package/dist/adapters/aws-lambda/index.d.mts +0 -20
- package/dist/adapters/aws-lambda/index.d.ts +0 -20
- package/dist/adapters/aws-lambda/index.mjs +0 -18
- package/dist/adapters/fastify/index.d.mts +0 -23
- package/dist/adapters/fastify/index.d.ts +0 -23
- package/dist/adapters/fastify/index.mjs +0 -18
- package/dist/shared/openapi.BB-W-NKv.mjs +0 -204
- package/dist/shared/openapi.BGy4N6eR.d.mts +0 -120
- package/dist/shared/openapi.BGy4N6eR.d.ts +0 -120
- package/dist/shared/openapi.BwdtJjDu.mjs +0 -878
- package/dist/shared/openapi.DwaweYRb.d.mts +0 -54
- package/dist/shared/openapi.DwaweYRb.d.ts +0 -54
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AnyORPCError } from '@orpc/client';
|
|
2
|
+
import { ErrorMap, AnySchema } from '@orpc/contract';
|
|
3
|
+
import { Context } from '@orpc/server';
|
|
4
|
+
import { O as OpenAPIMeta } from '../shared/openapi.DNNo0V-l.js';
|
|
5
|
+
import '@orpc/shared';
|
|
6
|
+
import '@standardserver/core';
|
|
7
|
+
import '../shared/openapi.ByT4oUeY.js';
|
|
8
|
+
import '@hey-api/spec-types';
|
|
9
|
+
|
|
10
|
+
declare module '@orpc/contract' {
|
|
11
|
+
interface ContractBuilder<TErrorMap extends ErrorMap> {
|
|
12
|
+
route(meta: OpenAPIMeta): ContractBuilder<TErrorMap>;
|
|
13
|
+
}
|
|
14
|
+
interface ProcedureContractBuilderWithInput<TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
15
|
+
route(meta: OpenAPIMeta): ProcedureContractBuilderWithInput<TInputSchema, TErrorMap>;
|
|
16
|
+
}
|
|
17
|
+
interface ProcedureContractBuilderWithOutput<TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
18
|
+
route(meta: OpenAPIMeta): ProcedureContractBuilderWithOutput<TOutputSchema, TErrorMap>;
|
|
19
|
+
}
|
|
20
|
+
interface ProcedureContractBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
21
|
+
route(meta: OpenAPIMeta): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
declare module '@orpc/server' {
|
|
25
|
+
interface Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
|
|
26
|
+
route(meta: OpenAPIMeta): Builder<TInitialContext, TErrorMap>;
|
|
27
|
+
}
|
|
28
|
+
interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
|
|
29
|
+
route(meta: OpenAPIMeta): BuilderWithMiddlewares<TInitialContext, TInjectedContext, TErrorMap>;
|
|
30
|
+
}
|
|
31
|
+
interface BuilderWithInput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
32
|
+
route(meta: OpenAPIMeta): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, TErrorMap>;
|
|
33
|
+
}
|
|
34
|
+
interface BuilderWithOutput<TInitialContext extends Context, TInjectedContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
35
|
+
route(meta: OpenAPIMeta): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, TErrorMap>;
|
|
36
|
+
}
|
|
37
|
+
interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
38
|
+
route(meta: OpenAPIMeta): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
39
|
+
}
|
|
40
|
+
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TReturnedError extends AnyORPCError> {
|
|
41
|
+
route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap, TReturnedError>;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ContractBuilder } from '@orpc/contract';
|
|
2
|
+
import { Builder, DecoratedProcedure } from '@orpc/server';
|
|
3
|
+
import { o as openapi } from '../shared/openapi.B9PQzqBn.mjs';
|
|
4
|
+
import '@orpc/shared';
|
|
5
|
+
|
|
6
|
+
ContractBuilder.prototype.route = function route(meta) {
|
|
7
|
+
return this.meta(openapi(meta));
|
|
8
|
+
};
|
|
9
|
+
Builder.prototype.route = function route2(meta) {
|
|
10
|
+
return this.meta(openapi(meta));
|
|
11
|
+
};
|
|
12
|
+
DecoratedProcedure.prototype.route = function route3(meta) {
|
|
13
|
+
return this.meta(openapi(meta));
|
|
14
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a form data with [bracket notation](https://orpc.dev/docs/openapi/bracket-notation) syntax
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const form = new FormData()
|
|
7
|
+
* form.append('a', '1')
|
|
8
|
+
* form.append('user[name]', 'John')
|
|
9
|
+
* form.append('user[age]', '20')
|
|
10
|
+
* form.append('user[friends][]', 'Bob')
|
|
11
|
+
* form.append('user[friends][]', 'Alice')
|
|
12
|
+
* form.append('user[friends][]', 'Charlie')
|
|
13
|
+
* form.append('thumb', new Blob(['hello']), 'thumb.png')
|
|
14
|
+
*
|
|
15
|
+
* parseFormData(form)
|
|
16
|
+
* // {
|
|
17
|
+
* // a: '1',
|
|
18
|
+
* // user: {
|
|
19
|
+
* // name: 'John',
|
|
20
|
+
* // age: '20',
|
|
21
|
+
* // friends: ['Bob', 'Alice', 'Charlie'],
|
|
22
|
+
* // },
|
|
23
|
+
* // thumb: form.get('thumb'),
|
|
24
|
+
* // }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function parseFormData(form: FormData): any;
|
|
28
|
+
/**
|
|
29
|
+
* Get the issue message from the error.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const { error, data, execute } = useServerAction(someAction)
|
|
34
|
+
*
|
|
35
|
+
* return <form action={(form) => execute(parseFormData(form))}>
|
|
36
|
+
* <input name="user[name]" type="text" />
|
|
37
|
+
* <p>{getIssueMessage(error, 'user[name]')}</p>
|
|
38
|
+
*
|
|
39
|
+
* <input name="user[age]" type="number" />
|
|
40
|
+
* <p>{getIssueMessage(error, 'user[age]')}</p>
|
|
41
|
+
*
|
|
42
|
+
* <input name="images[]" type="file" />
|
|
43
|
+
* <p>{getIssueMessage(error, 'images[]')}</p>
|
|
44
|
+
* </form>
|
|
45
|
+
*
|
|
46
|
+
* @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
|
|
47
|
+
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
|
|
48
|
+
*/
|
|
49
|
+
declare function getIssueMessage(error: unknown, path: string): string | undefined;
|
|
50
|
+
|
|
51
|
+
export { getIssueMessage, parseFormData };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a form data with [bracket notation](https://orpc.dev/docs/openapi/bracket-notation) syntax
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const form = new FormData()
|
|
7
|
+
* form.append('a', '1')
|
|
8
|
+
* form.append('user[name]', 'John')
|
|
9
|
+
* form.append('user[age]', '20')
|
|
10
|
+
* form.append('user[friends][]', 'Bob')
|
|
11
|
+
* form.append('user[friends][]', 'Alice')
|
|
12
|
+
* form.append('user[friends][]', 'Charlie')
|
|
13
|
+
* form.append('thumb', new Blob(['hello']), 'thumb.png')
|
|
14
|
+
*
|
|
15
|
+
* parseFormData(form)
|
|
16
|
+
* // {
|
|
17
|
+
* // a: '1',
|
|
18
|
+
* // user: {
|
|
19
|
+
* // name: 'John',
|
|
20
|
+
* // age: '20',
|
|
21
|
+
* // friends: ['Bob', 'Alice', 'Charlie'],
|
|
22
|
+
* // },
|
|
23
|
+
* // thumb: form.get('thumb'),
|
|
24
|
+
* // }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function parseFormData(form: FormData): any;
|
|
28
|
+
/**
|
|
29
|
+
* Get the issue message from the error.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const { error, data, execute } = useServerAction(someAction)
|
|
34
|
+
*
|
|
35
|
+
* return <form action={(form) => execute(parseFormData(form))}>
|
|
36
|
+
* <input name="user[name]" type="text" />
|
|
37
|
+
* <p>{getIssueMessage(error, 'user[name]')}</p>
|
|
38
|
+
*
|
|
39
|
+
* <input name="user[age]" type="number" />
|
|
40
|
+
* <p>{getIssueMessage(error, 'user[age]')}</p>
|
|
41
|
+
*
|
|
42
|
+
* <input name="images[]" type="file" />
|
|
43
|
+
* <p>{getIssueMessage(error, 'images[]')}</p>
|
|
44
|
+
* </form>
|
|
45
|
+
*
|
|
46
|
+
* @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
|
|
47
|
+
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
|
|
48
|
+
*/
|
|
49
|
+
declare function getIssueMessage(error: unknown, path: string): string | undefined;
|
|
50
|
+
|
|
51
|
+
export { getIssueMessage, parseFormData };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isSchemaIssue } from '@orpc/contract';
|
|
2
|
+
import { isTypescriptObject } from '@orpc/shared';
|
|
3
|
+
import { B as BracketNotationSerializer } from '../shared/openapi.Bt87OzTt.mjs';
|
|
4
|
+
|
|
5
|
+
function parseFormData(form) {
|
|
6
|
+
const serializer = new BracketNotationSerializer();
|
|
7
|
+
return serializer.deserialize(Array.from(form.entries()));
|
|
8
|
+
}
|
|
9
|
+
function getIssueMessage(error, path) {
|
|
10
|
+
if (!isTypescriptObject(error) || !isTypescriptObject(error.data) || !Array.isArray(error.data.issues)) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
const serializer = new BracketNotationSerializer();
|
|
14
|
+
for (const issue of error.data.issues) {
|
|
15
|
+
if (!isSchemaIssue(issue)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (issue.path === void 0) {
|
|
19
|
+
if (path === "") {
|
|
20
|
+
return issue.message;
|
|
21
|
+
}
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const issuePath = serializer.stringifyPath(
|
|
25
|
+
issue.path.map((segment) => typeof segment === "object" ? segment.key.toString() : segment.toString())
|
|
26
|
+
);
|
|
27
|
+
if (issuePath === path) {
|
|
28
|
+
return issue.message;
|
|
29
|
+
}
|
|
30
|
+
if (path.endsWith("[]") && issuePath.replace(/\[(?:0|[1-9]\d*)\]$/, "[]") === path) {
|
|
31
|
+
return issue.message;
|
|
32
|
+
}
|
|
33
|
+
if (path === "" && /(?:0|[1-9]\d*)$/.test(issuePath)) {
|
|
34
|
+
return issue.message;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { getIssueMessage, parseFormData };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,117 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import '@orpc/
|
|
1
|
+
import { O as OpenAPISerializer } from './shared/openapi.BOOA-bde.mjs';
|
|
2
|
+
export { B as BracketNotationSerializeResult, a as BracketNotationSerializer, b as BracketNotationSerializerOptions, c as OpenAPIJsonSerialization, d as OpenAPIJsonSerializer, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.BOOA-bde.mjs';
|
|
3
|
+
import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
|
+
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
|
+
import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
|
|
6
|
+
import { J as JsonifiedClient, a as OpenAPIDocument } from './shared/openapi.ByT4oUeY.mjs';
|
|
7
|
+
export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue, O as OpenAPIOperationObject } from './shared/openapi.ByT4oUeY.mjs';
|
|
8
|
+
export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.hg_rhZ4x.mjs';
|
|
9
|
+
import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
|
|
10
|
+
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
11
|
+
import { Value } from '@orpc/shared';
|
|
12
|
+
export { StandardBodyHint } from '@standardserver/core';
|
|
13
|
+
import '@hey-api/spec-types';
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
|
|
16
|
+
<T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
|
|
17
|
+
}
|
|
18
|
+
interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
|
|
19
|
+
/**
|
|
20
|
+
* An optional reference to the root router-contract.
|
|
21
|
+
* When provided, the client factory will automatically register the passed contract
|
|
22
|
+
* into the router at the path defined by `meta.path`.
|
|
23
|
+
*/
|
|
24
|
+
contractRef?: undefined | RouterContract;
|
|
25
|
+
}
|
|
26
|
+
declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
type: 'object';
|
|
27
|
-
} & object;
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
type FileSchema = JSONSchema & {
|
|
32
|
-
type: 'string';
|
|
33
|
-
contentMediaType: string;
|
|
34
|
-
} & object;
|
|
35
|
-
/**
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
declare const LOGIC_KEYWORDS: string[];
|
|
28
|
+
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
29
|
+
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
30
|
+
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
31
|
+
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
39
32
|
|
|
40
33
|
/**
|
|
41
|
-
*
|
|
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
|
|
34
|
+
* GET and HEAD requests cannot carry a request body,
|
|
35
|
+
* so their compact input maps to query parameters instead.
|
|
62
36
|
*/
|
|
63
|
-
declare function
|
|
37
|
+
declare function isBodylessMethod(method: string): boolean;
|
|
64
38
|
/**
|
|
65
|
-
*
|
|
39
|
+
* Dynamic parameters are always returned in path order.
|
|
66
40
|
*/
|
|
67
|
-
declare function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
declare function simplifyComposedObjectJsonSchemasAndRefs(schema: JSONSchema, doc?: OpenAPI.Document): JSONSchema;
|
|
41
|
+
declare function getDynamicPathParams(path: `/${string}`): {
|
|
42
|
+
segment: string;
|
|
43
|
+
startIndex: number;
|
|
44
|
+
parameterName: string;
|
|
45
|
+
allowsSlash: boolean;
|
|
46
|
+
}[] | undefined;
|
|
75
47
|
|
|
76
|
-
declare
|
|
48
|
+
declare class OpenAPIGeneratorError extends TypeError {
|
|
49
|
+
}
|
|
50
|
+
interface OpenAPIErrorBodyDefinition {
|
|
51
|
+
code: string;
|
|
52
|
+
defaultMessage: string | undefined;
|
|
53
|
+
dataOptional: boolean;
|
|
54
|
+
dataJsonSchema: JsonSchema;
|
|
55
|
+
}
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
57
|
+
interface OpenAPIGeneratorOptions {
|
|
58
|
+
converters?: JsonSchemaConverter[] | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* The serializer used to serialize the generated OpenAPI documentation
|
|
61
|
+
*/
|
|
62
|
+
serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer> | undefined;
|
|
63
|
+
}
|
|
64
|
+
interface OpenAPIGeneratorGenerateOptions {
|
|
65
|
+
base?: Partial<OpenAPIDocument> | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Root-level `$defs` are always moved into `components.schemas`.
|
|
68
|
+
* Use this to customize the component name of a hoisted def.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* - The returned name is a preference, conflicting names are still postfixed (`Planet`, `PlanetInput`, `Planet2`, ...).
|
|
72
|
+
* - Return `undefined` to keep the original def name.
|
|
73
|
+
*
|
|
74
|
+
* @default defName => defName
|
|
75
|
+
*/
|
|
76
|
+
customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
79
|
+
*
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
filter?: Value<boolean, [contract: AnyProcedureContract | AnyProcedure, path: string[]]>;
|
|
83
|
+
/**
|
|
84
|
+
* Define a custom JSON schema for the error response body when using
|
|
85
|
+
* type-safe errors. Helps align ORPC error formatting with existing API
|
|
86
|
+
* response standards or conventions.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* - Return `null | undefined` to use the default error response body shaper.
|
|
90
|
+
*/
|
|
91
|
+
customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
|
|
92
|
+
definedErrors: OpenAPIErrorBodyDefinition[],
|
|
93
|
+
status: number
|
|
94
|
+
]>;
|
|
95
|
+
/**
|
|
96
|
+
* Mapping ORPCError Code -> HTTP Status Code
|
|
97
|
+
*
|
|
98
|
+
* @default COMMON_ERROR_STATUS_MAP
|
|
99
|
+
*/
|
|
100
|
+
errorStatusMap?: Record<string, number> | undefined;
|
|
101
|
+
}
|
|
102
|
+
declare class OpenAPIGenerator {
|
|
103
|
+
private readonly serializer;
|
|
104
|
+
private readonly converter;
|
|
105
|
+
constructor(options?: OpenAPIGeneratorOptions);
|
|
106
|
+
generate(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPIDocument>;
|
|
107
|
+
private convertSchema;
|
|
108
|
+
private convertSchemas;
|
|
109
|
+
}
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : {
|
|
112
|
+
[K in keyof T]: T[K] extends RouterContract ? PopulatedContractRouterOpenAPIPaths<T[K]> : never;
|
|
114
113
|
};
|
|
114
|
+
interface PopulateRouterContractOpenAPIPathsOptions {
|
|
115
|
+
/**
|
|
116
|
+
* Base path segments.
|
|
117
|
+
*/
|
|
118
|
+
path?: undefined | string[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Automatically populates missing openapi.path using router structure.
|
|
122
|
+
*
|
|
123
|
+
* Builds paths by joining router keys with `/`.
|
|
124
|
+
* Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
|
|
125
|
+
*/
|
|
126
|
+
declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
|
|
115
127
|
|
|
116
|
-
export {
|
|
117
|
-
export type {
|
|
128
|
+
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedClientFactory, getDynamicPathParams, isBodylessMethod, populateRouterContractOpenAPIPaths };
|
|
129
|
+
export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
|