@orpc/client 0.37.0 → 0.38.0
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
CHANGED
@@ -26,7 +26,7 @@ var RPCLink = class {
|
|
26
26
|
};
|
27
27
|
}
|
28
28
|
async call(path, input, options) {
|
29
|
-
const clientContext = options.context;
|
29
|
+
const clientContext = options.context ?? {};
|
30
30
|
const encoded = await this.encode(path, input, options);
|
31
31
|
if (encoded.body instanceof Blob && !encoded.headers.has("content-disposition")) {
|
32
32
|
encoded.headers.set("content-disposition", contentDisposition(encoded.body instanceof File ? encoded.body.name : "blob"));
|
package/dist/index.js
CHANGED
@@ -24,8 +24,9 @@ var DynamicLink = class {
|
|
24
24
|
this.linkResolver = linkResolver;
|
25
25
|
}
|
26
26
|
async call(path, input, options) {
|
27
|
-
const
|
28
|
-
const
|
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 });
|
29
30
|
return output;
|
30
31
|
}
|
31
32
|
};
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import type { ClientOptions, HTTPMethod } from '@orpc/contract';
|
1
|
+
import type { ClientContext, ClientOptions, HTTPMethod } from '@orpc/contract';
|
2
2
|
import type { Promisable } from '@orpc/shared';
|
3
3
|
import type { ClientLink } from '../../types';
|
4
4
|
import type { FetchWithContext } from './types';
|
5
5
|
import { RPCSerializer } from '@orpc/server/standard';
|
6
|
-
export interface RPCLinkOptions<TClientContext> {
|
6
|
+
export interface RPCLinkOptions<TClientContext extends ClientContext> {
|
7
7
|
/**
|
8
8
|
* Base url for all requests.
|
9
9
|
*/
|
@@ -31,7 +31,7 @@ export interface RPCLinkOptions<TClientContext> {
|
|
31
31
|
fetch?: FetchWithContext<TClientContext>;
|
32
32
|
rpcSerializer?: RPCSerializer;
|
33
33
|
}
|
34
|
-
export declare class RPCLink<TClientContext> implements ClientLink<TClientContext> {
|
34
|
+
export declare class RPCLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
35
35
|
private readonly fetch;
|
36
36
|
private readonly rpcSerializer;
|
37
37
|
private readonly maxURLLength;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
import type { ClientContext } from '@orpc/contract';
|
2
|
+
export interface FetchWithContext<TClientContext extends ClientContext> {
|
2
3
|
(url: Request | string | URL, init: RequestInit | undefined, context: TClientContext): Promise<Response>;
|
3
4
|
}
|
4
5
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/client.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { AnyContractRouter, ContractRouterClient } from '@orpc/contract';
|
1
|
+
import type { AnyContractRouter, ClientContext, ContractRouterClient } from '@orpc/contract';
|
2
2
|
import type { AnyRouter, RouterClient } from '@orpc/server';
|
3
3
|
import type { ClientLink } from './types';
|
4
4
|
export interface createORPCClientOptions {
|
@@ -7,5 +7,5 @@ export interface createORPCClientOptions {
|
|
7
7
|
*/
|
8
8
|
path?: string[];
|
9
9
|
}
|
10
|
-
export declare function createORPCClient<TRouter extends AnyRouter | AnyContractRouter, TClientContext =
|
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
11
|
//# sourceMappingURL=client.d.ts.map
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import type { ClientOptions } from '@orpc/contract';
|
1
|
+
import type { ClientContext, ClientOptions } from '@orpc/contract';
|
2
2
|
import type { Promisable } from '@orpc/shared';
|
3
3
|
import type { ClientLink } from './types';
|
4
4
|
/**
|
5
5
|
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
6
6
|
* based on the request path, input, and context.
|
7
7
|
*/
|
8
|
-
export declare class DynamicLink<TClientContext> implements ClientLink<TClientContext> {
|
8
|
+
export declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
9
9
|
private readonly linkResolver;
|
10
10
|
constructor(linkResolver: (path: readonly string[], input: unknown, context: TClientContext) => Promisable<ClientLink<TClientContext>>);
|
11
11
|
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
package/dist/src/types.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { ClientOptions } from '@orpc/contract';
|
2
|
-
export interface ClientLink<TClientContext> {
|
1
|
+
import type { ClientContext, ClientOptions } from '@orpc/contract';
|
2
|
+
export interface ClientLink<TClientContext extends ClientContext> {
|
3
3
|
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
4
4
|
}
|
5
5
|
//# sourceMappingURL=types.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.
|
4
|
+
"version": "0.38.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -35,13 +35,13 @@
|
|
35
35
|
],
|
36
36
|
"dependencies": {
|
37
37
|
"@tinyhttp/content-disposition": "^2.2.2",
|
38
|
-
"@orpc/contract": "0.
|
39
|
-
"@orpc/shared": "0.
|
40
|
-
"@orpc/server": "0.
|
38
|
+
"@orpc/contract": "0.38.0",
|
39
|
+
"@orpc/shared": "0.38.0",
|
40
|
+
"@orpc/server": "0.38.0"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
43
|
"zod": "^3.24.1",
|
44
|
-
"@orpc/openapi": "0.
|
44
|
+
"@orpc/openapi": "0.38.0"
|
45
45
|
},
|
46
46
|
"scripts": {
|
47
47
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.fetch=src/adapters/fetch/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|