@orpc/client 1.0.0-beta.2 → 1.0.0-beta.4

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
@@ -87,6 +87,14 @@ const client: RouterClient<typeof router> = createORPCClient(link)
87
87
  const client: ContractRouterClient<typeof contract> = createORPCClient(link)
88
88
  ```
89
89
 
90
+ ## Sponsors
91
+
92
+ <p align="center">
93
+ <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
94
+ <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
95
+ </a>
96
+ </p>
97
+
90
98
  ## License
91
99
 
92
100
  Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
@@ -1,18 +1,18 @@
1
1
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
2
2
  import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
3
- import { a as ClientContext, C as ClientOptionsOut, b as ClientLink } from '../../shared/client.CupM8eRP.mjs';
4
- import { b as StandardLinkClient } from '../../shared/client.DrOAzyMB.mjs';
3
+ import { a as ClientContext, C as ClientOptions, b as ClientLink } from '../../shared/client.RZs5Myak.mjs';
4
+ import { b as StandardLinkClient } from '../../shared/client.CKw2tbcl.mjs';
5
5
  import { StandardRPCLinkOptions } from '../standard/index.mjs';
6
6
  import '@orpc/shared';
7
7
 
8
8
  interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
9
- fetch?: (request: Request, init: Record<never, never>, options: ClientOptionsOut<T>, path: readonly string[], input: unknown) => Promise<Response>;
9
+ fetch?: (request: Request, init: Record<never, never>, options: ClientOptions<T>, path: readonly string[], input: unknown) => Promise<Response>;
10
10
  }
11
11
  declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
12
12
  private readonly fetch;
13
13
  private readonly toFetchRequestOptions;
14
14
  constructor(options: LinkFetchClientOptions<T>);
15
- call(request: StandardRequest, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
15
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
16
16
  }
17
17
 
18
18
  interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions<T>, LinkFetchClientOptions<T> {
@@ -20,11 +20,11 @@ interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions
20
20
  declare class RPCLink<T extends ClientContext> implements ClientLink<T> {
21
21
  private readonly standardLink;
22
22
  constructor(options: RPCLinkOptions<T>);
23
- call(path: readonly string[], input: unknown, options: ClientOptionsOut<T>): Promise<unknown>;
23
+ call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
24
24
  }
25
25
 
26
26
  interface FetchWithContext<TClientContext extends ClientContext> {
27
- (url: URL, init: RequestInit, options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
27
+ (url: URL, init: RequestInit, options: ClientOptions<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
28
28
  }
29
29
 
30
30
  export { type FetchWithContext, LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
@@ -1,18 +1,18 @@
1
1
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
2
2
  import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
3
- import { a as ClientContext, C as ClientOptionsOut, b as ClientLink } from '../../shared/client.CupM8eRP.js';
4
- import { b as StandardLinkClient } from '../../shared/client.aGal-uGY.js';
3
+ import { a as ClientContext, C as ClientOptions, b as ClientLink } from '../../shared/client.RZs5Myak.js';
4
+ import { b as StandardLinkClient } from '../../shared/client.Bt40CWA-.js';
5
5
  import { StandardRPCLinkOptions } from '../standard/index.js';
6
6
  import '@orpc/shared';
7
7
 
8
8
  interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
9
- fetch?: (request: Request, init: Record<never, never>, options: ClientOptionsOut<T>, path: readonly string[], input: unknown) => Promise<Response>;
9
+ fetch?: (request: Request, init: Record<never, never>, options: ClientOptions<T>, path: readonly string[], input: unknown) => Promise<Response>;
10
10
  }
11
11
  declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
12
12
  private readonly fetch;
13
13
  private readonly toFetchRequestOptions;
14
14
  constructor(options: LinkFetchClientOptions<T>);
15
- call(request: StandardRequest, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
15
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
16
16
  }
17
17
 
18
18
  interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions<T>, LinkFetchClientOptions<T> {
@@ -20,11 +20,11 @@ interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions
20
20
  declare class RPCLink<T extends ClientContext> implements ClientLink<T> {
21
21
  private readonly standardLink;
22
22
  constructor(options: RPCLinkOptions<T>);
23
- call(path: readonly string[], input: unknown, options: ClientOptionsOut<T>): Promise<unknown>;
23
+ call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
24
24
  }
25
25
 
26
26
  interface FetchWithContext<TClientContext extends ClientContext> {
27
- (url: URL, init: RequestInit, options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
27
+ (url: URL, init: RequestInit, options: ClientOptions<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
28
28
  }
29
29
 
30
30
  export { type FetchWithContext, LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
@@ -1,9 +1,8 @@
1
1
  import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
2
- import { b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer, S as StandardLink } from '../../shared/client.Be-O_tdu.mjs';
2
+ import { b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer, S as StandardLink } from '../../shared/client.CAwgYDwB.mjs';
3
3
  import '@orpc/shared';
4
- import '../../shared/client.CvnV7_uV.mjs';
5
- import '@orpc/standard-server';
6
4
  import '../../shared/client.BacCdg3F.mjs';
5
+ import '@orpc/standard-server';
7
6
 
8
7
  class LinkFetchClient {
9
8
  fetch;
@@ -1,7 +1,7 @@
1
- import { c as StandardLinkCodec, S as StandardLinkOptions } from '../../shared/client.DrOAzyMB.mjs';
2
- export { I as InvalidEventIteratorRetryResponse, d as StandardLink, b as StandardLinkClient } from '../../shared/client.DrOAzyMB.mjs';
1
+ import { c as StandardLinkCodec, a as StandardLinkOptions } from '../../shared/client.CKw2tbcl.mjs';
2
+ export { I as InvalidEventIteratorRetryResponse, d as StandardLink, b as StandardLinkClient, S as StandardLinkPlugin } from '../../shared/client.CKw2tbcl.mjs';
3
3
  import { Segment, Value } from '@orpc/shared';
4
- import { a as ClientContext, C as ClientOptionsOut } from '../../shared/client.CupM8eRP.mjs';
4
+ import { a as ClientContext, C as ClientOptions } from '../../shared/client.RZs5Myak.mjs';
5
5
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
6
6
 
7
7
  declare const STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES: {
@@ -47,7 +47,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
47
47
  * Base url for all requests.
48
48
  */
49
49
  url: Value<string | URL, [
50
- options: ClientOptionsOut<T>,
50
+ options: ClientOptions<T>,
51
51
  path: readonly string[],
52
52
  input: unknown
53
53
  ]>;
@@ -57,7 +57,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
57
57
  * @default 2083
58
58
  */
59
59
  maxUrlLength?: Value<number, [
60
- options: ClientOptionsOut<T>,
60
+ options: ClientOptions<T>,
61
61
  path: readonly string[],
62
62
  input: unknown
63
63
  ]>;
@@ -67,7 +67,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
67
67
  * @default 'POST'
68
68
  */
69
69
  method?: Value<HTTPMethod, [
70
- options: ClientOptionsOut<T>,
70
+ options: ClientOptions<T>,
71
71
  path: readonly string[],
72
72
  input: unknown
73
73
  ]>;
@@ -82,7 +82,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
82
82
  * Inject headers to the request.
83
83
  */
84
84
  headers?: Value<StandardHeaders, [
85
- options: ClientOptionsOut<T>,
85
+ options: ClientOptions<T>,
86
86
  path: readonly string[],
87
87
  input: unknown
88
88
  ]>;
@@ -95,7 +95,7 @@ declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardL
95
95
  private readonly expectedMethod;
96
96
  private readonly headers;
97
97
  constructor(serializer: StandardRPCSerializer, options: StandardRPCLinkCodecOptions<T>);
98
- encode(path: readonly string[], input: unknown, options: ClientOptionsOut<any>): Promise<StandardRequest>;
98
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
99
99
  decode(response: StandardLazyResponse): Promise<unknown>;
100
100
  }
101
101
 
@@ -1,7 +1,7 @@
1
- import { c as StandardLinkCodec, S as StandardLinkOptions } from '../../shared/client.aGal-uGY.js';
2
- export { I as InvalidEventIteratorRetryResponse, d as StandardLink, b as StandardLinkClient } from '../../shared/client.aGal-uGY.js';
1
+ import { c as StandardLinkCodec, a as StandardLinkOptions } from '../../shared/client.Bt40CWA-.js';
2
+ export { I as InvalidEventIteratorRetryResponse, d as StandardLink, b as StandardLinkClient, S as StandardLinkPlugin } from '../../shared/client.Bt40CWA-.js';
3
3
  import { Segment, Value } from '@orpc/shared';
4
- import { a as ClientContext, C as ClientOptionsOut } from '../../shared/client.CupM8eRP.js';
4
+ import { a as ClientContext, C as ClientOptions } from '../../shared/client.RZs5Myak.js';
5
5
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
6
6
 
7
7
  declare const STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES: {
@@ -47,7 +47,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
47
47
  * Base url for all requests.
48
48
  */
49
49
  url: Value<string | URL, [
50
- options: ClientOptionsOut<T>,
50
+ options: ClientOptions<T>,
51
51
  path: readonly string[],
52
52
  input: unknown
53
53
  ]>;
@@ -57,7 +57,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
57
57
  * @default 2083
58
58
  */
59
59
  maxUrlLength?: Value<number, [
60
- options: ClientOptionsOut<T>,
60
+ options: ClientOptions<T>,
61
61
  path: readonly string[],
62
62
  input: unknown
63
63
  ]>;
@@ -67,7 +67,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
67
67
  * @default 'POST'
68
68
  */
69
69
  method?: Value<HTTPMethod, [
70
- options: ClientOptionsOut<T>,
70
+ options: ClientOptions<T>,
71
71
  path: readonly string[],
72
72
  input: unknown
73
73
  ]>;
@@ -82,7 +82,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
82
82
  * Inject headers to the request.
83
83
  */
84
84
  headers?: Value<StandardHeaders, [
85
- options: ClientOptionsOut<T>,
85
+ options: ClientOptions<T>,
86
86
  path: readonly string[],
87
87
  input: unknown
88
88
  ]>;
@@ -95,7 +95,7 @@ declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardL
95
95
  private readonly expectedMethod;
96
96
  private readonly headers;
97
97
  constructor(serializer: StandardRPCSerializer, options: StandardRPCLinkCodecOptions<T>);
98
- encode(path: readonly string[], input: unknown, options: ClientOptionsOut<any>): Promise<StandardRequest>;
98
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
99
99
  decode(response: StandardLazyResponse): Promise<unknown>;
100
100
  }
101
101
 
@@ -1,5 +1,4 @@
1
- export { I as InvalidEventIteratorRetryResponse, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.Be-O_tdu.mjs';
1
+ export { I as InvalidEventIteratorRetryResponse, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.CAwgYDwB.mjs';
2
2
  import '@orpc/shared';
3
- import '../../shared/client.CvnV7_uV.mjs';
4
- import '@orpc/standard-server';
5
3
  import '../../shared/client.BacCdg3F.mjs';
4
+ import '@orpc/standard-server';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NestedClient, b as ClientLink, I as InferClientContext, a as ClientContext, C as ClientOptionsOut, c as ClientPromiseResult } from './shared/client.CupM8eRP.mjs';
2
- export { f as Client, d as ClientOptions, e as ClientRest } from './shared/client.CupM8eRP.mjs';
1
+ import { N as NestedClient, b as ClientLink, I as InferClientContext, a as ClientContext, C as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.RZs5Myak.mjs';
2
+ export { e as Client, d as ClientRest } from './shared/client.RZs5Myak.mjs';
3
3
  import { Promisable, MaybeOptionalOptions } from '@orpc/shared';
4
4
  export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
5
5
  export { ErrorEvent } from '@orpc/standard-server';
@@ -18,8 +18,8 @@ declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<
18
18
  */
19
19
  declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
20
20
  private readonly linkResolver;
21
- constructor(linkResolver: (options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
22
- call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
21
+ constructor(linkResolver: (options: ClientOptions<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
22
+ call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
23
23
  }
24
24
 
25
25
  declare const COMMON_ORPC_ERROR_DEFS: {
@@ -146,5 +146,6 @@ type SafeResult<TOutput, TError extends Error> = [error: null, data: TOutput, is
146
146
  isDefined: true;
147
147
  };
148
148
  declare function safe<TOutput, TError extends Error>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
149
+ declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
149
150
 
150
- export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink, ClientOptionsOut, ClientPromiseResult, type CommonORPCErrorCode, DynamicLink, InferClientContext, NestedClient, ORPCError, type ORPCErrorCode, type ORPCErrorJSON, type ORPCErrorOptions, type SafeResult, createORPCClient, type createORPCClientOptions, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, mapEventIterator, safe, toORPCError };
151
+ 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, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NestedClient, b as ClientLink, I as InferClientContext, a as ClientContext, C as ClientOptionsOut, c as ClientPromiseResult } from './shared/client.CupM8eRP.js';
2
- export { f as Client, d as ClientOptions, e as ClientRest } from './shared/client.CupM8eRP.js';
1
+ import { N as NestedClient, b as ClientLink, I as InferClientContext, a as ClientContext, C as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.RZs5Myak.js';
2
+ export { e as Client, d as ClientRest } from './shared/client.RZs5Myak.js';
3
3
  import { Promisable, MaybeOptionalOptions } from '@orpc/shared';
4
4
  export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
5
5
  export { ErrorEvent } from '@orpc/standard-server';
@@ -18,8 +18,8 @@ declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<
18
18
  */
19
19
  declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
20
20
  private readonly linkResolver;
21
- constructor(linkResolver: (options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
22
- call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
21
+ constructor(linkResolver: (options: ClientOptions<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
22
+ call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
23
23
  }
24
24
 
25
25
  declare const COMMON_ORPC_ERROR_DEFS: {
@@ -146,5 +146,6 @@ type SafeResult<TOutput, TError extends Error> = [error: null, data: TOutput, is
146
146
  isDefined: true;
147
147
  };
148
148
  declare function safe<TOutput, TError extends Error>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
149
+ declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
149
150
 
150
- export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink, ClientOptionsOut, ClientPromiseResult, type CommonORPCErrorCode, DynamicLink, InferClientContext, NestedClient, ORPCError, type ORPCErrorCode, type ORPCErrorJSON, type ORPCErrorOptions, type SafeResult, createORPCClient, type createORPCClientOptions, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, mapEventIterator, safe, toORPCError };
151
+ 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, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
package/dist/index.mjs CHANGED
@@ -3,15 +3,39 @@ export { C as COMMON_ORPC_ERROR_DEFS, O as ORPCError, a as fallbackORPCErrorMess
3
3
  export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
4
4
  export { ErrorEvent } from '@orpc/standard-server';
5
5
 
6
+ async function safe(promise) {
7
+ try {
8
+ const output = await promise;
9
+ return Object.assign(
10
+ [null, output, false],
11
+ { error: null, data: output, isDefined: false }
12
+ );
13
+ } catch (e) {
14
+ const error = e;
15
+ if (isDefinedError(error)) {
16
+ return Object.assign(
17
+ [error, void 0, true],
18
+ { error, data: void 0, isDefined: true }
19
+ );
20
+ }
21
+ return Object.assign(
22
+ [error, void 0, false],
23
+ { error, data: void 0, isDefined: false }
24
+ );
25
+ }
26
+ }
27
+ function resolveFriendlyClientOptions(options) {
28
+ return {
29
+ ...options,
30
+ context: options?.context ?? {}
31
+ // Context only optional if all fields are optional
32
+ };
33
+ }
34
+
6
35
  function createORPCClient(link, options) {
7
36
  const path = options?.path ?? [];
8
- const procedureClient = async (...[input, options2]) => {
9
- const optionsOut = {
10
- ...options2,
11
- context: options2?.context ?? {}
12
- // options.context can be undefined when all field is optional
13
- };
14
- return await link.call(path, input, optionsOut);
37
+ const procedureClient = async (...[input, options2 = {}]) => {
38
+ return await link.call(path, input, resolveFriendlyClientOptions(options2));
15
39
  };
16
40
  const recursive = new Proxy(procedureClient, {
17
41
  get(target, key) {
@@ -38,26 +62,4 @@ class DynamicLink {
38
62
  }
39
63
  }
40
64
 
41
- async function safe(promise) {
42
- try {
43
- const output = await promise;
44
- return Object.assign(
45
- [null, output, false],
46
- { error: null, data: output, isDefined: false }
47
- );
48
- } catch (e) {
49
- const error = e;
50
- if (isDefinedError(error)) {
51
- return Object.assign(
52
- [error, void 0, true],
53
- { error, data: void 0, isDefined: true }
54
- );
55
- }
56
- return Object.assign(
57
- [error, void 0, false],
58
- { error, data: void 0, isDefined: false }
59
- );
60
- }
61
- }
62
-
63
- export { DynamicLink, createORPCClient, isDefinedError, safe };
65
+ export { DynamicLink, createORPCClient, isDefinedError, resolveFriendlyClientOptions, safe };
@@ -1,12 +1,11 @@
1
- import { C as ClientPlugin, S as StandardLinkOptions } from '../shared/client.DrOAzyMB.mjs';
2
- export { a as CompositeClientPlugin } from '../shared/client.DrOAzyMB.mjs';
3
1
  import { Value } from '@orpc/shared';
4
- import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM8eRP.mjs';
2
+ import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.CKw2tbcl.mjs';
3
+ import { C as ClientOptions } from '../shared/client.RZs5Myak.mjs';
5
4
  import '@orpc/standard-server';
6
5
 
7
6
  interface ClientRetryPluginAttemptOptions {
8
- eventIteratorLastRetry: number | undefined;
9
- eventIteratorLastEventId: string | undefined;
7
+ lastEventRetry: number | undefined;
8
+ lastEventId: string | undefined;
10
9
  attemptIndex: number;
11
10
  error: unknown;
12
11
  }
@@ -21,11 +20,11 @@ interface ClientRetryPluginContext {
21
20
  /**
22
21
  * Delay (in ms) before retrying.
23
22
  *
24
- * @default (o) => o.eventIteratorLastRetry ?? 2000
23
+ * @default (o) => o.lastEventRetry ?? 2000
25
24
  */
26
25
  retryDelay?: Value<number, [
27
26
  attemptOptions: ClientRetryPluginAttemptOptions,
28
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
27
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
29
28
  path: readonly string[],
30
29
  input: unknown
31
30
  ]>;
@@ -36,21 +35,21 @@ interface ClientRetryPluginContext {
36
35
  */
37
36
  shouldRetry?: Value<boolean, [
38
37
  attemptOptions: ClientRetryPluginAttemptOptions,
39
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
38
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
40
39
  path: readonly string[],
41
40
  input: unknown
42
41
  ]>;
43
42
  /**
44
43
  * The hook called when retrying, and return the unsubscribe function.
45
44
  */
46
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptionsOut<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
45
+ onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
47
46
  }
48
47
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
49
48
  }
50
49
  interface ClientRetryPluginOptions {
51
50
  default?: ClientRetryPluginContext;
52
51
  }
53
- declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginContext> implements ClientPlugin<T> {
52
+ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
54
53
  private readonly defaultRetry;
55
54
  private readonly defaultRetryDelay;
56
55
  private readonly defaultShouldRetry;
@@ -59,4 +58,4 @@ declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginConte
59
58
  init(options: StandardLinkOptions<T>): void;
60
59
  }
61
60
 
62
- export { ClientPlugin, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
61
+ export { ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
@@ -1,12 +1,11 @@
1
- import { C as ClientPlugin, S as StandardLinkOptions } from '../shared/client.aGal-uGY.js';
2
- export { a as CompositeClientPlugin } from '../shared/client.aGal-uGY.js';
3
1
  import { Value } from '@orpc/shared';
4
- import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM8eRP.js';
2
+ import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.Bt40CWA-.js';
3
+ import { C as ClientOptions } from '../shared/client.RZs5Myak.js';
5
4
  import '@orpc/standard-server';
6
5
 
7
6
  interface ClientRetryPluginAttemptOptions {
8
- eventIteratorLastRetry: number | undefined;
9
- eventIteratorLastEventId: string | undefined;
7
+ lastEventRetry: number | undefined;
8
+ lastEventId: string | undefined;
10
9
  attemptIndex: number;
11
10
  error: unknown;
12
11
  }
@@ -21,11 +20,11 @@ interface ClientRetryPluginContext {
21
20
  /**
22
21
  * Delay (in ms) before retrying.
23
22
  *
24
- * @default (o) => o.eventIteratorLastRetry ?? 2000
23
+ * @default (o) => o.lastEventRetry ?? 2000
25
24
  */
26
25
  retryDelay?: Value<number, [
27
26
  attemptOptions: ClientRetryPluginAttemptOptions,
28
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
27
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
29
28
  path: readonly string[],
30
29
  input: unknown
31
30
  ]>;
@@ -36,21 +35,21 @@ interface ClientRetryPluginContext {
36
35
  */
37
36
  shouldRetry?: Value<boolean, [
38
37
  attemptOptions: ClientRetryPluginAttemptOptions,
39
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
38
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
40
39
  path: readonly string[],
41
40
  input: unknown
42
41
  ]>;
43
42
  /**
44
43
  * The hook called when retrying, and return the unsubscribe function.
45
44
  */
46
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptionsOut<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
45
+ onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
47
46
  }
48
47
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
49
48
  }
50
49
  interface ClientRetryPluginOptions {
51
50
  default?: ClientRetryPluginContext;
52
51
  }
53
- declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginContext> implements ClientPlugin<T> {
52
+ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
54
53
  private readonly defaultRetry;
55
54
  private readonly defaultRetryDelay;
56
55
  private readonly defaultShouldRetry;
@@ -59,4 +58,4 @@ declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginConte
59
58
  init(options: StandardLinkOptions<T>): void;
60
59
  }
61
60
 
62
- export { ClientPlugin, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
61
+ export { ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
@@ -1,4 +1,3 @@
1
- export { C as CompositeClientPlugin } from '../shared/client.CvnV7_uV.mjs';
2
1
  import { isAsyncIteratorObject, value } from '@orpc/shared';
3
2
  import { getEventMeta } from '@orpc/standard-server';
4
3
 
@@ -11,7 +10,7 @@ class ClientRetryPlugin {
11
10
  defaultOnRetry;
12
11
  constructor(options = {}) {
13
12
  this.defaultRetry = options.default?.retry ?? 0;
14
- this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.eventIteratorLastRetry ?? 2e3);
13
+ this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.lastEventRetry ?? 2e3);
15
14
  this.defaultShouldRetry = options.default?.shouldRetry ?? true;
16
15
  this.defaultOnRetry = options.default?.onRetry;
17
16
  }
@@ -25,13 +24,14 @@ class ClientRetryPlugin {
25
24
  if (maxAttempts <= 0) {
26
25
  return interceptorOptions.next();
27
26
  }
28
- let eventIteratorLastEventId = interceptorOptions.options.lastEventId;
29
- let eventIteratorLastRetry;
27
+ let lastEventId = interceptorOptions.options.lastEventId;
28
+ let lastEventRetry;
30
29
  let unsubscribe;
31
30
  let attemptIndex = 0;
32
31
  const next = async (initial) => {
33
32
  let current = initial;
34
33
  while (true) {
34
+ const newClientOptions = { ...interceptorOptions.options, lastEventId };
35
35
  if (current) {
36
36
  if (attemptIndex >= maxAttempts) {
37
37
  throw current.error;
@@ -39,13 +39,13 @@ class ClientRetryPlugin {
39
39
  const attemptOptions = {
40
40
  attemptIndex,
41
41
  error: current.error,
42
- eventIteratorLastEventId,
43
- eventIteratorLastRetry
42
+ lastEventId,
43
+ lastEventRetry
44
44
  };
45
45
  const shouldRetryBool = await value(
46
46
  shouldRetry,
47
47
  attemptOptions,
48
- interceptorOptions.options,
48
+ newClientOptions,
49
49
  interceptorOptions.path,
50
50
  interceptorOptions.input
51
51
  );
@@ -54,14 +54,14 @@ class ClientRetryPlugin {
54
54
  }
55
55
  unsubscribe = onRetry?.(
56
56
  attemptOptions,
57
- interceptorOptions.options,
57
+ newClientOptions,
58
58
  interceptorOptions.path,
59
59
  interceptorOptions.input
60
60
  );
61
61
  const retryDelayMs = await value(
62
62
  retryDelay,
63
63
  attemptOptions,
64
- interceptorOptions.options,
64
+ newClientOptions,
65
65
  interceptorOptions.path,
66
66
  interceptorOptions.input
67
67
  );
@@ -69,14 +69,13 @@ class ClientRetryPlugin {
69
69
  attemptIndex++;
70
70
  }
71
71
  try {
72
- const newClientOptions = { ...interceptorOptions.options, lastEventId: eventIteratorLastEventId };
73
72
  const output2 = await interceptorOptions.next({
74
73
  ...interceptorOptions,
75
74
  options: newClientOptions
76
75
  });
77
76
  return output2;
78
77
  } catch (error) {
79
- if (interceptorOptions.options.signal?.aborted === true) {
78
+ if (newClientOptions.signal?.aborted === true) {
80
79
  throw error;
81
80
  }
82
81
  current = { error };
@@ -97,16 +96,16 @@ class ClientRetryPlugin {
97
96
  try {
98
97
  const item = await current.next();
99
98
  const meta = getEventMeta(item.value);
100
- eventIteratorLastEventId = meta?.id ?? eventIteratorLastEventId;
101
- eventIteratorLastRetry = meta?.retry ?? eventIteratorLastRetry;
99
+ lastEventId = meta?.id ?? lastEventId;
100
+ lastEventRetry = meta?.retry ?? lastEventRetry;
102
101
  if (item.done) {
103
102
  return item.value;
104
103
  }
105
104
  yield item.value;
106
105
  } catch (error) {
107
106
  const meta = getEventMeta(error);
108
- eventIteratorLastEventId = meta?.id ?? eventIteratorLastEventId;
109
- eventIteratorLastRetry = meta?.retry ?? eventIteratorLastRetry;
107
+ lastEventId = meta?.id ?? lastEventId;
108
+ lastEventRetry = meta?.retry ?? lastEventRetry;
110
109
  const maybeEventIterator = await next({ error });
111
110
  if (!isAsyncIteratorObject(maybeEventIterator)) {
112
111
  throw new ClientRetryPluginInvalidEventIteratorRetryResponse(
@@ -1,27 +1,30 @@
1
1
  import { Interceptor } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { a as ClientContext, C as ClientOptionsOut, b as ClientLink } from './client.CupM8eRP.js';
3
+ import { a as ClientContext, C as ClientOptions, b as ClientLink } from './client.RZs5Myak.js';
4
4
 
5
5
  interface StandardLinkCodec<T extends ClientContext> {
6
- encode(path: readonly string[], input: unknown, options: ClientOptionsOut<any>): Promise<StandardRequest>;
7
- decode(response: StandardLazyResponse, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<unknown>;
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
8
  }
9
9
  interface StandardLinkClient<T extends ClientContext> {
10
- call(request: StandardRequest, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
10
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
11
11
  }
12
12
 
13
13
  declare class InvalidEventIteratorRetryResponse extends Error {
14
14
  }
15
+ interface StandardLinkPlugin<T extends ClientContext> {
16
+ init?(options: StandardLinkOptions<T>): void;
17
+ }
15
18
  interface StandardLinkOptions<T extends ClientContext> {
16
19
  interceptors?: Interceptor<{
17
20
  path: readonly string[];
18
21
  input: unknown;
19
- options: ClientOptionsOut<T>;
22
+ options: ClientOptions<T>;
20
23
  }, unknown, unknown>[];
21
24
  clientInterceptors?: Interceptor<{
22
25
  request: StandardRequest;
23
26
  }, StandardLazyResponse, unknown>[];
24
- plugins?: ClientPlugin<T>[];
27
+ plugins?: StandardLinkPlugin<T>[];
25
28
  }
26
29
  declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
27
30
  #private;
@@ -30,16 +33,7 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
30
33
  private readonly interceptors;
31
34
  private readonly clientInterceptors;
32
35
  constructor(codec: StandardLinkCodec<T>, sender: StandardLinkClient<T>, options?: StandardLinkOptions<T>);
33
- call(path: readonly string[], input: unknown, options: ClientOptionsOut<T>): Promise<unknown>;
34
- }
35
-
36
- interface ClientPlugin<T extends ClientContext> {
37
- init?(options: StandardLinkOptions<T>): void;
38
- }
39
- declare class CompositeClientPlugin<T extends ClientContext> implements ClientPlugin<T> {
40
- private readonly plugins;
41
- constructor(plugins?: ClientPlugin<T>[]);
42
- init(options: StandardLinkOptions<T>): void;
36
+ call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
43
37
  }
44
38
 
45
- export { type ClientPlugin as C, InvalidEventIteratorRetryResponse as I, type StandardLinkOptions as S, CompositeClientPlugin as a, type StandardLinkClient as b, type StandardLinkCodec as c, StandardLink as d };
39
+ export { InvalidEventIteratorRetryResponse as I, type StandardLinkPlugin as S, type StandardLinkOptions as a, type StandardLinkClient as b, type StandardLinkCodec as c, StandardLink as d };
@@ -1,7 +1,6 @@
1
- import { intercept, isObject, value, trim, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
2
- import { C as CompositeClientPlugin } from './client.CvnV7_uV.mjs';
3
- import { ErrorEvent } from '@orpc/standard-server';
1
+ import { toArray, intercept, isObject, value, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
4
2
  import { O as ORPCError, m as mapEventIterator, t as toORPCError } from './client.BacCdg3F.mjs';
3
+ import { ErrorEvent } from '@orpc/standard-server';
5
4
 
6
5
  class InvalidEventIteratorRetryResponse extends Error {
7
6
  }
@@ -9,10 +8,11 @@ class StandardLink {
9
8
  constructor(codec, sender, options = {}) {
10
9
  this.codec = codec;
11
10
  this.sender = sender;
12
- const plugin = new CompositeClientPlugin(options.plugins);
13
- plugin.init(options);
14
- this.interceptors = options.interceptors ?? [];
15
- this.clientInterceptors = options.clientInterceptors ?? [];
11
+ for (const plugin of toArray(options.plugins)) {
12
+ plugin.init?.(options);
13
+ }
14
+ this.interceptors = toArray(options.interceptors);
15
+ this.clientInterceptors = toArray(options.clientInterceptors);
16
16
  }
17
17
  interceptors;
18
18
  clientInterceptors;
@@ -111,6 +111,9 @@ class StandardRPCJsonSerializer {
111
111
  if (isObject(data)) {
112
112
  const json = {};
113
113
  for (const k in data) {
114
+ if (k === "toJSON" && typeof data[k] === "function") {
115
+ continue;
116
+ }
114
117
  json[k] = this.serialize(data[k], [...segments, k], meta, maps, blobs)[0];
115
118
  }
116
119
  return [json, meta, maps, blobs];
@@ -195,7 +198,7 @@ class StandardRPCLinkCodec {
195
198
  const expectedMethod = await value(this.expectedMethod, options, path, input);
196
199
  const headers = { ...await value(this.headers, options, path, input) };
197
200
  const baseUrl = await value(this.baseUrl, options, path, input);
198
- const url = new URL(`${trim(baseUrl.toString(), "/")}/${path.map(encodeURIComponent).join("/")}`);
201
+ const url = new URL(`${baseUrl.toString().replace(/\/$/, "")}/${path.map(encodeURIComponent).join("/")}`);
199
202
  if (options.lastEventId !== void 0) {
200
203
  if (Array.isArray(headers["last-event-id"])) {
201
204
  headers["last-event-id"] = [...headers["last-event-id"], options.lastEventId];
@@ -1,27 +1,30 @@
1
1
  import { Interceptor } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { a as ClientContext, C as ClientOptionsOut, b as ClientLink } from './client.CupM8eRP.mjs';
3
+ import { a as ClientContext, C as ClientOptions, b as ClientLink } from './client.RZs5Myak.mjs';
4
4
 
5
5
  interface StandardLinkCodec<T extends ClientContext> {
6
- encode(path: readonly string[], input: unknown, options: ClientOptionsOut<any>): Promise<StandardRequest>;
7
- decode(response: StandardLazyResponse, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<unknown>;
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
8
  }
9
9
  interface StandardLinkClient<T extends ClientContext> {
10
- call(request: StandardRequest, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
10
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
11
11
  }
12
12
 
13
13
  declare class InvalidEventIteratorRetryResponse extends Error {
14
14
  }
15
+ interface StandardLinkPlugin<T extends ClientContext> {
16
+ init?(options: StandardLinkOptions<T>): void;
17
+ }
15
18
  interface StandardLinkOptions<T extends ClientContext> {
16
19
  interceptors?: Interceptor<{
17
20
  path: readonly string[];
18
21
  input: unknown;
19
- options: ClientOptionsOut<T>;
22
+ options: ClientOptions<T>;
20
23
  }, unknown, unknown>[];
21
24
  clientInterceptors?: Interceptor<{
22
25
  request: StandardRequest;
23
26
  }, StandardLazyResponse, unknown>[];
24
- plugins?: ClientPlugin<T>[];
27
+ plugins?: StandardLinkPlugin<T>[];
25
28
  }
26
29
  declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
27
30
  #private;
@@ -30,16 +33,7 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
30
33
  private readonly interceptors;
31
34
  private readonly clientInterceptors;
32
35
  constructor(codec: StandardLinkCodec<T>, sender: StandardLinkClient<T>, options?: StandardLinkOptions<T>);
33
- call(path: readonly string[], input: unknown, options: ClientOptionsOut<T>): Promise<unknown>;
34
- }
35
-
36
- interface ClientPlugin<T extends ClientContext> {
37
- init?(options: StandardLinkOptions<T>): void;
38
- }
39
- declare class CompositeClientPlugin<T extends ClientContext> implements ClientPlugin<T> {
40
- private readonly plugins;
41
- constructor(plugins?: ClientPlugin<T>[]);
42
- init(options: StandardLinkOptions<T>): void;
36
+ call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
43
37
  }
44
38
 
45
- export { type ClientPlugin as C, InvalidEventIteratorRetryResponse as I, type StandardLinkOptions as S, CompositeClientPlugin as a, type StandardLinkClient as b, type StandardLinkCodec as c, StandardLink as d };
39
+ export { InvalidEventIteratorRetryResponse as I, type StandardLinkPlugin as S, type StandardLinkOptions as a, type StandardLinkClient as b, type StandardLinkCodec as c, StandardLink as d };
@@ -1,5 +1,5 @@
1
1
  type ClientContext = Record<string, any>;
2
- type ClientOptions<TClientContext extends ClientContext> = {
2
+ type FriendlyClientOptions<TClientContext extends ClientContext> = {
3
3
  signal?: AbortSignal;
4
4
  lastEventId?: string | undefined;
5
5
  } & (Record<never, never> extends TClientContext ? {
@@ -7,7 +7,7 @@ type ClientOptions<TClientContext extends ClientContext> = {
7
7
  } : {
8
8
  context: TClientContext;
9
9
  });
10
- type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options: ClientOptions<TClientContext>];
10
+ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
11
11
  type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
12
12
  __error?: {
13
13
  type: TError;
@@ -20,11 +20,11 @@ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext,
20
20
  [k: string]: NestedClient<TClientContext>;
21
21
  };
22
22
  type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
23
- type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
23
+ type ClientOptions<TClientContext extends ClientContext> = FriendlyClientOptions<TClientContext> & {
24
24
  context: TClientContext;
25
25
  };
26
26
  interface ClientLink<TClientContext extends ClientContext> {
27
- call: (path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>) => Promise<unknown>;
27
+ call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
28
28
  }
29
29
 
30
- export type { ClientOptionsOut as C, InferClientContext as I, NestedClient as N, ClientContext as a, ClientLink as b, ClientPromiseResult as c, ClientOptions as d, ClientRest as e, Client as f };
30
+ export type { ClientOptions as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ClientContext as a, ClientLink as b, ClientPromiseResult as c, ClientRest as d, Client as e };
@@ -1,5 +1,5 @@
1
1
  type ClientContext = Record<string, any>;
2
- type ClientOptions<TClientContext extends ClientContext> = {
2
+ type FriendlyClientOptions<TClientContext extends ClientContext> = {
3
3
  signal?: AbortSignal;
4
4
  lastEventId?: string | undefined;
5
5
  } & (Record<never, never> extends TClientContext ? {
@@ -7,7 +7,7 @@ type ClientOptions<TClientContext extends ClientContext> = {
7
7
  } : {
8
8
  context: TClientContext;
9
9
  });
10
- type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options: ClientOptions<TClientContext>];
10
+ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
11
11
  type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
12
12
  __error?: {
13
13
  type: TError;
@@ -20,11 +20,11 @@ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext,
20
20
  [k: string]: NestedClient<TClientContext>;
21
21
  };
22
22
  type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
23
- type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
23
+ type ClientOptions<TClientContext extends ClientContext> = FriendlyClientOptions<TClientContext> & {
24
24
  context: TClientContext;
25
25
  };
26
26
  interface ClientLink<TClientContext extends ClientContext> {
27
- call: (path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>) => Promise<unknown>;
27
+ call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
28
28
  }
29
29
 
30
- export type { ClientOptionsOut as C, InferClientContext as I, NestedClient as N, ClientContext as a, ClientLink as b, ClientPromiseResult as c, ClientOptions as d, ClientRest as e, Client as f };
30
+ export type { ClientOptions as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ClientContext as a, ClientLink as b, ClientPromiseResult as c, ClientRest as d, Client as e };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/client",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-beta.4",
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": "1.0.0-beta.2",
43
- "@orpc/standard-server-fetch": "1.0.0-beta.2",
44
- "@orpc/standard-server": "1.0.0-beta.2"
42
+ "@orpc/shared": "1.0.0-beta.4",
43
+ "@orpc/standard-server": "1.0.0-beta.4",
44
+ "@orpc/standard-server-fetch": "1.0.0-beta.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "zod": "^3.24.2"
@@ -1,12 +0,0 @@
1
- class CompositeClientPlugin {
2
- constructor(plugins = []) {
3
- this.plugins = plugins;
4
- }
5
- init(options) {
6
- for (const plugin of this.plugins) {
7
- plugin.init?.(options);
8
- }
9
- }
10
- }
11
-
12
- export { CompositeClientPlugin as C };