@orpc/client 0.0.0-next.d16a1b6 → 0.0.0-next.d452413
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/README.md +3 -1
- package/dist/adapters/fetch/index.d.mts +6 -6
- package/dist/adapters/fetch/index.d.ts +6 -6
- package/dist/adapters/fetch/index.mjs +10 -7
- package/dist/adapters/standard/index.d.mts +2 -3
- package/dist/adapters/standard/index.d.ts +2 -3
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +2 -2
- package/dist/shared/{client.MkoaGU3v.mjs → client.Df5pd75N.mjs} +76 -77
- package/dist/shared/{client.DcaJQZfy.mjs → client.XAn8cDTM.mjs} +2 -1
- package/package.json +5 -5
package/README.md
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
@@ -55,6 +55,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
56
56
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
57
57
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
58
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
59
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
58
60
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
59
61
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
60
62
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
@@ -1,20 +1,20 @@
|
|
1
|
-
import { C as ClientContext, a as ClientOptionsOut, b as ClientLink } from '../../shared/client.D_CzLDyB.mjs';
|
2
|
-
import { StandardLinkClient, StandardLinkOptions, StandardRPCLinkCodecOptions, StandardRPCLinkCodec } from '../standard/index.mjs';
|
3
1
|
import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
|
2
|
+
import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
|
3
|
+
import { C as ClientContext, a as ClientOptionsOut, b as ClientLink } from '../../shared/client.D_CzLDyB.mjs';
|
4
|
+
import { StandardLinkClient, StandardLinkOptions, StandardRPCLinkCodecOptions } from '../standard/index.mjs';
|
4
5
|
import '@orpc/shared';
|
5
6
|
|
6
|
-
interface LinkFetchClientOptions<T extends ClientContext> {
|
7
|
+
interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
|
7
8
|
fetch?: (request: Request, init: Record<never, never>, options: ClientOptionsOut<T>, path: readonly string[], input: unknown) => Promise<Response>;
|
8
9
|
}
|
9
10
|
declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
|
10
11
|
private readonly fetch;
|
12
|
+
private readonly toFetchRequestOptions;
|
11
13
|
constructor(options: LinkFetchClientOptions<T>);
|
12
14
|
call(request: StandardRequest, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
|
13
15
|
}
|
14
16
|
|
15
17
|
interface RPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardRPCLinkCodecOptions<T>, LinkFetchClientOptions<T> {
|
16
|
-
linkCodec?: StandardRPCLinkCodec<T>;
|
17
|
-
linkClient?: LinkFetchClient<T>;
|
18
18
|
}
|
19
19
|
declare class RPCLink<T extends ClientContext> implements ClientLink<T> {
|
20
20
|
private readonly standardLink;
|
@@ -26,4 +26,4 @@ interface FetchWithContext<TClientContext extends ClientContext> {
|
|
26
26
|
(url: URL, init: RequestInit, options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
|
27
27
|
}
|
28
28
|
|
29
|
-
export { type FetchWithContext, RPCLink, type RPCLinkOptions };
|
29
|
+
export { type FetchWithContext, LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
|
@@ -1,20 +1,20 @@
|
|
1
|
-
import { C as ClientContext, a as ClientOptionsOut, b as ClientLink } from '../../shared/client.D_CzLDyB.js';
|
2
|
-
import { StandardLinkClient, StandardLinkOptions, StandardRPCLinkCodecOptions, StandardRPCLinkCodec } from '../standard/index.js';
|
3
1
|
import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
|
2
|
+
import { ToFetchRequestOptions } from '@orpc/standard-server-fetch';
|
3
|
+
import { C as ClientContext, a as ClientOptionsOut, b as ClientLink } from '../../shared/client.D_CzLDyB.js';
|
4
|
+
import { StandardLinkClient, StandardLinkOptions, StandardRPCLinkCodecOptions } from '../standard/index.js';
|
4
5
|
import '@orpc/shared';
|
5
6
|
|
6
|
-
interface LinkFetchClientOptions<T extends ClientContext> {
|
7
|
+
interface LinkFetchClientOptions<T extends ClientContext> extends ToFetchRequestOptions {
|
7
8
|
fetch?: (request: Request, init: Record<never, never>, options: ClientOptionsOut<T>, path: readonly string[], input: unknown) => Promise<Response>;
|
8
9
|
}
|
9
10
|
declare class LinkFetchClient<T extends ClientContext> implements StandardLinkClient<T> {
|
10
11
|
private readonly fetch;
|
12
|
+
private readonly toFetchRequestOptions;
|
11
13
|
constructor(options: LinkFetchClientOptions<T>);
|
12
14
|
call(request: StandardRequest, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
|
13
15
|
}
|
14
16
|
|
15
17
|
interface RPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardRPCLinkCodecOptions<T>, LinkFetchClientOptions<T> {
|
16
|
-
linkCodec?: StandardRPCLinkCodec<T>;
|
17
|
-
linkClient?: LinkFetchClient<T>;
|
18
18
|
}
|
19
19
|
declare class RPCLink<T extends ClientContext> implements ClientLink<T> {
|
20
20
|
private readonly standardLink;
|
@@ -26,4 +26,4 @@ interface FetchWithContext<TClientContext extends ClientContext> {
|
|
26
26
|
(url: URL, init: RequestInit, options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
|
27
27
|
}
|
28
28
|
|
29
|
-
export { type FetchWithContext, RPCLink, type RPCLinkOptions };
|
29
|
+
export { type FetchWithContext, LinkFetchClient, type LinkFetchClientOptions, RPCLink, type RPCLinkOptions };
|
@@ -1,16 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
|
2
|
+
import { a as StandardRPCLinkCodec, b as RPCSerializer, S as StandardLink } from '../../shared/client.Df5pd75N.mjs';
|
2
3
|
import '@orpc/shared';
|
4
|
+
import '../../shared/client.XAn8cDTM.mjs';
|
3
5
|
import '@orpc/standard-server';
|
4
|
-
import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/client.DcaJQZfy.mjs';
|
6
6
|
|
7
7
|
class LinkFetchClient {
|
8
8
|
fetch;
|
9
|
+
toFetchRequestOptions;
|
9
10
|
constructor(options) {
|
10
11
|
this.fetch = options?.fetch ?? globalThis.fetch.bind(globalThis);
|
12
|
+
this.toFetchRequestOptions = options;
|
11
13
|
}
|
12
14
|
async call(request, options, path, input) {
|
13
|
-
const fetchRequest = toFetchRequest(request);
|
15
|
+
const fetchRequest = toFetchRequest(request, this.toFetchRequestOptions);
|
14
16
|
const fetchResponse = await this.fetch(fetchRequest, {}, options, path, input);
|
15
17
|
const lazyResponse = toStandardLazyResponse(fetchResponse);
|
16
18
|
return lazyResponse;
|
@@ -20,8 +22,9 @@ class LinkFetchClient {
|
|
20
22
|
class RPCLink {
|
21
23
|
standardLink;
|
22
24
|
constructor(options) {
|
23
|
-
const
|
24
|
-
const
|
25
|
+
const serializer = new RPCSerializer();
|
26
|
+
const linkCodec = new StandardRPCLinkCodec(serializer, options);
|
27
|
+
const linkClient = new LinkFetchClient(options);
|
25
28
|
this.standardLink = new StandardLink(linkCodec, linkClient, options);
|
26
29
|
}
|
27
30
|
async call(path, input, options) {
|
@@ -29,4 +32,4 @@ class RPCLink {
|
|
29
32
|
}
|
30
33
|
}
|
31
34
|
|
32
|
-
export { RPCLink };
|
35
|
+
export { LinkFetchClient, RPCLink };
|
@@ -132,16 +132,15 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
|
|
132
132
|
path: readonly string[],
|
133
133
|
input: unknown
|
134
134
|
]>;
|
135
|
-
rpcSerializer?: RPCSerializer;
|
136
135
|
}
|
137
136
|
declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
137
|
+
private readonly serializer;
|
138
138
|
private readonly baseUrl;
|
139
139
|
private readonly maxUrlLength;
|
140
140
|
private readonly fallbackMethod;
|
141
141
|
private readonly expectedMethod;
|
142
142
|
private readonly headers;
|
143
|
-
|
144
|
-
constructor(options: StandardRPCLinkCodecOptions<T>);
|
143
|
+
constructor(serializer: RPCSerializer, options: StandardRPCLinkCodecOptions<T>);
|
145
144
|
encode(path: readonly string[], input: unknown, options: ClientOptionsOut<any>): Promise<StandardRequest>;
|
146
145
|
decode(response: StandardLazyResponse): Promise<unknown>;
|
147
146
|
}
|
@@ -132,16 +132,15 @@ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
|
|
132
132
|
path: readonly string[],
|
133
133
|
input: unknown
|
134
134
|
]>;
|
135
|
-
rpcSerializer?: RPCSerializer;
|
136
135
|
}
|
137
136
|
declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
137
|
+
private readonly serializer;
|
138
138
|
private readonly baseUrl;
|
139
139
|
private readonly maxUrlLength;
|
140
140
|
private readonly fallbackMethod;
|
141
141
|
private readonly expectedMethod;
|
142
142
|
private readonly headers;
|
143
|
-
|
144
|
-
constructor(options: StandardRPCLinkCodecOptions<T>);
|
143
|
+
constructor(serializer: RPCSerializer, options: StandardRPCLinkCodecOptions<T>);
|
145
144
|
encode(path: readonly string[], input: unknown, options: ClientOptionsOut<any>): Promise<StandardRequest>;
|
146
145
|
decode(response: StandardLazyResponse): Promise<unknown>;
|
147
146
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { I as InvalidEventIteratorRetryResponse, R as RPCJsonSerializer, b as RPCSerializer, S as StandardLink, a as StandardRPCLinkCodec } from '../../shared/client.
|
1
|
+
export { I as InvalidEventIteratorRetryResponse, R as RPCJsonSerializer, b as RPCSerializer, S as StandardLink, a as StandardRPCLinkCodec } from '../../shared/client.Df5pd75N.mjs';
|
2
2
|
import '@orpc/shared';
|
3
|
-
import '../../shared/client.
|
3
|
+
import '../../shared/client.XAn8cDTM.mjs';
|
4
4
|
import '@orpc/standard-server';
|
package/dist/index.d.mts
CHANGED
@@ -133,7 +133,9 @@ interface EventIteratorState {
|
|
133
133
|
}
|
134
134
|
declare function registerEventIteratorState(iterator: AsyncIteratorObject<unknown, unknown, void>, state: EventIteratorState): void;
|
135
135
|
declare function updateEventIteratorStatus(state: EventIteratorState, status: ConnectionStatus): void;
|
136
|
-
declare function onEventIteratorStatusChange(iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void,
|
136
|
+
declare function onEventIteratorStatusChange(iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void, options?: {
|
137
|
+
notifyImmediately?: boolean;
|
138
|
+
}): () => void;
|
137
139
|
|
138
140
|
type SafeResult<TOutput, TError extends Error> = [error: null, data: TOutput, isDefined: false] & {
|
139
141
|
error: null;
|
package/dist/index.d.ts
CHANGED
@@ -133,7 +133,9 @@ interface EventIteratorState {
|
|
133
133
|
}
|
134
134
|
declare function registerEventIteratorState(iterator: AsyncIteratorObject<unknown, unknown, void>, state: EventIteratorState): void;
|
135
135
|
declare function updateEventIteratorStatus(state: EventIteratorState, status: ConnectionStatus): void;
|
136
|
-
declare function onEventIteratorStatusChange(iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void,
|
136
|
+
declare function onEventIteratorStatusChange(iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void, options?: {
|
137
|
+
notifyImmediately?: boolean;
|
138
|
+
}): () => void;
|
137
139
|
|
138
140
|
type SafeResult<TOutput, TError extends Error> = [error: null, data: TOutput, isDefined: false] & {
|
139
141
|
error: null;
|
package/dist/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { i as isDefinedError } from './shared/client.
|
2
|
-
export { C as COMMON_ORPC_ERROR_DEFS, O as ORPCError, c as createAutoRetryEventIterator, a as fallbackORPCErrorMessage, f as fallbackORPCErrorStatus, m as mapEventIterator, o as onEventIteratorStatusChange, r as registerEventIteratorState, t as toORPCError, u as updateEventIteratorStatus } from './shared/client.
|
1
|
+
import { i as isDefinedError } from './shared/client.XAn8cDTM.mjs';
|
2
|
+
export { C as COMMON_ORPC_ERROR_DEFS, O as ORPCError, c as createAutoRetryEventIterator, a as fallbackORPCErrorMessage, f as fallbackORPCErrorStatus, m as mapEventIterator, o as onEventIteratorStatusChange, r as registerEventIteratorState, t as toORPCError, u as updateEventIteratorStatus } from './shared/client.XAn8cDTM.mjs';
|
3
3
|
export { ErrorEvent } from '@orpc/standard-server';
|
4
4
|
import '@orpc/shared';
|
5
5
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { intercept, isAsyncIteratorObject, value, isObject,
|
2
|
-
import { c as createAutoRetryEventIterator,
|
1
|
+
import { intercept, isAsyncIteratorObject, value, isObject, trim, stringifyJSON } from '@orpc/shared';
|
2
|
+
import { c as createAutoRetryEventIterator, O as ORPCError, m as mapEventIterator, t as toORPCError } from './client.XAn8cDTM.mjs';
|
3
3
|
import { ErrorEvent } from '@orpc/standard-server';
|
4
4
|
|
5
5
|
class InvalidEventIteratorRetryResponse extends Error {
|
@@ -39,7 +39,7 @@ class StandardLink {
|
|
39
39
|
const updatedOptions = { ...options2, lastEventId: reconnectOptions.lastEventId };
|
40
40
|
const maybeIterator = await this.#call(path2, input2, updatedOptions);
|
41
41
|
if (!isAsyncIteratorObject(maybeIterator)) {
|
42
|
-
throw new InvalidEventIteratorRetryResponse("Invalid
|
42
|
+
throw new InvalidEventIteratorRetryResponse("Invalid Event Iterator retry response");
|
43
43
|
}
|
44
44
|
return maybeIterator;
|
45
45
|
}, options2.lastEventId);
|
@@ -169,6 +169,79 @@ class RPCJsonSerializer {
|
|
169
169
|
}
|
170
170
|
}
|
171
171
|
|
172
|
+
class StandardRPCLinkCodec {
|
173
|
+
constructor(serializer, options) {
|
174
|
+
this.serializer = serializer;
|
175
|
+
this.baseUrl = options.url;
|
176
|
+
this.maxUrlLength = options.maxUrlLength ?? 2083;
|
177
|
+
this.fallbackMethod = options.fallbackMethod ?? "POST";
|
178
|
+
this.expectedMethod = options.method ?? this.fallbackMethod;
|
179
|
+
this.headers = options.headers ?? {};
|
180
|
+
}
|
181
|
+
baseUrl;
|
182
|
+
maxUrlLength;
|
183
|
+
fallbackMethod;
|
184
|
+
expectedMethod;
|
185
|
+
headers;
|
186
|
+
async encode(path, input, options) {
|
187
|
+
const expectedMethod = await value(this.expectedMethod, options, path, input);
|
188
|
+
const headers = await value(this.headers, options, path, input);
|
189
|
+
const baseUrl = await value(this.baseUrl, options, path, input);
|
190
|
+
const url = new URL(`${trim(baseUrl.toString(), "/")}/${path.map(encodeURIComponent).join("/")}`);
|
191
|
+
const serialized = this.serializer.serialize(input);
|
192
|
+
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !(serialized instanceof Blob) && !isAsyncIteratorObject(serialized)) {
|
193
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path, input);
|
194
|
+
const getUrl = new URL(url);
|
195
|
+
getUrl.searchParams.append("data", stringifyJSON(serialized) ?? "");
|
196
|
+
if (getUrl.toString().length <= maxUrlLength) {
|
197
|
+
return {
|
198
|
+
body: void 0,
|
199
|
+
method: expectedMethod,
|
200
|
+
headers,
|
201
|
+
url: getUrl,
|
202
|
+
signal: options.signal
|
203
|
+
};
|
204
|
+
}
|
205
|
+
}
|
206
|
+
return {
|
207
|
+
url,
|
208
|
+
method: expectedMethod === "GET" ? this.fallbackMethod : expectedMethod,
|
209
|
+
headers,
|
210
|
+
body: serialized,
|
211
|
+
signal: options.signal
|
212
|
+
};
|
213
|
+
}
|
214
|
+
async decode(response) {
|
215
|
+
const isOk = response.status >= 200 && response.status < 300;
|
216
|
+
const deserialized = await (async () => {
|
217
|
+
let isBodyOk = false;
|
218
|
+
try {
|
219
|
+
const body = await response.body();
|
220
|
+
isBodyOk = true;
|
221
|
+
return this.serializer.deserialize(body);
|
222
|
+
} catch (error) {
|
223
|
+
if (!isBodyOk) {
|
224
|
+
throw new Error("Cannot parse response body, please check the response body and content-type.", {
|
225
|
+
cause: error
|
226
|
+
});
|
227
|
+
}
|
228
|
+
throw new Error("Invalid RPC response format.", {
|
229
|
+
cause: error
|
230
|
+
});
|
231
|
+
}
|
232
|
+
})();
|
233
|
+
if (!isOk) {
|
234
|
+
if (ORPCError.isValidJSON(deserialized)) {
|
235
|
+
throw ORPCError.fromJSON(deserialized);
|
236
|
+
}
|
237
|
+
throw new Error("Invalid RPC error response format.", {
|
238
|
+
cause: deserialized
|
239
|
+
});
|
240
|
+
}
|
241
|
+
return deserialized;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
172
245
|
class RPCSerializer {
|
173
246
|
constructor(jsonSerializer = new RPCJsonSerializer()) {
|
174
247
|
this.jsonSerializer = jsonSerializer;
|
@@ -244,78 +317,4 @@ class RPCSerializer {
|
|
244
317
|
}
|
245
318
|
}
|
246
319
|
|
247
|
-
class StandardRPCLinkCodec {
|
248
|
-
baseUrl;
|
249
|
-
maxUrlLength;
|
250
|
-
fallbackMethod;
|
251
|
-
expectedMethod;
|
252
|
-
headers;
|
253
|
-
rpcSerializer;
|
254
|
-
constructor(options) {
|
255
|
-
this.baseUrl = options.url;
|
256
|
-
this.maxUrlLength = options.maxUrlLength ?? 2083;
|
257
|
-
this.fallbackMethod = options.fallbackMethod ?? "POST";
|
258
|
-
this.expectedMethod = options.method ?? this.fallbackMethod;
|
259
|
-
this.headers = options.headers ?? {};
|
260
|
-
this.rpcSerializer = options.rpcSerializer ?? new RPCSerializer();
|
261
|
-
}
|
262
|
-
async encode(path, input, options) {
|
263
|
-
const expectedMethod = await value(this.expectedMethod, options, path, input);
|
264
|
-
const headers = await value(this.headers, options, path, input);
|
265
|
-
const baseUrl = await value(this.baseUrl, options, path, input);
|
266
|
-
const url = new URL(`${trim(baseUrl.toString(), "/")}/${path.map(encodeURIComponent).join("/")}`);
|
267
|
-
const serialized = this.rpcSerializer.serialize(input);
|
268
|
-
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !(serialized instanceof Blob) && !isAsyncIteratorObject(serialized)) {
|
269
|
-
const maxUrlLength = await value(this.maxUrlLength, options, path, input);
|
270
|
-
const getUrl = new URL(url);
|
271
|
-
getUrl.searchParams.append("data", stringifyJSON(serialized) ?? "");
|
272
|
-
if (getUrl.toString().length <= maxUrlLength) {
|
273
|
-
return {
|
274
|
-
body: void 0,
|
275
|
-
method: expectedMethod,
|
276
|
-
headers,
|
277
|
-
url: getUrl,
|
278
|
-
signal: options.signal
|
279
|
-
};
|
280
|
-
}
|
281
|
-
}
|
282
|
-
return {
|
283
|
-
url,
|
284
|
-
method: expectedMethod === "GET" ? this.fallbackMethod : expectedMethod,
|
285
|
-
headers,
|
286
|
-
body: serialized,
|
287
|
-
signal: options.signal
|
288
|
-
};
|
289
|
-
}
|
290
|
-
async decode(response) {
|
291
|
-
const isOk = response.status >= 200 && response.status < 300;
|
292
|
-
const deserialized = await (async () => {
|
293
|
-
let isBodyOk = false;
|
294
|
-
try {
|
295
|
-
const body = await response.body();
|
296
|
-
isBodyOk = true;
|
297
|
-
return this.rpcSerializer.deserialize(body);
|
298
|
-
} catch (error) {
|
299
|
-
if (!isBodyOk) {
|
300
|
-
throw new Error("Cannot parse response body, please check the response body and content-type.", {
|
301
|
-
cause: error
|
302
|
-
});
|
303
|
-
}
|
304
|
-
throw new Error("Invalid RPC response format.", {
|
305
|
-
cause: error
|
306
|
-
});
|
307
|
-
}
|
308
|
-
})();
|
309
|
-
if (!isOk) {
|
310
|
-
if (ORPCError.isValidJSON(deserialized)) {
|
311
|
-
throw ORPCError.fromJSON(deserialized);
|
312
|
-
}
|
313
|
-
throw new Error("Invalid RPC error response format.", {
|
314
|
-
cause: deserialized
|
315
|
-
});
|
316
|
-
}
|
317
|
-
return deserialized;
|
318
|
-
}
|
319
|
-
}
|
320
|
-
|
321
320
|
export { InvalidEventIteratorRetryResponse as I, RPCJsonSerializer as R, StandardLink as S, StandardRPCLinkCodec as a, RPCSerializer as b };
|
@@ -147,7 +147,8 @@ function updateEventIteratorStatus(state, status) {
|
|
147
147
|
state.listeners.forEach((cb) => cb(status));
|
148
148
|
}
|
149
149
|
}
|
150
|
-
function onEventIteratorStatusChange(iterator, callback,
|
150
|
+
function onEventIteratorStatusChange(iterator, callback, options = {}) {
|
151
|
+
const notifyImmediately = options.notifyImmediately ?? true;
|
151
152
|
const state = iteratorStates.get(iterator);
|
152
153
|
if (!state) {
|
153
154
|
throw new Error("Iterator is not registered.");
|
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.
|
4
|
+
"version": "0.0.0-next.d452413",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -34,12 +34,12 @@
|
|
34
34
|
"dist"
|
35
35
|
],
|
36
36
|
"dependencies": {
|
37
|
-
"@orpc/shared": "0.0.0-next.
|
38
|
-
"@orpc/standard-server": "0.0.0-next.
|
39
|
-
"@orpc/standard-server-fetch": "0.0.0-next.
|
37
|
+
"@orpc/shared": "0.0.0-next.d452413",
|
38
|
+
"@orpc/standard-server": "0.0.0-next.d452413",
|
39
|
+
"@orpc/standard-server-fetch": "0.0.0-next.d452413"
|
40
40
|
},
|
41
41
|
"devDependencies": {
|
42
|
-
"zod": "^3.24.
|
42
|
+
"zod": "^3.24.2"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "unbuild",
|