@orpc/client 0.50.0 → 1.0.0-beta.2

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,5 +1,5 @@
1
1
  import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
2
- import { b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer, S as StandardLink } from '../../shared/client.3Q53fveR.mjs';
2
+ import { b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer, S as StandardLink } from '../../shared/client.Be-O_tdu.mjs';
3
3
  import '@orpc/shared';
4
4
  import '../../shared/client.CvnV7_uV.mjs';
5
5
  import '@orpc/standard-server';
@@ -1,4 +1,4 @@
1
- export { I as InvalidEventIteratorRetryResponse, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.3Q53fveR.mjs';
1
+ export { I as InvalidEventIteratorRetryResponse, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.Be-O_tdu.mjs';
2
2
  import '@orpc/shared';
3
3
  import '../../shared/client.CvnV7_uV.mjs';
4
4
  import '@orpc/standard-server';
@@ -5,8 +5,8 @@ import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM
5
5
  import '@orpc/standard-server';
6
6
 
7
7
  interface ClientRetryPluginAttemptOptions {
8
- lastEventRetry: number | undefined;
9
- lastEventId: string | undefined;
8
+ eventIteratorLastRetry: number | undefined;
9
+ eventIteratorLastEventId: string | undefined;
10
10
  attemptIndex: number;
11
11
  error: unknown;
12
12
  }
@@ -21,7 +21,7 @@ interface ClientRetryPluginContext {
21
21
  /**
22
22
  * Delay (in ms) before retrying.
23
23
  *
24
- * @default (o) => o.lastEventRetry ?? 2000
24
+ * @default (o) => o.eventIteratorLastRetry ?? 2000
25
25
  */
26
26
  retryDelay?: Value<number, [
27
27
  attemptOptions: ClientRetryPluginAttemptOptions,
@@ -5,8 +5,8 @@ import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM
5
5
  import '@orpc/standard-server';
6
6
 
7
7
  interface ClientRetryPluginAttemptOptions {
8
- lastEventRetry: number | undefined;
9
- lastEventId: string | undefined;
8
+ eventIteratorLastRetry: number | undefined;
9
+ eventIteratorLastEventId: string | undefined;
10
10
  attemptIndex: number;
11
11
  error: unknown;
12
12
  }
@@ -21,7 +21,7 @@ interface ClientRetryPluginContext {
21
21
  /**
22
22
  * Delay (in ms) before retrying.
23
23
  *
24
- * @default (o) => o.lastEventRetry ?? 2000
24
+ * @default (o) => o.eventIteratorLastRetry ?? 2000
25
25
  */
26
26
  retryDelay?: Value<number, [
27
27
  attemptOptions: ClientRetryPluginAttemptOptions,
@@ -11,7 +11,7 @@ class ClientRetryPlugin {
11
11
  defaultOnRetry;
12
12
  constructor(options = {}) {
13
13
  this.defaultRetry = options.default?.retry ?? 0;
14
- this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.lastEventRetry ?? 2e3);
14
+ this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.eventIteratorLastRetry ?? 2e3);
15
15
  this.defaultShouldRetry = options.default?.shouldRetry ?? true;
16
16
  this.defaultOnRetry = options.default?.onRetry;
17
17
  }
@@ -25,14 +25,13 @@ class ClientRetryPlugin {
25
25
  if (maxAttempts <= 0) {
26
26
  return interceptorOptions.next();
27
27
  }
28
- let lastEventId = interceptorOptions.options.lastEventId;
29
- let lastEventRetry;
28
+ let eventIteratorLastEventId = interceptorOptions.options.lastEventId;
29
+ let eventIteratorLastRetry;
30
30
  let unsubscribe;
31
31
  let attemptIndex = 0;
32
32
  const next = async (initial) => {
33
33
  let current = initial;
34
34
  while (true) {
35
- const newClientOptions = { ...interceptorOptions.options, lastEventId };
36
35
  if (current) {
37
36
  if (attemptIndex >= maxAttempts) {
38
37
  throw current.error;
@@ -40,13 +39,13 @@ class ClientRetryPlugin {
40
39
  const attemptOptions = {
41
40
  attemptIndex,
42
41
  error: current.error,
43
- lastEventId,
44
- lastEventRetry
42
+ eventIteratorLastEventId,
43
+ eventIteratorLastRetry
45
44
  };
46
45
  const shouldRetryBool = await value(
47
46
  shouldRetry,
48
47
  attemptOptions,
49
- newClientOptions,
48
+ interceptorOptions.options,
50
49
  interceptorOptions.path,
51
50
  interceptorOptions.input
52
51
  );
@@ -55,14 +54,14 @@ class ClientRetryPlugin {
55
54
  }
56
55
  unsubscribe = onRetry?.(
57
56
  attemptOptions,
58
- newClientOptions,
57
+ interceptorOptions.options,
59
58
  interceptorOptions.path,
60
59
  interceptorOptions.input
61
60
  );
62
61
  const retryDelayMs = await value(
63
62
  retryDelay,
64
63
  attemptOptions,
65
- newClientOptions,
64
+ interceptorOptions.options,
66
65
  interceptorOptions.path,
67
66
  interceptorOptions.input
68
67
  );
@@ -70,13 +69,14 @@ class ClientRetryPlugin {
70
69
  attemptIndex++;
71
70
  }
72
71
  try {
72
+ const newClientOptions = { ...interceptorOptions.options, lastEventId: eventIteratorLastEventId };
73
73
  const output2 = await interceptorOptions.next({
74
74
  ...interceptorOptions,
75
75
  options: newClientOptions
76
76
  });
77
77
  return output2;
78
78
  } catch (error) {
79
- if (newClientOptions.signal?.aborted === true) {
79
+ if (interceptorOptions.options.signal?.aborted === true) {
80
80
  throw error;
81
81
  }
82
82
  current = { error };
@@ -97,16 +97,16 @@ class ClientRetryPlugin {
97
97
  try {
98
98
  const item = await current.next();
99
99
  const meta = getEventMeta(item.value);
100
- lastEventId = meta?.id ?? lastEventId;
101
- lastEventRetry = meta?.retry ?? lastEventRetry;
100
+ eventIteratorLastEventId = meta?.id ?? eventIteratorLastEventId;
101
+ eventIteratorLastRetry = meta?.retry ?? eventIteratorLastRetry;
102
102
  if (item.done) {
103
103
  return item.value;
104
104
  }
105
105
  yield item.value;
106
106
  } catch (error) {
107
107
  const meta = getEventMeta(error);
108
- lastEventId = meta?.id ?? lastEventId;
109
- lastEventRetry = meta?.retry ?? lastEventRetry;
108
+ eventIteratorLastEventId = meta?.id ?? eventIteratorLastEventId;
109
+ eventIteratorLastRetry = meta?.retry ?? eventIteratorLastRetry;
110
110
  const maybeEventIterator = await next({ error });
111
111
  if (!isAsyncIteratorObject(maybeEventIterator)) {
112
112
  throw new ClientRetryPluginInvalidEventIteratorRetryResponse(
@@ -111,9 +111,6 @@ class StandardRPCJsonSerializer {
111
111
  if (isObject(data)) {
112
112
  const json = {};
113
113
  for (const k in data) {
114
- if (k === "toJSON" && typeof data[k] === "function") {
115
- continue;
116
- }
117
114
  json[k] = this.serialize(data[k], [...segments, k], meta, maps, blobs)[0];
118
115
  }
119
116
  return [json, meta, maps, blobs];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/client",
3
3
  "type": "module",
4
- "version": "0.50.0",
4
+ "version": "1.0.0-beta.2",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -39,9 +39,9 @@
39
39
  "dist"
40
40
  ],
41
41
  "dependencies": {
42
- "@orpc/shared": "0.50.0",
43
- "@orpc/standard-server-fetch": "0.50.0",
44
- "@orpc/standard-server": "0.50.0"
42
+ "@orpc/shared": "1.0.0-beta.2",
43
+ "@orpc/standard-server-fetch": "1.0.0-beta.2",
44
+ "@orpc/standard-server": "1.0.0-beta.2"
45
45
  },
46
46
  "devDependencies": {
47
47
  "zod": "^3.24.2"