@orpc/client 0.0.0-next.cd121e3 → 0.0.0-next.cf06e99
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 +14 -1
- package/dist/adapters/fetch/index.d.mts +20 -97
- package/dist/adapters/fetch/index.d.ts +20 -97
- package/dist/adapters/fetch/index.mjs +20 -112
- package/dist/adapters/standard/index.d.mts +8 -20
- package/dist/adapters/standard/index.d.ts +8 -20
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.d.mts +22 -20
- package/dist/index.d.ts +22 -20
- package/dist/index.mjs +35 -33
- package/dist/plugins/index.d.mts +143 -0
- package/dist/plugins/index.d.ts +143 -0
- package/dist/plugins/index.mjs +290 -0
- package/dist/shared/client.Bt2hFtM_.d.mts +45 -0
- package/dist/shared/client.CRWEpqLB.mjs +175 -0
- package/dist/shared/client.CipPQkhk.d.mts +29 -0
- package/dist/shared/client.CipPQkhk.d.ts +29 -0
- package/dist/shared/client.DXvQo1nS.d.mts +90 -0
- package/dist/shared/client.Dc8eXpCj.d.ts +90 -0
- package/dist/shared/client.DpICn1BD.mjs +355 -0
- package/dist/shared/client.FvDtk0Vr.d.ts +45 -0
- package/package.json +10 -5
- package/dist/shared/client.DHJ8vRIG.mjs +0 -192
- package/dist/shared/client.D_CzLDyB.d.mts +0 -42
- package/dist/shared/client.D_CzLDyB.d.ts +0 -42
- package/dist/shared/client.Ly4zGQrc.mjs +0 -265
package/README.md
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
@@ -53,11 +53,16 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
53
53
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
54
54
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
56
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
56
57
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
57
58
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
59
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
60
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
58
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
59
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
60
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
61
66
|
|
62
67
|
## `@orpc/client`
|
63
68
|
|
@@ -83,6 +88,14 @@ const client: RouterClient<typeof router> = createORPCClient(link)
|
|
83
88
|
const client: ContractRouterClient<typeof contract> = createORPCClient(link)
|
84
89
|
```
|
85
90
|
|
91
|
+
## Sponsors
|
92
|
+
|
93
|
+
<p align="center">
|
94
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
95
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
96
|
+
</a>
|
97
|
+
</p>
|
98
|
+
|
86
99
|
## License
|
87
100
|
|
88
101
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
@@ -1,103 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
1
|
+
import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
|
2
|
+
import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
|
3
|
+
import { a as ClientContext, b as ClientOptions } from '../../shared/client.CipPQkhk.mjs';
|
4
|
+
import { f as StandardLinkClient } from '../../shared/client.Bt2hFtM_.mjs';
|
5
|
+
import { f as StandardRPCLinkOptions, g as StandardRPCLink } from '../../shared/client.DXvQo1nS.mjs';
|
6
|
+
import '@orpc/shared';
|
5
7
|
|
6
|
-
interface
|
7
|
-
(
|
8
|
+
interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
|
9
|
+
fetch?: (request: Request, init: {
|
10
|
+
redirect?: Request['redirect'];
|
11
|
+
}, options: ClientOptions<T>, path: readonly string[], input: unknown) => Promise<Response>;
|
8
12
|
}
|
9
|
-
|
10
|
-
|
11
|
-
|
13
|
+
declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
|
14
|
+
private readonly fetch;
|
15
|
+
private readonly toFetchRequestOptions;
|
16
|
+
constructor(options: LinkFetchClientOptions<T>);
|
17
|
+
call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
|
12
18
|
}
|
13
|
-
|
14
|
-
|
15
|
-
* Base url for all requests.
|
16
|
-
*/
|
17
|
-
url: string;
|
18
|
-
/**
|
19
|
-
* The maximum length of the URL.
|
20
|
-
*
|
21
|
-
* @default 2083
|
22
|
-
*/
|
23
|
-
maxUrlLength?: number;
|
24
|
-
/**
|
25
|
-
* The method used to make the request.
|
26
|
-
*
|
27
|
-
* @default 'POST'
|
28
|
-
*/
|
29
|
-
method?: Value<HTTPMethod, [
|
30
|
-
options: ClientOptionsOut<TClientContext>,
|
31
|
-
path: readonly string[],
|
32
|
-
input: unknown
|
33
|
-
]>;
|
34
|
-
/**
|
35
|
-
* The method to use when the payload cannot safely pass to the server with method return from method function.
|
36
|
-
* GET is not allowed, it's very dangerous.
|
37
|
-
*
|
38
|
-
* @default 'POST'
|
39
|
-
*/
|
40
|
-
fallbackMethod?: Exclude<HTTPMethod, 'GET'>;
|
41
|
-
/**
|
42
|
-
* Inject headers to the request.
|
43
|
-
*/
|
44
|
-
headers?: Value<[string, string][] | Record<string, string> | Headers, [
|
45
|
-
options: ClientOptionsOut<TClientContext>,
|
46
|
-
path: readonly string[],
|
47
|
-
input: unknown
|
48
|
-
]>;
|
49
|
-
/**
|
50
|
-
* Custom fetch implementation.
|
51
|
-
*
|
52
|
-
* @default globalThis.fetch.bind(globalThis)
|
53
|
-
*/
|
54
|
-
fetch?: FetchWithContext<TClientContext>;
|
55
|
-
rpcSerializer?: RPCSerializer;
|
56
|
-
/**
|
57
|
-
* Maximum number of retry attempts for EventSource errors before throwing.
|
58
|
-
*
|
59
|
-
* @default 5
|
60
|
-
*/
|
61
|
-
eventSourceMaxNumberOfRetries?: number;
|
62
|
-
/**
|
63
|
-
* Delay (in ms) before retrying an EventSource call.
|
64
|
-
*
|
65
|
-
* @default ({retryTimes, lastRetry}) => lastRetry ?? (1000 * 2 ** retryTimes)
|
66
|
-
*/
|
67
|
-
eventSourceRetryDelay?: Value<number, [
|
68
|
-
reconnectOptions: EventIteratorReconnectOptions,
|
69
|
-
options: ClientOptionsOut<TClientContext>,
|
70
|
-
path: readonly string[],
|
71
|
-
input: unknown
|
72
|
-
]>;
|
73
|
-
/**
|
74
|
-
* Function to determine if an error is retryable.
|
75
|
-
*
|
76
|
-
* @default true
|
77
|
-
*/
|
78
|
-
eventSourceRetry?: Value<boolean, [
|
79
|
-
reconnectOptions: EventIteratorReconnectOptions,
|
80
|
-
options: ClientOptionsOut<TClientContext>,
|
81
|
-
path: readonly string[],
|
82
|
-
input: unknown
|
83
|
-
]>;
|
19
|
+
|
20
|
+
interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions<T>, LinkFetchClientOptions<T> {
|
84
21
|
}
|
85
|
-
declare class RPCLink<
|
86
|
-
|
87
|
-
private readonly rpcSerializer;
|
88
|
-
private readonly maxUrlLength;
|
89
|
-
private readonly fallbackMethod;
|
90
|
-
private readonly method;
|
91
|
-
private readonly headers;
|
92
|
-
private readonly url;
|
93
|
-
private readonly eventSourceMaxNumberOfRetries;
|
94
|
-
private readonly eventSourceRetryDelay;
|
95
|
-
private readonly eventSourceRetry;
|
96
|
-
private readonly toFetchBodyOptions;
|
97
|
-
constructor(options: RPCLinkOptions<TClientContext>);
|
98
|
-
call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
|
99
|
-
private performCall;
|
100
|
-
private encodeRequest;
|
22
|
+
declare class RPCLink<T extends ClientContext> extends StandardRPCLink<T> {
|
23
|
+
constructor(options: RPCLinkOptions<T>);
|
101
24
|
}
|
102
25
|
|
103
|
-
export { type
|
26
|
+
export { LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
|
@@ -1,103 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
1
|
+
import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
|
2
|
+
import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
|
3
|
+
import { a as ClientContext, b as ClientOptions } from '../../shared/client.CipPQkhk.js';
|
4
|
+
import { f as StandardLinkClient } from '../../shared/client.FvDtk0Vr.js';
|
5
|
+
import { f as StandardRPCLinkOptions, g as StandardRPCLink } from '../../shared/client.Dc8eXpCj.js';
|
6
|
+
import '@orpc/shared';
|
5
7
|
|
6
|
-
interface
|
7
|
-
(
|
8
|
+
interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
|
9
|
+
fetch?: (request: Request, init: {
|
10
|
+
redirect?: Request['redirect'];
|
11
|
+
}, options: ClientOptions<T>, path: readonly string[], input: unknown) => Promise<Response>;
|
8
12
|
}
|
9
|
-
|
10
|
-
|
11
|
-
|
13
|
+
declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
|
14
|
+
private readonly fetch;
|
15
|
+
private readonly toFetchRequestOptions;
|
16
|
+
constructor(options: LinkFetchClientOptions<T>);
|
17
|
+
call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
|
12
18
|
}
|
13
|
-
|
14
|
-
|
15
|
-
* Base url for all requests.
|
16
|
-
*/
|
17
|
-
url: string;
|
18
|
-
/**
|
19
|
-
* The maximum length of the URL.
|
20
|
-
*
|
21
|
-
* @default 2083
|
22
|
-
*/
|
23
|
-
maxUrlLength?: number;
|
24
|
-
/**
|
25
|
-
* The method used to make the request.
|
26
|
-
*
|
27
|
-
* @default 'POST'
|
28
|
-
*/
|
29
|
-
method?: Value<HTTPMethod, [
|
30
|
-
options: ClientOptionsOut<TClientContext>,
|
31
|
-
path: readonly string[],
|
32
|
-
input: unknown
|
33
|
-
]>;
|
34
|
-
/**
|
35
|
-
* The method to use when the payload cannot safely pass to the server with method return from method function.
|
36
|
-
* GET is not allowed, it's very dangerous.
|
37
|
-
*
|
38
|
-
* @default 'POST'
|
39
|
-
*/
|
40
|
-
fallbackMethod?: Exclude<HTTPMethod, 'GET'>;
|
41
|
-
/**
|
42
|
-
* Inject headers to the request.
|
43
|
-
*/
|
44
|
-
headers?: Value<[string, string][] | Record<string, string> | Headers, [
|
45
|
-
options: ClientOptionsOut<TClientContext>,
|
46
|
-
path: readonly string[],
|
47
|
-
input: unknown
|
48
|
-
]>;
|
49
|
-
/**
|
50
|
-
* Custom fetch implementation.
|
51
|
-
*
|
52
|
-
* @default globalThis.fetch.bind(globalThis)
|
53
|
-
*/
|
54
|
-
fetch?: FetchWithContext<TClientContext>;
|
55
|
-
rpcSerializer?: RPCSerializer;
|
56
|
-
/**
|
57
|
-
* Maximum number of retry attempts for EventSource errors before throwing.
|
58
|
-
*
|
59
|
-
* @default 5
|
60
|
-
*/
|
61
|
-
eventSourceMaxNumberOfRetries?: number;
|
62
|
-
/**
|
63
|
-
* Delay (in ms) before retrying an EventSource call.
|
64
|
-
*
|
65
|
-
* @default ({retryTimes, lastRetry}) => lastRetry ?? (1000 * 2 ** retryTimes)
|
66
|
-
*/
|
67
|
-
eventSourceRetryDelay?: Value<number, [
|
68
|
-
reconnectOptions: EventIteratorReconnectOptions,
|
69
|
-
options: ClientOptionsOut<TClientContext>,
|
70
|
-
path: readonly string[],
|
71
|
-
input: unknown
|
72
|
-
]>;
|
73
|
-
/**
|
74
|
-
* Function to determine if an error is retryable.
|
75
|
-
*
|
76
|
-
* @default true
|
77
|
-
*/
|
78
|
-
eventSourceRetry?: Value<boolean, [
|
79
|
-
reconnectOptions: EventIteratorReconnectOptions,
|
80
|
-
options: ClientOptionsOut<TClientContext>,
|
81
|
-
path: readonly string[],
|
82
|
-
input: unknown
|
83
|
-
]>;
|
19
|
+
|
20
|
+
interface RPCLinkOptions<T extends ClientContext> extends StandardRPCLinkOptions<T>, LinkFetchClientOptions<T> {
|
84
21
|
}
|
85
|
-
declare class RPCLink<
|
86
|
-
|
87
|
-
private readonly rpcSerializer;
|
88
|
-
private readonly maxUrlLength;
|
89
|
-
private readonly fallbackMethod;
|
90
|
-
private readonly method;
|
91
|
-
private readonly headers;
|
92
|
-
private readonly url;
|
93
|
-
private readonly eventSourceMaxNumberOfRetries;
|
94
|
-
private readonly eventSourceRetryDelay;
|
95
|
-
private readonly eventSourceRetry;
|
96
|
-
private readonly toFetchBodyOptions;
|
97
|
-
constructor(options: RPCLinkOptions<TClientContext>);
|
98
|
-
call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
|
99
|
-
private performCall;
|
100
|
-
private encodeRequest;
|
22
|
+
declare class RPCLink<T extends ClientContext> extends StandardRPCLink<T> {
|
23
|
+
constructor(options: RPCLinkOptions<T>);
|
101
24
|
}
|
102
25
|
|
103
|
-
export { type
|
26
|
+
export { LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
|
@@ -1,121 +1,29 @@
|
|
1
|
-
import {
|
2
|
-
import
|
3
|
-
import { c as
|
4
|
-
import { a as RPCSerializer } from '../../shared/client.DHJ8vRIG.mjs';
|
1
|
+
import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
|
2
|
+
import '@orpc/shared';
|
3
|
+
import { c as StandardRPCLink } from '../../shared/client.DpICn1BD.mjs';
|
5
4
|
import '@orpc/standard-server';
|
5
|
+
import '../../shared/client.CRWEpqLB.mjs';
|
6
6
|
|
7
|
-
class
|
8
|
-
}
|
9
|
-
class RPCLink {
|
7
|
+
class LinkFetchClient {
|
10
8
|
fetch;
|
11
|
-
|
12
|
-
maxUrlLength;
|
13
|
-
fallbackMethod;
|
14
|
-
method;
|
15
|
-
headers;
|
16
|
-
url;
|
17
|
-
eventSourceMaxNumberOfRetries;
|
18
|
-
eventSourceRetryDelay;
|
19
|
-
eventSourceRetry;
|
20
|
-
toFetchBodyOptions;
|
9
|
+
toFetchRequestOptions;
|
21
10
|
constructor(options) {
|
22
|
-
this.fetch = options
|
23
|
-
this.
|
24
|
-
this.maxUrlLength = options.maxUrlLength ?? 2083;
|
25
|
-
this.fallbackMethod = options.fallbackMethod ?? "POST";
|
26
|
-
this.url = options.url;
|
27
|
-
this.eventSourceMaxNumberOfRetries = options.eventSourceMaxNumberOfRetries ?? 5;
|
28
|
-
this.method = options.method ?? this.fallbackMethod;
|
29
|
-
this.headers = options.headers ?? {};
|
30
|
-
this.eventSourceRetry = options.eventSourceRetry ?? true;
|
31
|
-
this.eventSourceRetryDelay = options.eventSourceRetryDelay ?? (({ retryTimes, lastRetry }) => lastRetry ?? 1e3 * 2 ** retryTimes);
|
32
|
-
this.toFetchBodyOptions = options;
|
33
|
-
}
|
34
|
-
async call(path, input, options) {
|
35
|
-
const output = await this.performCall(path, input, options);
|
36
|
-
if (!isAsyncIteratorObject(output)) {
|
37
|
-
return output;
|
38
|
-
}
|
39
|
-
return createAutoRetryEventIterator(output, async (reconnectOptions) => {
|
40
|
-
if (options.signal?.aborted || reconnectOptions.retryTimes > this.eventSourceMaxNumberOfRetries) {
|
41
|
-
return null;
|
42
|
-
}
|
43
|
-
if (!await value(this.eventSourceRetry, reconnectOptions, options, path, input)) {
|
44
|
-
return null;
|
45
|
-
}
|
46
|
-
const delay = await value(this.eventSourceRetryDelay, reconnectOptions, options, path, input);
|
47
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
48
|
-
const updatedOptions = { ...options, lastEventId: reconnectOptions.lastEventId };
|
49
|
-
const maybeIterator = await this.performCall(path, input, updatedOptions);
|
50
|
-
if (!isAsyncIteratorObject(maybeIterator)) {
|
51
|
-
throw new InvalidEventSourceRetryResponse("Invalid EventSource retry response");
|
52
|
-
}
|
53
|
-
return maybeIterator;
|
54
|
-
}, void 0);
|
11
|
+
this.fetch = options?.fetch ?? globalThis.fetch.bind(globalThis);
|
12
|
+
this.toFetchRequestOptions = options;
|
55
13
|
}
|
56
|
-
async
|
57
|
-
const
|
58
|
-
const
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
const response = await this.fetch(encoded.url, {
|
63
|
-
method: encoded.method,
|
64
|
-
headers: encoded.headers,
|
65
|
-
body: fetchBody,
|
66
|
-
signal: options.signal
|
67
|
-
}, options, path, input);
|
68
|
-
const body = await toStandardBody(response);
|
69
|
-
const deserialized = (() => {
|
70
|
-
try {
|
71
|
-
return this.rpcSerializer.deserialize(body);
|
72
|
-
} catch (error) {
|
73
|
-
if (response.ok) {
|
74
|
-
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
75
|
-
message: "Invalid RPC response",
|
76
|
-
cause: error
|
77
|
-
});
|
78
|
-
}
|
79
|
-
throw new ORPCError(response.status.toString(), {
|
80
|
-
message: response.statusText
|
81
|
-
});
|
82
|
-
}
|
83
|
-
})();
|
84
|
-
if (!response.ok) {
|
85
|
-
if (ORPCError.isValidJSON(deserialized)) {
|
86
|
-
throw ORPCError.fromJSON(deserialized);
|
87
|
-
}
|
88
|
-
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
89
|
-
message: "Invalid RPC error response",
|
90
|
-
cause: deserialized
|
91
|
-
});
|
92
|
-
}
|
93
|
-
return deserialized;
|
14
|
+
async call(request, options, path, input) {
|
15
|
+
const fetchRequest = toFetchRequest(request, this.toFetchRequestOptions);
|
16
|
+
const fetchResponse = await this.fetch(fetchRequest, { redirect: "manual" }, options, path, input);
|
17
|
+
const lazyResponse = toStandardLazyResponse(fetchResponse);
|
18
|
+
return lazyResponse;
|
94
19
|
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
const
|
100
|
-
|
101
|
-
const getUrl = new URL(url);
|
102
|
-
getUrl.searchParams.append("data", stringifyJSON(serialized) ?? "");
|
103
|
-
if (getUrl.toString().length <= this.maxUrlLength) {
|
104
|
-
return {
|
105
|
-
body: void 0,
|
106
|
-
method: expectedMethod,
|
107
|
-
headers,
|
108
|
-
url: getUrl
|
109
|
-
};
|
110
|
-
}
|
111
|
-
}
|
112
|
-
return {
|
113
|
-
url,
|
114
|
-
method: expectedMethod === "GET" ? this.fallbackMethod : expectedMethod,
|
115
|
-
headers,
|
116
|
-
body: serialized
|
117
|
-
};
|
20
|
+
}
|
21
|
+
|
22
|
+
class RPCLink extends StandardRPCLink {
|
23
|
+
constructor(options) {
|
24
|
+
const linkClient = new LinkFetchClient(options);
|
25
|
+
super(linkClient, options);
|
118
26
|
}
|
119
27
|
}
|
120
28
|
|
121
|
-
export {
|
29
|
+
export { LinkFetchClient, RPCLink };
|
@@ -1,22 +1,10 @@
|
|
1
|
-
|
1
|
+
export { C as CompositeStandardLinkPlugin, d as StandardLink, f as StandardLinkClient, S as StandardLinkClientInterceptorOptions, e as StandardLinkCodec, c as StandardLinkInterceptorOptions, b as StandardLinkOptions, a as StandardLinkPlugin } from '../../shared/client.Bt2hFtM_.mjs';
|
2
|
+
export { S as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, c as StandardRPCCustomJsonSerializer, b as StandardRPCJsonSerialized, a as StandardRPCJsonSerializedMetaItem, e as StandardRPCJsonSerializer, d as StandardRPCJsonSerializerOptions, g as StandardRPCLink, i as StandardRPCLinkCodec, h as StandardRPCLinkCodecOptions, f as StandardRPCLinkOptions, j as StandardRPCSerializer } from '../../shared/client.DXvQo1nS.mjs';
|
3
|
+
import { H as HTTPPath } from '../../shared/client.CipPQkhk.mjs';
|
4
|
+
import '@orpc/shared';
|
5
|
+
import '@orpc/standard-server';
|
2
6
|
|
3
|
-
|
4
|
-
|
5
|
-
Segment[]
|
6
|
-
][];
|
7
|
-
type RPCJsonSerialized = [json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], blobs: Blob[]];
|
8
|
-
declare class RPCJsonSerializer {
|
9
|
-
serialize(data: unknown, segments?: Segment[], meta?: RPCJsonSerializedMeta, maps?: Segment[][], blobs?: Blob[]): RPCJsonSerialized;
|
10
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta): unknown;
|
11
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], getBlob: (index: number) => Blob): unknown;
|
12
|
-
}
|
7
|
+
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
8
|
+
declare function getMalformedResponseErrorCode(status: number): string;
|
13
9
|
|
14
|
-
|
15
|
-
#private;
|
16
|
-
private readonly jsonSerializer;
|
17
|
-
constructor(jsonSerializer?: RPCJsonSerializer);
|
18
|
-
serialize(data: unknown): unknown;
|
19
|
-
deserialize(data: unknown): unknown;
|
20
|
-
}
|
21
|
-
|
22
|
-
export { type RPCJsonSerialized, type RPCJsonSerializedMeta, RPCJsonSerializer, RPCSerializer };
|
10
|
+
export { getMalformedResponseErrorCode, toHttpPath };
|
@@ -1,22 +1,10 @@
|
|
1
|
-
|
1
|
+
export { C as CompositeStandardLinkPlugin, d as StandardLink, f as StandardLinkClient, S as StandardLinkClientInterceptorOptions, e as StandardLinkCodec, c as StandardLinkInterceptorOptions, b as StandardLinkOptions, a as StandardLinkPlugin } from '../../shared/client.FvDtk0Vr.js';
|
2
|
+
export { S as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, c as StandardRPCCustomJsonSerializer, b as StandardRPCJsonSerialized, a as StandardRPCJsonSerializedMetaItem, e as StandardRPCJsonSerializer, d as StandardRPCJsonSerializerOptions, g as StandardRPCLink, i as StandardRPCLinkCodec, h as StandardRPCLinkCodecOptions, f as StandardRPCLinkOptions, j as StandardRPCSerializer } from '../../shared/client.Dc8eXpCj.js';
|
3
|
+
import { H as HTTPPath } from '../../shared/client.CipPQkhk.js';
|
4
|
+
import '@orpc/shared';
|
5
|
+
import '@orpc/standard-server';
|
2
6
|
|
3
|
-
|
4
|
-
|
5
|
-
Segment[]
|
6
|
-
][];
|
7
|
-
type RPCJsonSerialized = [json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], blobs: Blob[]];
|
8
|
-
declare class RPCJsonSerializer {
|
9
|
-
serialize(data: unknown, segments?: Segment[], meta?: RPCJsonSerializedMeta, maps?: Segment[][], blobs?: Blob[]): RPCJsonSerialized;
|
10
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta): unknown;
|
11
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], getBlob: (index: number) => Blob): unknown;
|
12
|
-
}
|
7
|
+
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
8
|
+
declare function getMalformedResponseErrorCode(status: number): string;
|
13
9
|
|
14
|
-
|
15
|
-
#private;
|
16
|
-
private readonly jsonSerializer;
|
17
|
-
constructor(jsonSerializer?: RPCJsonSerializer);
|
18
|
-
serialize(data: unknown): unknown;
|
19
|
-
deserialize(data: unknown): unknown;
|
20
|
-
}
|
21
|
-
|
22
|
-
export { type RPCJsonSerialized, type RPCJsonSerializedMeta, RPCJsonSerializer, RPCSerializer };
|
10
|
+
export { getMalformedResponseErrorCode, toHttpPath };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export {
|
1
|
+
export { C as CompositeStandardLinkPlugin, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLink, d as StandardRPCLinkCodec, e as StandardRPCSerializer, g as getMalformedResponseErrorCode, t as toHttpPath } from '../../shared/client.DpICn1BD.mjs';
|
2
2
|
import '@orpc/shared';
|
3
3
|
import '@orpc/standard-server';
|
4
|
-
import '../../shared/client.
|
4
|
+
import '../../shared/client.CRWEpqLB.mjs';
|
package/dist/index.d.mts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import { N as NestedClient,
|
2
|
-
export {
|
3
|
-
import { Promisable, MaybeOptionalOptions } from '@orpc/shared';
|
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
|
+
import { Promisable, MaybeOptionalOptions, ThrowableError } from '@orpc/shared';
|
4
|
+
export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
4
5
|
export { ErrorEvent } from '@orpc/standard-server';
|
5
6
|
|
6
7
|
interface createORPCClientOptions {
|
@@ -17,8 +18,8 @@ declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<
|
|
17
18
|
*/
|
18
19
|
declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
19
20
|
private readonly linkResolver;
|
20
|
-
constructor(linkResolver: (options:
|
21
|
-
call(path: readonly string[], input: unknown, options:
|
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>;
|
22
23
|
}
|
23
24
|
|
24
25
|
declare const COMMON_ORPC_ERROR_DEFS: {
|
@@ -119,35 +120,36 @@ declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
119
120
|
readonly data: TData;
|
120
121
|
constructor(code: TCode, ...[options]: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
|
121
122
|
toJSON(): ORPCErrorJSON<TCode, TData>;
|
122
|
-
static fromJSON<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
123
|
-
static isValidJSON(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
124
123
|
}
|
125
124
|
type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
|
126
125
|
declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
|
127
126
|
declare function toORPCError(error: unknown): ORPCError<any, any>;
|
127
|
+
declare function isORPCErrorStatus(status: number): boolean;
|
128
|
+
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
129
|
+
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
128
130
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
}
|
134
|
-
declare function registerEventIteratorState(iterator: AsyncIteratorObject<unknown, unknown, void>, state: EventIteratorState): void;
|
135
|
-
declare function updateEventIteratorStatus(state: EventIteratorState, status: ConnectionStatus): void;
|
136
|
-
declare function onEventIteratorStatusChange(iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void, notifyImmediately?: boolean): () => void;
|
131
|
+
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
132
|
+
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
133
|
+
error: (error: unknown) => Promise<unknown>;
|
134
|
+
}): AsyncGenerator<TMap, TMap, TNext>;
|
137
135
|
|
138
|
-
type SafeResult<TOutput, TError
|
136
|
+
type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
139
137
|
error: null;
|
140
138
|
data: TOutput;
|
141
139
|
isDefined: false;
|
142
|
-
|
140
|
+
isSuccess: true;
|
141
|
+
} | [error: Exclude<TError, ORPCError<any, any>>, data: undefined, isDefined: false, isSuccess: false] & {
|
143
142
|
error: Exclude<TError, ORPCError<any, any>>;
|
144
143
|
data: undefined;
|
145
144
|
isDefined: false;
|
146
|
-
|
145
|
+
isSuccess: false;
|
146
|
+
} | [error: Extract<TError, ORPCError<any, any>>, data: undefined, isDefined: true, isSuccess: false] & {
|
147
147
|
error: Extract<TError, ORPCError<any, any>>;
|
148
148
|
data: undefined;
|
149
149
|
isDefined: true;
|
150
|
+
isSuccess: false;
|
150
151
|
};
|
151
|
-
declare function safe<TOutput, TError
|
152
|
+
declare function safe<TOutput, TError = ThrowableError>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
153
|
+
declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
|
152
154
|
|
153
|
-
export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink,
|
155
|
+
export { COMMON_ORPC_ERROR_DEFS, ClientContext, ClientLink, ClientOptions, ClientPromiseResult, type CommonORPCErrorCode, DynamicLink, FriendlyClientOptions, InferClientContext, NestedClient, ORPCError, type ORPCErrorCode, type ORPCErrorJSON, type ORPCErrorOptions, type SafeResult, createORPCClient, type createORPCClientOptions, createORPCErrorFromJson, fallbackORPCErrorMessage, fallbackORPCErrorStatus, isDefinedError, isORPCErrorJson, isORPCErrorStatus, mapEventIterator, resolveFriendlyClientOptions, safe, toORPCError };
|