@orpc/openapi-client 1.15.6 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/fetch/index.mjs +1 -1
- package/dist/adapters/standard/index.d.mts +8 -1
- package/dist/adapters/standard/index.d.ts +8 -1
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/shared/{openapi-client.B2Q9qU5m.mjs → openapi-client.DgkI_tTF.mjs} +16 -6
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LinkFetchClient } from '@orpc/client/fetch';
|
|
2
|
-
import { a as StandardOpenAPILink } from '../../shared/openapi-client.
|
|
2
|
+
import { a as StandardOpenAPILink } from '../../shared/openapi-client.DgkI_tTF.mjs';
|
|
3
3
|
import '@orpc/client/standard';
|
|
4
4
|
import '../../shared/openapi-client.t9fCAe3x.mjs';
|
|
5
5
|
import '@orpc/shared';
|
|
@@ -6,6 +6,13 @@ import '@orpc/contract';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@orpc/standard-server';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* OpenAPIHandler v2 omits `status` from error JSON, so fill it in
|
|
11
|
+
* (from `status`, or from the error code when omitted) to let v2 errors pass `isORPCErrorJson`.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
declare function fillORPCErrorJsonStatus(json: unknown, status?: number): unknown;
|
|
9
16
|
/**
|
|
10
17
|
* @internal
|
|
11
18
|
*/
|
|
@@ -18,4 +25,4 @@ declare function getDynamicParams(path: HTTPPath | undefined): {
|
|
|
18
25
|
name: string;
|
|
19
26
|
}[] | undefined;
|
|
20
27
|
|
|
21
|
-
export { getDynamicParams, standardizeHTTPPath };
|
|
28
|
+
export { fillORPCErrorJsonStatus, getDynamicParams, standardizeHTTPPath };
|
|
@@ -6,6 +6,13 @@ import '@orpc/contract';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@orpc/standard-server';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* OpenAPIHandler v2 omits `status` from error JSON, so fill it in
|
|
11
|
+
* (from `status`, or from the error code when omitted) to let v2 errors pass `isORPCErrorJson`.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
declare function fillORPCErrorJsonStatus(json: unknown, status?: number): unknown;
|
|
9
16
|
/**
|
|
10
17
|
* @internal
|
|
11
18
|
*/
|
|
@@ -18,4 +25,4 @@ declare function getDynamicParams(path: HTTPPath | undefined): {
|
|
|
18
25
|
name: string;
|
|
19
26
|
}[] | undefined;
|
|
20
27
|
|
|
21
|
-
export { getDynamicParams, standardizeHTTPPath };
|
|
28
|
+
export { fillORPCErrorJsonStatus, getDynamicParams, standardizeHTTPPath };
|
|
@@ -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, f as fillORPCErrorJsonStatus, g as getDynamicParams, s as standardizeHTTPPath } from '../../shared/openapi-client.DgkI_tTF.mjs';
|
|
4
4
|
import '@orpc/shared';
|
|
5
5
|
import '@orpc/contract';
|
|
6
6
|
import '@orpc/client/standard';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toStandardHeaders, toHttpPath, getMalformedResponseErrorCode, StandardLink } from '@orpc/client/standard';
|
|
2
2
|
import { S as StandardBracketNotationSerializer } from './openapi-client.t9fCAe3x.mjs';
|
|
3
3
|
import { isObject, value, get, isAsyncIteratorObject } from '@orpc/shared';
|
|
4
|
-
import { isORPCErrorStatus, isORPCErrorJson, createORPCErrorFromJson, mapEventIterator, toORPCError } from '@orpc/client';
|
|
4
|
+
import { fallbackORPCErrorStatus, isORPCErrorStatus, isORPCErrorJson, createORPCErrorFromJson, mapEventIterator, toORPCError } from '@orpc/client';
|
|
5
5
|
import { isContractProcedure, fallbackContractConfig, ORPCError } from '@orpc/contract';
|
|
6
6
|
import { mergeStandardHeaders, ErrorEvent } from '@orpc/standard-server';
|
|
7
7
|
|
|
@@ -54,6 +54,12 @@ class StandardOpenAPIJsonSerializer {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
function fillORPCErrorJsonStatus(json, status) {
|
|
58
|
+
if (!isObject(json) || json.status !== void 0 || typeof json.code !== "string") {
|
|
59
|
+
return json;
|
|
60
|
+
}
|
|
61
|
+
return { ...json, status: fallbackORPCErrorStatus(json.code, status) };
|
|
62
|
+
}
|
|
57
63
|
function standardizeHTTPPath(path) {
|
|
58
64
|
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
59
65
|
}
|
|
@@ -200,8 +206,9 @@ class StandardOpenapiLinkCodec {
|
|
|
200
206
|
if (error !== null && error !== void 0) {
|
|
201
207
|
throw error;
|
|
202
208
|
}
|
|
203
|
-
|
|
204
|
-
|
|
209
|
+
const errorJson = fillORPCErrorJsonStatus(deserialized, response.status);
|
|
210
|
+
if (isORPCErrorJson(errorJson)) {
|
|
211
|
+
throw createORPCErrorFromJson(errorJson);
|
|
205
212
|
}
|
|
206
213
|
throw new ORPCError(getMalformedResponseErrorCode(response.status), {
|
|
207
214
|
status: response.status,
|
|
@@ -278,8 +285,11 @@ class StandardOpenAPISerializer {
|
|
|
278
285
|
return mapEventIterator(data, {
|
|
279
286
|
value: async (value) => value,
|
|
280
287
|
error: async (e) => {
|
|
281
|
-
if (e instanceof ErrorEvent
|
|
282
|
-
|
|
288
|
+
if (e instanceof ErrorEvent) {
|
|
289
|
+
const errorJson = fillORPCErrorJsonStatus(e.data);
|
|
290
|
+
if (isORPCErrorJson(errorJson)) {
|
|
291
|
+
return createORPCErrorFromJson(errorJson, { cause: e });
|
|
292
|
+
}
|
|
283
293
|
}
|
|
284
294
|
return e;
|
|
285
295
|
}
|
|
@@ -299,4 +309,4 @@ class StandardOpenAPILink extends StandardLink {
|
|
|
299
309
|
}
|
|
300
310
|
}
|
|
301
311
|
|
|
302
|
-
export { StandardOpenAPIJsonSerializer as S, StandardOpenAPILink as a, StandardOpenapiLinkCodec as b, StandardOpenAPISerializer as c, getDynamicParams as g, standardizeHTTPPath as s };
|
|
312
|
+
export { StandardOpenAPIJsonSerializer as S, StandardOpenAPILink as a, StandardOpenapiLinkCodec as b, StandardOpenAPISerializer as c, fillORPCErrorJsonStatus as f, getDynamicParams as g, standardizeHTTPPath as s };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi-client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orpc/contract": "1.
|
|
43
|
-
"@orpc/
|
|
44
|
-
"@orpc/
|
|
45
|
-
"@orpc/standard-server": "1.
|
|
42
|
+
"@orpc/contract": "1.16.0",
|
|
43
|
+
"@orpc/shared": "1.16.0",
|
|
44
|
+
"@orpc/client": "1.16.0",
|
|
45
|
+
"@orpc/standard-server": "1.16.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@orpc/server": "1.
|
|
48
|
+
"@orpc/server": "1.16.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "unbuild",
|