@orpc/client 0.0.0-next.b15d206 → 0.0.0-next.b4e6d3a

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/dist/fetch.js ADDED
@@ -0,0 +1,111 @@
1
+ // src/adapters/fetch/orpc-link.ts
2
+ import { ORPCError } from "@orpc/contract";
3
+ import { fetchReToStandardBody } from "@orpc/server/fetch";
4
+ import { RPCSerializer } from "@orpc/server/standard";
5
+ import { isObject, trim } from "@orpc/shared";
6
+ import { contentDisposition } from "@tinyhttp/content-disposition";
7
+ var RPCLink = class {
8
+ fetch;
9
+ rpcSerializer;
10
+ maxURLLength;
11
+ fallbackMethod;
12
+ getMethod;
13
+ getHeaders;
14
+ url;
15
+ constructor(options) {
16
+ this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
17
+ this.rpcSerializer = options.rpcSerializer ?? new RPCSerializer();
18
+ this.maxURLLength = options.maxURLLength ?? 2083;
19
+ this.fallbackMethod = options.fallbackMethod ?? "POST";
20
+ this.url = options.url;
21
+ this.getMethod = async (path, input, context) => {
22
+ return await options.method?.(path, input, context) ?? this.fallbackMethod;
23
+ };
24
+ this.getHeaders = async (path, input, context) => {
25
+ return new Headers(await options.headers?.(path, input, context));
26
+ };
27
+ }
28
+ async call(path, input, options) {
29
+ const clientContext = options.context ?? {};
30
+ const encoded = await this.encode(path, input, options);
31
+ if (encoded.body instanceof Blob && !encoded.headers.has("content-disposition")) {
32
+ encoded.headers.set("content-disposition", contentDisposition(encoded.body instanceof File ? encoded.body.name : "blob"));
33
+ }
34
+ const response = await this.fetch(encoded.url, {
35
+ method: encoded.method,
36
+ headers: encoded.headers,
37
+ body: encoded.body,
38
+ signal: options.signal
39
+ }, clientContext);
40
+ const body = await fetchReToStandardBody(response);
41
+ const deserialized = (() => {
42
+ try {
43
+ return this.rpcSerializer.deserialize(body);
44
+ } catch (error) {
45
+ if (response.ok) {
46
+ throw new ORPCError("INTERNAL_SERVER_ERROR", {
47
+ message: "Invalid RPC response",
48
+ cause: error
49
+ });
50
+ }
51
+ throw new ORPCError(response.status.toString(), {
52
+ message: response.statusText
53
+ });
54
+ }
55
+ })();
56
+ if (response.ok) {
57
+ return deserialized;
58
+ }
59
+ throw ORPCError.fromJSON(deserialized);
60
+ }
61
+ async encode(path, input, options) {
62
+ const clientContext = options.context;
63
+ const expectMethod = await this.getMethod(path, input, clientContext);
64
+ const headers = await this.getHeaders(path, input, clientContext);
65
+ const url = new URL(`${trim(this.url, "/")}/${path.map(encodeURIComponent).join("/")}`);
66
+ headers.append("x-orpc-handler", "rpc");
67
+ const serialized = this.rpcSerializer.serialize(input);
68
+ if (expectMethod === "GET" && isObject(serialized)) {
69
+ const tryURL = new URL(url);
70
+ tryURL.searchParams.append("data", JSON.stringify(serialized));
71
+ if (tryURL.toString().length <= this.maxURLLength) {
72
+ return {
73
+ body: void 0,
74
+ method: expectMethod,
75
+ headers,
76
+ url: tryURL
77
+ };
78
+ }
79
+ }
80
+ const method = expectMethod === "GET" ? this.fallbackMethod : expectMethod;
81
+ if (input === void 0) {
82
+ return {
83
+ body: void 0,
84
+ method,
85
+ headers,
86
+ url
87
+ };
88
+ }
89
+ if (isObject(serialized)) {
90
+ if (!headers.has("content-type")) {
91
+ headers.set("content-type", "application/json");
92
+ }
93
+ return {
94
+ body: JSON.stringify(serialized),
95
+ method,
96
+ headers,
97
+ url
98
+ };
99
+ }
100
+ return {
101
+ body: serialized,
102
+ method,
103
+ headers,
104
+ url
105
+ };
106
+ }
107
+ };
108
+ export {
109
+ RPCLink
110
+ };
111
+ //# sourceMappingURL=fetch.js.map
package/dist/index.js CHANGED
@@ -1,83 +1,43 @@
1
- // src/procedure.ts
2
- import {
3
- ORPC_HEADER,
4
- ORPC_HEADER_VALUE
5
- } from "@orpc/contract";
6
- import { trim } from "@orpc/shared";
7
- import { ORPCError } from "@orpc/shared/error";
8
- import { ORPCDeserializer, ORPCSerializer } from "@orpc/transformer";
9
- function createProcedureClient(options) {
10
- const serializer = new ORPCSerializer();
11
- const deserializer = new ORPCDeserializer();
12
- const client = async (input) => {
13
- const fetch_ = options.fetch ?? fetch;
14
- const url = `${trim(options.baseURL, "/")}/${options.path.map(encodeURIComponent).join("/")}`;
15
- let headers = await options.headers?.(input);
16
- headers = headers instanceof Headers ? headers : new Headers(headers);
17
- const { body, headers: headers_ } = serializer.serialize(input);
18
- for (const [key, value] of headers_.entries()) {
19
- headers.set(key, value);
20
- }
21
- headers.set(ORPC_HEADER, ORPC_HEADER_VALUE);
22
- const response = await fetch_(url, {
23
- method: "POST",
24
- headers,
25
- body
26
- });
27
- const json = await (async () => {
28
- try {
29
- return await deserializer.deserialize(response);
30
- } catch (e) {
31
- throw new ORPCError({
32
- code: "INTERNAL_SERVER_ERROR",
33
- message: "Cannot parse response.",
34
- cause: e
35
- });
1
+ // src/client.ts
2
+ function createORPCClient(link, options) {
3
+ const path = options?.path ?? [];
4
+ const procedureClient = async (...[input, options2]) => {
5
+ return await link.call(path, input, options2 ?? {});
6
+ };
7
+ const recursive = new Proxy(procedureClient, {
8
+ get(target, key) {
9
+ if (typeof key !== "string") {
10
+ return Reflect.get(target, key);
36
11
  }
37
- })();
38
- if (!response.ok) {
39
- throw ORPCError.fromJSON(json) ?? new ORPCError({
40
- status: response.status,
41
- code: "INTERNAL_SERVER_ERROR",
42
- message: "Internal server error"
12
+ return createORPCClient(link, {
13
+ ...options,
14
+ path: [...path, key]
43
15
  });
44
16
  }
45
- return json;
46
- };
47
- return client;
17
+ });
18
+ return recursive;
48
19
  }
49
20
 
50
- // src/router.ts
51
- function createRouterClient(options) {
52
- const path = options?.path ?? [];
53
- const client = new Proxy(
54
- createProcedureClient({
55
- baseURL: options.baseURL,
56
- fetch: options.fetch,
57
- headers: options.headers,
58
- path
59
- }),
60
- {
61
- get(target, key) {
62
- if (typeof key !== "string") {
63
- return Reflect.get(target, key);
64
- }
65
- return createRouterClient({
66
- ...options,
67
- path: [...path, key]
68
- });
69
- }
70
- }
71
- );
72
- return client;
73
- }
21
+ // src/dynamic-link.ts
22
+ var DynamicLink = class {
23
+ constructor(linkResolver) {
24
+ this.linkResolver = linkResolver;
25
+ }
26
+ async call(path, input, options) {
27
+ const clientContext = options.context ?? {};
28
+ const resolvedLink = await this.linkResolver(path, input, clientContext);
29
+ const output = await resolvedLink.call(path, input, { ...options, context: clientContext });
30
+ return output;
31
+ }
32
+ };
74
33
 
75
34
  // src/index.ts
76
- export * from "@orpc/shared/error";
77
- var createORPCClient = createRouterClient;
35
+ import { isDefinedError, ORPCError, safe } from "@orpc/contract";
78
36
  export {
37
+ DynamicLink,
38
+ ORPCError,
79
39
  createORPCClient,
80
- createProcedureClient,
81
- createRouterClient
40
+ isDefinedError,
41
+ safe
82
42
  };
83
43
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export * from './orpc-link';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,46 @@
1
+ import type { ClientContext, ClientOptions, HTTPMethod } from '@orpc/contract';
2
+ import type { Promisable } from '@orpc/shared';
3
+ import type { ClientLink } from '../../types';
4
+ import type { FetchWithContext } from './types';
5
+ import { RPCSerializer } from '@orpc/server/standard';
6
+ export interface RPCLinkOptions<TClientContext extends ClientContext> {
7
+ /**
8
+ * Base url for all requests.
9
+ */
10
+ url: string;
11
+ /**
12
+ * The maximum length of the URL.
13
+ *
14
+ * @default 2083
15
+ */
16
+ maxURLLength?: number;
17
+ /**
18
+ * The method used to make the request.
19
+ *
20
+ * @default 'POST'
21
+ */
22
+ method?(path: readonly string[], input: unknown, context: TClientContext): Promisable<HTTPMethod | undefined>;
23
+ /**
24
+ * The method to use when the payload cannot safely pass to the server with method return from method function.
25
+ * GET is not allowed, it's very dangerous.
26
+ *
27
+ * @default 'POST'
28
+ */
29
+ fallbackMethod?: Exclude<HTTPMethod, 'GET'>;
30
+ headers?(path: readonly string[], input: unknown, context: TClientContext): Promisable<Headers | Record<string, string>>;
31
+ fetch?: FetchWithContext<TClientContext>;
32
+ rpcSerializer?: RPCSerializer;
33
+ }
34
+ export declare class RPCLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
35
+ private readonly fetch;
36
+ private readonly rpcSerializer;
37
+ private readonly maxURLLength;
38
+ private readonly fallbackMethod;
39
+ private readonly getMethod;
40
+ private readonly getHeaders;
41
+ private readonly url;
42
+ constructor(options: RPCLinkOptions<TClientContext>);
43
+ call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
44
+ private encode;
45
+ }
46
+ //# sourceMappingURL=orpc-link.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { ClientContext } from '@orpc/contract';
2
+ export interface FetchWithContext<TClientContext extends ClientContext> {
3
+ (url: Request | string | URL, init: RequestInit | undefined, context: TClientContext): Promise<Response>;
4
+ }
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,13 @@
1
+ import type { ClientContext, ClientOptions } from '@orpc/contract';
2
+ import type { Promisable } from '@orpc/shared';
3
+ import type { ClientLink } 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: (path: readonly string[], input: unknown, context: TClientContext) => Promisable<ClientLink<TClientContext>>);
11
+ call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
12
+ }
13
+ //# sourceMappingURL=dynamic-link.d.ts.map
@@ -1,7 +1,6 @@
1
1
  /** unnoq */
2
- import { createRouterClient } from './router';
3
- export * from './procedure';
4
- export * from './router';
5
- export * from '@orpc/shared/error';
6
- export declare const createORPCClient: typeof createRouterClient;
2
+ export * from './client';
3
+ export * from './dynamic-link';
4
+ export * from './types';
5
+ export { isDefinedError, ORPCError, safe } from '@orpc/contract';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { ClientContext, ClientOptions } from '@orpc/contract';
2
+ export interface ClientLink<TClientContext extends ClientContext> {
3
+ call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
4
+ }
5
+ //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,21 +1,17 @@
1
1
  {
2
2
  "name": "@orpc/client",
3
3
  "type": "module",
4
- "version": "0.0.0-next.b15d206",
5
- "author": {
6
- "name": "unnoq",
7
- "email": "contact@unnoq.com",
8
- "url": "https://unnoq.com"
9
- },
4
+ "version": "0.0.0-next.b4e6d3a",
10
5
  "license": "MIT",
11
- "homepage": "https://github.com/unnoq/orpc",
6
+ "homepage": "https://orpc.unnoq.com",
12
7
  "repository": {
13
8
  "type": "git",
14
- "url": "https://github.com/unnoq/orpc.git",
9
+ "url": "git+https://github.com/unnoq/orpc.git",
15
10
  "directory": "packages/client"
16
11
  },
17
12
  "keywords": [
18
- "unnoq"
13
+ "unnoq",
14
+ "orpc"
19
15
  ],
20
16
  "exports": {
21
17
  ".": {
@@ -23,27 +19,32 @@
23
19
  "import": "./dist/index.js",
24
20
  "default": "./dist/index.js"
25
21
  },
22
+ "./fetch": {
23
+ "types": "./dist/src/adapters/fetch/index.d.ts",
24
+ "import": "./dist/fetch.js",
25
+ "default": "./dist/fetch.js"
26
+ },
26
27
  "./🔒/*": {
27
28
  "types": "./dist/src/*.d.ts"
28
29
  }
29
30
  },
30
31
  "files": [
31
- "dist",
32
- "src"
32
+ "!**/*.map",
33
+ "!**/*.tsbuildinfo",
34
+ "dist"
33
35
  ],
34
- "peerDependencies": {
35
- "@orpc/contract": "0.0.0-next.b15d206",
36
- "@orpc/server": "0.0.0-next.b15d206"
37
- },
38
36
  "dependencies": {
39
- "@orpc/transformer": "0.0.0-next.b15d206",
40
- "@orpc/shared": "0.0.0-next.b15d206"
37
+ "@tinyhttp/content-disposition": "^2.2.2",
38
+ "@orpc/contract": "0.0.0-next.b4e6d3a",
39
+ "@orpc/server": "0.0.0-next.b4e6d3a",
40
+ "@orpc/shared": "0.0.0-next.b4e6d3a"
41
41
  },
42
42
  "devDependencies": {
43
- "zod": "^3.23.8"
43
+ "zod": "^3.24.1",
44
+ "@orpc/openapi": "0.0.0-next.b4e6d3a"
44
45
  },
45
46
  "scripts": {
46
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
47
+ "build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.fetch=src/adapters/fetch/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
47
48
  "build:watch": "pnpm run build --watch",
48
49
  "type:check": "tsc -b"
49
50
  }
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/procedure.ts","../src/router.ts","../src/index.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n/// <reference lib=\"dom.iterable\" />\n\nimport type { Promisable } from '@orpc/shared'\nimport {\n ORPC_HEADER,\n ORPC_HEADER_VALUE,\n type Schema,\n type SchemaInput,\n type SchemaOutput,\n} from '@orpc/contract'\nimport { trim } from '@orpc/shared'\nimport { ORPCError } from '@orpc/shared/error'\nimport { ORPCDeserializer, ORPCSerializer } from '@orpc/transformer'\n\nexport interface ProcedureClient<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n TFuncOutput extends SchemaOutput<TOutputSchema>,\n> {\n (\n input: SchemaInput<TInputSchema>,\n ): Promise<SchemaOutput<TOutputSchema, TFuncOutput>>\n}\n\nexport interface CreateProcedureClientOptions {\n /**\n * The base url of the server.\n */\n baseURL: string\n\n /**\n * The fetch function used to make the request.\n * @default global fetch\n */\n fetch?: typeof fetch\n\n /**\n * The headers used to make the request.\n * Invoked before the request is made.\n */\n headers?: (input: unknown) => Promisable<Headers | Record<string, string>>\n\n /**\n * The path of the procedure on server.\n */\n path: string[]\n}\n\nexport function createProcedureClient<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n TFuncOutput extends SchemaOutput<TOutputSchema>,\n>(\n options: CreateProcedureClientOptions,\n): ProcedureClient<TInputSchema, TOutputSchema, TFuncOutput> {\n const serializer = new ORPCSerializer()\n const deserializer = new ORPCDeserializer()\n\n const client = async (input: unknown): Promise<unknown> => {\n const fetch_ = options.fetch ?? fetch\n const url = `${trim(options.baseURL, '/')}/${options.path.map(encodeURIComponent).join('/')}`\n let headers = await options.headers?.(input)\n headers = headers instanceof Headers ? headers : new Headers(headers)\n\n const { body, headers: headers_ } = serializer.serialize(input)\n\n for (const [key, value] of headers_.entries()) {\n headers.set(key, value)\n }\n\n headers.set(ORPC_HEADER, ORPC_HEADER_VALUE)\n\n const response = await fetch_(url, {\n method: 'POST',\n headers,\n body,\n })\n\n const json = await (async () => {\n try {\n return await deserializer.deserialize(response)\n }\n catch (e) {\n throw new ORPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Cannot parse response.',\n cause: e,\n })\n }\n })()\n\n if (!response.ok) {\n throw (\n ORPCError.fromJSON(json)\n ?? new ORPCError({\n status: response.status,\n code: 'INTERNAL_SERVER_ERROR',\n message: 'Internal server error',\n })\n )\n }\n\n return json\n }\n\n return client as any\n}\n","/// <reference lib=\"dom\" />\n\nimport type {\n ContractProcedure,\n ContractRouter,\n SchemaOutput,\n} from '@orpc/contract'\nimport type { Procedure, Router } from '@orpc/server'\nimport type { Promisable } from '@orpc/shared'\nimport { createProcedureClient, type ProcedureClient } from './procedure'\n\nexport type RouterClientWithContractRouter<TRouter extends ContractRouter> = {\n [K in keyof TRouter]: TRouter[K] extends ContractProcedure<\n infer UInputSchema,\n infer UOutputSchema\n >\n ? ProcedureClient<UInputSchema, UOutputSchema, SchemaOutput<UOutputSchema>>\n : TRouter[K] extends ContractRouter\n ? RouterClientWithContractRouter<TRouter[K]>\n : never\n}\n\nexport type RouterClientWithRouter<TRouter extends Router<any>> = {\n [K in keyof TRouter]: TRouter[K] extends Procedure<\n any,\n any,\n infer UInputSchema,\n infer UOutputSchema,\n infer UFuncOutput\n >\n ? ProcedureClient<UInputSchema, UOutputSchema, UFuncOutput>\n : TRouter[K] extends Router<any>\n ? RouterClientWithRouter<TRouter[K]>\n : never\n}\n\nexport interface CreateRouterClientOptions {\n /**\n * The base url of the server.\n */\n baseURL: string\n\n /**\n * The fetch function used to make the request.\n * @default global fetch\n */\n fetch?: typeof fetch\n\n /**\n * The headers used to make the request.\n * Invoked before the request is made.\n */\n headers?: (input: unknown) => Promisable<Headers | Record<string, string>>\n\n /**\n * This used for internal purpose only.\n *\n * @internal\n */\n path?: string[]\n}\n\nexport function createRouterClient<\n TRouter extends Router<any> | ContractRouter,\n>(\n options: CreateRouterClientOptions,\n): TRouter extends Router<any>\n ? RouterClientWithRouter<TRouter>\n : TRouter extends ContractRouter\n ? RouterClientWithContractRouter<TRouter>\n : never {\n const path = options?.path ?? []\n\n const client = new Proxy(\n createProcedureClient({\n baseURL: options.baseURL,\n fetch: options.fetch,\n headers: options.headers,\n path,\n }),\n {\n get(target, key) {\n if (typeof key !== 'string') {\n return Reflect.get(target, key)\n }\n\n return createRouterClient({\n ...options,\n path: [...path, key],\n })\n },\n },\n )\n\n return client as any\n}\n","/** unnoq */\n\nimport { createRouterClient } from './router'\n\nexport * from './procedure'\nexport * from './router'\nexport * from '@orpc/shared/error'\n\nexport const createORPCClient = create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AKY;AACZ,QAAM,OAAO,SAAS,QAAQ,CAAC;AAE/B,QAAM,SAAS,IAAI;AAAA,IACjB,sBAAsB;AAAA,MACpB,SAAS,QAAQ;AAAA,MACjB,OAAO,QAAQ;AAAA,MACf,SAAS,QAAQ;AAAA,MACjB;AAAA,IACF,CAAC;AAAA,IACD;AAAA,MACE,IAAI,QAAQ,KAAK;AACf,YAAI,OAAO,QAAQ,UAAU;AAC3B,iBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,QAChC;AAEA,eAAO,mBAAmB;AAAA,UACxB,GAAG;AAAA,UACH,MAAM,CAAC,GAAG,MAAM,GAAG;AAAA,QACrB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;;;ACzFA,cAAc;AAEP,IAAM,mBAAmB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAE7C,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAElC,eAAO,MAAM,gBAAgB,2BAAqB,CAAA"}
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/procedure.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAKvB,MAAM,WAAW,eAAe,CAC9B,YAAY,SAAS,MAAM,EAC3B,aAAa,SAAS,MAAM,EAC5B,WAAW,SAAS,YAAY,CAAC,aAAa,CAAC;IAE/C,CACE,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,GAC/B,OAAO,CAAC,YAAY,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;CACrD;AAED,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAE1E;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED,wBAAgB,qBAAqB,CACnC,YAAY,SAAS,MAAM,EAC3B,aAAa,SAAS,MAAM,EAC5B,WAAW,SAAS,YAAY,CAAC,aAAa,CAAC,EAE/C,OAAO,EAAE,4BAA4B,GACpC,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,CAoD3D"}
@@ -1,34 +0,0 @@
1
- import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
2
- import type { 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> ? 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
@@ -1 +0,0 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,YAAY,EACb,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrD,OA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