@orpc/openapi-client 1.10.0 → 1.10.2

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.
@@ -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.Cv0hBP4Y.mjs';
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';
@@ -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.Cv0hBP4Y.js';
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';
@@ -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.InKGcjFv.mjs';
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.Cv0hBP4Y.mjs';
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.Cv0hBP4Y.js';
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.InKGcjFv.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.B2Q9qU5m.mjs';
4
4
  import '@orpc/shared';
5
5
  import '@orpc/contract';
6
6
  import '@orpc/client/standard';
@@ -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, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
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, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/openapi-client",
3
3
  "type": "module",
4
- "version": "1.10.0",
4
+ "version": "1.10.2",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -39,13 +39,13 @@
39
39
  "dist"
40
40
  ],
41
41
  "dependencies": {
42
- "@orpc/client": "1.10.0",
43
- "@orpc/standard-server": "1.10.0",
44
- "@orpc/shared": "1.10.0",
45
- "@orpc/contract": "1.10.0"
42
+ "@orpc/client": "1.10.2",
43
+ "@orpc/contract": "1.10.2",
44
+ "@orpc/shared": "1.10.2",
45
+ "@orpc/standard-server": "1.10.2"
46
46
  },
47
47
  "devDependencies": {
48
- "@orpc/server": "1.10.0"
48
+ "@orpc/server": "1.10.2"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "unbuild",