@orpc/client 0.0.0-next.a689803 → 0.0.0-next.a72b189
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 +8 -8
- package/dist/adapters/fetch/index.d.mts +23 -10
- package/dist/adapters/fetch/index.d.ts +23 -10
- package/dist/adapters/fetch/index.mjs +24 -8
- package/dist/adapters/message-port/index.d.mts +12 -12
- package/dist/adapters/message-port/index.d.ts +12 -12
- package/dist/adapters/message-port/index.mjs +9 -8
- package/dist/adapters/standard/index.d.mts +6 -5
- package/dist/adapters/standard/index.d.ts +6 -5
- package/dist/adapters/standard/index.mjs +3 -2
- package/dist/adapters/websocket/index.d.mts +12 -12
- package/dist/adapters/websocket/index.d.ts +12 -12
- package/dist/adapters/websocket/index.mjs +25 -10
- package/dist/index.d.mts +41 -25
- package/dist/index.d.ts +41 -25
- package/dist/index.mjs +25 -8
- package/dist/plugins/index.d.mts +46 -6
- package/dist/plugins/index.d.ts +46 -6
- package/dist/plugins/index.mjs +142 -27
- package/dist/shared/{client.C0KbSWlC.d.ts → client.BG98rYdO.d.ts} +1 -2
- package/dist/shared/{client.4TS_0JaO.d.mts → client.BOYsZIRq.d.mts} +1 -1
- package/dist/shared/{client.4TS_0JaO.d.ts → client.BOYsZIRq.d.ts} +1 -1
- package/dist/shared/{client.DpICn1BD.mjs → client.Bp1jlnBk.mjs} +62 -20
- package/dist/shared/{client.BMoG_EdN.d.mts → client.Bwgm6dgk.d.mts} +1 -2
- package/dist/shared/{client.7UM0t5o-.d.ts → client.CVVVqf1Y.d.ts} +3 -3
- package/dist/shared/{client.BdD8cpjs.d.mts → client._Y_enhib.d.mts} +3 -3
- package/dist/shared/{client.CRWEpqLB.mjs → client.txdq_i5V.mjs} +37 -32
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { N as NestedClient, C as ClientLink, I as InferClientContext, a as
|
|
2
|
-
export { f as
|
|
3
|
-
import {
|
|
4
|
-
export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
1
|
+
import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientPromiseResult, b as ClientContext, F as FriendlyClientOptions, c as ClientOptions, d as Client, e as ClientRest } from './shared/client.BOYsZIRq.mjs';
|
|
2
|
+
export { f as HTTPMethod, H as HTTPPath } from './shared/client.BOYsZIRq.mjs';
|
|
3
|
+
import { MaybeOptionalOptions, ThrowableError, Promisable, AsyncIteratorClass } from '@orpc/shared';
|
|
4
|
+
export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
5
5
|
export { ErrorEvent } from '@orpc/standard-server';
|
|
6
6
|
|
|
7
7
|
interface createORPCClientOptions {
|
|
8
8
|
/**
|
|
9
9
|
* Use as base path for all procedure, useful when you only want to call a subset of the procedure.
|
|
10
10
|
*/
|
|
11
|
-
path?: string[];
|
|
11
|
+
path?: readonly string[];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Create a oRPC client-side client from a link.
|
|
@@ -17,18 +17,6 @@ interface createORPCClientOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<InferClientContext<T>>, options?: createORPCClientOptions): T;
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
|
22
|
-
* based on the request path, input, and context.
|
|
23
|
-
*
|
|
24
|
-
* @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
|
|
25
|
-
*/
|
|
26
|
-
declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
|
27
|
-
private readonly linkResolver;
|
|
28
|
-
constructor(linkResolver: (options: ClientOptions<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
|
|
29
|
-
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
20
|
declare const COMMON_ORPC_ERROR_DEFS: {
|
|
33
21
|
readonly BAD_REQUEST: {
|
|
34
22
|
readonly status: 400;
|
|
@@ -125,7 +113,7 @@ declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
|
125
113
|
readonly code: TCode;
|
|
126
114
|
readonly status: number;
|
|
127
115
|
readonly data: TData;
|
|
128
|
-
constructor(code: TCode, ...
|
|
116
|
+
constructor(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
|
|
129
117
|
toJSON(): ORPCErrorJSON<TCode, TData>;
|
|
130
118
|
}
|
|
131
119
|
type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
|
|
@@ -135,11 +123,6 @@ declare function isORPCErrorStatus(status: number): boolean;
|
|
|
135
123
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
136
124
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
137
125
|
|
|
138
|
-
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
139
|
-
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
140
|
-
error: (error: unknown) => Promise<unknown>;
|
|
141
|
-
}): AsyncGenerator<TMap, TMap, TNext>;
|
|
142
|
-
|
|
143
126
|
type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
144
127
|
error: null;
|
|
145
128
|
data: TOutput;
|
|
@@ -165,5 +148,38 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false
|
|
|
165
148
|
declare function safe<TOutput, TError = ThrowableError>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
166
149
|
declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
|
|
167
150
|
|
|
168
|
-
|
|
169
|
-
|
|
151
|
+
type SafeClient<T extends NestedClient<any>> = T extends Client<infer UContext, infer UInput, infer UOutput, infer UError> ? (...rest: ClientRest<UContext, UInput>) => Promise<SafeResult<UOutput, UError>> : {
|
|
152
|
+
[K in keyof T]: T[K] extends NestedClient<any> ? SafeClient<T[K]> : never;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Create a safe client that automatically wraps all procedure calls with the `safe` util.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const safeClient = createSafeClient(client)
|
|
160
|
+
* const { error, data, isDefined } = await safeClient.doSomething({ id: '123' })
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @see {@link https://orpc.unnoq.com/docs/client/error-handling#using-createsafeclient Safe Client Docs}
|
|
164
|
+
*/
|
|
165
|
+
declare function createSafeClient<T extends NestedClient<any>>(client: T): SafeClient<T>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
|
169
|
+
* based on the request path, input, and context.
|
|
170
|
+
*
|
|
171
|
+
* @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
|
|
172
|
+
*/
|
|
173
|
+
declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
|
174
|
+
private readonly linkResolver;
|
|
175
|
+
constructor(linkResolver: (options: ClientOptions<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
|
|
176
|
+
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
180
|
+
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
181
|
+
error: (error: unknown) => Promise<unknown>;
|
|
182
|
+
}): AsyncIteratorClass<TMap, TMap, TNext>;
|
|
183
|
+
|
|
184
|
+
export { COMMON_ORPC_ERROR_DEFS, Client, ClientContext, ClientLink, ClientOptions, ClientPromiseResult, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, NestedClient, ORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, isORPCErrorJson, isORPCErrorStatus, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
|
|
185
|
+
export type { CommonORPCErrorCode, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, SafeClient, SafeResult, createORPCClientOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { N as NestedClient, C as ClientLink, I as InferClientContext, a as
|
|
2
|
-
export { f as
|
|
3
|
-
import {
|
|
4
|
-
export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
1
|
+
import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientPromiseResult, b as ClientContext, F as FriendlyClientOptions, c as ClientOptions, d as Client, e as ClientRest } from './shared/client.BOYsZIRq.js';
|
|
2
|
+
export { f as HTTPMethod, H as HTTPPath } from './shared/client.BOYsZIRq.js';
|
|
3
|
+
import { MaybeOptionalOptions, ThrowableError, Promisable, AsyncIteratorClass } from '@orpc/shared';
|
|
4
|
+
export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
5
5
|
export { ErrorEvent } from '@orpc/standard-server';
|
|
6
6
|
|
|
7
7
|
interface createORPCClientOptions {
|
|
8
8
|
/**
|
|
9
9
|
* Use as base path for all procedure, useful when you only want to call a subset of the procedure.
|
|
10
10
|
*/
|
|
11
|
-
path?: string[];
|
|
11
|
+
path?: readonly string[];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Create a oRPC client-side client from a link.
|
|
@@ -17,18 +17,6 @@ interface createORPCClientOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<InferClientContext<T>>, options?: createORPCClientOptions): T;
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
|
22
|
-
* based on the request path, input, and context.
|
|
23
|
-
*
|
|
24
|
-
* @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
|
|
25
|
-
*/
|
|
26
|
-
declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
|
27
|
-
private readonly linkResolver;
|
|
28
|
-
constructor(linkResolver: (options: ClientOptions<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
|
|
29
|
-
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
20
|
declare const COMMON_ORPC_ERROR_DEFS: {
|
|
33
21
|
readonly BAD_REQUEST: {
|
|
34
22
|
readonly status: 400;
|
|
@@ -125,7 +113,7 @@ declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
|
125
113
|
readonly code: TCode;
|
|
126
114
|
readonly status: number;
|
|
127
115
|
readonly data: TData;
|
|
128
|
-
constructor(code: TCode, ...
|
|
116
|
+
constructor(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
|
|
129
117
|
toJSON(): ORPCErrorJSON<TCode, TData>;
|
|
130
118
|
}
|
|
131
119
|
type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
|
|
@@ -135,11 +123,6 @@ declare function isORPCErrorStatus(status: number): boolean;
|
|
|
135
123
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
136
124
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
137
125
|
|
|
138
|
-
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
139
|
-
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
140
|
-
error: (error: unknown) => Promise<unknown>;
|
|
141
|
-
}): AsyncGenerator<TMap, TMap, TNext>;
|
|
142
|
-
|
|
143
126
|
type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
144
127
|
error: null;
|
|
145
128
|
data: TOutput;
|
|
@@ -165,5 +148,38 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false
|
|
|
165
148
|
declare function safe<TOutput, TError = ThrowableError>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
166
149
|
declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
|
|
167
150
|
|
|
168
|
-
|
|
169
|
-
|
|
151
|
+
type SafeClient<T extends NestedClient<any>> = T extends Client<infer UContext, infer UInput, infer UOutput, infer UError> ? (...rest: ClientRest<UContext, UInput>) => Promise<SafeResult<UOutput, UError>> : {
|
|
152
|
+
[K in keyof T]: T[K] extends NestedClient<any> ? SafeClient<T[K]> : never;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Create a safe client that automatically wraps all procedure calls with the `safe` util.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const safeClient = createSafeClient(client)
|
|
160
|
+
* const { error, data, isDefined } = await safeClient.doSomething({ id: '123' })
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @see {@link https://orpc.unnoq.com/docs/client/error-handling#using-createsafeclient Safe Client Docs}
|
|
164
|
+
*/
|
|
165
|
+
declare function createSafeClient<T extends NestedClient<any>>(client: T): SafeClient<T>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
|
169
|
+
* based on the request path, input, and context.
|
|
170
|
+
*
|
|
171
|
+
* @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
|
|
172
|
+
*/
|
|
173
|
+
declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
|
174
|
+
private readonly linkResolver;
|
|
175
|
+
constructor(linkResolver: (options: ClientOptions<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
|
|
176
|
+
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
180
|
+
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
181
|
+
error: (error: unknown) => Promise<unknown>;
|
|
182
|
+
}): AsyncIteratorClass<TMap, TMap, TNext>;
|
|
183
|
+
|
|
184
|
+
export { COMMON_ORPC_ERROR_DEFS, Client, ClientContext, ClientLink, ClientOptions, ClientPromiseResult, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, NestedClient, ORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, isORPCErrorJson, isORPCErrorStatus, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
|
|
185
|
+
export type { CommonORPCErrorCode, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, SafeClient, SafeResult, createORPCClientOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { preventNativeAwait, isTypescriptObject } from '@orpc/shared';
|
|
2
|
+
export { AsyncIteratorClass, EventPublisher, asyncIteratorToStream as eventIteratorToStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
3
|
+
import { i as isDefinedError } from './shared/client.txdq_i5V.mjs';
|
|
4
|
+
export { C as COMMON_ORPC_ERROR_DEFS, O as ORPCError, d as createORPCErrorFromJson, a as fallbackORPCErrorMessage, f as fallbackORPCErrorStatus, c as isORPCErrorJson, b as isORPCErrorStatus, m as mapEventIterator, t as toORPCError } from './shared/client.txdq_i5V.mjs';
|
|
4
5
|
export { ErrorEvent } from '@orpc/standard-server';
|
|
5
6
|
|
|
6
7
|
async function safe(promise) {
|
|
@@ -27,13 +28,13 @@ async function safe(promise) {
|
|
|
27
28
|
function resolveFriendlyClientOptions(options) {
|
|
28
29
|
return {
|
|
29
30
|
...options,
|
|
30
|
-
context: options
|
|
31
|
+
context: options.context ?? {}
|
|
31
32
|
// Context only optional if all fields are optional
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
function createORPCClient(link, options) {
|
|
36
|
-
const path = options
|
|
36
|
+
function createORPCClient(link, options = {}) {
|
|
37
|
+
const path = options.path ?? [];
|
|
37
38
|
const procedureClient = async (...[input, options2 = {}]) => {
|
|
38
39
|
return await link.call(path, input, resolveFriendlyClientOptions(options2));
|
|
39
40
|
};
|
|
@@ -48,7 +49,23 @@ function createORPCClient(link, options) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
|
-
return recursive;
|
|
52
|
+
return preventNativeAwait(recursive);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function createSafeClient(client) {
|
|
56
|
+
const proxy = new Proxy((...args) => safe(client(...args)), {
|
|
57
|
+
get(_, prop, receiver) {
|
|
58
|
+
const value = Reflect.get(client, prop, receiver);
|
|
59
|
+
if (typeof prop !== "string") {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
if (!isTypescriptObject(value)) {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
return createSafeClient(value);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return proxy;
|
|
52
69
|
}
|
|
53
70
|
|
|
54
71
|
class DynamicLink {
|
|
@@ -62,4 +79,4 @@ class DynamicLink {
|
|
|
62
79
|
}
|
|
63
80
|
}
|
|
64
81
|
|
|
65
|
-
export { DynamicLink, createORPCClient, isDefinedError, resolveFriendlyClientOptions, safe };
|
|
82
|
+
export { DynamicLink, createORPCClient, createSafeClient, isDefinedError, resolveFriendlyClientOptions, safe };
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
2
|
import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
3
|
+
import { BatchResponseMode } from '@orpc/standard-server/batch';
|
|
4
|
+
import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.Bwgm6dgk.mjs';
|
|
5
|
+
import { b as ClientContext } from '../shared/client.BOYsZIRq.mjs';
|
|
5
6
|
|
|
6
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
7
8
|
condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
|
|
@@ -17,6 +18,12 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
17
18
|
* @default 10
|
|
18
19
|
*/
|
|
19
20
|
maxSize?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
21
|
+
/**
|
|
22
|
+
* The batch response mode.
|
|
23
|
+
*
|
|
24
|
+
* @default 'streaming'
|
|
25
|
+
*/
|
|
26
|
+
mode?: Value<BatchResponseMode, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
20
27
|
/**
|
|
21
28
|
* Defines the URL to use for the batch request.
|
|
22
29
|
*
|
|
@@ -52,10 +59,10 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
52
59
|
exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
|
|
53
60
|
}
|
|
54
61
|
/**
|
|
55
|
-
* The Batch
|
|
62
|
+
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
56
63
|
* reducing the overhead of sending each one separately.
|
|
57
64
|
*
|
|
58
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-
|
|
65
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
59
66
|
*/
|
|
60
67
|
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
61
68
|
#private;
|
|
@@ -66,12 +73,45 @@ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPl
|
|
|
66
73
|
private readonly batchHeaders;
|
|
67
74
|
private readonly mapRequestItem;
|
|
68
75
|
private readonly exclude;
|
|
76
|
+
private readonly mode;
|
|
69
77
|
private pending;
|
|
70
78
|
order: number;
|
|
71
79
|
constructor(options: NoInfer<BatchLinkPluginOptions<T>>);
|
|
72
80
|
init(options: StandardLinkOptions<T>): void;
|
|
73
81
|
}
|
|
74
82
|
|
|
83
|
+
interface DedupeRequestsPluginGroup<T extends ClientContext> {
|
|
84
|
+
condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The context used for the rest of the request lifecycle.
|
|
87
|
+
*/
|
|
88
|
+
context: T;
|
|
89
|
+
}
|
|
90
|
+
interface DedupeRequestsPluginOptions<T extends ClientContext> {
|
|
91
|
+
/**
|
|
92
|
+
* To enable deduplication, a request must match at least one defined group.
|
|
93
|
+
* Requests that fall into the same group are considered for deduplication together.
|
|
94
|
+
*/
|
|
95
|
+
groups: readonly [DedupeRequestsPluginGroup<T>, ...DedupeRequestsPluginGroup<T>[]];
|
|
96
|
+
/**
|
|
97
|
+
* Filters requests to dedupe
|
|
98
|
+
*
|
|
99
|
+
* @default (({ request }) => request.method === 'GET')
|
|
100
|
+
*/
|
|
101
|
+
filter?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Prevents duplicate requests by deduplicating similar ones to reduce server load.
|
|
105
|
+
*
|
|
106
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/dedupe-requests Dedupe Requests Plugin}
|
|
107
|
+
*/
|
|
108
|
+
declare class DedupeRequestsPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
109
|
+
#private;
|
|
110
|
+
order: number;
|
|
111
|
+
constructor(options: NoInfer<DedupeRequestsPluginOptions<T>>);
|
|
112
|
+
init(options: StandardLinkOptions<T>): void;
|
|
113
|
+
}
|
|
114
|
+
|
|
75
115
|
interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
|
|
76
116
|
lastEventRetry: number | undefined;
|
|
77
117
|
attemptIndex: number;
|
|
@@ -158,5 +198,5 @@ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements
|
|
|
158
198
|
init(options: StandardLinkOptions<T>): void;
|
|
159
199
|
}
|
|
160
200
|
|
|
161
|
-
export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, SimpleCsrfProtectionLinkPlugin };
|
|
162
|
-
export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
|
|
201
|
+
export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, SimpleCsrfProtectionLinkPlugin };
|
|
202
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
2
|
import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
3
|
+
import { BatchResponseMode } from '@orpc/standard-server/batch';
|
|
4
|
+
import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.BG98rYdO.js';
|
|
5
|
+
import { b as ClientContext } from '../shared/client.BOYsZIRq.js';
|
|
5
6
|
|
|
6
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
7
8
|
condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
|
|
@@ -17,6 +18,12 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
17
18
|
* @default 10
|
|
18
19
|
*/
|
|
19
20
|
maxSize?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
21
|
+
/**
|
|
22
|
+
* The batch response mode.
|
|
23
|
+
*
|
|
24
|
+
* @default 'streaming'
|
|
25
|
+
*/
|
|
26
|
+
mode?: Value<BatchResponseMode, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
|
|
20
27
|
/**
|
|
21
28
|
* Defines the URL to use for the batch request.
|
|
22
29
|
*
|
|
@@ -52,10 +59,10 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
52
59
|
exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
|
|
53
60
|
}
|
|
54
61
|
/**
|
|
55
|
-
* The Batch
|
|
62
|
+
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
56
63
|
* reducing the overhead of sending each one separately.
|
|
57
64
|
*
|
|
58
|
-
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-
|
|
65
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
59
66
|
*/
|
|
60
67
|
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
61
68
|
#private;
|
|
@@ -66,12 +73,45 @@ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPl
|
|
|
66
73
|
private readonly batchHeaders;
|
|
67
74
|
private readonly mapRequestItem;
|
|
68
75
|
private readonly exclude;
|
|
76
|
+
private readonly mode;
|
|
69
77
|
private pending;
|
|
70
78
|
order: number;
|
|
71
79
|
constructor(options: NoInfer<BatchLinkPluginOptions<T>>);
|
|
72
80
|
init(options: StandardLinkOptions<T>): void;
|
|
73
81
|
}
|
|
74
82
|
|
|
83
|
+
interface DedupeRequestsPluginGroup<T extends ClientContext> {
|
|
84
|
+
condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The context used for the rest of the request lifecycle.
|
|
87
|
+
*/
|
|
88
|
+
context: T;
|
|
89
|
+
}
|
|
90
|
+
interface DedupeRequestsPluginOptions<T extends ClientContext> {
|
|
91
|
+
/**
|
|
92
|
+
* To enable deduplication, a request must match at least one defined group.
|
|
93
|
+
* Requests that fall into the same group are considered for deduplication together.
|
|
94
|
+
*/
|
|
95
|
+
groups: readonly [DedupeRequestsPluginGroup<T>, ...DedupeRequestsPluginGroup<T>[]];
|
|
96
|
+
/**
|
|
97
|
+
* Filters requests to dedupe
|
|
98
|
+
*
|
|
99
|
+
* @default (({ request }) => request.method === 'GET')
|
|
100
|
+
*/
|
|
101
|
+
filter?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Prevents duplicate requests by deduplicating similar ones to reduce server load.
|
|
105
|
+
*
|
|
106
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/dedupe-requests Dedupe Requests Plugin}
|
|
107
|
+
*/
|
|
108
|
+
declare class DedupeRequestsPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
109
|
+
#private;
|
|
110
|
+
order: number;
|
|
111
|
+
constructor(options: NoInfer<DedupeRequestsPluginOptions<T>>);
|
|
112
|
+
init(options: StandardLinkOptions<T>): void;
|
|
113
|
+
}
|
|
114
|
+
|
|
75
115
|
interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
|
|
76
116
|
lastEventRetry: number | undefined;
|
|
77
117
|
attemptIndex: number;
|
|
@@ -158,5 +198,5 @@ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements
|
|
|
158
198
|
init(options: StandardLinkOptions<T>): void;
|
|
159
199
|
}
|
|
160
200
|
|
|
161
|
-
export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, SimpleCsrfProtectionLinkPlugin };
|
|
162
|
-
export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
|
|
201
|
+
export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, SimpleCsrfProtectionLinkPlugin };
|
|
202
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
|