@orpc/client 0.0.0-next.dcc6c29 → 0.0.0-next.de766b3

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.
@@ -1,14 +1,6 @@
1
- import { Interceptor, ThrowableError } from '@orpc/shared';
1
+ import { Interceptor } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.CipPQkhk.js';
4
-
5
- interface StandardLinkCodec<T extends ClientContext> {
6
- encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
7
- decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
8
- }
9
- interface StandardLinkClient<T extends ClientContext> {
10
- call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
11
- }
3
+ import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.4TS_0JaO.mjs';
12
4
 
13
5
  interface StandardLinkPlugin<T extends ClientContext> {
14
6
  order?: number;
@@ -20,6 +12,14 @@ declare class CompositeStandardLinkPlugin<T extends ClientContext, TPlugin exten
20
12
  init(options: StandardLinkOptions<T>): void;
21
13
  }
22
14
 
15
+ interface StandardLinkCodec<T extends ClientContext> {
16
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
17
+ decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
18
+ }
19
+ interface StandardLinkClient<T extends ClientContext> {
20
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
21
+ }
22
+
23
23
  interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
24
24
  path: readonly string[];
25
25
  input: unknown;
@@ -28,8 +28,8 @@ interface StandardLinkClientInterceptorOptions<T extends ClientContext> extends
28
28
  request: StandardRequest;
29
29
  }
30
30
  interface StandardLinkOptions<T extends ClientContext> {
31
- interceptors?: Interceptor<StandardLinkInterceptorOptions<T>, unknown, ThrowableError>[];
32
- clientInterceptors?: Interceptor<StandardLinkClientInterceptorOptions<T>, StandardLazyResponse, ThrowableError>[];
31
+ interceptors?: Interceptor<StandardLinkInterceptorOptions<T>, Promise<unknown>>[];
32
+ clientInterceptors?: Interceptor<StandardLinkClientInterceptorOptions<T>, Promise<StandardLazyResponse>>[];
33
33
  plugins?: StandardLinkPlugin<T>[];
34
34
  }
35
35
  declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
@@ -42,4 +42,5 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
42
42
  call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
43
43
  }
44
44
 
45
- export { CompositeStandardLinkPlugin as C, type StandardLinkClientInterceptorOptions as S, type StandardLinkPlugin as a, type StandardLinkOptions as b, type StandardLinkInterceptorOptions as c, StandardLink as d, type StandardLinkCodec as e, type StandardLinkClient as f };
45
+ export { CompositeStandardLinkPlugin as C, StandardLink as d };
46
+ export type { StandardLinkClientInterceptorOptions as S, StandardLinkPlugin as a, StandardLinkOptions as b, StandardLinkInterceptorOptions as c, StandardLinkCodec as e, StandardLinkClient as f };
@@ -1,4 +1,4 @@
1
- import { isObject, isTypescriptObject } from '@orpc/shared';
1
+ import { isObject, AsyncIteratorClass, isTypescriptObject } from '@orpc/shared';
2
2
  import { getEventMeta, withEventMeta } from '@orpc/standard-server';
3
3
 
4
4
  const COMMON_ORPC_ERROR_DEFS = {
@@ -141,22 +141,17 @@ function createORPCErrorFromJson(json, options = {}) {
141
141
  }
142
142
 
143
143
  function mapEventIterator(iterator, maps) {
144
- return async function* () {
144
+ return new AsyncIteratorClass(async () => {
145
145
  try {
146
- while (true) {
147
- const { done, value } = await iterator.next();
148
- let mappedValue = await maps.value(value, done);
149
- if (mappedValue !== value) {
150
- const meta = getEventMeta(value);
151
- if (meta && isTypescriptObject(mappedValue)) {
152
- mappedValue = withEventMeta(mappedValue, meta);
153
- }
146
+ const { done, value } = await iterator.next();
147
+ let mappedValue = await maps.value(value, done);
148
+ if (mappedValue !== value) {
149
+ const meta = getEventMeta(value);
150
+ if (meta && isTypescriptObject(mappedValue)) {
151
+ mappedValue = withEventMeta(mappedValue, meta);
154
152
  }
155
- if (done) {
156
- return mappedValue;
157
- }
158
- yield mappedValue;
159
153
  }
154
+ return { done, value: mappedValue };
160
155
  } catch (error) {
161
156
  let mappedError = await maps.error(error);
162
157
  if (mappedError !== error) {
@@ -166,10 +161,12 @@ function mapEventIterator(iterator, maps) {
166
161
  }
167
162
  }
168
163
  throw mappedError;
169
- } finally {
164
+ }
165
+ }, async (reason) => {
166
+ if (reason !== "next") {
170
167
  await iterator.return?.();
171
168
  }
172
- }();
169
+ });
173
170
  }
174
171
 
175
172
  export { COMMON_ORPC_ERROR_DEFS as C, ORPCError as O, fallbackORPCErrorMessage as a, isORPCErrorStatus as b, isORPCErrorJson as c, createORPCErrorFromJson as d, fallbackORPCErrorStatus as f, isDefinedError as i, mapEventIterator as m, toORPCError as t };
@@ -1,6 +1,6 @@
1
- import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.CipPQkhk.mjs';
2
- import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.Bt2hFtM_.mjs';
3
- import { Segment, Value } from '@orpc/shared';
1
+ import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.4TS_0JaO.mjs';
2
+ import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.BMoG_EdN.mjs';
3
+ import { Segment, Value, Promisable } from '@orpc/shared';
4
4
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
5
 
6
6
  declare const STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES: {
@@ -44,30 +44,30 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
44
44
  /**
45
45
  * Base url for all requests.
46
46
  */
47
- url: Value<string | URL, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
47
+ url: Value<Promisable<string | URL>, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
48
48
  /**
49
49
  * The maximum length of the URL.
50
50
  *
51
51
  * @default 2083
52
52
  */
53
- maxUrlLength?: Value<number, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
53
+ maxUrlLength?: Value<Promisable<number>, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
54
54
  /**
55
55
  * The method used to make the request.
56
56
  *
57
57
  * @default 'POST'
58
58
  */
59
- method?: Value<HTTPMethod, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
59
+ method?: Value<Promisable<Exclude<HTTPMethod, 'HEAD'>>, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
60
60
  /**
61
61
  * The method to use when the payload cannot safely pass to the server with method return from method function.
62
62
  * GET is not allowed, it's very dangerous.
63
63
  *
64
64
  * @default 'POST'
65
65
  */
66
- fallbackMethod?: Exclude<HTTPMethod, 'GET'>;
66
+ fallbackMethod?: Exclude<HTTPMethod, 'HEAD' | 'GET'>;
67
67
  /**
68
68
  * Inject headers to the request.
69
69
  */
70
- headers?: Value<StandardHeaders, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
70
+ headers?: Value<Promisable<StandardHeaders>, [options: ClientOptions<T>, path: readonly string[], input: unknown]>;
71
71
  }
72
72
  declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
73
73
  private readonly serializer;
@@ -87,4 +87,5 @@ declare class StandardRPCLink<T extends ClientContext> extends StandardLink<T> {
87
87
  constructor(linkClient: StandardLinkClient<T>, options: StandardRPCLinkOptions<T>);
88
88
  }
89
89
 
90
- export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, type StandardRPCJsonSerializedMetaItem as a, type StandardRPCJsonSerialized as b, type StandardRPCCustomJsonSerializer as c, type StandardRPCJsonSerializerOptions as d, StandardRPCJsonSerializer as e, type StandardRPCLinkOptions as f, StandardRPCLink as g, type StandardRPCLinkCodecOptions as h, StandardRPCLinkCodec as i, StandardRPCSerializer as j };
90
+ export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, StandardRPCJsonSerializer as e, StandardRPCLink as g, StandardRPCLinkCodec as i, StandardRPCSerializer as j };
91
+ export type { StandardRPCJsonSerializedMetaItem as a, StandardRPCJsonSerialized as b, StandardRPCCustomJsonSerializer as c, StandardRPCJsonSerializerOptions as d, StandardRPCLinkOptions as f, StandardRPCLinkCodecOptions as h };
@@ -1,14 +1,6 @@
1
- import { Interceptor, ThrowableError } from '@orpc/shared';
1
+ import { Interceptor } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.CipPQkhk.mjs';
4
-
5
- interface StandardLinkCodec<T extends ClientContext> {
6
- encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
7
- decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
8
- }
9
- interface StandardLinkClient<T extends ClientContext> {
10
- call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
11
- }
3
+ import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.4TS_0JaO.js';
12
4
 
13
5
  interface StandardLinkPlugin<T extends ClientContext> {
14
6
  order?: number;
@@ -20,6 +12,14 @@ declare class CompositeStandardLinkPlugin<T extends ClientContext, TPlugin exten
20
12
  init(options: StandardLinkOptions<T>): void;
21
13
  }
22
14
 
15
+ interface StandardLinkCodec<T extends ClientContext> {
16
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
17
+ decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
18
+ }
19
+ interface StandardLinkClient<T extends ClientContext> {
20
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
21
+ }
22
+
23
23
  interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
24
24
  path: readonly string[];
25
25
  input: unknown;
@@ -28,8 +28,8 @@ interface StandardLinkClientInterceptorOptions<T extends ClientContext> extends
28
28
  request: StandardRequest;
29
29
  }
30
30
  interface StandardLinkOptions<T extends ClientContext> {
31
- interceptors?: Interceptor<StandardLinkInterceptorOptions<T>, unknown, ThrowableError>[];
32
- clientInterceptors?: Interceptor<StandardLinkClientInterceptorOptions<T>, StandardLazyResponse, ThrowableError>[];
31
+ interceptors?: Interceptor<StandardLinkInterceptorOptions<T>, Promise<unknown>>[];
32
+ clientInterceptors?: Interceptor<StandardLinkClientInterceptorOptions<T>, Promise<StandardLazyResponse>>[];
33
33
  plugins?: StandardLinkPlugin<T>[];
34
34
  }
35
35
  declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
@@ -42,4 +42,5 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
42
42
  call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
43
43
  }
44
44
 
45
- export { CompositeStandardLinkPlugin as C, type StandardLinkClientInterceptorOptions as S, type StandardLinkPlugin as a, type StandardLinkOptions as b, type StandardLinkInterceptorOptions as c, StandardLink as d, type StandardLinkCodec as e, type StandardLinkClient as f };
45
+ export { CompositeStandardLinkPlugin as C, StandardLink as d };
46
+ export type { StandardLinkClientInterceptorOptions as S, StandardLinkPlugin as a, StandardLinkOptions as b, StandardLinkInterceptorOptions as c, StandardLinkCodec as e, StandardLinkClient as f };
@@ -1,6 +1,6 @@
1
1
  import { toArray, intercept, isObject, value, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
2
2
  import { mergeStandardHeaders, ErrorEvent } from '@orpc/standard-server';
3
- import { C as COMMON_ORPC_ERROR_DEFS, b as isORPCErrorStatus, c as isORPCErrorJson, d as createORPCErrorFromJson, O as ORPCError, m as mapEventIterator, t as toORPCError } from './client.CRWEpqLB.mjs';
3
+ import { C as COMMON_ORPC_ERROR_DEFS, b as isORPCErrorStatus, c as isORPCErrorJson, d as createORPCErrorFromJson, O as ORPCError, m as mapEventIterator, t as toORPCError } from './client.BX0_8bnM.mjs';
4
4
 
5
5
  class CompositeStandardLinkPlugin {
6
6
  plugins;
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.dcc6c29",
4
+ "version": "0.0.0-next.de766b3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -33,18 +33,29 @@
33
33
  "types": "./dist/adapters/fetch/index.d.mts",
34
34
  "import": "./dist/adapters/fetch/index.mjs",
35
35
  "default": "./dist/adapters/fetch/index.mjs"
36
+ },
37
+ "./websocket": {
38
+ "types": "./dist/adapters/websocket/index.d.mts",
39
+ "import": "./dist/adapters/websocket/index.mjs",
40
+ "default": "./dist/adapters/websocket/index.mjs"
41
+ },
42
+ "./message-port": {
43
+ "types": "./dist/adapters/message-port/index.d.mts",
44
+ "import": "./dist/adapters/message-port/index.mjs",
45
+ "default": "./dist/adapters/message-port/index.mjs"
36
46
  }
37
47
  },
38
48
  "files": [
39
49
  "dist"
40
50
  ],
41
51
  "dependencies": {
42
- "@orpc/shared": "0.0.0-next.dcc6c29",
43
- "@orpc/standard-server": "0.0.0-next.dcc6c29",
44
- "@orpc/standard-server-fetch": "0.0.0-next.dcc6c29"
52
+ "@orpc/shared": "0.0.0-next.de766b3",
53
+ "@orpc/standard-server": "0.0.0-next.de766b3",
54
+ "@orpc/standard-server-fetch": "0.0.0-next.de766b3",
55
+ "@orpc/standard-server-peer": "0.0.0-next.de766b3"
45
56
  },
46
57
  "devDependencies": {
47
- "zod": "^3.24.2"
58
+ "zod": "^3.25.49"
48
59
  },
49
60
  "scripts": {
50
61
  "build": "unbuild",