@orpc/openapi-client 0.0.0-next.b12bcdb → 0.0.0-next.b2d00a3
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 +5 -2
- package/dist/adapters/fetch/index.d.mts +2 -2
- package/dist/adapters/fetch/index.d.ts +2 -2
- package/dist/adapters/fetch/index.mjs +1 -1
- package/dist/adapters/standard/index.d.mts +1 -1
- package/dist/adapters/standard/index.d.ts +1 -1
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.d.ts +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared/{openapi-client.InKGcjFv.mjs → openapi-client.B2Q9qU5m.mjs} +6 -0
- package/dist/shared/{openapi-client.Cv0hBP4Y.d.mts → openapi-client.Dx4REA6z.d.mts} +12 -2
- package/dist/shared/{openapi-client.Cv0hBP4Y.d.ts → openapi-client.Dx4REA6z.d.ts} +12 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<image align="center" src="https://orpc.
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<h1></h1>
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
45
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
46
49
|
|
|
47
50
|
## Packages
|
|
48
51
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientContext } from '@orpc/client';
|
|
2
2
|
import { LinkFetchClientOptions } from '@orpc/client/fetch';
|
|
3
3
|
import { AnyContractRouter } from '@orpc/contract';
|
|
4
|
-
import { g as StandardOpenAPILinkOptions, h as StandardOpenAPILink } from '../../shared/openapi-client.
|
|
4
|
+
import { g as StandardOpenAPILinkOptions, h as StandardOpenAPILink } from '../../shared/openapi-client.Dx4REA6z.mjs';
|
|
5
5
|
import '@orpc/client/standard';
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@orpc/standard-server';
|
|
@@ -11,7 +11,7 @@ interface OpenAPILinkOptions<T extends ClientContext> extends LinkFetchClientOpt
|
|
|
11
11
|
/**
|
|
12
12
|
* The OpenAPI Link for fetch runtime communicates with the server that follow the OpenAPI specification.
|
|
13
13
|
*
|
|
14
|
-
* @see {@link https://orpc.
|
|
14
|
+
* @see {@link https://orpc.dev/docs/openapi/client/openapi-link OpenAPI Link Docs}
|
|
15
15
|
* @see {@link https://swagger.io/specification/ OpenAPI Specification}
|
|
16
16
|
*/
|
|
17
17
|
declare class OpenAPILink<T extends ClientContext> extends StandardOpenAPILink<T> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientContext } from '@orpc/client';
|
|
2
2
|
import { LinkFetchClientOptions } from '@orpc/client/fetch';
|
|
3
3
|
import { AnyContractRouter } from '@orpc/contract';
|
|
4
|
-
import { g as StandardOpenAPILinkOptions, h as StandardOpenAPILink } from '../../shared/openapi-client.
|
|
4
|
+
import { g as StandardOpenAPILinkOptions, h as StandardOpenAPILink } from '../../shared/openapi-client.Dx4REA6z.js';
|
|
5
5
|
import '@orpc/client/standard';
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@orpc/standard-server';
|
|
@@ -11,7 +11,7 @@ interface OpenAPILinkOptions<T extends ClientContext> extends LinkFetchClientOpt
|
|
|
11
11
|
/**
|
|
12
12
|
* The OpenAPI Link for fetch runtime communicates with the server that follow the OpenAPI specification.
|
|
13
13
|
*
|
|
14
|
-
* @see {@link https://orpc.
|
|
14
|
+
* @see {@link https://orpc.dev/docs/openapi/client/openapi-link OpenAPI Link Docs}
|
|
15
15
|
* @see {@link https://swagger.io/specification/ OpenAPI Specification}
|
|
16
16
|
*/
|
|
17
17
|
declare class OpenAPILink<T extends ClientContext> extends StandardOpenAPILink<T> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LinkFetchClient } from '@orpc/client/fetch';
|
|
2
2
|
import '@orpc/shared';
|
|
3
3
|
import '@orpc/contract';
|
|
4
|
-
import { a as StandardOpenAPILink } from '../../shared/openapi-client.
|
|
4
|
+
import { a as StandardOpenAPILink } from '../../shared/openapi-client.B2Q9qU5m.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/client/standard';
|
|
7
7
|
import '@orpc/standard-server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as StandardBracketNotationSerialized, b as StandardBracketNotationSerializer, a as StandardBracketNotationSerializerOptions, d as StandardOpenAPICustomJsonSerializer, c as StandardOpenAPIJsonSerialized, f as StandardOpenAPIJsonSerializer, e as StandardOpenAPIJsonSerializerOptions, h as StandardOpenAPILink, g as StandardOpenAPILinkOptions, k as StandardOpenAPISerializeOptions, l as StandardOpenAPISerializer, j as StandardOpenapiLinkCodec, i as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.
|
|
1
|
+
export { S as StandardBracketNotationSerialized, b as StandardBracketNotationSerializer, a as StandardBracketNotationSerializerOptions, d as StandardOpenAPICustomJsonSerializer, c as StandardOpenAPIJsonSerialized, f as StandardOpenAPIJsonSerializer, e as StandardOpenAPIJsonSerializerOptions, h as StandardOpenAPILink, g as StandardOpenAPILinkOptions, k as StandardOpenAPISerializeOptions, l as StandardOpenAPISerializer, j as StandardOpenapiLinkCodec, i as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.Dx4REA6z.mjs';
|
|
2
2
|
export { getIssueMessage, parseFormData } from '../../helpers/index.mjs';
|
|
3
3
|
import { HTTPPath } from '@orpc/client';
|
|
4
4
|
import '@orpc/client/standard';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as StandardBracketNotationSerialized, b as StandardBracketNotationSerializer, a as StandardBracketNotationSerializerOptions, d as StandardOpenAPICustomJsonSerializer, c as StandardOpenAPIJsonSerialized, f as StandardOpenAPIJsonSerializer, e as StandardOpenAPIJsonSerializerOptions, h as StandardOpenAPILink, g as StandardOpenAPILinkOptions, k as StandardOpenAPISerializeOptions, l as StandardOpenAPISerializer, j as StandardOpenapiLinkCodec, i as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.
|
|
1
|
+
export { S as StandardBracketNotationSerialized, b as StandardBracketNotationSerializer, a as StandardBracketNotationSerializerOptions, d as StandardOpenAPICustomJsonSerializer, c as StandardOpenAPIJsonSerialized, f as StandardOpenAPIJsonSerializer, e as StandardOpenAPIJsonSerializerOptions, h as StandardOpenAPILink, g as StandardOpenAPILinkOptions, k as StandardOpenAPISerializeOptions, l as StandardOpenAPISerializer, j as StandardOpenapiLinkCodec, i as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.Dx4REA6z.js';
|
|
2
2
|
export { getIssueMessage, parseFormData } from '../../helpers/index.js';
|
|
3
3
|
import { HTTPPath } from '@orpc/client';
|
|
4
4
|
import '@orpc/client/standard';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { S as StandardBracketNotationSerializer } from '../../shared/openapi-client.t9fCAe3x.mjs';
|
|
2
2
|
export { g as getIssueMessage, p as parseFormData } from '../../shared/openapi-client.Dgl8z2tb.mjs';
|
|
3
|
-
export { S as StandardOpenAPIJsonSerializer, a as StandardOpenAPILink, c as StandardOpenAPISerializer, b as StandardOpenapiLinkCodec, g as getDynamicParams, s as standardizeHTTPPath } from '../../shared/openapi-client.
|
|
3
|
+
export { S as StandardOpenAPIJsonSerializer, a as StandardOpenAPILink, c as StandardOpenAPISerializer, b as StandardOpenapiLinkCodec, g as getDynamicParams, s as standardizeHTTPPath } from '../../shared/openapi-client.B2Q9qU5m.mjs';
|
|
4
4
|
import '@orpc/shared';
|
|
5
5
|
import '@orpc/contract';
|
|
6
6
|
import '@orpc/client/standard';
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
* // }
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
|
-
* @see {@link https://orpc.
|
|
27
|
+
* @see {@link https://orpc.dev/docs/openapi/bracket-notation Bracket Notation Docs}
|
|
28
28
|
*/
|
|
29
29
|
declare function parseFormData(form: FormData): any;
|
|
30
30
|
/**
|
|
31
31
|
* Get the issue message from the error.
|
|
32
32
|
*
|
|
33
33
|
* @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
|
|
34
|
-
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.
|
|
34
|
+
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```tsx
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
* // }
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
|
-
* @see {@link https://orpc.
|
|
27
|
+
* @see {@link https://orpc.dev/docs/openapi/bracket-notation Bracket Notation Docs}
|
|
28
28
|
*/
|
|
29
29
|
declare function parseFormData(form: FormData): any;
|
|
30
30
|
/**
|
|
31
31
|
* Get the issue message from the error.
|
|
32
32
|
*
|
|
33
33
|
* @param error - The error (can be anything) can contain `data.issues` (standard schema issues)
|
|
34
|
-
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.
|
|
34
|
+
* @param path - The path of the field that has the issue follow [bracket notation](https://orpc.dev/docs/openapi/bracket-notation)
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```tsx
|
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ type JsonifiedArray<T extends Array<unknown>> = T extends readonly [] ? [] : T e
|
|
|
7
7
|
/**
|
|
8
8
|
* Convert types that JSON not support to corresponding json types
|
|
9
9
|
*
|
|
10
|
-
* @see {@link https://orpc.
|
|
10
|
+
* @see {@link https://orpc.dev/docs/openapi/client/openapi-link OpenAPI Link Docs}
|
|
11
11
|
*/
|
|
12
12
|
type JsonifiedClient<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, UError extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : UError> : {
|
|
13
13
|
[K in keyof T]: T[K] extends NestedClient<any> ? JsonifiedClient<T[K]> : T[K];
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ type JsonifiedArray<T extends Array<unknown>> = T extends readonly [] ? [] : T e
|
|
|
7
7
|
/**
|
|
8
8
|
* Convert types that JSON not support to corresponding json types
|
|
9
9
|
*
|
|
10
|
-
* @see {@link https://orpc.
|
|
10
|
+
* @see {@link https://orpc.dev/docs/openapi/client/openapi-link OpenAPI Link Docs}
|
|
11
11
|
*/
|
|
12
12
|
type JsonifiedClient<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, UError extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : UError> : {
|
|
13
13
|
[K in keyof T]: T[K] extends NestedClient<any> ? JsonifiedClient<T[K]> : T[K];
|
|
@@ -70,9 +70,11 @@ class StandardOpenapiLinkCodec {
|
|
|
70
70
|
this.serializer = serializer;
|
|
71
71
|
this.baseUrl = options.url;
|
|
72
72
|
this.headers = options.headers ?? {};
|
|
73
|
+
this.customErrorResponseBodyDecoder = options.customErrorResponseBodyDecoder;
|
|
73
74
|
}
|
|
74
75
|
baseUrl;
|
|
75
76
|
headers;
|
|
77
|
+
customErrorResponseBodyDecoder;
|
|
76
78
|
async encode(path, input, options) {
|
|
77
79
|
let headers = toStandardHeaders(await value(this.headers, options, path, input));
|
|
78
80
|
if (options.lastEventId !== void 0) {
|
|
@@ -194,6 +196,10 @@ class StandardOpenapiLinkCodec {
|
|
|
194
196
|
}
|
|
195
197
|
})();
|
|
196
198
|
if (!isOk) {
|
|
199
|
+
const error = this.customErrorResponseBodyDecoder?.(deserialized, response);
|
|
200
|
+
if (error !== null && error !== void 0) {
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
197
203
|
if (isORPCErrorJson(deserialized)) {
|
|
198
204
|
throw createORPCErrorFromJson(deserialized);
|
|
199
205
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '@orpc/client';
|
|
2
2
|
import { StandardLinkCodec, StandardLinkOptions, StandardLink, StandardLinkClient } from '@orpc/client/standard';
|
|
3
|
-
import { AnyContractRouter } from '@orpc/contract';
|
|
3
|
+
import { ORPCError, AnyContractRouter } from '@orpc/contract';
|
|
4
4
|
import { Segment, Value, Promisable } from '@orpc/shared';
|
|
5
|
-
import { StandardHeaders,
|
|
5
|
+
import { StandardHeaders, StandardLazyResponse, StandardRequest } from '@orpc/standard-server';
|
|
6
6
|
|
|
7
7
|
type StandardBracketNotationSerialized = [string, unknown][];
|
|
8
8
|
interface StandardBracketNotationSerializerOptions {
|
|
@@ -75,6 +75,15 @@ interface StandardOpenapiLinkCodecOptions<T extends ClientContext> {
|
|
|
75
75
|
path: readonly string[],
|
|
76
76
|
input: unknown
|
|
77
77
|
]>;
|
|
78
|
+
/**
|
|
79
|
+
* Customize how a response body is decoded into an ORPC error.
|
|
80
|
+
* Useful when the default decoder cannot fully interpret
|
|
81
|
+
* your server's error format.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* - Return `null | undefined` to fallback to default behavior.
|
|
85
|
+
*/
|
|
86
|
+
customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => ORPCError<any, any> | null | undefined;
|
|
78
87
|
}
|
|
79
88
|
declare class StandardOpenapiLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
80
89
|
#private;
|
|
@@ -82,6 +91,7 @@ declare class StandardOpenapiLinkCodec<T extends ClientContext> implements Stand
|
|
|
82
91
|
private readonly serializer;
|
|
83
92
|
private readonly baseUrl;
|
|
84
93
|
private readonly headers;
|
|
94
|
+
private readonly customErrorResponseBodyDecoder;
|
|
85
95
|
constructor(contract: AnyContractRouter, serializer: StandardOpenAPISerializer, options: StandardOpenapiLinkCodecOptions<T>);
|
|
86
96
|
encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
|
|
87
97
|
decode(response: StandardLazyResponse, _options: ClientOptions<T>, path: readonly string[]): Promise<unknown>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '@orpc/client';
|
|
2
2
|
import { StandardLinkCodec, StandardLinkOptions, StandardLink, StandardLinkClient } from '@orpc/client/standard';
|
|
3
|
-
import { AnyContractRouter } from '@orpc/contract';
|
|
3
|
+
import { ORPCError, AnyContractRouter } from '@orpc/contract';
|
|
4
4
|
import { Segment, Value, Promisable } from '@orpc/shared';
|
|
5
|
-
import { StandardHeaders,
|
|
5
|
+
import { StandardHeaders, StandardLazyResponse, StandardRequest } from '@orpc/standard-server';
|
|
6
6
|
|
|
7
7
|
type StandardBracketNotationSerialized = [string, unknown][];
|
|
8
8
|
interface StandardBracketNotationSerializerOptions {
|
|
@@ -75,6 +75,15 @@ interface StandardOpenapiLinkCodecOptions<T extends ClientContext> {
|
|
|
75
75
|
path: readonly string[],
|
|
76
76
|
input: unknown
|
|
77
77
|
]>;
|
|
78
|
+
/**
|
|
79
|
+
* Customize how a response body is decoded into an ORPC error.
|
|
80
|
+
* Useful when the default decoder cannot fully interpret
|
|
81
|
+
* your server's error format.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* - Return `null | undefined` to fallback to default behavior.
|
|
85
|
+
*/
|
|
86
|
+
customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => ORPCError<any, any> | null | undefined;
|
|
78
87
|
}
|
|
79
88
|
declare class StandardOpenapiLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
80
89
|
#private;
|
|
@@ -82,6 +91,7 @@ declare class StandardOpenapiLinkCodec<T extends ClientContext> implements Stand
|
|
|
82
91
|
private readonly serializer;
|
|
83
92
|
private readonly baseUrl;
|
|
84
93
|
private readonly headers;
|
|
94
|
+
private readonly customErrorResponseBodyDecoder;
|
|
85
95
|
constructor(contract: AnyContractRouter, serializer: StandardOpenAPISerializer, options: StandardOpenapiLinkCodecOptions<T>);
|
|
86
96
|
encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
|
|
87
97
|
decode(response: StandardLazyResponse, _options: ClientOptions<T>, path: readonly string[]): Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi-client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.b2d00a3",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/unnoq/orpc.git",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orpc/client": "0.0.0-next.
|
|
43
|
-
"@orpc/contract": "0.0.0-next.
|
|
44
|
-
"@orpc/
|
|
45
|
-
"@orpc/
|
|
42
|
+
"@orpc/client": "0.0.0-next.b2d00a3",
|
|
43
|
+
"@orpc/contract": "0.0.0-next.b2d00a3",
|
|
44
|
+
"@orpc/shared": "0.0.0-next.b2d00a3",
|
|
45
|
+
"@orpc/standard-server": "0.0.0-next.b2d00a3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@orpc/server": "0.0.0-next.
|
|
48
|
+
"@orpc/server": "0.0.0-next.b2d00a3"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "unbuild",
|