@orpc/client 2.0.0-beta.49 → 2.0.0-beta.50

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.
Files changed (75) hide show
  1. package/dist/adapters/fetch/index.d.ts +3 -2
  2. package/dist/adapters/fetch/index.js +2 -2
  3. package/dist/adapters/fetch/rpc-link.d.ts +8 -8
  4. package/dist/adapters/fetch/rpc-link.js +16 -13
  5. package/dist/adapters/fetch/transport.d.ts +29 -31
  6. package/dist/adapters/fetch/transport.js +49 -63
  7. package/dist/adapters/message-port/index.d.ts +4 -3
  8. package/dist/adapters/message-port/index.js +3 -3
  9. package/dist/adapters/message-port/message-port.d.ts +13 -13
  10. package/dist/adapters/message-port/message-port.js +35 -53
  11. package/dist/adapters/message-port/rpc-link.d.ts +8 -8
  12. package/dist/adapters/message-port/rpc-link.js +17 -14
  13. package/dist/adapters/message-port/transport.d.ts +31 -34
  14. package/dist/adapters/message-port/transport.js +38 -52
  15. package/dist/adapters/standard/codec.d.ts +10 -10
  16. package/dist/adapters/standard/index.d.ts +6 -5
  17. package/dist/adapters/standard/index.js +2 -4
  18. package/dist/adapters/standard/link.d.ts +31 -31
  19. package/dist/adapters/standard/link.js +101 -85
  20. package/dist/adapters/standard/plugin.d.ts +25 -31
  21. package/dist/adapters/standard/plugin.js +14 -16
  22. package/dist/adapters/standard/rpc-link-codec.d.ts +53 -60
  23. package/dist/adapters/standard/rpc-link-codec.js +98 -102
  24. package/dist/adapters/standard/transport.d.ts +7 -7
  25. package/dist/adapters/websocket/index.d.ts +3 -2
  26. package/dist/adapters/websocket/index.js +2 -2
  27. package/dist/adapters/websocket/rpc-link.d.ts +8 -8
  28. package/dist/adapters/websocket/rpc-link.js +16 -13
  29. package/dist/adapters/websocket/transport.d.ts +101 -100
  30. package/dist/adapters/websocket/transport.js +102 -130
  31. package/dist/async-iterator-object.d.ts +2 -2
  32. package/dist/async-iterator-object.js +27 -28
  33. package/dist/client-safe.d.ts +4 -6
  34. package/dist/client-safe.js +29 -34
  35. package/dist/client.d.ts +24 -26
  36. package/dist/client.js +35 -37
  37. package/dist/consts.d.ts +1 -1
  38. package/dist/consts.js +18 -41
  39. package/dist/dynamic-link.d.ts +6 -6
  40. package/dist/dynamic-link.js +16 -16
  41. package/dist/error-utils.d.ts +3 -4
  42. package/dist/error-utils.js +47 -51
  43. package/dist/error.d.ts +79 -79
  44. package/dist/error.js +154 -166
  45. package/dist/index.d.ts +14 -53
  46. package/dist/index.js +12 -40
  47. package/dist/plugins/batch.d.ts +122 -155
  48. package/dist/plugins/batch.js +320 -391
  49. package/dist/plugins/cookie-jar.d.ts +64 -61
  50. package/dist/plugins/cookie-jar.js +208 -245
  51. package/dist/plugins/dedupe.d.ts +49 -53
  52. package/dist/plugins/dedupe.js +168 -211
  53. package/dist/plugins/index.d.ts +9 -28
  54. package/dist/plugins/index.js +8 -23
  55. package/dist/plugins/request-compression.d.ts +38 -35
  56. package/dist/plugins/request-compression.js +131 -177
  57. package/dist/plugins/response-compression.d.ts +21 -18
  58. package/dist/plugins/response-compression.js +64 -88
  59. package/dist/plugins/retry-after.d.ts +31 -38
  60. package/dist/plugins/retry-after.js +60 -85
  61. package/dist/plugins/retry.d.ts +55 -55
  62. package/dist/plugins/retry.js +118 -137
  63. package/dist/plugins/timeout.d.ts +19 -17
  64. package/dist/plugins/timeout.js +41 -36
  65. package/dist/rpc-json-serializer.d.ts +84 -84
  66. package/dist/rpc-json-serializer.js +338 -383
  67. package/dist/rpc-serializer.d.ts +20 -21
  68. package/dist/rpc-serializer.js +97 -125
  69. package/dist/types.d.ts +19 -31
  70. package/dist/utils.d.ts +18 -29
  71. package/dist/utils.js +63 -47
  72. package/package.json +5 -5
  73. package/dist/adapters/standard/codec.js +0 -1
  74. package/dist/adapters/standard/transport.js +0 -1
  75. package/dist/types.js +0 -1
package/dist/error.js CHANGED
@@ -1,178 +1,166 @@
1
- import { getConstructors, isPlainObject, resolveMaybeOptionalOptions } from '@orpc/shared';
1
+ import { getConstructors, isPlainObject, resolveMaybeOptionalOptions } from "@orpc/shared";
2
+ // src/error.ts
2
3
  /**
3
- * Default mapping between common oRPC error codes and HTTP status codes.
4
- * Handlers use it to determine response status codes; spread it to build a custom `errorStatusMap`.
5
- *
6
- * @see {@link https://orpc.dev/docs/rpc/handler#custom-error-response | RPC Handler - Custom Error Response}
7
- * @see {@link https://orpc.dev/docs/openapi/handler#custom-error-response | OpenAPI Handler - Custom Error Response}
8
- */
9
- export const COMMON_ERROR_STATUS_MAP = {
10
- BAD_REQUEST: 400,
11
- UNAUTHORIZED: 401,
12
- PAYMENT_REQUIRED: 402,
13
- FORBIDDEN: 403,
14
- NOT_FOUND: 404,
15
- METHOD_NOT_SUPPORTED: 405,
16
- NOT_ACCEPTABLE: 406,
17
- TIMEOUT: 408,
18
- CONFLICT: 409,
19
- GONE: 410,
20
- LENGTH_REQUIRED: 411,
21
- PRECONDITION_FAILED: 412,
22
- PAYLOAD_TOO_LARGE: 413,
23
- UNSUPPORTED_MEDIA_TYPE: 415,
24
- UNPROCESSABLE_CONTENT: 422,
25
- PRECONDITION_REQUIRED: 428,
26
- TOO_MANY_REQUESTS: 429,
27
- CLIENT_CLOSED_REQUEST: 499,
28
- INTERNAL_SERVER_ERROR: 500,
29
- NOT_IMPLEMENTED: 501,
30
- BAD_GATEWAY: 502,
31
- SERVICE_UNAVAILABLE: 503,
32
- GATEWAY_TIMEOUT: 504,
4
+ * Default mapping between common oRPC error codes and HTTP status codes.
5
+ * Handlers use it to determine response status codes; spread it to build a custom `errorStatusMap`.
6
+ *
7
+ * @see {@link https://orpc.dev/docs/rpc/handler#custom-error-response | RPC Handler - Custom Error Response}
8
+ * @see {@link https://orpc.dev/docs/openapi/handler#custom-error-response | OpenAPI Handler - Custom Error Response}
9
+ */
10
+ const COMMON_ERROR_STATUS_MAP = {
11
+ BAD_REQUEST: 400,
12
+ UNAUTHORIZED: 401,
13
+ PAYMENT_REQUIRED: 402,
14
+ FORBIDDEN: 403,
15
+ NOT_FOUND: 404,
16
+ METHOD_NOT_SUPPORTED: 405,
17
+ NOT_ACCEPTABLE: 406,
18
+ TIMEOUT: 408,
19
+ CONFLICT: 409,
20
+ GONE: 410,
21
+ LENGTH_REQUIRED: 411,
22
+ PRECONDITION_FAILED: 412,
23
+ PAYLOAD_TOO_LARGE: 413,
24
+ UNSUPPORTED_MEDIA_TYPE: 415,
25
+ UNPROCESSABLE_CONTENT: 422,
26
+ PRECONDITION_REQUIRED: 428,
27
+ TOO_MANY_REQUESTS: 429,
28
+ CLIENT_CLOSED_REQUEST: 499,
29
+ INTERNAL_SERVER_ERROR: 500,
30
+ NOT_IMPLEMENTED: 501,
31
+ BAD_GATEWAY: 502,
32
+ SERVICE_UNAVAILABLE: 503,
33
+ GATEWAY_TIMEOUT: 504
33
34
  };
34
35
  let ORPCErrorConstructors;
35
36
  /**
36
- * Typed error carrying a `code`, a `message`, and optional `data`.
37
- * Throw it from handlers or middleware to produce typed error responses on the client.
38
- *
39
- * @see {@link https://orpc.dev/docs/error-handling#orpcerror-class | Error Handling - ORPCError Class}
40
- */
41
- export class ORPCError extends Error {
42
- /**
43
- * Placed inside a static block (rather than at module level) to ensure this
44
- * registration is treated as part of the class definition by bundlers.
45
- *
46
- * With `"sideEffects": false` in package.json, bundlers like webpack/Rollup
47
- * are allowed to tree-shake any module-level statements that appear to have
48
- * no consumers. A free-floating `globalORPCErrorConstructors.add(ORPCError)`
49
- * at module level could be dropped entirely if the bundler decides the module
50
- * is only partially used.
51
- *
52
- * By placing this inside `static {}`, the registration becomes inseparable
53
- * from the class body itself — a bundler cannot include `ORPCError` without
54
- * executing this block.
55
- *
56
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Static_initialization_blocks
57
- */
58
- static {
59
- /**
60
- * Store all ORPCError constructors
61
- * for workaround of instanceof check in case multiple dependency graphs exist
62
- */
63
- const ORPC_ERROR_CONSTRUCTORS_SYMBOL = Symbol.for('ORPC_ERROR_CONSTRUCTORS');
64
- void (globalThis[ORPC_ERROR_CONSTRUCTORS_SYMBOL] ??= new WeakSet());
65
- ORPCErrorConstructors = globalThis[ORPC_ERROR_CONSTRUCTORS_SYMBOL];
66
- ORPCErrorConstructors.add(ORPCError);
67
- }
68
- /**
69
- * @remarks
70
- * **Note**: The `__branch` property is used for type branding, helping TypeScript distinguish
71
- * an `ORPCError` instance from plain objects with a similar structure.
72
- */
73
- name = 'ORPCError';
74
- /**
75
- * Indicates whether the error matches a definition in the procedure's `.errors` map,
76
- * which makes its type inferable on the client.
77
- */
78
- defined = false;
79
- code;
80
- data;
81
- constructor(code, ...rest) {
82
- const options = resolveMaybeOptionalOptions(rest);
83
- const message = options.message ?? codeToMessage(code);
84
- super(message, options);
85
- this.code = code;
86
- this.data = options.data; // data only optional when TData is undefinable so can safely cast here
87
- }
88
- toJSON() {
89
- return {
90
- defined: this.defined,
91
- code: this.code,
92
- message: this.message,
93
- data: this.data,
94
- };
95
- }
96
- /**
97
- * Workaround for Next.js where different contexts use separate
98
- * dependency graphs, causing multiple ORPCError constructors existing and breaking
99
- * `instanceof` checks across contexts.
100
- *
101
- * This is particularly problematic with "Optimized SSR", where orpc-client
102
- * executes in one context but is invoked from another. When an error is thrown
103
- * in the execution context, `instanceof ORPCError` checks fail in the
104
- * invocation context due to separate class constructors.
105
- *
106
- * @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
107
- */
108
- static [Symbol.hasInstance](instance) {
109
- if (!ORPCErrorConstructors.has(this)) {
110
- // not applicable to extended classes
111
- return super[Symbol.hasInstance](instance);
112
- }
113
- for (const constructor of getConstructors(instance)) {
114
- if (ORPCErrorConstructors.has(constructor)) {
115
- return true;
116
- }
117
- }
118
- return false;
119
- }
120
- }
37
+ * Typed error carrying a `code`, a `message`, and optional `data`.
38
+ * Throw it from handlers or middleware to produce typed error responses on the client.
39
+ *
40
+ * @see {@link https://orpc.dev/docs/error-handling#orpcerror-class | Error Handling - ORPCError Class}
41
+ */
42
+ var ORPCError = class ORPCError extends Error {
43
+ /**
44
+ * Placed inside a static block (rather than at module level) to ensure this
45
+ * registration is treated as part of the class definition by bundlers.
46
+ *
47
+ * With `"sideEffects": false` in package.json, bundlers like webpack/Rollup
48
+ * are allowed to tree-shake any module-level statements that appear to have
49
+ * no consumers. A free-floating `globalORPCErrorConstructors.add(ORPCError)`
50
+ * at module level could be dropped entirely if the bundler decides the module
51
+ * is only partially used.
52
+ *
53
+ * By placing this inside `static {}`, the registration becomes inseparable
54
+ * from the class body itself — a bundler cannot include `ORPCError` without
55
+ * executing this block.
56
+ *
57
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Static_initialization_blocks
58
+ */
59
+ static {
60
+ /**
61
+ * Store all ORPCError constructors
62
+ * for workaround of instanceof check in case multiple dependency graphs exist
63
+ */
64
+ const ORPC_ERROR_CONSTRUCTORS_SYMBOL = Symbol.for("ORPC_ERROR_CONSTRUCTORS");
65
+ globalThis[ORPC_ERROR_CONSTRUCTORS_SYMBOL] ??= /* @__PURE__ */ new WeakSet();
66
+ ORPCErrorConstructors = globalThis[ORPC_ERROR_CONSTRUCTORS_SYMBOL];
67
+ ORPCErrorConstructors.add(ORPCError);
68
+ }
69
+ /**
70
+ * @remarks
71
+ * **Note**: The `__branch` property is used for type branding, helping TypeScript distinguish
72
+ * an `ORPCError` instance from plain objects with a similar structure.
73
+ */
74
+ name = "ORPCError";
75
+ /**
76
+ * Indicates whether the error matches a definition in the procedure's `.errors` map,
77
+ * which makes its type inferable on the client.
78
+ */
79
+ defined = false;
80
+ code;
81
+ data;
82
+ constructor(code, ...rest) {
83
+ const options = resolveMaybeOptionalOptions(rest);
84
+ const message = options.message ?? codeToMessage(code);
85
+ super(message, options);
86
+ this.code = code;
87
+ this.data = options.data;
88
+ }
89
+ toJSON() {
90
+ return {
91
+ defined: this.defined,
92
+ code: this.code,
93
+ message: this.message,
94
+ data: this.data
95
+ };
96
+ }
97
+ /**
98
+ * Workaround for Next.js where different contexts use separate
99
+ * dependency graphs, causing multiple ORPCError constructors existing and breaking
100
+ * `instanceof` checks across contexts.
101
+ *
102
+ * This is particularly problematic with "Optimized SSR", where orpc-client
103
+ * executes in one context but is invoked from another. When an error is thrown
104
+ * in the execution context, `instanceof ORPCError` checks fail in the
105
+ * invocation context due to separate class constructors.
106
+ *
107
+ * @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
108
+ */
109
+ static [Symbol.hasInstance](instance) {
110
+ if (!ORPCErrorConstructors.has(this)) return super[Symbol.hasInstance](instance);
111
+ for (const constructor of getConstructors(instance)) if (ORPCErrorConstructors.has(constructor)) return true;
112
+ return false;
113
+ }
114
+ };
121
115
  /**
122
- * Error carrying the resolved response a link received. Links set it as the `cause`
123
- * of an `ORPCError` decoded from an error response, so details that are not part
124
- * of the error itself, such as its status or headers, stay available.
125
- *
126
- * @see {@link https://orpc.dev/docs/rpc/link#error-responses | RPC Link - Error Responses}
127
- * @see {@link https://orpc.dev/docs/openapi/link#error-responses | OpenAPI Link - Error Responses}
128
- */
129
- export class ResponseError extends Error {
130
- name = 'ResponseError';
131
- response;
132
- constructor(options) {
133
- super(options.message ?? `Received a ${options.response.status} response.`, options);
134
- this.response = options.response;
135
- }
136
- }
116
+ * Error carrying the resolved response a link received. Links set it as the `cause`
117
+ * of an `ORPCError` decoded from an error response, so details that are not part
118
+ * of the error itself, such as its status or headers, stay available.
119
+ *
120
+ * @see {@link https://orpc.dev/docs/rpc/link#error-responses | RPC Link - Error Responses}
121
+ * @see {@link https://orpc.dev/docs/openapi/link#error-responses | OpenAPI Link - Error Responses}
122
+ */
123
+ var ResponseError = class extends Error {
124
+ name = "ResponseError";
125
+ response;
126
+ constructor(options) {
127
+ super(options.message ?? `Received a ${options.response.status} response.`, options);
128
+ this.response = options.response;
129
+ }
130
+ };
137
131
  /**
138
- * Error thrown by links when a response does not follow the expected oRPC format,
139
- * for example when a proxy or gateway answers instead of your handler. Extends
140
- * `ResponseError`, so it carries the resolved response. Unless overridden via
141
- * `options.message`, the message is inferred from the response body or status.
142
- *
143
- * Unlike `ORPCError`, it reaches a handler's callers as a generic `INTERNAL_SERVER_ERROR`
144
- * when thrown from the handler, so an upstream's response is not sent to them.
145
- *
146
- * @see {@link https://orpc.dev/docs/rpc/link#malformed-responses | RPC Link - Malformed Responses}
147
- * @see {@link https://orpc.dev/docs/openapi/link#malformed-responses | OpenAPI Link - Malformed Responses}
148
- */
149
- export class MalformedResponseError extends ResponseError {
150
- name = 'MalformedResponseError';
151
- constructor(options) {
152
- super({
153
- ...options,
154
- message: options.message ?? inferMalformedResponseMessage(options.response),
155
- });
156
- }
157
- }
132
+ * Error thrown by links when a response does not follow the expected oRPC format,
133
+ * for example when a proxy or gateway answers instead of your handler. Extends
134
+ * `ResponseError`, so it carries the resolved response. Unless overridden via
135
+ * `options.message`, the message is inferred from the response body or status.
136
+ *
137
+ * Unlike `ORPCError`, it reaches a handler's callers as a generic `INTERNAL_SERVER_ERROR`
138
+ * when thrown from the handler, so an upstream's response is not sent to them.
139
+ *
140
+ * @see {@link https://orpc.dev/docs/rpc/link#malformed-responses | RPC Link - Malformed Responses}
141
+ * @see {@link https://orpc.dev/docs/openapi/link#malformed-responses | OpenAPI Link - Malformed Responses}
142
+ */
143
+ var MalformedResponseError = class extends ResponseError {
144
+ name = "MalformedResponseError";
145
+ constructor(options) {
146
+ super({
147
+ ...options,
148
+ message: options.message ?? inferMalformedResponseMessage(options.response)
149
+ });
150
+ }
151
+ };
158
152
  /**
159
- * Longer body strings are not used as the error message,
160
- * e.g. full HTML error pages from a proxy or gateway.
161
- */
153
+ * Longer body strings are not used as the error message,
154
+ * e.g. full HTML error pages from a proxy or gateway.
155
+ */
162
156
  const INFERRED_MESSAGE_MAX_LENGTH = 256;
163
157
  function inferMalformedResponseMessage(response) {
164
- const candidate = isPlainObject(response.body) ? response.body.message : response.body;
165
- if (typeof candidate === 'string' &&
166
- candidate.length > 0 &&
167
- candidate.length <= INFERRED_MESSAGE_MAX_LENGTH) {
168
- return candidate;
169
- }
170
- const commonCode = Object.entries(COMMON_ERROR_STATUS_MAP).find(([, status]) => status === response.status)?.[0];
171
- return commonCode ? codeToMessage(commonCode) : 'Malformed oRPC Response';
158
+ const candidate = isPlainObject(response.body) ? response.body.message : response.body;
159
+ if (typeof candidate === "string" && candidate.length > 0 && candidate.length <= INFERRED_MESSAGE_MAX_LENGTH) return candidate;
160
+ const commonCode = Object.entries(COMMON_ERROR_STATUS_MAP).find(([, status]) => status === response.status)?.[0];
161
+ return commonCode ? codeToMessage(commonCode) : "Malformed oRPC Response";
172
162
  }
173
163
  function codeToMessage(code) {
174
- return code
175
- .split('_')
176
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
177
- .join(' ');
164
+ return code.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
178
165
  }
166
+ export { COMMON_ERROR_STATUS_MAP, MalformedResponseError, ORPCError, ResponseError };
package/dist/index.d.ts CHANGED
@@ -1,53 +1,14 @@
1
- export * from './async-iterator-object.ts';
2
- export * from './client.ts';
3
- export * from './client-safe.ts';
4
- export * from './consts.ts';
5
- export * from './dynamic-link.ts';
6
- export * from './error.ts';
7
- export * from './error-utils.ts';
8
- export * from './rpc-json-serializer.ts';
9
- export * from './rpc-serializer.ts';
10
- export * from './types.ts';
11
- export type {
12
- /**
13
- * @deprecated Use `InferClientError` instead.
14
- */
15
- InferClientError as InferClientErrorUnion, } from './types.ts';
16
- export { resolveClientRest, safe } from './utils.ts';
17
- export type { SafeResult } from './utils.ts';
18
- export type { AsyncCleanupFn, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, } from '@orpc/shared';
19
- export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator,
20
- /**
21
- * @deprecated Use `consumeAsyncIterator` instead.
22
- */
23
- consumeAsyncIterator as consumeEventIterator,
24
- /**
25
- * @deprecated Use `asyncIteratorToStream` instead.
26
- */
27
- asyncIteratorToStream as eventIteratorToStream,
28
- /**
29
- * @deprecated Use `asyncIteratorToUnproxiedDataStream` instead.
30
- */
31
- asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject,
32
- /**
33
- * @deprecated Use `streamToAsyncIteratorObject` instead.
34
- */
35
- streamToAsyncIteratorObject as streamToEventIterator, } from '@orpc/shared';
36
- export type {
37
- /**
38
- * @deprecated Use `PromiseWithError` instead.
39
- */
40
- PromiseWithError as ClientPromiseResult, } from '@orpc/shared';
41
- export type { EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, } from '@standard-server/core';
42
- export {
43
- /**
44
- * @deprecated Use `EventStreamErrorEvent` instead.
45
- */
46
- EventStreamErrorEvent as ErrorEvent, EventStreamErrorEvent,
47
- /**
48
- * Retrieves event metadata (such as the event id and retry interval)
49
- * attached to a single iterator event value.
50
- *
51
- * @see {@link https://orpc.dev/docs/client/async-iterator-object#event-metadata | AsyncIteratorObject in Client - Event Metadata}
52
- */
53
- getEventMeta, unwrapEvent, withEventMeta, } from '@standard-server/core';
1
+ import { wrapAsyncIteratorPreservingEventMeta } from "./async-iterator-object.js";
2
+ import { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, createORPCClient } from "./client.js";
3
+ import { SafeClient, createSafeClient } from "./client-safe.js";
4
+ import { RECURSIVE_CLIENT_UNWRAP_KEYS } from "./consts.js";
5
+ import { DynamicLink } from "./dynamic-link.js";
6
+ import { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, MalformedResponseError, MalformedResponseErrorOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, ResponseError, ResponseErrorOptions } from "./error.js";
7
+ import { cloneORPCError, createORPCErrorFromJson, isDefinedError, isORPCErrorJson, toORPCError } from "./error-utils.js";
8
+ import { RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions } from "./rpc-json-serializer.js";
9
+ import { RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions } from "./rpc-serializer.js";
10
+ import { AnyNestedClient, Client, ClientContext, ClientLink, ClientOptions, ClientRest, FriendlyClientOptions, InferClientBodyInputs, InferClientBodyOutputs, InferClientContext, InferClientError, InferClientErrors, InferClientInputs, InferClientOutputs, NestedClient } from "./types.js";
11
+ import { SafeResult, resolveClientRest, safe } from "./utils.js";
12
+ import { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, PromiseWithError as ClientPromiseResult, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from "@orpc/shared";
13
+ import { EventMeta, EventStreamErrorEvent, EventStreamErrorEvent as ErrorEvent, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from "@standard-server/core";
14
+ export { AnyNestedClient, AnyORPCError, AnyORPCErrorJSON, type AsyncCleanupFn, AsyncIteratorClass, type AsyncIteratorClassNextFn, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientLink, ClientOptions, type ClientPromiseResult, ClientRest, DynamicLink, ErrorEvent, type EventMeta, EventStreamErrorEvent, FriendlyClientOptions, InferClientBodyInputs, InferClientBodyOutputs, InferClientContext, InferClientError, type InferClientError as InferClientErrorUnion, InferClientErrors, InferClientInputs, InferClientOutputs, MalformedResponseError, MalformedResponseErrorOptions, type MaybeOptionalOptions, NestedClient, ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, type PromiseWithError, RECURSIVE_CLIENT_UNWRAP_KEYS, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, type Registry, ResponseError, ResponseErrorOptions, SafeClient, type SafeResult, type StandardBody, type StandardBodyHint, type StandardHeaders, type StandardLazyRequest, type StandardLazyResponse, type StandardMethod, type StandardRequest, type StandardResponse, type StandardUrl, type ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, cloneORPCError, consumeAsyncIterator, consumeEventIterator, createORPCClient, createORPCErrorFromJson, createSafeClient, eventIteratorToStream, eventIteratorToUnproxiedDataStream, getEventMeta, isDefinedError, isORPCErrorJson, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, resolveClientRest, safe, streamToAsyncIteratorObject, streamToEventIterator, toORPCError, unwrapEvent, withEventMeta, wrapAsyncIteratorPreservingEventMeta };
package/dist/index.js CHANGED
@@ -1,40 +1,12 @@
1
- export * from './async-iterator-object.js';
2
- export * from './client.js';
3
- export * from './client-safe.js';
4
- export * from './consts.js';
5
- export * from './dynamic-link.js';
6
- export * from './error.js';
7
- export * from './error-utils.js';
8
- export * from './rpc-json-serializer.js';
9
- export * from './rpc-serializer.js';
10
- export * from './types.js';
11
- export { resolveClientRest, safe } from './utils.js';
12
- export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator,
13
- /**
14
- * @deprecated Use `consumeAsyncIterator` instead.
15
- */
16
- consumeAsyncIterator as consumeEventIterator,
17
- /**
18
- * @deprecated Use `asyncIteratorToStream` instead.
19
- */
20
- asyncIteratorToStream as eventIteratorToStream,
21
- /**
22
- * @deprecated Use `asyncIteratorToUnproxiedDataStream` instead.
23
- */
24
- asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject,
25
- /**
26
- * @deprecated Use `streamToAsyncIteratorObject` instead.
27
- */
28
- streamToAsyncIteratorObject as streamToEventIterator, } from '@orpc/shared';
29
- export {
30
- /**
31
- * @deprecated Use `EventStreamErrorEvent` instead.
32
- */
33
- EventStreamErrorEvent as ErrorEvent, EventStreamErrorEvent,
34
- /**
35
- * Retrieves event metadata (such as the event id and retry interval)
36
- * attached to a single iterator event value.
37
- *
38
- * @see {@link https://orpc.dev/docs/client/async-iterator-object#event-metadata | AsyncIteratorObject in Client - Event Metadata}
39
- */
40
- getEventMeta, unwrapEvent, withEventMeta, } from '@standard-server/core';
1
+ export { wrapAsyncIteratorPreservingEventMeta } from "./async-iterator-object.js";
2
+ export { createORPCClient } from "./client.js";
3
+ export { createSafeClient } from "./client-safe.js";
4
+ export { RECURSIVE_CLIENT_UNWRAP_KEYS } from "./consts.js";
5
+ export { DynamicLink } from "./dynamic-link.js";
6
+ export { COMMON_ERROR_STATUS_MAP, MalformedResponseError, ORPCError, ResponseError } from "./error.js";
7
+ export { cloneORPCError, createORPCErrorFromJson, isDefinedError, isORPCErrorJson, toORPCError } from "./error-utils.js";
8
+ export { RPCJsonSerializer } from "./rpc-json-serializer.js";
9
+ export { RPCSerializer } from "./rpc-serializer.js";
10
+ export { resolveClientRest, safe } from "./utils.js";
11
+ export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from "@orpc/shared";
12
+ export { EventStreamErrorEvent, EventStreamErrorEvent as ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from "@standard-server/core";