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

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
@@ -2,8 +2,8 @@
2
2
  import { ORPCError } from "@orpc/contract";
3
3
  import { fetchReToStandardBody } from "@orpc/server/fetch";
4
4
  import { RPCSerializer } from "@orpc/server/standard";
5
- import { isObject, trim } from "@orpc/shared";
6
- import { contentDisposition } from "@tinyhttp/content-disposition";
5
+ import { isPlainObject, trim } from "@orpc/shared";
6
+ import cd from "content-disposition";
7
7
  var RPCLink = class {
8
8
  fetch;
9
9
  rpcSerializer;
@@ -26,10 +26,10 @@ 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
- encoded.headers.set("content-disposition", contentDisposition(encoded.body instanceof File ? encoded.body.name : "blob"));
32
+ encoded.headers.set("content-disposition", cd(encoded.body instanceof File ? encoded.body.name : "blob"));
33
33
  }
34
34
  const response = await this.fetch(encoded.url, {
35
35
  method: encoded.method,
@@ -65,7 +65,7 @@ var RPCLink = class {
65
65
  const url = new URL(`${trim(this.url, "/")}/${path.map(encodeURIComponent).join("/")}`);
66
66
  headers.append("x-orpc-handler", "rpc");
67
67
  const serialized = this.rpcSerializer.serialize(input);
68
- if (expectMethod === "GET" && isObject(serialized)) {
68
+ if (expectMethod === "GET" && isPlainObject(serialized)) {
69
69
  const tryURL = new URL(url);
70
70
  tryURL.searchParams.append("data", JSON.stringify(serialized));
71
71
  if (tryURL.toString().length <= this.maxURLLength) {
@@ -78,15 +78,7 @@ var RPCLink = class {
78
78
  }
79
79
  }
80
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)) {
81
+ if (isPlainObject(serialized)) {
90
82
  if (!headers.has("content-type")) {
91
83
  headers.set("content-type", "application/json");
92
84
  }
package/dist/index.js CHANGED
@@ -24,9 +24,8 @@ var DynamicLink = class {
24
24
  this.linkResolver = linkResolver;
25
25
  }
26
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 });
27
+ const resolvedLink = await this.linkResolver(path, input, options.context);
28
+ const output = await resolvedLink.call(path, input, options);
30
29
  return output;
31
30
  }
32
31
  };
@@ -1,9 +1,9 @@
1
- import type { ClientContext, ClientOptions, HTTPMethod } from '@orpc/contract';
1
+ import type { 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 extends ClientContext> {
6
+ export interface RPCLinkOptions<TClientContext> {
7
7
  /**
8
8
  * Base url for all requests.
9
9
  */
@@ -31,7 +31,7 @@ export interface RPCLinkOptions<TClientContext extends ClientContext> {
31
31
  fetch?: FetchWithContext<TClientContext>;
32
32
  rpcSerializer?: RPCSerializer;
33
33
  }
34
- export declare class RPCLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
34
+ export declare class RPCLink<TClientContext> implements ClientLink<TClientContext> {
35
35
  private readonly fetch;
36
36
  private readonly rpcSerializer;
37
37
  private readonly maxURLLength;
@@ -1,5 +1,4 @@
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>;
1
+ export interface FetchWithContext<TClientContext> {
2
+ (input: RequestInfo | URL, init: RequestInit | undefined, context: TClientContext): Promise<Response>;
4
3
  }
5
4
  //# sourceMappingURL=types.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { AnyContractRouter, ClientContext, ContractRouterClient } from '@orpc/contract';
1
+ import type { AnyContractRouter, 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 extends ClientContext = Record<never, never>>(link: ClientLink<TClientContext>, options?: createORPCClientOptions): TRouter extends AnyRouter ? RouterClient<TRouter, TClientContext> : TRouter extends AnyContractRouter ? ContractRouterClient<TRouter, TClientContext> : never;
10
+ export declare function createORPCClient<TRouter extends AnyRouter | AnyContractRouter, TClientContext = unknown>(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 { ClientContext, ClientOptions } from '@orpc/contract';
1
+ import type { 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 extends ClientContext> implements ClientLink<TClientContext> {
8
+ export declare class DynamicLink<TClientContext> 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>;
@@ -1,5 +1,5 @@
1
- import type { ClientContext, ClientOptions } from '@orpc/contract';
2
- export interface ClientLink<TClientContext extends ClientContext> {
1
+ import type { ClientOptions } from '@orpc/contract';
2
+ export interface ClientLink<TClientContext> {
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.0.0-next.b4e6d3a",
4
+ "version": "0.0.0-next.b825e0c",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -34,14 +34,14 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
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"
37
+ "content-disposition": "^0.5.4",
38
+ "@orpc/contract": "0.0.0-next.b825e0c",
39
+ "@orpc/server": "0.0.0-next.b825e0c",
40
+ "@orpc/shared": "0.0.0-next.b825e0c"
41
41
  },
42
42
  "devDependencies": {
43
43
  "zod": "^3.24.1",
44
- "@orpc/openapi": "0.0.0-next.b4e6d3a"
44
+ "@orpc/openapi": "0.0.0-next.b825e0c"
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'",