@orpc/client 0.0.0-next.3191601 → 0.0.0-next.32a6de9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
2
2
  import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
3
- import { a as ClientContext, b as ClientOptions } from '../../shared/client.C0lT7w02.mjs';
4
- import { d as StandardLinkClient, b as StandardLink } from '../../shared/client.5813Ufvs.mjs';
5
- import { f as StandardRPCLinkOptions } from '../../shared/client.Bt94sjrK.mjs';
3
+ import { a as ClientContext, b as ClientOptions } from '../../shared/client.CipPQkhk.mjs';
4
+ import { c as StandardLinkInterceptorOptions, f as StandardLinkClient, d as StandardLink } from '../../shared/client.C7z5zk4v.mjs';
5
+ import { f as StandardRPCLinkOptions } from '../../shared/client.Cev5VIeo.mjs';
6
6
  import '@orpc/shared';
7
7
 
8
8
  interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
9
9
  fetch?: (request: Request, init: {
10
10
  redirect?: Request['redirect'];
11
- }, options: ClientOptions<T>, path: readonly string[], input: unknown) => Promise<Response>;
11
+ }, options: StandardLinkInterceptorOptions<T>) => Promise<Response>;
12
12
  }
13
13
  declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
14
14
  private readonly fetch;
@@ -1,14 +1,14 @@
1
1
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
2
2
  import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
3
- import { a as ClientContext, b as ClientOptions } from '../../shared/client.C0lT7w02.js';
4
- import { d as StandardLinkClient, b as StandardLink } from '../../shared/client.grRbC25r.js';
5
- import { f as StandardRPCLinkOptions } from '../../shared/client.D-jrSuDb.js';
3
+ import { a as ClientContext, b as ClientOptions } from '../../shared/client.CipPQkhk.js';
4
+ import { c as StandardLinkInterceptorOptions, f as StandardLinkClient, d as StandardLink } from '../../shared/client.p3ON_yzu.js';
5
+ import { f as StandardRPCLinkOptions } from '../../shared/client.cs2A0fEV.js';
6
6
  import '@orpc/shared';
7
7
 
8
8
  interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
9
9
  fetch?: (request: Request, init: {
10
10
  redirect?: Request['redirect'];
11
- }, options: ClientOptions<T>, path: readonly string[], input: unknown) => Promise<Response>;
11
+ }, options: StandardLinkInterceptorOptions<T>) => Promise<Response>;
12
12
  }
13
13
  declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
14
14
  private readonly fetch;
@@ -1,5 +1,5 @@
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.DSPm2IGZ.mjs';
2
+ import { S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.BQuFq0Vi.mjs';
3
3
  import '@orpc/shared';
4
4
  import '@orpc/standard-server';
5
5
  import '../../shared/client.jKEwIsRd.mjs';
@@ -13,7 +13,7 @@ class LinkFetchClient {
13
13
  }
14
14
  async call(request, options, path, input) {
15
15
  const fetchRequest = toFetchRequest(request, this.toFetchRequestOptions);
16
- const fetchResponse = await this.fetch(fetchRequest, { redirect: "manual" }, options, path, input);
16
+ const fetchResponse = await this.fetch(fetchRequest, { redirect: "manual" }, { ...options, path, input });
17
17
  const lazyResponse = toStandardLazyResponse(fetchResponse);
18
18
  return lazyResponse;
19
19
  }
@@ -1,6 +1,6 @@
1
- export { I as InvalidEventIteratorRetryResponse, b as StandardLink, d as StandardLinkClient, c as StandardLinkCodec, a as StandardLinkOptions, S as StandardLinkPlugin } from '../../shared/client.5813Ufvs.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.Bt94sjrK.mjs';
3
- import { H as HTTPPath } from '../../shared/client.C0lT7w02.mjs';
1
+ export { 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.C7z5zk4v.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.Cev5VIeo.mjs';
3
+ import { H as HTTPPath } from '../../shared/client.CipPQkhk.mjs';
4
4
  import '@orpc/shared';
5
5
  import '@orpc/standard-server';
6
6
 
@@ -1,6 +1,6 @@
1
- export { I as InvalidEventIteratorRetryResponse, b as StandardLink, d as StandardLinkClient, c as StandardLinkCodec, a as StandardLinkOptions, S as StandardLinkPlugin } from '../../shared/client.grRbC25r.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.D-jrSuDb.js';
3
- import { H as HTTPPath } from '../../shared/client.C0lT7w02.js';
1
+ export { 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.p3ON_yzu.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.cs2A0fEV.js';
3
+ import { H as HTTPPath } from '../../shared/client.CipPQkhk.js';
4
4
  import '@orpc/shared';
5
5
  import '@orpc/standard-server';
6
6
 
@@ -1,4 +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, g as getMalformedResponseErrorCode, t as toHttpPath } from '../../shared/client.DSPm2IGZ.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, g as getMalformedResponseErrorCode, t as toHttpPath } from '../../shared/client.BQuFq0Vi.mjs';
2
2
  import '@orpc/shared';
3
3
  import '@orpc/standard-server';
4
4
  import '../../shared/client.jKEwIsRd.mjs';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientContext, b as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.C0lT7w02.mjs';
2
- export { f as Client, e as ClientRest, d as HTTPMethod, H as HTTPPath } from './shared/client.C0lT7w02.mjs';
1
+ import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientContext, b as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.CipPQkhk.mjs';
2
+ export { f as Client, e as ClientRest, d as HTTPMethod, H as HTTPPath } from './shared/client.CipPQkhk.mjs';
3
3
  import { Promisable, MaybeOptionalOptions, ThrowableError } from '@orpc/shared';
4
4
  export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
5
5
  export { ErrorEvent } from '@orpc/standard-server';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientContext, b as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.C0lT7w02.js';
2
- export { f as Client, e as ClientRest, d as HTTPMethod, H as HTTPPath } from './shared/client.C0lT7w02.js';
1
+ import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientContext, b as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.CipPQkhk.js';
2
+ export { f as Client, e as ClientRest, d as HTTPMethod, H as HTTPPath } from './shared/client.CipPQkhk.js';
3
3
  import { Promisable, MaybeOptionalOptions, ThrowableError } from '@orpc/shared';
4
4
  export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
5
5
  export { ErrorEvent } from '@orpc/standard-server';
@@ -1,11 +1,72 @@
1
1
  import { Value } from '@orpc/shared';
2
- import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.5813Ufvs.mjs';
3
- import { b as ClientOptions } from '../shared/client.C0lT7w02.mjs';
4
- import '@orpc/standard-server';
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.C7z5zk4v.mjs';
4
+ import { a as ClientContext } from '../shared/client.CipPQkhk.mjs';
5
5
 
6
- interface ClientRetryPluginAttemptOptions {
6
+ interface BatchLinkPluginGroup<T extends ClientContext> {
7
+ condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
8
+ context: T;
9
+ path?: readonly string[];
10
+ input?: unknown;
11
+ }
12
+ interface BatchLinkPluginOptions<T extends ClientContext> {
13
+ groups: readonly [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
14
+ /**
15
+ * The maximum number of requests in the batch.
16
+ *
17
+ * @default 10
18
+ */
19
+ maxSize?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
20
+ /**
21
+ * Defines the URL to use for the batch request.
22
+ *
23
+ * @default the URL of the first request in the batch + '/__batch__'
24
+ */
25
+ url?: Value<string | URL, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
26
+ /**
27
+ * The maximum length of the URL.
28
+ *
29
+ * @default 2083
30
+ */
31
+ maxUrlLength?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
32
+ /**
33
+ * Defines the HTTP headers to use for the batch request.
34
+ *
35
+ * @default The same headers of all requests in the batch
36
+ */
37
+ headers?: Value<StandardHeaders, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
38
+ /**
39
+ * Map the batch request items before sending them.
40
+ *
41
+ * @default Removes headers that are duplicated in the batch headers.
42
+ */
43
+ mapRequestItem?: (options: StandardLinkClientInterceptorOptions<T> & {
44
+ batchUrl: URL;
45
+ batchHeaders: StandardHeaders;
46
+ }) => StandardRequest;
47
+ /**
48
+ * Exclude a request from the batch.
49
+ *
50
+ * @default () => false
51
+ */
52
+ exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
53
+ }
54
+ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
55
+ #private;
56
+ private readonly groups;
57
+ private readonly maxSize;
58
+ private readonly batchUrl;
59
+ private readonly maxUrlLength;
60
+ private readonly batchHeaders;
61
+ private readonly mapRequestItem;
62
+ private readonly exclude;
63
+ private pending;
64
+ constructor(options: BatchLinkPluginOptions<T>);
65
+ init(options: StandardLinkOptions<T>): void;
66
+ }
67
+
68
+ interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
7
69
  lastEventRetry: number | undefined;
8
- lastEventId: string | undefined;
9
70
  attemptIndex: number;
10
71
  error: unknown;
11
72
  }
@@ -16,37 +77,23 @@ interface ClientRetryPluginContext {
16
77
  *
17
78
  * @default 0
18
79
  */
19
- retry?: Value<number, [
20
- clientOptions: ClientOptions<ClientRetryPluginContext>,
21
- path: readonly string[],
22
- input: unknown
23
- ]>;
80
+ retry?: Value<number, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
24
81
  /**
25
82
  * Delay (in ms) before retrying.
26
83
  *
27
84
  * @default (o) => o.lastEventRetry ?? 2000
28
85
  */
29
- retryDelay?: Value<number, [
30
- attemptOptions: ClientRetryPluginAttemptOptions,
31
- clientOptions: ClientOptions<ClientRetryPluginContext>,
32
- path: readonly string[],
33
- input: unknown
34
- ]>;
86
+ retryDelay?: Value<number, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
35
87
  /**
36
88
  * Determine should retry or not.
37
89
  *
38
90
  * @default true
39
91
  */
40
- shouldRetry?: Value<boolean, [
41
- attemptOptions: ClientRetryPluginAttemptOptions,
42
- clientOptions: ClientOptions<ClientRetryPluginContext>,
43
- path: readonly string[],
44
- input: unknown
45
- ]>;
92
+ shouldRetry?: Value<boolean, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
46
93
  /**
47
94
  * The hook called when retrying, and return the unsubscribe function.
48
95
  */
49
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
96
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | (() => void);
50
97
  }
51
98
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
52
99
  }
@@ -62,4 +109,4 @@ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements S
62
109
  init(options: StandardLinkOptions<T>): void;
63
110
  }
64
111
 
65
- export { ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
112
+ export { BatchLinkPlugin, type BatchLinkPluginGroup, type BatchLinkPluginOptions, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
@@ -1,11 +1,72 @@
1
1
  import { Value } from '@orpc/shared';
2
- import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.grRbC25r.js';
3
- import { b as ClientOptions } from '../shared/client.C0lT7w02.js';
4
- import '@orpc/standard-server';
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.p3ON_yzu.js';
4
+ import { a as ClientContext } from '../shared/client.CipPQkhk.js';
5
5
 
6
- interface ClientRetryPluginAttemptOptions {
6
+ interface BatchLinkPluginGroup<T extends ClientContext> {
7
+ condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
8
+ context: T;
9
+ path?: readonly string[];
10
+ input?: unknown;
11
+ }
12
+ interface BatchLinkPluginOptions<T extends ClientContext> {
13
+ groups: readonly [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
14
+ /**
15
+ * The maximum number of requests in the batch.
16
+ *
17
+ * @default 10
18
+ */
19
+ maxSize?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
20
+ /**
21
+ * Defines the URL to use for the batch request.
22
+ *
23
+ * @default the URL of the first request in the batch + '/__batch__'
24
+ */
25
+ url?: Value<string | URL, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
26
+ /**
27
+ * The maximum length of the URL.
28
+ *
29
+ * @default 2083
30
+ */
31
+ maxUrlLength?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
32
+ /**
33
+ * Defines the HTTP headers to use for the batch request.
34
+ *
35
+ * @default The same headers of all requests in the batch
36
+ */
37
+ headers?: Value<StandardHeaders, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
38
+ /**
39
+ * Map the batch request items before sending them.
40
+ *
41
+ * @default Removes headers that are duplicated in the batch headers.
42
+ */
43
+ mapRequestItem?: (options: StandardLinkClientInterceptorOptions<T> & {
44
+ batchUrl: URL;
45
+ batchHeaders: StandardHeaders;
46
+ }) => StandardRequest;
47
+ /**
48
+ * Exclude a request from the batch.
49
+ *
50
+ * @default () => false
51
+ */
52
+ exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
53
+ }
54
+ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
55
+ #private;
56
+ private readonly groups;
57
+ private readonly maxSize;
58
+ private readonly batchUrl;
59
+ private readonly maxUrlLength;
60
+ private readonly batchHeaders;
61
+ private readonly mapRequestItem;
62
+ private readonly exclude;
63
+ private pending;
64
+ constructor(options: BatchLinkPluginOptions<T>);
65
+ init(options: StandardLinkOptions<T>): void;
66
+ }
67
+
68
+ interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
7
69
  lastEventRetry: number | undefined;
8
- lastEventId: string | undefined;
9
70
  attemptIndex: number;
10
71
  error: unknown;
11
72
  }
@@ -16,37 +77,23 @@ interface ClientRetryPluginContext {
16
77
  *
17
78
  * @default 0
18
79
  */
19
- retry?: Value<number, [
20
- clientOptions: ClientOptions<ClientRetryPluginContext>,
21
- path: readonly string[],
22
- input: unknown
23
- ]>;
80
+ retry?: Value<number, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
24
81
  /**
25
82
  * Delay (in ms) before retrying.
26
83
  *
27
84
  * @default (o) => o.lastEventRetry ?? 2000
28
85
  */
29
- retryDelay?: Value<number, [
30
- attemptOptions: ClientRetryPluginAttemptOptions,
31
- clientOptions: ClientOptions<ClientRetryPluginContext>,
32
- path: readonly string[],
33
- input: unknown
34
- ]>;
86
+ retryDelay?: Value<number, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
35
87
  /**
36
88
  * Determine should retry or not.
37
89
  *
38
90
  * @default true
39
91
  */
40
- shouldRetry?: Value<boolean, [
41
- attemptOptions: ClientRetryPluginAttemptOptions,
42
- clientOptions: ClientOptions<ClientRetryPluginContext>,
43
- path: readonly string[],
44
- input: unknown
45
- ]>;
92
+ shouldRetry?: Value<boolean, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
46
93
  /**
47
94
  * The hook called when retrying, and return the unsubscribe function.
48
95
  */
49
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
96
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | (() => void);
50
97
  }
51
98
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
52
99
  }
@@ -62,4 +109,4 @@ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements S
62
109
  init(options: StandardLinkOptions<T>): void;
63
110
  }
64
111
 
65
- export { ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
112
+ export { BatchLinkPlugin, type BatchLinkPluginGroup, type BatchLinkPluginOptions, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
@@ -1,6 +1,151 @@
1
- import { value, isAsyncIteratorObject } from '@orpc/shared';
1
+ import { isAsyncIteratorObject, value, splitInHalf, toArray } from '@orpc/shared';
2
+ import { toBatchRequest, parseBatchResponse } from '@orpc/standard-server/batch';
2
3
  import { getEventMeta } from '@orpc/standard-server';
3
4
 
5
+ class BatchLinkPlugin {
6
+ groups;
7
+ maxSize;
8
+ batchUrl;
9
+ maxUrlLength;
10
+ batchHeaders;
11
+ mapRequestItem;
12
+ exclude;
13
+ pending;
14
+ constructor(options) {
15
+ this.groups = options.groups;
16
+ this.pending = /* @__PURE__ */ new Map();
17
+ this.maxSize = options.maxSize ?? 10;
18
+ this.maxUrlLength = options.maxUrlLength ?? 2083;
19
+ this.batchUrl = options.url ?? (([options2]) => `${options2.request.url.origin}${options2.request.url.pathname}/__batch__`);
20
+ this.batchHeaders = options.headers ?? (([options2, ...rest]) => {
21
+ const headers = {};
22
+ for (const [key, value2] of Object.entries(options2.request.headers)) {
23
+ if (rest.every((item) => item.request.headers[key] === value2)) {
24
+ headers[key] = value2;
25
+ }
26
+ }
27
+ return headers;
28
+ });
29
+ this.mapRequestItem = options.mapRequestItem ?? (({ request, batchHeaders }) => {
30
+ const headers = {};
31
+ for (const [key, value2] of Object.entries(request.headers)) {
32
+ if (batchHeaders[key] !== value2) {
33
+ headers[key] = value2;
34
+ }
35
+ }
36
+ return {
37
+ method: request.method,
38
+ url: request.url,
39
+ headers,
40
+ body: request.body,
41
+ signal: request.signal
42
+ };
43
+ });
44
+ this.exclude = options.exclude ?? (() => false);
45
+ }
46
+ init(options) {
47
+ options.clientInterceptors ??= [];
48
+ options.clientInterceptors.push((options2) => {
49
+ if (options2.request.headers["x-orpc-batch"] !== "1") {
50
+ return options2.next();
51
+ }
52
+ return options2.next({
53
+ ...options2,
54
+ request: {
55
+ ...options2.request,
56
+ headers: {
57
+ ...options2.request.headers,
58
+ "x-orpc-batch": void 0
59
+ }
60
+ }
61
+ });
62
+ });
63
+ options.clientInterceptors.push((options2) => {
64
+ if (this.exclude(options2) || options2.request.body instanceof Blob || options2.request.body instanceof FormData || isAsyncIteratorObject(options2.request.body)) {
65
+ return options2.next();
66
+ }
67
+ const group = this.groups.find((group2) => group2.condition(options2));
68
+ if (!group) {
69
+ return options2.next();
70
+ }
71
+ return new Promise((resolve, reject) => {
72
+ this.#enqueueRequest(group, options2, resolve, reject);
73
+ setTimeout(() => this.#processPendingBatches());
74
+ });
75
+ });
76
+ }
77
+ #enqueueRequest(group, options, resolve, reject) {
78
+ const items = this.pending.get(group);
79
+ if (items) {
80
+ items.push([options, resolve, reject]);
81
+ } else {
82
+ this.pending.set(group, [[options, resolve, reject]]);
83
+ }
84
+ }
85
+ async #processPendingBatches() {
86
+ const pending = this.pending;
87
+ this.pending = /* @__PURE__ */ new Map();
88
+ for (const [group, items] of pending) {
89
+ const getItems = items.filter(([options]) => options.request.method === "GET");
90
+ const restItems = items.filter(([options]) => options.request.method !== "GET");
91
+ this.#executeBatch("GET", group, getItems);
92
+ this.#executeBatch("POST", group, restItems);
93
+ }
94
+ }
95
+ async #executeBatch(method, group, groupItems) {
96
+ if (!groupItems.length) {
97
+ return;
98
+ }
99
+ const batchItems = groupItems;
100
+ if (batchItems.length === 1) {
101
+ batchItems[0][0].next().then(batchItems[0][1]).catch(batchItems[0][2]);
102
+ return;
103
+ }
104
+ try {
105
+ const options = batchItems.map(([options2]) => options2);
106
+ const maxSize = await value(this.maxSize, options);
107
+ if (batchItems.length > maxSize) {
108
+ const [first, second] = splitInHalf(batchItems);
109
+ this.#executeBatch(method, group, first);
110
+ this.#executeBatch(method, group, second);
111
+ return;
112
+ }
113
+ const batchUrl = new URL(await value(this.batchUrl, options));
114
+ const batchHeaders = await value(this.batchHeaders, options);
115
+ const mappedItems = batchItems.map(([options2]) => this.mapRequestItem({ ...options2, batchUrl, batchHeaders }));
116
+ const batchRequest = toBatchRequest({
117
+ method,
118
+ url: batchUrl,
119
+ headers: batchHeaders,
120
+ requests: mappedItems
121
+ });
122
+ const maxUrlLength = await value(this.maxUrlLength, options);
123
+ if (batchRequest.url.toString().length > maxUrlLength) {
124
+ const [first, second] = splitInHalf(batchItems);
125
+ this.#executeBatch(method, group, first);
126
+ this.#executeBatch(method, group, second);
127
+ return;
128
+ }
129
+ const lazyResponse = await options[0].next({
130
+ request: { ...batchRequest, headers: { ...batchRequest.headers, "x-orpc-batch": "1" } },
131
+ signal: batchRequest.signal,
132
+ context: group.context,
133
+ input: group.input,
134
+ path: toArray(group.path)
135
+ });
136
+ const parsed = parseBatchResponse({ ...lazyResponse, body: await lazyResponse.body() });
137
+ for await (const item of parsed) {
138
+ batchItems[item.index]?.[1]({ ...item, body: () => Promise.resolve(item.body) });
139
+ }
140
+ throw new Error("Something went wrong make batch response not contains enough responses. This can be a bug please report it.");
141
+ } catch (error) {
142
+ for (const [, , reject] of batchItems) {
143
+ reject(error);
144
+ }
145
+ }
146
+ }
147
+ }
148
+
4
149
  class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
5
150
  }
6
151
  class ClientRetryPlugin {
@@ -18,69 +163,49 @@ class ClientRetryPlugin {
18
163
  options.interceptors ??= [];
19
164
  options.interceptors.push(async (interceptorOptions) => {
20
165
  const maxAttempts = await value(
21
- interceptorOptions.options.context.retry ?? this.defaultRetry,
22
- interceptorOptions.options,
23
- interceptorOptions.path,
24
- interceptorOptions.input
166
+ interceptorOptions.context.retry ?? this.defaultRetry,
167
+ interceptorOptions
25
168
  );
26
- const retryDelay = interceptorOptions.options.context.retryDelay ?? this.defaultRetryDelay;
27
- const shouldRetry = interceptorOptions.options.context.shouldRetry ?? this.defaultShouldRetry;
28
- const onRetry = interceptorOptions.options.context.onRetry ?? this.defaultOnRetry;
169
+ const retryDelay = interceptorOptions.context.retryDelay ?? this.defaultRetryDelay;
170
+ const shouldRetry = interceptorOptions.context.shouldRetry ?? this.defaultShouldRetry;
171
+ const onRetry = interceptorOptions.context.onRetry ?? this.defaultOnRetry;
29
172
  if (maxAttempts <= 0) {
30
173
  return interceptorOptions.next();
31
174
  }
32
- let lastEventId = interceptorOptions.options.lastEventId;
175
+ let lastEventId = interceptorOptions.lastEventId;
33
176
  let lastEventRetry;
34
177
  let unsubscribe;
35
178
  let attemptIndex = 0;
36
179
  const next = async (initial) => {
37
180
  let current = initial;
38
181
  while (true) {
39
- const newClientOptions = { ...interceptorOptions.options, lastEventId };
182
+ const updatedInterceptorOptions = { ...interceptorOptions, lastEventId };
40
183
  if (current) {
41
184
  if (attemptIndex >= maxAttempts) {
42
185
  throw current.error;
43
186
  }
44
187
  const attemptOptions = {
188
+ ...updatedInterceptorOptions,
45
189
  attemptIndex,
46
190
  error: current.error,
47
- lastEventId,
48
191
  lastEventRetry
49
192
  };
50
193
  const shouldRetryBool = await value(
51
194
  shouldRetry,
52
- attemptOptions,
53
- newClientOptions,
54
- interceptorOptions.path,
55
- interceptorOptions.input
195
+ attemptOptions
56
196
  );
57
197
  if (!shouldRetryBool) {
58
198
  throw current.error;
59
199
  }
60
- unsubscribe = onRetry?.(
61
- attemptOptions,
62
- newClientOptions,
63
- interceptorOptions.path,
64
- interceptorOptions.input
65
- );
66
- const retryDelayMs = await value(
67
- retryDelay,
68
- attemptOptions,
69
- newClientOptions,
70
- interceptorOptions.path,
71
- interceptorOptions.input
72
- );
200
+ unsubscribe = onRetry?.(attemptOptions);
201
+ const retryDelayMs = await value(retryDelay, attemptOptions);
73
202
  await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
74
203
  attemptIndex++;
75
204
  }
76
205
  try {
77
- const output2 = await interceptorOptions.next({
78
- ...interceptorOptions,
79
- options: newClientOptions
80
- });
81
- return output2;
206
+ return await interceptorOptions.next(updatedInterceptorOptions);
82
207
  } catch (error) {
83
- if (newClientOptions.signal?.aborted === true) {
208
+ if (updatedInterceptorOptions.signal?.aborted === true) {
84
209
  throw error;
85
210
  }
86
211
  current = { error };
@@ -128,4 +253,4 @@ class ClientRetryPlugin {
128
253
  }
129
254
  }
130
255
 
131
- export { ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse };
256
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse };
@@ -17,7 +17,7 @@ class StandardLink {
17
17
  interceptors;
18
18
  clientInterceptors;
19
19
  call(path, input, options) {
20
- return intercept(this.interceptors, { path, input, options }, async ({ path: path2, input: input2, options: options2 }) => {
20
+ return intercept(this.interceptors, { ...options, path, input }, async ({ path: path2, input: input2, ...options2 }) => {
21
21
  const output = await this.#call(path2, input2, options2);
22
22
  return output;
23
23
  });
@@ -26,8 +26,8 @@ class StandardLink {
26
26
  const request = await this.codec.encode(path, input, options);
27
27
  const response = await intercept(
28
28
  this.clientInterceptors,
29
- { request },
30
- ({ request: request2 }) => this.sender.call(request2, options, path, input)
29
+ { ...options, input, path, request },
30
+ ({ input: input2, path: path2, request: request2, ...options2 }) => this.sender.call(request2, options2, path2, input2)
31
31
  );
32
32
  const output = await this.codec.decode(response, options, path, input);
33
33
  return output;
@@ -202,9 +202,10 @@ class StandardRPCLinkCodec {
202
202
  expectedMethod;
203
203
  headers;
204
204
  async encode(path, input, options) {
205
- const expectedMethod = await value(this.expectedMethod, options, path, input);
206
- let headers = await value(this.headers, options, path, input);
207
- const baseUrl = await value(this.baseUrl, options, path, input);
205
+ const generalOptions = { ...options, path, input };
206
+ const expectedMethod = await value(this.expectedMethod, generalOptions);
207
+ let headers = await value(this.headers, generalOptions);
208
+ const baseUrl = await value(this.baseUrl, generalOptions);
208
209
  const url = new URL(baseUrl);
209
210
  url.pathname = `${url.pathname.replace(/\/$/, "")}${toHttpPath(path)}`;
210
211
  if (options.lastEventId !== void 0) {
@@ -212,7 +213,7 @@ class StandardRPCLinkCodec {
212
213
  }
213
214
  const serialized = this.serializer.serialize(input);
214
215
  if (expectedMethod === "GET" && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
215
- const maxUrlLength = await value(this.maxUrlLength, options, path, input);
216
+ const maxUrlLength = await value(this.maxUrlLength, generalOptions);
216
217
  const getUrl = new URL(url);
217
218
  getUrl.searchParams.append("data", stringifyJSON(serialized));
218
219
  if (getUrl.toString().length <= maxUrlLength) {
@@ -1,6 +1,6 @@
1
1
  import { Interceptor, ThrowableError } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.C0lT7w02.js';
3
+ import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.CipPQkhk.mjs';
4
4
 
5
5
  interface StandardLinkCodec<T extends ClientContext> {
6
6
  encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
@@ -15,15 +15,16 @@ declare class InvalidEventIteratorRetryResponse extends Error {
15
15
  interface StandardLinkPlugin<T extends ClientContext> {
16
16
  init?(options: StandardLinkOptions<T>): void;
17
17
  }
18
+ interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
19
+ path: readonly string[];
20
+ input: unknown;
21
+ }
22
+ interface StandardLinkClientInterceptorOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
23
+ request: StandardRequest;
24
+ }
18
25
  interface StandardLinkOptions<T extends ClientContext> {
19
- interceptors?: Interceptor<{
20
- path: readonly string[];
21
- input: unknown;
22
- options: ClientOptions<T>;
23
- }, unknown, ThrowableError>[];
24
- clientInterceptors?: Interceptor<{
25
- request: StandardRequest;
26
- }, StandardLazyResponse, ThrowableError>[];
26
+ interceptors?: Interceptor<StandardLinkInterceptorOptions<T>, unknown, ThrowableError>[];
27
+ clientInterceptors?: Interceptor<StandardLinkClientInterceptorOptions<T>, StandardLazyResponse, ThrowableError>[];
27
28
  plugins?: StandardLinkPlugin<T>[];
28
29
  }
29
30
  declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
@@ -36,4 +37,4 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
36
37
  call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
37
38
  }
38
39
 
39
- export { InvalidEventIteratorRetryResponse as I, type StandardLinkPlugin as S, type StandardLinkOptions as a, StandardLink as b, type StandardLinkCodec as c, type StandardLinkClient as d };
40
+ export { 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 };
@@ -1,5 +1,5 @@
1
- import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.C0lT7w02.js';
2
- import { c as StandardLinkCodec, a as StandardLinkOptions } from './client.grRbC25r.js';
1
+ import { a as ClientContext, d as HTTPMethod, b as ClientOptions } from './client.CipPQkhk.mjs';
2
+ import { c as StandardLinkInterceptorOptions, e as StandardLinkCodec, b as StandardLinkOptions } from './client.C7z5zk4v.mjs';
3
3
  import { Segment, Value } from '@orpc/shared';
4
4
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
5
 
@@ -44,31 +44,19 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
44
44
  /**
45
45
  * Base url for all requests.
46
46
  */
47
- url: Value<string | URL, [
48
- options: ClientOptions<T>,
49
- path: readonly string[],
50
- input: unknown
51
- ]>;
47
+ url: Value<string | URL, [StandardLinkInterceptorOptions<T>]>;
52
48
  /**
53
49
  * The maximum length of the URL.
54
50
  *
55
51
  * @default 2083
56
52
  */
57
- maxUrlLength?: Value<number, [
58
- options: ClientOptions<T>,
59
- path: readonly string[],
60
- input: unknown
61
- ]>;
53
+ maxUrlLength?: Value<number, [StandardLinkInterceptorOptions<T>]>;
62
54
  /**
63
55
  * The method used to make the request.
64
56
  *
65
57
  * @default 'POST'
66
58
  */
67
- method?: Value<HTTPMethod, [
68
- options: ClientOptions<T>,
69
- path: readonly string[],
70
- input: unknown
71
- ]>;
59
+ method?: Value<HTTPMethod, [StandardLinkInterceptorOptions<T>]>;
72
60
  /**
73
61
  * The method to use when the payload cannot safely pass to the server with method return from method function.
74
62
  * GET is not allowed, it's very dangerous.
@@ -79,11 +67,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
79
67
  /**
80
68
  * Inject headers to the request.
81
69
  */
82
- headers?: Value<StandardHeaders, [
83
- options: ClientOptions<T>,
84
- path: readonly string[],
85
- input: unknown
86
- ]>;
70
+ headers?: Value<StandardHeaders, [StandardLinkInterceptorOptions<T>]>;
87
71
  }
88
72
  declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
89
73
  private readonly serializer;
@@ -3,13 +3,15 @@ import { PromiseWithError } from '@orpc/shared';
3
3
  type HTTPPath = `/${string}`;
4
4
  type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
5
5
  type ClientContext = Record<PropertyKey, any>;
6
- type FriendlyClientOptions<TClientContext extends ClientContext> = {
6
+ interface ClientOptions<T extends ClientContext> {
7
7
  signal?: AbortSignal;
8
8
  lastEventId?: string | undefined;
9
- } & (Record<never, never> extends TClientContext ? {
10
- context?: TClientContext;
9
+ context: T;
10
+ }
11
+ type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (Record<never, never> extends T ? {
12
+ context?: T;
11
13
  } : {
12
- context: TClientContext;
14
+ context: T;
13
15
  });
14
16
  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>];
15
17
  type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
@@ -20,9 +22,6 @@ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext,
20
22
  [k: string]: NestedClient<TClientContext>;
21
23
  };
22
24
  type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
23
- type ClientOptions<TClientContext extends ClientContext> = FriendlyClientOptions<TClientContext> & {
24
- context: TClientContext;
25
- };
26
25
  interface ClientLink<TClientContext extends ClientContext> {
27
26
  call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
28
27
  }
@@ -3,13 +3,15 @@ import { PromiseWithError } from '@orpc/shared';
3
3
  type HTTPPath = `/${string}`;
4
4
  type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
5
5
  type ClientContext = Record<PropertyKey, any>;
6
- type FriendlyClientOptions<TClientContext extends ClientContext> = {
6
+ interface ClientOptions<T extends ClientContext> {
7
7
  signal?: AbortSignal;
8
8
  lastEventId?: string | undefined;
9
- } & (Record<never, never> extends TClientContext ? {
10
- context?: TClientContext;
9
+ context: T;
10
+ }
11
+ type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (Record<never, never> extends T ? {
12
+ context?: T;
11
13
  } : {
12
- context: TClientContext;
14
+ context: T;
13
15
  });
14
16
  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>];
15
17
  type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
@@ -20,9 +22,6 @@ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext,
20
22
  [k: string]: NestedClient<TClientContext>;
21
23
  };
22
24
  type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
23
- type ClientOptions<TClientContext extends ClientContext> = FriendlyClientOptions<TClientContext> & {
24
- context: TClientContext;
25
- };
26
25
  interface ClientLink<TClientContext extends ClientContext> {
27
26
  call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
28
27
  }
@@ -1,5 +1,5 @@
1
- import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.C0lT7w02.mjs';
2
- import { c as StandardLinkCodec, a as StandardLinkOptions } from './client.5813Ufvs.mjs';
1
+ import { a as ClientContext, d as HTTPMethod, b as ClientOptions } from './client.CipPQkhk.js';
2
+ import { c as StandardLinkInterceptorOptions, e as StandardLinkCodec, b as StandardLinkOptions } from './client.p3ON_yzu.js';
3
3
  import { Segment, Value } from '@orpc/shared';
4
4
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
5
 
@@ -44,31 +44,19 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
44
44
  /**
45
45
  * Base url for all requests.
46
46
  */
47
- url: Value<string | URL, [
48
- options: ClientOptions<T>,
49
- path: readonly string[],
50
- input: unknown
51
- ]>;
47
+ url: Value<string | URL, [StandardLinkInterceptorOptions<T>]>;
52
48
  /**
53
49
  * The maximum length of the URL.
54
50
  *
55
51
  * @default 2083
56
52
  */
57
- maxUrlLength?: Value<number, [
58
- options: ClientOptions<T>,
59
- path: readonly string[],
60
- input: unknown
61
- ]>;
53
+ maxUrlLength?: Value<number, [StandardLinkInterceptorOptions<T>]>;
62
54
  /**
63
55
  * The method used to make the request.
64
56
  *
65
57
  * @default 'POST'
66
58
  */
67
- method?: Value<HTTPMethod, [
68
- options: ClientOptions<T>,
69
- path: readonly string[],
70
- input: unknown
71
- ]>;
59
+ method?: Value<HTTPMethod, [StandardLinkInterceptorOptions<T>]>;
72
60
  /**
73
61
  * The method to use when the payload cannot safely pass to the server with method return from method function.
74
62
  * GET is not allowed, it's very dangerous.
@@ -79,11 +67,7 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
79
67
  /**
80
68
  * Inject headers to the request.
81
69
  */
82
- headers?: Value<StandardHeaders, [
83
- options: ClientOptions<T>,
84
- path: readonly string[],
85
- input: unknown
86
- ]>;
70
+ headers?: Value<StandardHeaders, [StandardLinkInterceptorOptions<T>]>;
87
71
  }
88
72
  declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
89
73
  private readonly serializer;
@@ -1,6 +1,6 @@
1
1
  import { Interceptor, ThrowableError } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.C0lT7w02.mjs';
3
+ import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.CipPQkhk.js';
4
4
 
5
5
  interface StandardLinkCodec<T extends ClientContext> {
6
6
  encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
@@ -15,15 +15,16 @@ declare class InvalidEventIteratorRetryResponse extends Error {
15
15
  interface StandardLinkPlugin<T extends ClientContext> {
16
16
  init?(options: StandardLinkOptions<T>): void;
17
17
  }
18
+ interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
19
+ path: readonly string[];
20
+ input: unknown;
21
+ }
22
+ interface StandardLinkClientInterceptorOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
23
+ request: StandardRequest;
24
+ }
18
25
  interface StandardLinkOptions<T extends ClientContext> {
19
- interceptors?: Interceptor<{
20
- path: readonly string[];
21
- input: unknown;
22
- options: ClientOptions<T>;
23
- }, unknown, ThrowableError>[];
24
- clientInterceptors?: Interceptor<{
25
- request: StandardRequest;
26
- }, StandardLazyResponse, ThrowableError>[];
26
+ interceptors?: Interceptor<StandardLinkInterceptorOptions<T>, unknown, ThrowableError>[];
27
+ clientInterceptors?: Interceptor<StandardLinkClientInterceptorOptions<T>, StandardLazyResponse, ThrowableError>[];
27
28
  plugins?: StandardLinkPlugin<T>[];
28
29
  }
29
30
  declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
@@ -36,4 +37,4 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
36
37
  call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
37
38
  }
38
39
 
39
- export { InvalidEventIteratorRetryResponse as I, type StandardLinkPlugin as S, type StandardLinkOptions as a, StandardLink as b, type StandardLinkCodec as c, type StandardLinkClient as d };
40
+ export { 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 };
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.3191601",
4
+ "version": "0.0.0-next.32a6de9",
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.3191601",
43
- "@orpc/standard-server-fetch": "0.0.0-next.3191601",
44
- "@orpc/standard-server": "0.0.0-next.3191601"
42
+ "@orpc/standard-server-fetch": "0.0.0-next.32a6de9",
43
+ "@orpc/standard-server": "0.0.0-next.32a6de9",
44
+ "@orpc/shared": "0.0.0-next.32a6de9"
45
45
  },
46
46
  "devDependencies": {
47
47
  "zod": "^3.24.2"