@orpc/client 0.0.0-next.d137cdf → 0.0.0-next.d5f0415
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/chunk-2UPNYYFF.js +288 -0
- package/dist/chunk-TPEMQB7D.js +178 -0
- package/dist/fetch.js +128 -0
- package/dist/index.js +69 -71
- package/dist/openapi.js +329 -0
- package/dist/rpc.js +10 -0
- package/dist/src/adapters/fetch/index.d.ts +3 -0
- package/dist/src/adapters/fetch/rpc-link.d.ts +98 -0
- package/dist/src/adapters/fetch/types.d.ts +5 -0
- package/dist/src/client.d.ts +9 -0
- package/dist/src/dynamic-link.d.ts +12 -0
- package/dist/src/error.d.ts +106 -0
- package/dist/src/event-iterator-state.d.ts +9 -0
- package/dist/src/event-iterator.d.ts +12 -0
- package/dist/src/index.d.ts +7 -5
- package/dist/src/openapi/bracket-notation.d.ts +84 -0
- package/dist/src/openapi/index.d.ts +4 -0
- package/dist/src/openapi/json-serializer.d.ts +5 -0
- package/dist/src/openapi/serializer.d.ts +11 -0
- package/dist/src/rpc/index.d.ts +2 -0
- package/dist/src/rpc/serializer.d.ts +22 -0
- package/dist/src/types.d.ts +29 -0
- package/dist/src/utils.d.ts +5 -0
- package/package.json +21 -10
- package/dist/src/procedure.d.ts +0 -27
- package/dist/src/router.d.ts +0 -34
@@ -0,0 +1,106 @@
|
|
1
|
+
import { type MaybeOptionalOptions } from '@orpc/shared';
|
2
|
+
export declare const COMMON_ORPC_ERROR_DEFS: {
|
3
|
+
readonly BAD_REQUEST: {
|
4
|
+
readonly status: 400;
|
5
|
+
readonly message: "Bad Request";
|
6
|
+
};
|
7
|
+
readonly UNAUTHORIZED: {
|
8
|
+
readonly status: 401;
|
9
|
+
readonly message: "Unauthorized";
|
10
|
+
};
|
11
|
+
readonly FORBIDDEN: {
|
12
|
+
readonly status: 403;
|
13
|
+
readonly message: "Forbidden";
|
14
|
+
};
|
15
|
+
readonly NOT_FOUND: {
|
16
|
+
readonly status: 404;
|
17
|
+
readonly message: "Not Found";
|
18
|
+
};
|
19
|
+
readonly METHOD_NOT_SUPPORTED: {
|
20
|
+
readonly status: 405;
|
21
|
+
readonly message: "Method Not Supported";
|
22
|
+
};
|
23
|
+
readonly NOT_ACCEPTABLE: {
|
24
|
+
readonly status: 406;
|
25
|
+
readonly message: "Not Acceptable";
|
26
|
+
};
|
27
|
+
readonly TIMEOUT: {
|
28
|
+
readonly status: 408;
|
29
|
+
readonly message: "Request Timeout";
|
30
|
+
};
|
31
|
+
readonly CONFLICT: {
|
32
|
+
readonly status: 409;
|
33
|
+
readonly message: "Conflict";
|
34
|
+
};
|
35
|
+
readonly PRECONDITION_FAILED: {
|
36
|
+
readonly status: 412;
|
37
|
+
readonly message: "Precondition Failed";
|
38
|
+
};
|
39
|
+
readonly PAYLOAD_TOO_LARGE: {
|
40
|
+
readonly status: 413;
|
41
|
+
readonly message: "Payload Too Large";
|
42
|
+
};
|
43
|
+
readonly UNSUPPORTED_MEDIA_TYPE: {
|
44
|
+
readonly status: 415;
|
45
|
+
readonly message: "Unsupported Media Type";
|
46
|
+
};
|
47
|
+
readonly UNPROCESSABLE_CONTENT: {
|
48
|
+
readonly status: 422;
|
49
|
+
readonly message: "Unprocessable Content";
|
50
|
+
};
|
51
|
+
readonly TOO_MANY_REQUESTS: {
|
52
|
+
readonly status: 429;
|
53
|
+
readonly message: "Too Many Requests";
|
54
|
+
};
|
55
|
+
readonly CLIENT_CLOSED_REQUEST: {
|
56
|
+
readonly status: 499;
|
57
|
+
readonly message: "Client Closed Request";
|
58
|
+
};
|
59
|
+
readonly INTERNAL_SERVER_ERROR: {
|
60
|
+
readonly status: 500;
|
61
|
+
readonly message: "Internal Server Error";
|
62
|
+
};
|
63
|
+
readonly NOT_IMPLEMENTED: {
|
64
|
+
readonly status: 501;
|
65
|
+
readonly message: "Not Implemented";
|
66
|
+
};
|
67
|
+
readonly BAD_GATEWAY: {
|
68
|
+
readonly status: 502;
|
69
|
+
readonly message: "Bad Gateway";
|
70
|
+
};
|
71
|
+
readonly SERVICE_UNAVAILABLE: {
|
72
|
+
readonly status: 503;
|
73
|
+
readonly message: "Service Unavailable";
|
74
|
+
};
|
75
|
+
readonly GATEWAY_TIMEOUT: {
|
76
|
+
readonly status: 504;
|
77
|
+
readonly message: "Gateway Timeout";
|
78
|
+
};
|
79
|
+
};
|
80
|
+
export type CommonORPCErrorCode = keyof typeof COMMON_ORPC_ERROR_DEFS;
|
81
|
+
export type ORPCErrorCode = CommonORPCErrorCode | (string & {});
|
82
|
+
export declare function fallbackORPCErrorStatus(code: ORPCErrorCode, status: number | undefined): number;
|
83
|
+
export declare function fallbackORPCErrorMessage(code: ORPCErrorCode, message: string | undefined): string;
|
84
|
+
export type ORPCErrorOptions<TData> = ErrorOptions & {
|
85
|
+
defined?: boolean;
|
86
|
+
status?: number;
|
87
|
+
message?: string;
|
88
|
+
} & (undefined extends TData ? {
|
89
|
+
data?: TData;
|
90
|
+
} : {
|
91
|
+
data: TData;
|
92
|
+
});
|
93
|
+
export declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
94
|
+
readonly defined: boolean;
|
95
|
+
readonly code: TCode;
|
96
|
+
readonly status: number;
|
97
|
+
readonly data: TData;
|
98
|
+
constructor(code: TCode, ...[options]: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
|
99
|
+
toJSON(): ORPCErrorJSON<TCode, TData>;
|
100
|
+
static fromJSON<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
101
|
+
static isValidJSON(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
102
|
+
}
|
103
|
+
export type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
|
104
|
+
export declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
|
105
|
+
export declare function toORPCError(error: unknown): ORPCError<any, any>;
|
106
|
+
//# sourceMappingURL=error.d.ts.map
|
@@ -0,0 +1,9 @@
|
|
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
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
2
|
+
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
3
|
+
error: (error: unknown) => Promise<unknown>;
|
4
|
+
}): AsyncGenerator<TMap, TMap, TNext>;
|
5
|
+
export interface EventIteratorReconnectOptions {
|
6
|
+
lastRetry: number | undefined;
|
7
|
+
lastEventId: string | undefined;
|
8
|
+
retryTimes: number;
|
9
|
+
error: unknown;
|
10
|
+
}
|
11
|
+
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>;
|
12
|
+
//# sourceMappingURL=event-iterator.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
/** unnoq */
|
2
|
-
|
3
|
-
export * from './
|
4
|
-
export * from './
|
5
|
-
export * from '
|
6
|
-
export
|
2
|
+
export * from './client';
|
3
|
+
export * from './dynamic-link';
|
4
|
+
export * from './error';
|
5
|
+
export * from './event-iterator';
|
6
|
+
export * from './event-iterator-state';
|
7
|
+
export * from './types';
|
8
|
+
export * from './utils';
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
* Serialize an object or array into a list of [key, value] pairs.
|
3
|
+
* The key will express by using bracket-notation.
|
4
|
+
*
|
5
|
+
* Notice: This way cannot express the empty object or array.
|
6
|
+
*
|
7
|
+
* @example
|
8
|
+
* ```ts
|
9
|
+
* const payload = {
|
10
|
+
* name: 'John Doe',
|
11
|
+
* pets: ['dog', 'cat'],
|
12
|
+
* }
|
13
|
+
*
|
14
|
+
* const entities = serialize(payload)
|
15
|
+
*
|
16
|
+
* expect(entities).toEqual([
|
17
|
+
* ['name', 'John Doe'],
|
18
|
+
* ['name[pets][0]', 'dog'],
|
19
|
+
* ['name[pets][1]', 'cat'],
|
20
|
+
* ])
|
21
|
+
* ```
|
22
|
+
*/
|
23
|
+
export declare function serialize(payload: unknown, parentKey?: string): [string, unknown][];
|
24
|
+
/**
|
25
|
+
* Deserialize a list of [key, value] pairs into an object or array.
|
26
|
+
* The key is expressed by using bracket-notation.
|
27
|
+
*
|
28
|
+
* @example
|
29
|
+
* ```ts
|
30
|
+
* const entities = [
|
31
|
+
* ['name', 'John Doe'],
|
32
|
+
* ['name[pets][0]', 'dog'],
|
33
|
+
* ['name[pets][1]', 'cat'],
|
34
|
+
* ['name[dogs][]', 'hello'],
|
35
|
+
* ['name[dogs][]', 'kitty'],
|
36
|
+
* ]
|
37
|
+
*
|
38
|
+
* const payload = deserialize(entities)
|
39
|
+
*
|
40
|
+
* expect(payload).toEqual({
|
41
|
+
* name: 'John Doe',
|
42
|
+
* pets: { 0: 'dog', 1: 'cat' },
|
43
|
+
* dogs: ['hello', 'kitty'],
|
44
|
+
* })
|
45
|
+
* ```
|
46
|
+
*/
|
47
|
+
export declare function deserialize(entities: readonly (readonly [string, unknown])[]): Record<string, unknown> | unknown[] | undefined;
|
48
|
+
/**
|
49
|
+
* Escape the `[`, `]`, and `\` chars in a path segment.
|
50
|
+
*
|
51
|
+
* @example
|
52
|
+
* ```ts
|
53
|
+
* expect(escapeSegment('name[pets')).toEqual('name\\[pets')
|
54
|
+
* ```
|
55
|
+
*/
|
56
|
+
export declare function escapeSegment(segment: string): string;
|
57
|
+
/**
|
58
|
+
* Convert an array of path segments into a path string using bracket-notation.
|
59
|
+
*
|
60
|
+
* For the special char `[`, `]`, and `\` will be escaped by adding `\` at start.
|
61
|
+
*
|
62
|
+
* @example
|
63
|
+
* ```ts
|
64
|
+
* expect(stringifyPath(['name', 'pets', '0'])).toEqual('name[pets][0]')
|
65
|
+
* ```
|
66
|
+
*/
|
67
|
+
export declare function stringifyPath(path: readonly [string, ...string[]]): string;
|
68
|
+
/**
|
69
|
+
* Convert a path string using bracket-notation into an array of path segments.
|
70
|
+
*
|
71
|
+
* For the special char `[`, `]`, and `\` you should escape by adding `\` at start.
|
72
|
+
* It only treats a pair `[${string}]` as a path segment.
|
73
|
+
* If missing or escape it will bypass and treat as normal string.
|
74
|
+
*
|
75
|
+
* @example
|
76
|
+
* ```ts
|
77
|
+
* expect(parsePath('name[pets][0]')).toEqual(['name', 'pets', '0'])
|
78
|
+
* expect(parsePath('name[pets][0')).toEqual(['name', 'pets', '[0'])
|
79
|
+
* expect(parsePath('name[pets[0]')).toEqual(['name', 'pets[0')
|
80
|
+
* expect(parsePath('name\\[pets][0]')).toEqual(['name[pets]', '0'])
|
81
|
+
* ```
|
82
|
+
*/
|
83
|
+
export declare function parsePath(path: string): [string, ...string[]];
|
84
|
+
//# sourceMappingURL=bracket-notation.d.ts.map
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { PublicOpenAPIJsonSerializer } from './json-serializer';
|
2
|
+
export interface OpenAPISerializerOptions {
|
3
|
+
jsonSerializer?: PublicOpenAPIJsonSerializer;
|
4
|
+
}
|
5
|
+
export declare class OpenAPISerializer {
|
6
|
+
private readonly jsonSerializer;
|
7
|
+
constructor(options?: OpenAPISerializerOptions);
|
8
|
+
serialize(data: unknown): unknown;
|
9
|
+
deserialize(serialized: unknown): unknown;
|
10
|
+
}
|
11
|
+
//# sourceMappingURL=serializer.d.ts.map
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { Segment } from '@orpc/shared';
|
2
|
+
export type RPCSerializedJsonMeta = ['bigint' | 'date' | 'nan' | 'undefined' | 'set' | 'map' | 'regexp' | 'url', Segment[]][];
|
3
|
+
export type RPCSerialized = {
|
4
|
+
json: unknown;
|
5
|
+
meta: RPCSerializedJsonMeta;
|
6
|
+
} | FormData | AsyncIteratorObject<{
|
7
|
+
json: unknown;
|
8
|
+
meta: RPCSerializedJsonMeta;
|
9
|
+
}, {
|
10
|
+
json: unknown;
|
11
|
+
meta: RPCSerializedJsonMeta;
|
12
|
+
}, void>;
|
13
|
+
export type RPCSerializedFormDataMaps = Segment[][];
|
14
|
+
export declare class RPCSerializer {
|
15
|
+
serialize(data: unknown): RPCSerialized;
|
16
|
+
deserialize(serialized: RPCSerialized): unknown;
|
17
|
+
}
|
18
|
+
export declare function serializeRPCJson(value: unknown, segments?: Segment[], meta?: RPCSerializedJsonMeta): {
|
19
|
+
json: unknown;
|
20
|
+
meta: RPCSerializedJsonMeta;
|
21
|
+
};
|
22
|
+
//# sourceMappingURL=serializer.d.ts.map
|
@@ -0,0 +1,29 @@
|
|
1
|
+
export type ClientContext = Record<string, any>;
|
2
|
+
export type ClientOptions<TClientContext extends ClientContext> = {
|
3
|
+
signal?: AbortSignal;
|
4
|
+
lastEventId?: string | undefined;
|
5
|
+
} & (Record<never, never> extends TClientContext ? {
|
6
|
+
context?: TClientContext;
|
7
|
+
} : {
|
8
|
+
context: TClientContext;
|
9
|
+
});
|
10
|
+
export type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options: ClientOptions<TClientContext>];
|
11
|
+
export type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
|
12
|
+
__error?: {
|
13
|
+
type: TError;
|
14
|
+
};
|
15
|
+
};
|
16
|
+
export interface Client<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
17
|
+
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
18
|
+
}
|
19
|
+
export type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
|
20
|
+
[k: string]: NestedClient<TClientContext>;
|
21
|
+
};
|
22
|
+
export type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
23
|
+
export type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
|
24
|
+
context: TClientContext;
|
25
|
+
};
|
26
|
+
export interface ClientLink<TClientContext extends ClientContext> {
|
27
|
+
call: (path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>) => Promise<unknown>;
|
28
|
+
}
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { ORPCError } from './error';
|
2
|
+
import type { ClientPromiseResult } from './types';
|
3
|
+
export type SafeResult<TOutput, TError extends Error> = [output: TOutput, error: undefined, isDefinedError: false] | [output: undefined, error: TError, isDefinedError: false] | [output: undefined, error: Extract<TError, ORPCError<any, any>>, isDefinedError: true];
|
4
|
+
export declare function safe<TOutput, TError extends Error>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
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.
|
4
|
+
"version": "0.0.0-next.d5f0415",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -19,6 +19,21 @@
|
|
19
19
|
"import": "./dist/index.js",
|
20
20
|
"default": "./dist/index.js"
|
21
21
|
},
|
22
|
+
"./openapi": {
|
23
|
+
"types": "./dist/src/openapi/index.d.ts",
|
24
|
+
"import": "./dist/openapi.js",
|
25
|
+
"default": "./dist/openapi.js"
|
26
|
+
},
|
27
|
+
"./rpc": {
|
28
|
+
"types": "./dist/src/rpc/index.d.ts",
|
29
|
+
"import": "./dist/rpc.js",
|
30
|
+
"default": "./dist/rpc.js"
|
31
|
+
},
|
32
|
+
"./fetch": {
|
33
|
+
"types": "./dist/src/adapters/fetch/index.d.ts",
|
34
|
+
"import": "./dist/fetch.js",
|
35
|
+
"default": "./dist/fetch.js"
|
36
|
+
},
|
22
37
|
"./🔒/*": {
|
23
38
|
"types": "./dist/src/*.d.ts"
|
24
39
|
}
|
@@ -28,20 +43,16 @@
|
|
28
43
|
"!**/*.tsbuildinfo",
|
29
44
|
"dist"
|
30
45
|
],
|
31
|
-
"peerDependencies": {
|
32
|
-
"@orpc/server": "0.0.0-next.d137cdf",
|
33
|
-
"@orpc/contract": "0.0.0-next.d137cdf"
|
34
|
-
},
|
35
46
|
"dependencies": {
|
36
|
-
"@orpc/
|
37
|
-
"@orpc/
|
47
|
+
"@orpc/server-standard": "^0.4.0",
|
48
|
+
"@orpc/server-standard-fetch": "^0.4.0",
|
49
|
+
"@orpc/shared": "0.0.0-next.d5f0415"
|
38
50
|
},
|
39
51
|
"devDependencies": {
|
40
|
-
"zod": "^3.
|
41
|
-
"@orpc/openapi": "0.0.0-next.d137cdf"
|
52
|
+
"zod": "^3.24.1"
|
42
53
|
},
|
43
54
|
"scripts": {
|
44
|
-
"build": "tsup --
|
55
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
45
56
|
"build:watch": "pnpm run build --watch",
|
46
57
|
"type:check": "tsc -b"
|
47
58
|
}
|
package/dist/src/procedure.d.ts
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
import type { Promisable } from '@orpc/shared';
|
2
|
-
import { type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
|
3
|
-
export interface ProcedureClient<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> {
|
4
|
-
(input: SchemaInput<TInputSchema>): Promise<SchemaOutput<TOutputSchema, TFuncOutput>>;
|
5
|
-
}
|
6
|
-
export interface CreateProcedureClientOptions {
|
7
|
-
/**
|
8
|
-
* The base url of the server.
|
9
|
-
*/
|
10
|
-
baseURL: string;
|
11
|
-
/**
|
12
|
-
* The fetch function used to make the request.
|
13
|
-
* @default global fetch
|
14
|
-
*/
|
15
|
-
fetch?: typeof fetch;
|
16
|
-
/**
|
17
|
-
* The headers used to make the request.
|
18
|
-
* Invoked before the request is made.
|
19
|
-
*/
|
20
|
-
headers?: (input: unknown) => Promisable<Headers | Record<string, string>>;
|
21
|
-
/**
|
22
|
-
* The path of the procedure on server.
|
23
|
-
*/
|
24
|
-
path: string[];
|
25
|
-
}
|
26
|
-
export declare function createProcedureClient<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>>(options: CreateProcedureClientOptions): ProcedureClient<TInputSchema, TOutputSchema, TFuncOutput>;
|
27
|
-
//# sourceMappingURL=procedure.d.ts.map
|
package/dist/src/router.d.ts
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Lazy, Procedure, Router } from '@orpc/server';
|
3
|
-
import type { Promisable } from '@orpc/shared';
|
4
|
-
import { type ProcedureClient } from './procedure';
|
5
|
-
export type RouterClientWithContractRouter<TRouter extends ContractRouter> = {
|
6
|
-
[K in keyof TRouter]: TRouter[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureClient<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>> : TRouter[K] extends ContractRouter ? RouterClientWithContractRouter<TRouter[K]> : never;
|
7
|
-
};
|
8
|
-
export type RouterClientWithRouter<TRouter extends Router<any>> = {
|
9
|
-
[K in keyof TRouter]: TRouter[K] extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> | Lazy<Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput>> ? ProcedureClient<UInputSchema, UOutputSchema, UFuncOutput> : TRouter[K] extends Router<any> ? RouterClientWithRouter<TRouter[K]> : never;
|
10
|
-
};
|
11
|
-
export interface CreateRouterClientOptions {
|
12
|
-
/**
|
13
|
-
* The base url of the server.
|
14
|
-
*/
|
15
|
-
baseURL: string;
|
16
|
-
/**
|
17
|
-
* The fetch function used to make the request.
|
18
|
-
* @default global fetch
|
19
|
-
*/
|
20
|
-
fetch?: typeof fetch;
|
21
|
-
/**
|
22
|
-
* The headers used to make the request.
|
23
|
-
* Invoked before the request is made.
|
24
|
-
*/
|
25
|
-
headers?: (input: unknown) => Promisable<Headers | Record<string, string>>;
|
26
|
-
/**
|
27
|
-
* This used for internal purpose only.
|
28
|
-
*
|
29
|
-
* @internal
|
30
|
-
*/
|
31
|
-
path?: string[];
|
32
|
-
}
|
33
|
-
export declare function createRouterClient<TRouter extends Router<any> | ContractRouter>(options: CreateRouterClientOptions): TRouter extends Router<any> ? RouterClientWithRouter<TRouter> : TRouter extends ContractRouter ? RouterClientWithContractRouter<TRouter> : never;
|
34
|
-
//# sourceMappingURL=router.d.ts.map
|