@orpc/openapi 2.0.0-beta.4 → 2.0.0-beta.41
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 +97 -94
- package/dist/adapters/aws-lambda/index.d.mts +26 -0
- package/dist/adapters/aws-lambda/index.d.ts +26 -0
- package/dist/adapters/aws-lambda/index.mjs +21 -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 +21 -0
- package/dist/adapters/fetch/index.d.mts +15 -5
- package/dist/adapters/fetch/index.d.ts +15 -5
- package/dist/adapters/fetch/index.mjs +6 -6
- package/dist/adapters/node/index.d.mts +9 -4
- package/dist/adapters/node/index.d.ts +9 -4
- package/dist/adapters/node/index.mjs +4 -4
- package/dist/adapters/standard/index.d.mts +10 -46
- package/dist/adapters/standard/index.d.ts +10 -46
- package/dist/adapters/standard/index.mjs +6 -6
- package/dist/extensions/route.d.mts +5 -7
- package/dist/extensions/route.d.ts +5 -7
- package/dist/helpers/index.d.mts +9 -1
- package/dist/helpers/index.d.ts +9 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/index.d.mts +77 -45
- package/dist/index.d.ts +77 -45
- package/dist/index.mjs +614 -765
- package/dist/plugins/index.d.mts +35 -6
- package/dist/plugins/index.d.ts +35 -6
- package/dist/plugins/index.mjs +15 -10
- package/dist/shared/{openapi.B2SK0ZAr.mjs → openapi.8cM6P94D.mjs} +32 -36
- package/dist/shared/openapi.B2G-HeFn.mjs +123 -0
- package/dist/shared/{openapi.7vgmPxca.d.ts → openapi.BCNfESWr.d.ts} +12 -9
- package/dist/shared/{openapi.CX6Ri5dP.d.mts → openapi.BgpM--nz.d.mts} +12 -9
- package/dist/shared/{openapi.CTlpLuKN.mjs → openapi.Bi1qxGF9.mjs} +102 -54
- package/dist/shared/{openapi.DmAa7YPO.mjs → openapi.Bu_PfTtX.mjs} +140 -61
- package/dist/shared/{openapi.C7m7NAmH.d.mts → openapi.C2LayTNZ.d.mts} +16 -5
- package/dist/shared/{openapi.C7m7NAmH.d.ts → openapi.C2LayTNZ.d.ts} +16 -5
- package/dist/shared/openapi.C6FFC29v.d.mts +31 -0
- package/dist/shared/openapi.C6FFC29v.d.ts +31 -0
- package/dist/shared/{openapi.BQzzr4-4.d.ts → openapi.Cem81Zhm.d.mts} +41 -12
- package/dist/shared/{openapi.BcEtAxQj.d.mts → openapi.Cem81Zhm.d.ts} +41 -12
- package/dist/shared/openapi.Cg9h6jpm.d.mts +45 -0
- package/dist/shared/openapi.D0yWs-uW.d.ts +45 -0
- package/package.json +57 -17
- package/dist/shared/openapi.Bt87OzTt.mjs +0 -131
- package/dist/shared/openapi.CYgMBSUF.d.mts +0 -18
- package/dist/shared/openapi.CYgMBSUF.d.ts +0 -18
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
|
|
3
3
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
|
-
import {
|
|
4
|
+
import { OpenAPIHandlerCodecOptions } from '../standard/index.js';
|
|
5
5
|
import { ClientContext } from '@orpc/client';
|
|
6
6
|
import { FetchLinkTransportOptions } from '@orpc/client/fetch';
|
|
7
7
|
import { StandardLink, StandardLinkOptions } from '@orpc/client/standard';
|
|
8
8
|
import { RouterContract } from '@orpc/contract';
|
|
9
9
|
import { OpenAPILinkCodecOptions } from '../standard/index.js';
|
|
10
10
|
import '@orpc/shared';
|
|
11
|
-
import '@
|
|
12
|
-
import '../../shared/openapi.
|
|
11
|
+
import '@standard-server/core';
|
|
12
|
+
import '../../shared/openapi.C2LayTNZ.js';
|
|
13
13
|
|
|
14
|
-
interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>,
|
|
14
|
+
interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Serves oRPC procedures over the OpenAPI (RESTful) protocol using the Fetch API `Request`/`Response`.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://orpc.dev/docs/adapters/fetch-api | Fetch API Adapter}
|
|
20
|
+
*/
|
|
16
21
|
declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
|
|
17
22
|
constructor(router: Router<T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
interface OpenAPILinkOptions<T extends ClientContext> extends
|
|
25
|
+
interface OpenAPILinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, FetchLinkTransportOptions<T>, OpenAPILinkCodecOptions<T> {
|
|
21
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Client link that calls an OpenAPI (RESTful) oRPC server over HTTP using the Fetch API.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link https://orpc.dev/docs/openapi/link | OpenAPI Link}
|
|
31
|
+
*/
|
|
22
32
|
declare class OpenAPILink<T extends ClientContext> extends StandardLink<T> {
|
|
23
33
|
constructor(router: RouterContract, options?: OpenAPILinkOptions<T>);
|
|
24
34
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { FetchHandler } from '@orpc/server/fetch';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.Bi1qxGF9.mjs';
|
|
4
4
|
import { FetchLinkTransport } from '@orpc/client/fetch';
|
|
5
5
|
import { StandardLink } from '@orpc/client/standard';
|
|
6
|
-
import { O as OpenAPILinkCodec } from '../../shared/openapi.
|
|
6
|
+
import { O as OpenAPILinkCodec } from '../../shared/openapi.8cM6P94D.mjs';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/server';
|
|
9
9
|
import '@orpc/shared';
|
|
10
|
-
import '@
|
|
11
|
-
import '../../shared/openapi.
|
|
12
|
-
import '../../shared/openapi.
|
|
10
|
+
import '@standard-server/core';
|
|
11
|
+
import '../../shared/openapi.Bu_PfTtX.mjs';
|
|
12
|
+
import '../../shared/openapi.B2G-HeFn.mjs';
|
|
13
13
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
14
14
|
import 'rou3';
|
|
15
15
|
import '@orpc/contract';
|
|
16
|
-
import '@
|
|
16
|
+
import '@standard-server/fetch';
|
|
17
17
|
|
|
18
18
|
class OpenAPIHandler extends FetchHandler {
|
|
19
19
|
constructor(router, options = {}) {
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
|
3
3
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
|
-
import {
|
|
4
|
+
import { OpenAPIHandlerCodecOptions } from '../standard/index.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/shared';
|
|
7
|
-
import '@
|
|
7
|
+
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.C2LayTNZ.mjs';
|
|
10
10
|
|
|
11
|
-
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>,
|
|
11
|
+
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Serves oRPC procedures over the OpenAPI (RESTful) protocol using Node.js built-in HTTP request/response.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.dev/docs/adapters/node-http | Node HTTP Adapter}
|
|
17
|
+
*/
|
|
13
18
|
declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
14
19
|
constructor(router: Router<T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
15
20
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
|
3
3
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
|
-
import {
|
|
4
|
+
import { OpenAPIHandlerCodecOptions } from '../standard/index.js';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/shared';
|
|
7
|
-
import '@
|
|
7
|
+
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.C2LayTNZ.js';
|
|
10
10
|
|
|
11
|
-
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>,
|
|
11
|
+
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Serves oRPC procedures over the OpenAPI (RESTful) protocol using Node.js built-in HTTP request/response.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.dev/docs/adapters/node-http | Node HTTP Adapter}
|
|
17
|
+
*/
|
|
13
18
|
declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
14
19
|
constructor(router: Router<T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
15
20
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NodeHttpHandler } from '@orpc/server/node';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.Bi1qxGF9.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
7
|
-
import '@
|
|
8
|
-
import '../../shared/openapi.
|
|
9
|
-
import '../../shared/openapi.
|
|
7
|
+
import '@standard-server/core';
|
|
8
|
+
import '../../shared/openapi.Bu_PfTtX.mjs';
|
|
9
|
+
import '../../shared/openapi.B2G-HeFn.mjs';
|
|
10
10
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
11
11
|
import 'rou3';
|
|
12
12
|
|
|
@@ -1,50 +1,14 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standardserver/core';
|
|
7
|
-
import { O as OpenAPISerializer } from '../../shared/openapi.C7m7NAmH.mjs';
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.BgpM--nz.mjs';
|
|
2
|
+
export { a as OpenAPILinkCodec, O as OpenAPILinkCodecOptions } from '../../shared/openapi.Cg9h6jpm.mjs';
|
|
3
|
+
import { StandardHeaders } from '@standard-server/core';
|
|
4
|
+
import { OpenAPISerializer } from '../../index.mjs';
|
|
5
|
+
import '@orpc/client';
|
|
8
6
|
import '@orpc/server';
|
|
9
7
|
import '@orpc/server/standard';
|
|
8
|
+
import '@orpc/shared';
|
|
9
|
+
import '@orpc/contract';
|
|
10
|
+
import '@orpc/client/standard';
|
|
10
11
|
|
|
11
|
-
declare
|
|
12
|
-
}
|
|
13
|
-
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
14
|
-
/**
|
|
15
|
-
* Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
|
|
16
|
-
*
|
|
17
|
-
* @example '/api'
|
|
18
|
-
* @default '/'
|
|
19
|
-
*/
|
|
20
|
-
url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
|
|
21
|
-
/**
|
|
22
|
-
* Inject headers into the request.
|
|
23
|
-
*/
|
|
24
|
-
headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
|
|
25
|
-
/**
|
|
26
|
-
* Override the default OpenAPI serializer.
|
|
27
|
-
*/
|
|
28
|
-
serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer>;
|
|
29
|
-
/**
|
|
30
|
-
* Customize how an error response body is converted into an ORPC error.
|
|
31
|
-
* Return `null` or `undefined` to fall back to the default decoding behavior.
|
|
32
|
-
*/
|
|
33
|
-
customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
|
|
34
|
-
}
|
|
35
|
-
declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
36
|
-
private readonly router;
|
|
37
|
-
private readonly baseUrl;
|
|
38
|
-
private readonly headers;
|
|
39
|
-
private readonly serializer;
|
|
40
|
-
private readonly customErrorResponseBodyDecoder;
|
|
41
|
-
constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
|
|
42
|
-
encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
|
|
43
|
-
private encodePathParam;
|
|
44
|
-
private serializeQueryString;
|
|
45
|
-
decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
|
|
46
|
-
private resolveProcedure;
|
|
47
|
-
}
|
|
12
|
+
declare function serializeHeaders(headers: object, serializer: Pick<OpenAPISerializer, 'serialize'>): StandardHeaders;
|
|
48
13
|
|
|
49
|
-
export {
|
|
50
|
-
export type { OpenAPILinkCodecOptions };
|
|
14
|
+
export { serializeHeaders };
|
|
@@ -1,50 +1,14 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standardserver/core';
|
|
7
|
-
import { O as OpenAPISerializer } from '../../shared/openapi.C7m7NAmH.js';
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.BCNfESWr.js';
|
|
2
|
+
export { a as OpenAPILinkCodec, O as OpenAPILinkCodecOptions } from '../../shared/openapi.D0yWs-uW.js';
|
|
3
|
+
import { StandardHeaders } from '@standard-server/core';
|
|
4
|
+
import { OpenAPISerializer } from '../../index.js';
|
|
5
|
+
import '@orpc/client';
|
|
8
6
|
import '@orpc/server';
|
|
9
7
|
import '@orpc/server/standard';
|
|
8
|
+
import '@orpc/shared';
|
|
9
|
+
import '@orpc/contract';
|
|
10
|
+
import '@orpc/client/standard';
|
|
10
11
|
|
|
11
|
-
declare
|
|
12
|
-
}
|
|
13
|
-
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
14
|
-
/**
|
|
15
|
-
* Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
|
|
16
|
-
*
|
|
17
|
-
* @example '/api'
|
|
18
|
-
* @default '/'
|
|
19
|
-
*/
|
|
20
|
-
url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
|
|
21
|
-
/**
|
|
22
|
-
* Inject headers into the request.
|
|
23
|
-
*/
|
|
24
|
-
headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
|
|
25
|
-
/**
|
|
26
|
-
* Override the default OpenAPI serializer.
|
|
27
|
-
*/
|
|
28
|
-
serializer?: Pick<OpenAPISerializer, keyof OpenAPISerializer>;
|
|
29
|
-
/**
|
|
30
|
-
* Customize how an error response body is converted into an ORPC error.
|
|
31
|
-
* Return `null` or `undefined` to fall back to the default decoding behavior.
|
|
32
|
-
*/
|
|
33
|
-
customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
|
|
34
|
-
}
|
|
35
|
-
declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
36
|
-
private readonly router;
|
|
37
|
-
private readonly baseUrl;
|
|
38
|
-
private readonly headers;
|
|
39
|
-
private readonly serializer;
|
|
40
|
-
private readonly customErrorResponseBodyDecoder;
|
|
41
|
-
constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
|
|
42
|
-
encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
|
|
43
|
-
private encodePathParam;
|
|
44
|
-
private serializeQueryString;
|
|
45
|
-
decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
|
|
46
|
-
private resolveProcedure;
|
|
47
|
-
}
|
|
12
|
+
declare function serializeHeaders(headers: object, serializer: Pick<OpenAPISerializer, 'serialize'>): StandardHeaders;
|
|
48
13
|
|
|
49
|
-
export {
|
|
50
|
-
export type { OpenAPILinkCodecOptions };
|
|
14
|
+
export { serializeHeaders };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher } from '../../shared/openapi.
|
|
2
|
-
export { O as OpenAPILinkCodec
|
|
1
|
+
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher, s as serializeHeaders } from '../../shared/openapi.Bi1qxGF9.mjs';
|
|
2
|
+
export { O as OpenAPILinkCodec } from '../../shared/openapi.8cM6P94D.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/server';
|
|
5
5
|
import '@orpc/shared';
|
|
6
|
-
import '@
|
|
7
|
-
import '../../shared/openapi.
|
|
8
|
-
import '../../shared/openapi.
|
|
6
|
+
import '@standard-server/core';
|
|
7
|
+
import '../../shared/openapi.Bu_PfTtX.mjs';
|
|
8
|
+
import '../../shared/openapi.B2G-HeFn.mjs';
|
|
9
9
|
import '../../shared/openapi.B9PQzqBn.mjs';
|
|
10
10
|
import 'rou3';
|
|
11
11
|
import '@orpc/contract';
|
|
12
|
-
import '@
|
|
12
|
+
import '@standard-server/fetch';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { AnyORPCError } from '@orpc/client';
|
|
2
1
|
import { ErrorMap, AnySchema } from '@orpc/contract';
|
|
3
2
|
import { Context } from '@orpc/server';
|
|
4
|
-
import {
|
|
3
|
+
import { OpenAPIMeta } from '../index.mjs';
|
|
5
4
|
import '@orpc/shared';
|
|
6
|
-
import '@
|
|
7
|
-
import '
|
|
8
|
-
import '@hey-api/spec-types';
|
|
5
|
+
import '@standard-server/core';
|
|
6
|
+
import '@openapi-spec/types';
|
|
9
7
|
|
|
10
8
|
declare module '@orpc/contract' {
|
|
11
9
|
interface ContractBuilder<TErrorMap extends ErrorMap> {
|
|
@@ -37,7 +35,7 @@ declare module '@orpc/server' {
|
|
|
37
35
|
interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
38
36
|
route(meta: OpenAPIMeta): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
39
37
|
}
|
|
40
|
-
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap
|
|
41
|
-
route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap
|
|
38
|
+
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
39
|
+
route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { AnyORPCError } from '@orpc/client';
|
|
2
1
|
import { ErrorMap, AnySchema } from '@orpc/contract';
|
|
3
2
|
import { Context } from '@orpc/server';
|
|
4
|
-
import {
|
|
3
|
+
import { OpenAPIMeta } from '../index.js';
|
|
5
4
|
import '@orpc/shared';
|
|
6
|
-
import '@
|
|
7
|
-
import '
|
|
8
|
-
import '@hey-api/spec-types';
|
|
5
|
+
import '@standard-server/core';
|
|
6
|
+
import '@openapi-spec/types';
|
|
9
7
|
|
|
10
8
|
declare module '@orpc/contract' {
|
|
11
9
|
interface ContractBuilder<TErrorMap extends ErrorMap> {
|
|
@@ -37,7 +35,7 @@ declare module '@orpc/server' {
|
|
|
37
35
|
interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
38
36
|
route(meta: OpenAPIMeta): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
39
37
|
}
|
|
40
|
-
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap
|
|
41
|
-
route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap
|
|
38
|
+
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
|
|
39
|
+
route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
42
40
|
}
|
|
43
41
|
}
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -23,10 +23,15 @@
|
|
|
23
23
|
* // thumb: form.get('thumb'),
|
|
24
24
|
* // }
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://orpc.dev/docs/helpers/form-data#parseformdata | Form Data Helpers - parseFormData}
|
|
26
28
|
*/
|
|
27
29
|
declare function parseFormData(form: FormData): any;
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
* Gets the issue message from the error for a given field path.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* **Note**: Requires validation errors to follow the standard schema issue format, stored under `data.issues` — customized validation errors may not be found.
|
|
30
35
|
*
|
|
31
36
|
* @example
|
|
32
37
|
* ```tsx
|
|
@@ -42,9 +47,12 @@ declare function parseFormData(form: FormData): any;
|
|
|
42
47
|
* <input name="images[]" type="file" />
|
|
43
48
|
* <p>{getIssueMessage(error, 'images[]')}</p>
|
|
44
49
|
* </form>
|
|
50
|
+
* ```
|
|
45
51
|
*
|
|
46
52
|
* @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
|
|
47
53
|
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://orpc.dev/docs/helpers/form-data#getissuemessage | Form Data Helpers - getIssueMessage}
|
|
48
56
|
*/
|
|
49
57
|
declare function getIssueMessage(error: unknown, path: string): string | undefined;
|
|
50
58
|
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -23,10 +23,15 @@
|
|
|
23
23
|
* // thumb: form.get('thumb'),
|
|
24
24
|
* // }
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://orpc.dev/docs/helpers/form-data#parseformdata | Form Data Helpers - parseFormData}
|
|
26
28
|
*/
|
|
27
29
|
declare function parseFormData(form: FormData): any;
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
* Gets the issue message from the error for a given field path.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* **Note**: Requires validation errors to follow the standard schema issue format, stored under `data.issues` — customized validation errors may not be found.
|
|
30
35
|
*
|
|
31
36
|
* @example
|
|
32
37
|
* ```tsx
|
|
@@ -42,9 +47,12 @@ declare function parseFormData(form: FormData): any;
|
|
|
42
47
|
* <input name="images[]" type="file" />
|
|
43
48
|
* <p>{getIssueMessage(error, 'images[]')}</p>
|
|
44
49
|
* </form>
|
|
50
|
+
* ```
|
|
45
51
|
*
|
|
46
52
|
* @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
|
|
47
53
|
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://orpc.dev/docs/helpers/form-data#getissuemessage | Form Data Helpers - getIssueMessage}
|
|
48
56
|
*/
|
|
49
57
|
declare function getIssueMessage(error: unknown, path: string): string | undefined;
|
|
50
58
|
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isSchemaIssue } from '@orpc/contract';
|
|
2
2
|
import { isTypescriptObject } from '@orpc/shared';
|
|
3
|
-
import { B as BracketNotationSerializer } from '../shared/openapi.
|
|
3
|
+
import { B as BracketNotationSerializer } from '../shared/openapi.B2G-HeFn.mjs';
|
|
4
4
|
|
|
5
5
|
function parseFormData(form) {
|
|
6
6
|
const serializer = new BracketNotationSerializer();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,52 +1,93 @@
|
|
|
1
|
-
import { O as OpenAPISerializer } from './shared/openapi.
|
|
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.
|
|
3
|
-
import { ClientContext,
|
|
1
|
+
import { O as OpenAPISerializer } from './shared/openapi.C2LayTNZ.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.C2LayTNZ.mjs';
|
|
3
|
+
import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
import { JsonSchemaConverter, JsonSchema } from '@orpc/json-schema';
|
|
5
|
+
import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
|
|
6
|
+
import { J as JsonifiedClient, O as OpenAPIVersion, a as OpenAPIDocument } from './shared/openapi.C6FFC29v.mjs';
|
|
7
|
+
export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.C6FFC29v.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.Cem81Zhm.mjs';
|
|
9
|
+
import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
|
|
11
10
|
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
12
|
-
|
|
13
|
-
import '@
|
|
11
|
+
import { Public, Value } from '@orpc/shared';
|
|
12
|
+
import { OpenAPIV3_2 } from '@openapi-spec/types';
|
|
13
|
+
export { OpenAPIV3_0, OpenAPIV3_1, OpenAPIV3_2 } from '@openapi-spec/types';
|
|
14
|
+
export { StandardBodyHint } from '@standard-server/core';
|
|
14
15
|
|
|
15
|
-
interface
|
|
16
|
-
<
|
|
16
|
+
interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
|
|
17
|
+
<T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
|
|
17
18
|
}
|
|
18
|
-
interface
|
|
19
|
+
interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
|
|
19
20
|
/**
|
|
20
21
|
* An optional reference to the root router-contract.
|
|
21
|
-
* When provided, the
|
|
22
|
+
* When provided, the client factory will automatically register the passed contract
|
|
22
23
|
* into the router at the path defined by `meta.path`.
|
|
23
24
|
*/
|
|
24
25
|
contractRef?: undefined | RouterContract;
|
|
25
26
|
}
|
|
26
|
-
declare function
|
|
27
|
+
declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
|
27
28
|
|
|
28
29
|
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
29
30
|
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
30
31
|
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
31
32
|
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* GET and HEAD requests cannot carry a request body,
|
|
36
|
+
* so their compact input maps to query parameters instead.
|
|
37
|
+
*/
|
|
38
|
+
declare function isBodylessMethod(method: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Dynamic parameters are always returned in path order.
|
|
41
|
+
*/
|
|
42
|
+
declare function getDynamicPathParams(path: `/${string}`): {
|
|
43
|
+
segment: string;
|
|
44
|
+
startIndex: number;
|
|
45
|
+
parameterName: string;
|
|
46
|
+
allowsSlash: boolean;
|
|
47
|
+
}[] | undefined;
|
|
48
|
+
|
|
33
49
|
declare class OpenAPIGeneratorError extends TypeError {
|
|
34
50
|
}
|
|
51
|
+
interface OpenAPIErrorBodyDefinition {
|
|
52
|
+
code: string;
|
|
53
|
+
defaultMessage: string | undefined;
|
|
54
|
+
dataOptional: boolean;
|
|
55
|
+
dataJsonSchema: JsonSchema;
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
interface OpenAPIGeneratorOptions {
|
|
36
59
|
converters?: JsonSchemaConverter[] | undefined;
|
|
37
60
|
/**
|
|
38
61
|
* The serializer used to serialize the generated OpenAPI documentation
|
|
39
62
|
*/
|
|
40
|
-
serializer?:
|
|
63
|
+
serializer?: Public<OpenAPISerializer> | undefined;
|
|
41
64
|
}
|
|
42
|
-
interface OpenAPIGeneratorGenerateOptions {
|
|
43
|
-
base?: Partial<OpenAPIDocument> | undefined;
|
|
65
|
+
interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
|
|
44
66
|
/**
|
|
45
|
-
*
|
|
67
|
+
* The OpenAPI version of the generated document.
|
|
68
|
+
* The document is generated as OpenAPI 3.2 and downgraded when an older version is requested.
|
|
69
|
+
* The minor version selects the conversion, the document carries the exact value, such as `3.1.0`.
|
|
46
70
|
*
|
|
47
|
-
* @default
|
|
71
|
+
* @default '3.2.0'
|
|
72
|
+
*/
|
|
73
|
+
version?: TVersion | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* OpenAPI 3.2 document fields to start from, such as `info`, `servers`, or `components`.
|
|
76
|
+
* They are downgraded with the rest of the document when an older `version` is requested.
|
|
77
|
+
* The `openapi` field is derived from `version`.
|
|
78
|
+
*/
|
|
79
|
+
base?: Partial<Omit<OpenAPIV3_2.OpenAPIObject, 'openapi'>> | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Root-level `$defs` are always moved into `components.schemas`.
|
|
82
|
+
* Use this to customize the component name of a hoisted def.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* - The returned name is a preference, conflicting names are still postfixed (`Planet`, `PlanetInput`, `Planet2`, ...).
|
|
86
|
+
* - Return `undefined` to keep the original def name.
|
|
87
|
+
*
|
|
88
|
+
* @default defName => defName
|
|
48
89
|
*/
|
|
49
|
-
|
|
90
|
+
customComponentName?: (defName: string, defSchema: JsonSchema) => string | undefined;
|
|
50
91
|
/**
|
|
51
92
|
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
52
93
|
*
|
|
@@ -60,33 +101,32 @@ interface OpenAPIGeneratorGenerateOptions {
|
|
|
60
101
|
*
|
|
61
102
|
* @remarks
|
|
62
103
|
* - Return `null | undefined` to use the default error response body shaper.
|
|
104
|
+
* - The schema is an OpenAPI 3.2 Schema Object, it is downgraded with the rest of the document when an older `version` is requested.
|
|
63
105
|
*/
|
|
64
106
|
customErrorResponseBodySchema?: Value<JsonSchema | undefined | null, [
|
|
65
|
-
definedErrors:
|
|
66
|
-
code: string;
|
|
67
|
-
defaultMessage: string | undefined;
|
|
68
|
-
dataOptional: boolean;
|
|
69
|
-
dataJsonSchema: JsonSchema;
|
|
70
|
-
}[],
|
|
107
|
+
definedErrors: OpenAPIErrorBodyDefinition[],
|
|
71
108
|
status: number
|
|
72
109
|
]>;
|
|
73
110
|
/**
|
|
74
111
|
* Mapping ORPCError Code -> HTTP Status Code
|
|
75
112
|
*
|
|
76
|
-
* @default COMMON_ERROR_STATUS_MAP
|
|
113
|
+
* @default COMMON_ERROR_STATUS_MAP
|
|
77
114
|
*/
|
|
78
115
|
errorStatusMap?: Record<string, number> | undefined;
|
|
79
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Generates an OpenAPI document from a contract or router.
|
|
119
|
+
* Relies on JSON schema converters to translate input, output, and error schemas into JSON Schemas.
|
|
120
|
+
*
|
|
121
|
+
* @see {@link https://orpc.dev/docs/openapi/specification#openapi-generator | OpenAPI Specification - OpenAPI Generator}
|
|
122
|
+
*/
|
|
80
123
|
declare class OpenAPIGenerator {
|
|
81
124
|
private readonly serializer;
|
|
82
125
|
private readonly converter;
|
|
83
126
|
constructor(options?: OpenAPIGeneratorOptions);
|
|
84
|
-
generate(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPIDocument
|
|
127
|
+
generate<TVersion extends OpenAPIVersion = '3.2.0'>(router: RouterContract | AnyRouter, options?: OpenAPIGeneratorGenerateOptions<TVersion>): Promise<OpenAPIDocument<TVersion>>;
|
|
85
128
|
private convertSchema;
|
|
86
129
|
private convertSchemas;
|
|
87
|
-
private request;
|
|
88
|
-
private successResponse;
|
|
89
|
-
private errorResponse;
|
|
90
130
|
}
|
|
91
131
|
|
|
92
132
|
type PopulatedContractRouterOpenAPIPaths<T extends RouterContract> = T extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrors> ? ProcedureContract<UInputSchema, UOutputSchema, UErrors> : {
|
|
@@ -103,18 +143,10 @@ interface PopulateRouterContractOpenAPIPathsOptions {
|
|
|
103
143
|
*
|
|
104
144
|
* Builds paths by joining router keys with `/`.
|
|
105
145
|
* Useful when you want to ensure all contracts define openapi.path, such as for NestJS integration requirements.
|
|
146
|
+
*
|
|
147
|
+
* @see {@link https://orpc.dev/docs/integrations/nest | Implement oRPC contract with NestJS}
|
|
106
148
|
*/
|
|
107
149
|
declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
|
|
108
150
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*/
|
|
112
|
-
declare function getDynamicPathParams(path: `/${string}`): {
|
|
113
|
-
segment: string;
|
|
114
|
-
startIndex: number;
|
|
115
|
-
parameterName: string;
|
|
116
|
-
allowsSlash: boolean;
|
|
117
|
-
}[] | undefined;
|
|
118
|
-
|
|
119
|
-
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, JsonifiedClientError, JsonifiedValue, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, createContractJsonifiedCaller, getDynamicPathParams, populateRouterContractOpenAPIPaths };
|
|
120
|
-
export type { ContractJsonifiedCaller, ContractJsonifiedCallerOptions, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
|
|
151
|
+
export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPISerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, isBodylessMethod, populateRouterContractOpenAPIPaths };
|
|
152
|
+
export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
|