@orpc/client 0.0.0-next.8f9385e → 0.0.0-next.a895960

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/index.js CHANGED
@@ -9,7 +9,8 @@ import { ORPCDeserializer, ORPCSerializer } from "@orpc/transformer";
9
9
  function createProcedureClient(options) {
10
10
  const serializer = new ORPCSerializer();
11
11
  const deserializer = new ORPCDeserializer();
12
- const client = async (input) => {
12
+ const client = async (...args) => {
13
+ const [input, callerOptions] = args;
13
14
  const fetch_ = options.fetch ?? fetch;
14
15
  const url = `${trim(options.baseURL, "/")}/${options.path.map(encodeURIComponent).join("/")}`;
15
16
  let headers = await options.headers?.(input);
@@ -22,7 +23,8 @@ function createProcedureClient(options) {
22
23
  const response = await fetch_(url, {
23
24
  method: "POST",
24
25
  headers,
25
- body
26
+ body,
27
+ signal: callerOptions?.signal
26
28
  });
27
29
  const json = await (async () => {
28
30
  try {
@@ -1,8 +1,7 @@
1
+ import type { Caller } from '@orpc/server';
1
2
  import type { Promisable } from '@orpc/shared';
2
3
  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
- }
4
+ export type ProcedureClient<TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> = Caller<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, TFuncOutput>>;
6
5
  export interface CreateProcedureClientOptions {
7
6
  /**
8
7
  * The base url of the server.
@@ -1,12 +1,12 @@
1
1
  import type { ContractProcedure, ContractRouter, SchemaOutput } from '@orpc/contract';
2
- import type { Procedure, Router } from '@orpc/server';
2
+ import type { Lazy, Procedure, Router } from '@orpc/server';
3
3
  import type { Promisable } from '@orpc/shared';
4
4
  import { type ProcedureClient } from './procedure';
5
5
  export type RouterClientWithContractRouter<TRouter extends ContractRouter> = {
6
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
7
  };
8
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;
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
10
  };
11
11
  export interface CreateRouterClientOptions {
12
12
  /**
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.8f9385e",
4
+ "version": "0.0.0-next.a895960",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -29,16 +29,16 @@
29
29
  "dist"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@orpc/contract": "0.0.0-next.8f9385e",
33
- "@orpc/server": "0.0.0-next.8f9385e"
32
+ "@orpc/contract": "0.0.0-next.a895960",
33
+ "@orpc/server": "0.0.0-next.a895960"
34
34
  },
35
35
  "dependencies": {
36
- "@orpc/shared": "0.0.0-next.8f9385e",
37
- "@orpc/transformer": "0.0.0-next.8f9385e"
36
+ "@orpc/transformer": "0.0.0-next.a895960",
37
+ "@orpc/shared": "0.0.0-next.a895960"
38
38
  },
39
39
  "devDependencies": {
40
40
  "zod": "^3.23.8",
41
- "@orpc/openapi": "0.0.0-next.8f9385e"
41
+ "@orpc/openapi": "0.0.0-next.a895960"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",