@orpc/client 0.0.0-next.c72b962 → 0.0.0-next.c788572

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 CHANGED
@@ -21,28 +21,24 @@
21
21
 
22
22
  <h3 align="center">Typesafe APIs Made Simple 🪄</h3>
23
23
 
24
- **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards, ensuring a smooth and enjoyable developer experience.
24
+ **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
25
25
 
26
26
  ---
27
27
 
28
28
  ## Highlights
29
29
 
30
- - **End-to-End Type Safety 🔒**: Ensure complete type safety from inputs to outputs and errors, bridging server and client seamlessly.
31
- - **First-Class OpenAPI 📄**: Adheres to the OpenAPI standard out of the box, ensuring seamless integration and comprehensive API documentation.
32
- - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
- - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
- - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
- - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
- - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
- - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
- - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
39
- - **Native Types 📦**: Enjoy built-in support for Date, File, Blob, BigInt, URL and more with no extra setup.
40
- - **Lazy Router ⏱️**: Improve cold start times with our lazy routing feature.
41
- - **SSE & Streaming 📡**: Provides SSE and streaming features – perfect for real-time notifications and AI-powered streaming responses.
42
- - **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
43
- - **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
44
- - **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
45
- - **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
30
+ - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
31
+ - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
32
+ - **📝 Contract-First Development**: Optionally define your API contract before implementation.
33
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
34
+ - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
35
+ - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
36
+ - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
37
+ - **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
38
+ - **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
39
+ - **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
40
+ - **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
41
+ - **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
46
42
 
47
43
  ## Documentation
48
44
 
@@ -1,8 +1,8 @@
1
1
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
2
2
  import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
3
3
  import { a as ClientContext, b as ClientOptions } from '../../shared/client.CipPQkhk.mjs';
4
- import { f as StandardLinkClient, d as StandardLink } from '../../shared/client.2CWETx1V.mjs';
5
- import { f as StandardRPCLinkOptions } from '../../shared/client.DcDnlyRo.mjs';
4
+ import { f as StandardLinkClient } from '../../shared/client.FXep-a3a.mjs';
5
+ import { f as StandardRPCLinkOptions, g as StandardRPCLink } from '../../shared/client.BjJBZryq.mjs';
6
6
  import '@orpc/shared';
7
7
 
8
8
  interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
@@ -19,8 +19,15 @@ declare class LinkFetchClient<T extends ClientContext> implements StandardLinkCl
19
19
 
20
20
  interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions<T>, LinkFetchClientOptions<T> {
21
21
  }
22
- declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
22
+ /**
23
+ * The RPC Link communicates with the server using the RPC protocol.
24
+ *
25
+ * @see {@link https://orpc.unnoq.com/docs/client/rpc-link RPC Link Docs}
26
+ * @see {@link https://orpc.unnoq.com/docs/advanced/rpc-protocol RPC Protocol Docs}
27
+ */
28
+ declare class RPCLink<T extends ClientContext> extends StandardRPCLink<T> {
23
29
  constructor(options: RPCLinkOptions<T>);
24
30
  }
25
31
 
26
- export { LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
32
+ export { LinkFetchClient, RPCLink };
33
+ export type { LinkFetchClientOptions, RPCLinkOptions };
@@ -1,8 +1,8 @@
1
1
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
2
2
  import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
3
3
  import { a as ClientContext, b as ClientOptions } from '../../shared/client.CipPQkhk.js';
4
- import { f as StandardLinkClient, d as StandardLink } from '../../shared/client.DUjXqpDq.js';
5
- import { f as StandardRPCLinkOptions } from '../../shared/client.BCCZFC-T.js';
4
+ import { f as StandardLinkClient } from '../../shared/client.C9U9n1f3.js';
5
+ import { f as StandardRPCLinkOptions, g as StandardRPCLink } from '../../shared/client.8TjrVhkC.js';
6
6
  import '@orpc/shared';
7
7
 
8
8
  interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
@@ -19,8 +19,15 @@ declare class LinkFetchClient<T extends ClientContext> implements StandardLinkCl
19
19
 
20
20
  interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions<T>, LinkFetchClientOptions<T> {
21
21
  }
22
- declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
22
+ /**
23
+ * The RPC Link communicates with the server using the RPC protocol.
24
+ *
25
+ * @see {@link https://orpc.unnoq.com/docs/client/rpc-link RPC Link Docs}
26
+ * @see {@link https://orpc.unnoq.com/docs/advanced/rpc-protocol RPC Protocol Docs}
27
+ */
28
+ declare class RPCLink<T extends ClientContext> extends StandardRPCLink<T> {
23
29
  constructor(options: RPCLinkOptions<T>);
24
30
  }
25
31
 
26
- export { LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
32
+ export { LinkFetchClient, RPCLink };
33
+ export type { LinkFetchClientOptions, RPCLinkOptions };
@@ -1,6 +1,6 @@
1
1
  import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
2
- import { S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.vy3P78P6.mjs';
3
2
  import '@orpc/shared';
3
+ import { c as StandardRPCLink } from '../../shared/client.DpICn1BD.mjs';
4
4
  import '@orpc/standard-server';
5
5
  import '../../shared/client.CRWEpqLB.mjs';
6
6
 
@@ -19,13 +19,10 @@ class LinkFetchClient {
19
19
  }
20
20
  }
21
21
 
22
- class RPCLink extends StandardLink {
22
+ class RPCLink extends StandardRPCLink {
23
23
  constructor(options) {
24
- const jsonSerializer = new StandardRPCJsonSerializer(options);
25
- const serializer = new StandardRPCSerializer(jsonSerializer);
26
- const linkCodec = new StandardRPCLinkCodec(serializer, options);
27
24
  const linkClient = new LinkFetchClient(options);
28
- super(linkCodec, linkClient, options);
25
+ super(linkClient, options);
29
26
  }
30
27
  }
31
28
 
@@ -1,5 +1,5 @@
1
- export { C as CompositeStandardLinkPlugin, I as InvalidEventIteratorRetryResponse, d as StandardLink, f as StandardLinkClient, S as StandardLinkClientInterceptorOptions, e as StandardLinkCodec, c as StandardLinkInterceptorOptions, b as StandardLinkOptions, a as StandardLinkPlugin } from '../../shared/client.2CWETx1V.mjs';
2
- export { S as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, c as StandardRPCCustomJsonSerializer, b as StandardRPCJsonSerialized, a as StandardRPCJsonSerializedMetaItem, e as StandardRPCJsonSerializer, d as StandardRPCJsonSerializerOptions, h as StandardRPCLinkCodec, g as StandardRPCLinkCodecOptions, f as StandardRPCLinkOptions, i as StandardRPCSerializer } from '../../shared/client.DcDnlyRo.mjs';
1
+ export { C as CompositeStandardLinkPlugin, d as StandardLink, f as StandardLinkClient, S as StandardLinkClientInterceptorOptions, e as StandardLinkCodec, c as StandardLinkInterceptorOptions, b as StandardLinkOptions, a as StandardLinkPlugin } from '../../shared/client.FXep-a3a.mjs';
2
+ export { S as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, c as StandardRPCCustomJsonSerializer, b as StandardRPCJsonSerialized, a as StandardRPCJsonSerializedMetaItem, e as StandardRPCJsonSerializer, d as StandardRPCJsonSerializerOptions, g as StandardRPCLink, i as StandardRPCLinkCodec, h as StandardRPCLinkCodecOptions, f as StandardRPCLinkOptions, j as StandardRPCSerializer } from '../../shared/client.BjJBZryq.mjs';
3
3
  import { H as HTTPPath } from '../../shared/client.CipPQkhk.mjs';
4
4
  import '@orpc/shared';
5
5
  import '@orpc/standard-server';
@@ -1,5 +1,5 @@
1
- export { C as CompositeStandardLinkPlugin, I as InvalidEventIteratorRetryResponse, d as StandardLink, f as StandardLinkClient, S as StandardLinkClientInterceptorOptions, e as StandardLinkCodec, c as StandardLinkInterceptorOptions, b as StandardLinkOptions, a as StandardLinkPlugin } from '../../shared/client.DUjXqpDq.js';
2
- export { S as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, c as StandardRPCCustomJsonSerializer, b as StandardRPCJsonSerialized, a as StandardRPCJsonSerializedMetaItem, e as StandardRPCJsonSerializer, d as StandardRPCJsonSerializerOptions, h as StandardRPCLinkCodec, g as StandardRPCLinkCodecOptions, f as StandardRPCLinkOptions, i as StandardRPCSerializer } from '../../shared/client.BCCZFC-T.js';
1
+ export { C as CompositeStandardLinkPlugin, d as StandardLink, f as StandardLinkClient, S as StandardLinkClientInterceptorOptions, e as StandardLinkCodec, c as StandardLinkInterceptorOptions, b as StandardLinkOptions, a as StandardLinkPlugin } from '../../shared/client.C9U9n1f3.js';
2
+ export { S as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, c as StandardRPCCustomJsonSerializer, b as StandardRPCJsonSerialized, a as StandardRPCJsonSerializedMetaItem, e as StandardRPCJsonSerializer, d as StandardRPCJsonSerializerOptions, g as StandardRPCLink, i as StandardRPCLinkCodec, h as StandardRPCLinkCodecOptions, f as StandardRPCLinkOptions, j as StandardRPCSerializer } from '../../shared/client.8TjrVhkC.js';
3
3
  import { H as HTTPPath } from '../../shared/client.CipPQkhk.js';
4
4
  import '@orpc/shared';
5
5
  import '@orpc/standard-server';
@@ -1,4 +1,4 @@
1
- export { C as CompositeStandardLinkPlugin, I as InvalidEventIteratorRetryResponse, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer, g as getMalformedResponseErrorCode, t as toHttpPath } from '../../shared/client.vy3P78P6.mjs';
1
+ export { C as CompositeStandardLinkPlugin, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLink, d as StandardRPCLinkCodec, e as StandardRPCSerializer, g as getMalformedResponseErrorCode, t as toHttpPath } from '../../shared/client.DpICn1BD.mjs';
2
2
  import '@orpc/shared';
3
3
  import '@orpc/standard-server';
4
4
  import '../../shared/client.CRWEpqLB.mjs';
package/dist/index.d.mts CHANGED
@@ -10,11 +10,18 @@ interface createORPCClientOptions {
10
10
  */
11
11
  path?: string[];
12
12
  }
13
+ /**
14
+ * Create a oRPC client-side client from a link.
15
+ *
16
+ * @see {@link https://orpc.unnoq.com/docs/client/client-side Client-side Client Docs}
17
+ */
13
18
  declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<InferClientContext<T>>, options?: createORPCClientOptions): T;
14
19
 
15
20
  /**
16
21
  * DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
17
22
  * based on the request path, input, and context.
23
+ *
24
+ * @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
18
25
  */
19
26
  declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
20
27
  private readonly linkResolver;
@@ -149,7 +156,14 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false
149
156
  isDefined: true;
150
157
  isSuccess: false;
151
158
  };
159
+ /**
160
+ * Works like try/catch, but can infer error types.
161
+ *
162
+ * @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
163
+ * @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
164
+ */
152
165
  declare function safe<TOutput, TError = ThrowableError>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
153
166
  declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
154
167
 
155
- export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink, ClientOptions, ClientPromiseResult, type CommonORPCErrorCode, DynamicLink, FriendlyClientOptions, InferClientContext, NestedClient, ORPCError, type ORPCErrorCode, type ORPCErrorJSON, type ORPCErrorOptions, type SafeResult, createORPCClient, type createORPCClientOptions, createORPCErrorFromJson, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, isORPCErrorJson, isORPCErrorStatus, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
168
+ export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink, ClientOptions, ClientPromiseResult, DynamicLink, FriendlyClientOptions, InferClientContext, NestedClient, ORPCError, createORPCClient, createORPCErrorFromJson, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, isORPCErrorJson, isORPCErrorStatus, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
169
+ export type { CommonORPCErrorCode, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, SafeResult, createORPCClientOptions };
package/dist/index.d.ts CHANGED
@@ -10,11 +10,18 @@ interface createORPCClientOptions {
10
10
  */
11
11
  path?: string[];
12
12
  }
13
+ /**
14
+ * Create a oRPC client-side client from a link.
15
+ *
16
+ * @see {@link https://orpc.unnoq.com/docs/client/client-side Client-side Client Docs}
17
+ */
13
18
  declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<InferClientContext<T>>, options?: createORPCClientOptions): T;
14
19
 
15
20
  /**
16
21
  * DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
17
22
  * based on the request path, input, and context.
23
+ *
24
+ * @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
18
25
  */
19
26
  declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
20
27
  private readonly linkResolver;
@@ -149,7 +156,14 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false
149
156
  isDefined: true;
150
157
  isSuccess: false;
151
158
  };
159
+ /**
160
+ * Works like try/catch, but can infer error types.
161
+ *
162
+ * @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
163
+ * @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
164
+ */
152
165
  declare function safe<TOutput, TError = ThrowableError>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
153
166
  declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
154
167
 
155
- export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink, ClientOptions, ClientPromiseResult, type CommonORPCErrorCode, DynamicLink, FriendlyClientOptions, InferClientContext, NestedClient, ORPCError, type ORPCErrorCode, type ORPCErrorJSON, type ORPCErrorOptions, type SafeResult, createORPCClient, type createORPCClientOptions, createORPCErrorFromJson, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, isORPCErrorJson, isORPCErrorStatus, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
168
+ export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink, ClientOptions, ClientPromiseResult, DynamicLink, FriendlyClientOptions, InferClientContext, NestedClient, ORPCError, createORPCClient, createORPCErrorFromJson, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, isORPCErrorJson, isORPCErrorStatus, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
169
+ export type { CommonORPCErrorCode, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, SafeResult, createORPCClientOptions };
@@ -1,6 +1,6 @@
1
1
  import { Value } from '@orpc/shared';
2
2
  import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
3
- import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.2CWETx1V.mjs';
3
+ import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.FXep-a3a.mjs';
4
4
  import { a as ClientContext } from '../shared/client.CipPQkhk.mjs';
5
5
 
6
6
  interface BatchLinkPluginGroup<T extends ClientContext> {
@@ -51,6 +51,12 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
51
51
  */
52
52
  exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
53
53
  }
54
+ /**
55
+ * The Batch Request/Response Plugin allows you to combine multiple requests and responses into a single batch,
56
+ * reducing the overhead of sending each one separately.
57
+ *
58
+ * @see {@link https://orpc.unnoq.com/docs/plugins/batch-request-response Batch Request/Response Plugin Docs}
59
+ */
54
60
  declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
55
61
  #private;
56
62
  private readonly groups;
@@ -94,13 +100,18 @@ interface ClientRetryPluginContext {
94
100
  /**
95
101
  * The hook called when retrying, and return the unsubscribe function.
96
102
  */
97
- onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | (() => void);
103
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
98
104
  }
99
105
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
100
106
  }
101
107
  interface ClientRetryPluginOptions {
102
108
  default?: ClientRetryPluginContext;
103
109
  }
110
+ /**
111
+ * The Client Retry Plugin enables retrying client calls when errors occur.
112
+ *
113
+ * @see {@link https://orpc.unnoq.com/docs/plugins/client-retry Client Retry Plugin Docs}
114
+ */
104
115
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
105
116
  private readonly defaultRetry;
106
117
  private readonly defaultRetryDelay;
@@ -131,6 +142,13 @@ interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
131
142
  */
132
143
  exclude?: Value<boolean, [options: StandardLinkClientInterceptorOptions<T>]>;
133
144
  }
145
+ /**
146
+ * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
147
+ * It helps ensure that requests to your procedures originate from JavaScript code,
148
+ * not from other sources like standard HTML forms or direct browser navigation.
149
+ *
150
+ * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
151
+ */
134
152
  declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
135
153
  private readonly headerName;
136
154
  private readonly headerValue;
@@ -140,4 +158,5 @@ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements
140
158
  init(options: StandardLinkOptions<T>): void;
141
159
  }
142
160
 
143
- export { BatchLinkPlugin, type BatchLinkPluginGroup, type BatchLinkPluginOptions, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions, SimpleCsrfProtectionLinkPlugin, type SimpleCsrfProtectionLinkPluginOptions };
161
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, SimpleCsrfProtectionLinkPlugin };
162
+ export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
@@ -1,6 +1,6 @@
1
1
  import { Value } from '@orpc/shared';
2
2
  import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
3
- import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.DUjXqpDq.js';
3
+ import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.C9U9n1f3.js';
4
4
  import { a as ClientContext } from '../shared/client.CipPQkhk.js';
5
5
 
6
6
  interface BatchLinkPluginGroup<T extends ClientContext> {
@@ -51,6 +51,12 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
51
51
  */
52
52
  exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
53
53
  }
54
+ /**
55
+ * The Batch Request/Response Plugin allows you to combine multiple requests and responses into a single batch,
56
+ * reducing the overhead of sending each one separately.
57
+ *
58
+ * @see {@link https://orpc.unnoq.com/docs/plugins/batch-request-response Batch Request/Response Plugin Docs}
59
+ */
54
60
  declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
55
61
  #private;
56
62
  private readonly groups;
@@ -94,13 +100,18 @@ interface ClientRetryPluginContext {
94
100
  /**
95
101
  * The hook called when retrying, and return the unsubscribe function.
96
102
  */
97
- onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | (() => void);
103
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
98
104
  }
99
105
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
100
106
  }
101
107
  interface ClientRetryPluginOptions {
102
108
  default?: ClientRetryPluginContext;
103
109
  }
110
+ /**
111
+ * The Client Retry Plugin enables retrying client calls when errors occur.
112
+ *
113
+ * @see {@link https://orpc.unnoq.com/docs/plugins/client-retry Client Retry Plugin Docs}
114
+ */
104
115
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
105
116
  private readonly defaultRetry;
106
117
  private readonly defaultRetryDelay;
@@ -131,6 +142,13 @@ interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
131
142
  */
132
143
  exclude?: Value<boolean, [options: StandardLinkClientInterceptorOptions<T>]>;
133
144
  }
145
+ /**
146
+ * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
147
+ * It helps ensure that requests to your procedures originate from JavaScript code,
148
+ * not from other sources like standard HTML forms or direct browser navigation.
149
+ *
150
+ * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
151
+ */
134
152
  declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
135
153
  private readonly headerName;
136
154
  private readonly headerValue;
@@ -140,4 +158,5 @@ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements
140
158
  init(options: StandardLinkOptions<T>): void;
141
159
  }
142
160
 
143
- export { BatchLinkPlugin, type BatchLinkPluginGroup, type BatchLinkPluginOptions, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions, SimpleCsrfProtectionLinkPlugin, type SimpleCsrfProtectionLinkPluginOptions };
161
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, SimpleCsrfProtectionLinkPlugin };
162
+ export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
@@ -175,20 +175,20 @@ class ClientRetryPlugin {
175
175
  }
176
176
  let lastEventId = interceptorOptions.lastEventId;
177
177
  let lastEventRetry;
178
- let unsubscribe;
178
+ let callback;
179
179
  let attemptIndex = 0;
180
- const next = async (initial) => {
181
- let current = initial;
180
+ const next = async (initialError) => {
181
+ let currentError = initialError;
182
182
  while (true) {
183
183
  const updatedInterceptorOptions = { ...interceptorOptions, lastEventId };
184
- if (current) {
184
+ if (currentError) {
185
185
  if (attemptIndex >= maxAttempts) {
186
- throw current.error;
186
+ throw currentError.error;
187
187
  }
188
188
  const attemptOptions = {
189
189
  ...updatedInterceptorOptions,
190
190
  attemptIndex,
191
- error: current.error,
191
+ error: currentError.error,
192
192
  lastEventRetry
193
193
  };
194
194
  const shouldRetryBool = await value(
@@ -196,23 +196,24 @@ class ClientRetryPlugin {
196
196
  attemptOptions
197
197
  );
198
198
  if (!shouldRetryBool) {
199
- throw current.error;
199
+ throw currentError.error;
200
200
  }
201
- unsubscribe = onRetry?.(attemptOptions);
201
+ callback = onRetry?.(attemptOptions);
202
202
  const retryDelayMs = await value(retryDelay, attemptOptions);
203
203
  await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
204
204
  attemptIndex++;
205
205
  }
206
206
  try {
207
+ currentError = void 0;
207
208
  return await interceptorOptions.next(updatedInterceptorOptions);
208
209
  } catch (error) {
210
+ currentError = { error };
209
211
  if (updatedInterceptorOptions.signal?.aborted === true) {
210
212
  throw error;
211
213
  }
212
- current = { error };
213
214
  } finally {
214
- unsubscribe?.();
215
- unsubscribe = void 0;
215
+ callback?.(!currentError);
216
+ callback = void 0;
216
217
  }
217
218
  }
218
219
  };
@@ -1,5 +1,5 @@
1
1
  import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.CipPQkhk.js';
2
- import { e as StandardLinkCodec, b as StandardLinkOptions } from './client.DUjXqpDq.js';
2
+ import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.C9U9n1f3.js';
3
3
  import { Segment, Value } from '@orpc/shared';
4
4
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
5
 
@@ -83,5 +83,9 @@ declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardL
83
83
 
84
84
  interface StandardRPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardRPCLinkCodecOptions<T>, StandardRPCJsonSerializerOptions {
85
85
  }
86
+ declare class StandardRPCLink<T extends ClientContext> extends StandardLink<T> {
87
+ constructor(linkClient: StandardLinkClient<T>, options: StandardRPCLinkOptions<T>);
88
+ }
86
89
 
87
- export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, type StandardRPCJsonSerializedMetaItem as a, type StandardRPCJsonSerialized as b, type StandardRPCCustomJsonSerializer as c, type StandardRPCJsonSerializerOptions as d, StandardRPCJsonSerializer as e, type StandardRPCLinkOptions as f, type StandardRPCLinkCodecOptions as g, StandardRPCLinkCodec as h, StandardRPCSerializer as i };
90
+ export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, StandardRPCJsonSerializer as e, StandardRPCLink as g, StandardRPCLinkCodec as i, StandardRPCSerializer as j };
91
+ export type { StandardRPCJsonSerializedMetaItem as a, StandardRPCJsonSerialized as b, StandardRPCCustomJsonSerializer as c, StandardRPCJsonSerializerOptions as d, StandardRPCLinkOptions as f, StandardRPCLinkCodecOptions as h };
@@ -1,5 +1,5 @@
1
1
  import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.CipPQkhk.mjs';
2
- import { e as StandardLinkCodec, b as StandardLinkOptions } from './client.2CWETx1V.mjs';
2
+ import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.FXep-a3a.mjs';
3
3
  import { Segment, Value } from '@orpc/shared';
4
4
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
5
 
@@ -83,5 +83,9 @@ declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardL
83
83
 
84
84
  interface StandardRPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardRPCLinkCodecOptions<T>, StandardRPCJsonSerializerOptions {
85
85
  }
86
+ declare class StandardRPCLink<T extends ClientContext> extends StandardLink<T> {
87
+ constructor(linkClient: StandardLinkClient<T>, options: StandardRPCLinkOptions<T>);
88
+ }
86
89
 
87
- export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, type StandardRPCJsonSerializedMetaItem as a, type StandardRPCJsonSerialized as b, type StandardRPCCustomJsonSerializer as c, type StandardRPCJsonSerializerOptions as d, StandardRPCJsonSerializer as e, type StandardRPCLinkOptions as f, type StandardRPCLinkCodecOptions as g, StandardRPCLinkCodec as h, StandardRPCSerializer as i };
90
+ export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, StandardRPCJsonSerializer as e, StandardRPCLink as g, StandardRPCLinkCodec as i, StandardRPCSerializer as j };
91
+ export type { StandardRPCJsonSerializedMetaItem as a, StandardRPCJsonSerialized as b, StandardRPCCustomJsonSerializer as c, StandardRPCJsonSerializerOptions as d, StandardRPCLinkOptions as f, StandardRPCLinkCodecOptions as h };
@@ -2,14 +2,6 @@ import { Interceptor, ThrowableError } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
3
  import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.CipPQkhk.js';
4
4
 
5
- interface StandardLinkCodec<T extends ClientContext> {
6
- encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
7
- decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
8
- }
9
- interface StandardLinkClient<T extends ClientContext> {
10
- call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
11
- }
12
-
13
5
  interface StandardLinkPlugin<T extends ClientContext> {
14
6
  order?: number;
15
7
  init?(options: StandardLinkOptions<T>): void;
@@ -20,8 +12,14 @@ declare class CompositeStandardLinkPlugin<T extends ClientContext, TPlugin exten
20
12
  init(options: StandardLinkOptions<T>): void;
21
13
  }
22
14
 
23
- declare class InvalidEventIteratorRetryResponse extends Error {
15
+ interface StandardLinkCodec<T extends ClientContext> {
16
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
17
+ decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
24
18
  }
19
+ interface StandardLinkClient<T extends ClientContext> {
20
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
21
+ }
22
+
25
23
  interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
26
24
  path: readonly string[];
27
25
  input: unknown;
@@ -44,4 +42,5 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
44
42
  call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
45
43
  }
46
44
 
47
- export { CompositeStandardLinkPlugin as C, InvalidEventIteratorRetryResponse as I, type StandardLinkClientInterceptorOptions as S, type StandardLinkPlugin as a, type StandardLinkOptions as b, type StandardLinkInterceptorOptions as c, StandardLink as d, type StandardLinkCodec as e, type StandardLinkClient as f };
45
+ export { CompositeStandardLinkPlugin as C, StandardLink as d };
46
+ export type { StandardLinkClientInterceptorOptions as S, StandardLinkPlugin as a, StandardLinkOptions as b, StandardLinkInterceptorOptions as c, StandardLinkCodec as e, StandardLinkClient as f };
@@ -14,8 +14,6 @@ class CompositeStandardLinkPlugin {
14
14
  }
15
15
  }
16
16
 
17
- class InvalidEventIteratorRetryResponse extends Error {
18
- }
19
17
  class StandardLink {
20
18
  constructor(codec, sender, options = {}) {
21
19
  this.codec = codec;
@@ -345,4 +343,13 @@ class StandardRPCSerializer {
345
343
  }
346
344
  }
347
345
 
348
- export { CompositeStandardLinkPlugin as C, InvalidEventIteratorRetryResponse as I, StandardLink as S, STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as a, StandardRPCJsonSerializer as b, StandardRPCLinkCodec as c, StandardRPCSerializer as d, getMalformedResponseErrorCode as g, toHttpPath as t };
346
+ class StandardRPCLink extends StandardLink {
347
+ constructor(linkClient, options) {
348
+ const jsonSerializer = new StandardRPCJsonSerializer(options);
349
+ const serializer = new StandardRPCSerializer(jsonSerializer);
350
+ const linkCodec = new StandardRPCLinkCodec(serializer, options);
351
+ super(linkCodec, linkClient, options);
352
+ }
353
+ }
354
+
355
+ export { CompositeStandardLinkPlugin as C, StandardLink as S, STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as a, StandardRPCJsonSerializer as b, StandardRPCLink as c, StandardRPCLinkCodec as d, StandardRPCSerializer as e, getMalformedResponseErrorCode as g, toHttpPath as t };
@@ -2,14 +2,6 @@ import { Interceptor, ThrowableError } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
3
  import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.CipPQkhk.mjs';
4
4
 
5
- interface StandardLinkCodec<T extends ClientContext> {
6
- encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
7
- decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
8
- }
9
- interface StandardLinkClient<T extends ClientContext> {
10
- call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
11
- }
12
-
13
5
  interface StandardLinkPlugin<T extends ClientContext> {
14
6
  order?: number;
15
7
  init?(options: StandardLinkOptions<T>): void;
@@ -20,8 +12,14 @@ declare class CompositeStandardLinkPlugin<T extends ClientContext, TPlugin exten
20
12
  init(options: StandardLinkOptions<T>): void;
21
13
  }
22
14
 
23
- declare class InvalidEventIteratorRetryResponse extends Error {
15
+ interface StandardLinkCodec<T extends ClientContext> {
16
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
17
+ decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
24
18
  }
19
+ interface StandardLinkClient<T extends ClientContext> {
20
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
21
+ }
22
+
25
23
  interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
26
24
  path: readonly string[];
27
25
  input: unknown;
@@ -44,4 +42,5 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
44
42
  call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
45
43
  }
46
44
 
47
- export { CompositeStandardLinkPlugin as C, InvalidEventIteratorRetryResponse as I, type StandardLinkClientInterceptorOptions as S, type StandardLinkPlugin as a, type StandardLinkOptions as b, type StandardLinkInterceptorOptions as c, StandardLink as d, type StandardLinkCodec as e, type StandardLinkClient as f };
45
+ export { CompositeStandardLinkPlugin as C, StandardLink as d };
46
+ export type { StandardLinkClientInterceptorOptions as S, StandardLinkPlugin as a, StandardLinkOptions as b, StandardLinkInterceptorOptions as c, StandardLinkCodec as e, StandardLinkClient as f };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/client",
3
3
  "type": "module",
4
- "version": "0.0.0-next.c72b962",
4
+ "version": "0.0.0-next.c788572",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -39,9 +39,9 @@
39
39
  "dist"
40
40
  ],
41
41
  "dependencies": {
42
- "@orpc/shared": "0.0.0-next.c72b962",
43
- "@orpc/standard-server-fetch": "0.0.0-next.c72b962",
44
- "@orpc/standard-server": "0.0.0-next.c72b962"
42
+ "@orpc/standard-server": "0.0.0-next.c788572",
43
+ "@orpc/shared": "0.0.0-next.c788572",
44
+ "@orpc/standard-server-fetch": "0.0.0-next.c788572"
45
45
  },
46
46
  "devDependencies": {
47
47
  "zod": "^3.24.2"