@orpc/client 0.0.0-next.bf323bf → 0.0.0-next.c0088c7
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 +88 -0
- package/dist/adapters/fetch/index.d.mts +29 -0
- package/dist/adapters/fetch/index.d.ts +29 -0
- package/dist/adapters/fetch/index.mjs +35 -0
- package/dist/adapters/standard/index.d.mts +148 -0
- package/dist/adapters/standard/index.d.ts +148 -0
- package/dist/adapters/standard/index.mjs +4 -0
- package/dist/index.d.mts +153 -0
- package/dist/index.d.ts +153 -0
- package/dist/index.mjs +63 -0
- package/dist/shared/client.BMw2gtvr.mjs +320 -0
- package/dist/shared/client.D_CzLDyB.d.mts +42 -0
- package/dist/shared/client.D_CzLDyB.d.ts +42 -0
- package/dist/shared/client.DcaJQZfy.mjs +265 -0
- package/package.json +17 -20
- package/dist/chunk-HYT35LXG.js +0 -105
- package/dist/fetch.js +0 -126
- package/dist/index.js +0 -58
- package/dist/src/adapters/fetch/index.d.ts +0 -3
- package/dist/src/adapters/fetch/orpc-link.d.ts +0 -97
- package/dist/src/adapters/fetch/types.d.ts +0 -6
- package/dist/src/client.d.ts +0 -11
- package/dist/src/dynamic-link.d.ts +0 -13
- package/dist/src/event-iterator-state.d.ts +0 -9
- package/dist/src/event-iterator.d.ts +0 -8
- package/dist/src/index.d.ts +0 -8
- package/dist/src/types.d.ts +0 -8
@@ -1,97 +0,0 @@
|
|
1
|
-
import type { ClientContext, HTTPMethod } from '@orpc/contract';
|
2
|
-
import type { Value } from '@orpc/shared';
|
3
|
-
import type { ClientLink, ClientOptionsOut } from '../../types';
|
4
|
-
import type { FetchWithContext } from './types';
|
5
|
-
import { RPCSerializer } from '@orpc/server/standard';
|
6
|
-
import { type EventIteratorReconnectOptions } from '../../event-iterator';
|
7
|
-
export declare class InvalidEventSourceRetryResponse extends Error {
|
8
|
-
}
|
9
|
-
export interface RPCLinkOptions<TClientContext extends ClientContext> {
|
10
|
-
/**
|
11
|
-
* Base url for all requests.
|
12
|
-
*/
|
13
|
-
url: string;
|
14
|
-
/**
|
15
|
-
* The maximum length of the URL.
|
16
|
-
*
|
17
|
-
* @default 2083
|
18
|
-
*/
|
19
|
-
maxUrlLength?: number;
|
20
|
-
/**
|
21
|
-
* The method used to make the request.
|
22
|
-
*
|
23
|
-
* @default 'POST'
|
24
|
-
*/
|
25
|
-
method?: Value<HTTPMethod, [
|
26
|
-
options: ClientOptionsOut<TClientContext>,
|
27
|
-
path: readonly string[],
|
28
|
-
input: unknown
|
29
|
-
]>;
|
30
|
-
/**
|
31
|
-
* The method to use when the payload cannot safely pass to the server with method return from method function.
|
32
|
-
* GET is not allowed, it's very dangerous.
|
33
|
-
*
|
34
|
-
* @default 'POST'
|
35
|
-
*/
|
36
|
-
fallbackMethod?: Exclude<HTTPMethod, 'GET'>;
|
37
|
-
/**
|
38
|
-
* Inject headers to the request.
|
39
|
-
*/
|
40
|
-
headers?: Value<[string, string][] | Record<string, string> | Headers, [
|
41
|
-
options: ClientOptionsOut<TClientContext>,
|
42
|
-
path: readonly string[],
|
43
|
-
input: unknown
|
44
|
-
]>;
|
45
|
-
/**
|
46
|
-
* Custom fetch implementation.
|
47
|
-
*
|
48
|
-
* @default globalThis.fetch.bind(globalThis)
|
49
|
-
*/
|
50
|
-
fetch?: FetchWithContext<TClientContext>;
|
51
|
-
rpcSerializer?: RPCSerializer;
|
52
|
-
/**
|
53
|
-
* Maximum number of retry attempts for EventSource errors before throwing.
|
54
|
-
*
|
55
|
-
* @default 5
|
56
|
-
*/
|
57
|
-
eventSourceMaxNumberOfRetries?: number;
|
58
|
-
/**
|
59
|
-
* Delay (in ms) before retrying an EventSource call.
|
60
|
-
*
|
61
|
-
* @default ({retryTimes, lastRetry}) => lastRetry ?? (1000 * 2 ** retryTimes)
|
62
|
-
*/
|
63
|
-
eventSourceRetryDelay?: Value<number, [
|
64
|
-
reconnectOptions: EventIteratorReconnectOptions,
|
65
|
-
options: ClientOptionsOut<TClientContext>,
|
66
|
-
path: readonly string[],
|
67
|
-
input: unknown
|
68
|
-
]>;
|
69
|
-
/**
|
70
|
-
* Function to determine if an error is retryable.
|
71
|
-
*
|
72
|
-
* @default true
|
73
|
-
*/
|
74
|
-
eventSourceRetry?: Value<boolean, [
|
75
|
-
reconnectOptions: EventIteratorReconnectOptions,
|
76
|
-
options: ClientOptionsOut<TClientContext>,
|
77
|
-
path: readonly string[],
|
78
|
-
input: unknown
|
79
|
-
]>;
|
80
|
-
}
|
81
|
-
export declare class RPCLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
82
|
-
private readonly fetch;
|
83
|
-
private readonly rpcSerializer;
|
84
|
-
private readonly maxUrlLength;
|
85
|
-
private readonly fallbackMethod;
|
86
|
-
private readonly method;
|
87
|
-
private readonly headers;
|
88
|
-
private readonly url;
|
89
|
-
private readonly eventSourceMaxNumberOfRetries;
|
90
|
-
private readonly eventSourceRetryDelay;
|
91
|
-
private readonly eventSourceRetry;
|
92
|
-
constructor(options: RPCLinkOptions<TClientContext>);
|
93
|
-
call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
|
94
|
-
private performCall;
|
95
|
-
private encodeRequest;
|
96
|
-
}
|
97
|
-
//# sourceMappingURL=orpc-link.d.ts.map
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import type { ClientContext } from '@orpc/contract';
|
2
|
-
import type { ClientOptionsOut } from '../../types';
|
3
|
-
export interface FetchWithContext<TClientContext extends ClientContext> {
|
4
|
-
(url: URL, init: RequestInit, options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
|
5
|
-
}
|
6
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/client.d.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { AnyContractRouter, ClientContext, ContractRouterClient } from '@orpc/contract';
|
2
|
-
import type { AnyRouter, RouterClient } from '@orpc/server';
|
3
|
-
import type { ClientLink } from './types';
|
4
|
-
export interface createORPCClientOptions {
|
5
|
-
/**
|
6
|
-
* Use as base path for all procedure, useful when you only want to call a subset of the procedure.
|
7
|
-
*/
|
8
|
-
path?: string[];
|
9
|
-
}
|
10
|
-
export declare function createORPCClient<TRouter extends AnyRouter | AnyContractRouter, TClientContext extends ClientContext = Record<never, never>>(link: ClientLink<TClientContext>, options?: createORPCClientOptions): TRouter extends AnyRouter ? RouterClient<TRouter, TClientContext> : TRouter extends AnyContractRouter ? ContractRouterClient<TRouter, TClientContext> : never;
|
11
|
-
//# sourceMappingURL=client.d.ts.map
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import type { ClientContext } from '@orpc/contract';
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
3
|
-
import type { ClientLink, ClientOptionsOut } from './types';
|
4
|
-
/**
|
5
|
-
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
6
|
-
* based on the request path, input, and context.
|
7
|
-
*/
|
8
|
-
export declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
9
|
-
private readonly linkResolver;
|
10
|
-
constructor(linkResolver: (options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown) => Promisable<ClientLink<TClientContext>>);
|
11
|
-
call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
|
12
|
-
}
|
13
|
-
//# sourceMappingURL=dynamic-link.d.ts.map
|
@@ -1,9 +0,0 @@
|
|
1
|
-
export type ConnectionStatus = 'reconnecting' | 'connected' | 'closed';
|
2
|
-
export interface EventIteratorState {
|
3
|
-
status: ConnectionStatus;
|
4
|
-
listeners: Array<(newStatus: ConnectionStatus) => void>;
|
5
|
-
}
|
6
|
-
export declare function registerEventIteratorState(iterator: AsyncIteratorObject<unknown, unknown, void>, state: EventIteratorState): void;
|
7
|
-
export declare function updateEventIteratorStatus(state: EventIteratorState, status: ConnectionStatus): void;
|
8
|
-
export declare function onEventIteratorStatusChange(iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void, notifyImmediately?: boolean): () => void;
|
9
|
-
//# sourceMappingURL=event-iterator-state.d.ts.map
|
@@ -1,8 +0,0 @@
|
|
1
|
-
export interface EventIteratorReconnectOptions {
|
2
|
-
lastRetry: number | undefined;
|
3
|
-
lastEventId: string | undefined;
|
4
|
-
retryTimes: number;
|
5
|
-
error: unknown;
|
6
|
-
}
|
7
|
-
export declare function createAutoRetryEventIterator<TYield, TReturn>(initial: AsyncIterator<TYield, TReturn, void>, reconnect: (options: EventIteratorReconnectOptions) => Promise<AsyncIterator<TYield, TReturn, void> | null>, initialLastEventId: string | undefined): AsyncGenerator<TYield, TReturn, void>;
|
8
|
-
//# sourceMappingURL=event-iterator.d.ts.map
|
package/dist/src/index.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
/** unnoq */
|
2
|
-
export * from './client';
|
3
|
-
export * from './dynamic-link';
|
4
|
-
export * from './event-iterator';
|
5
|
-
export * from './event-iterator-state';
|
6
|
-
export * from './types';
|
7
|
-
export { isDefinedError, ORPCError, safe } from '@orpc/contract';
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/types.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { ClientContext, ClientOptions } from '@orpc/contract';
|
2
|
-
export type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
|
3
|
-
context: TClientContext;
|
4
|
-
};
|
5
|
-
export interface ClientLink<TClientContext extends ClientContext> {
|
6
|
-
call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
|
7
|
-
}
|
8
|
-
//# sourceMappingURL=types.d.ts.map
|