@orpc/client 0.0.0-next.dd4e882 → 0.0.0-next.dda04c5
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 +5 -7
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/message-port/index.mjs +4 -4
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.d.mts +1 -1
- package/dist/adapters/websocket/index.d.ts +1 -1
- package/dist/adapters/websocket/index.mjs +18 -5
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/shared/{client.CRWEpqLB.mjs → client.DHOfWE0c.mjs} +22 -25
- package/dist/shared/{client.DpICn1BD.mjs → client.DwfV9Oyl.mjs} +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
31
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
32
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
-
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
33
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
|
|
34
34
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
35
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
36
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -49,14 +49,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
49
49
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
50
50
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
51
51
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
52
|
-
- [@orpc/
|
|
52
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
53
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
53
54
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
54
|
-
- [@orpc/
|
|
55
|
-
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
56
|
-
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
57
|
-
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
55
|
+
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
58
56
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
59
|
-
- [@orpc/
|
|
57
|
+
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
60
58
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
61
59
|
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
62
60
|
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
|
|
2
2
|
import '@orpc/shared';
|
|
3
|
-
import { c as StandardRPCLink } from '../../shared/client.
|
|
3
|
+
import { c as StandardRPCLink } from '../../shared/client.DwfV9Oyl.mjs';
|
|
4
4
|
import '@orpc/standard-server';
|
|
5
|
-
import '../../shared/client.
|
|
5
|
+
import '../../shared/client.DHOfWE0c.mjs';
|
|
6
6
|
|
|
7
7
|
class LinkFetchClient {
|
|
8
8
|
fetch;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientPeer } from '@orpc/standard-server-peer';
|
|
2
2
|
import '@orpc/shared';
|
|
3
|
-
import { c as StandardRPCLink } from '../../shared/client.
|
|
3
|
+
import { c as StandardRPCLink } from '../../shared/client.DwfV9Oyl.mjs';
|
|
4
4
|
import '@orpc/standard-server';
|
|
5
|
-
import '../../shared/client.
|
|
5
|
+
import '../../shared/client.DHOfWE0c.mjs';
|
|
6
6
|
|
|
7
7
|
function postMessagePortMessage(port, data) {
|
|
8
8
|
port.postMessage(data);
|
|
@@ -45,8 +45,8 @@ function onMessagePortClose(port, callback) {
|
|
|
45
45
|
class experimental_LinkMessagePortClient {
|
|
46
46
|
peer;
|
|
47
47
|
constructor(options) {
|
|
48
|
-
this.peer = new ClientPeer(
|
|
49
|
-
postMessagePortMessage(options.port, message
|
|
48
|
+
this.peer = new ClientPeer((message) => {
|
|
49
|
+
return postMessagePortMessage(options.port, message);
|
|
50
50
|
});
|
|
51
51
|
onMessagePortMessage(options.port, async (message) => {
|
|
52
52
|
await this.peer.message(message);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CompositeStandardLinkPlugin, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLink, d as StandardRPCLinkCodec, e as StandardRPCSerializer, g as getMalformedResponseErrorCode, t as toHttpPath } from '../../shared/client.
|
|
1
|
+
export { C as CompositeStandardLinkPlugin, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLink, d as StandardRPCLinkCodec, e as StandardRPCSerializer, g as getMalformedResponseErrorCode, t as toHttpPath } from '../../shared/client.DwfV9Oyl.mjs';
|
|
2
2
|
import '@orpc/shared';
|
|
3
3
|
import '@orpc/standard-server';
|
|
4
|
-
import '../../shared/client.
|
|
4
|
+
import '../../shared/client.DHOfWE0c.mjs';
|
|
@@ -5,7 +5,7 @@ import { f as StandardRPCLinkOptions, g as StandardRPCLink } from '../../shared/
|
|
|
5
5
|
import '@orpc/shared';
|
|
6
6
|
|
|
7
7
|
interface experimental_LinkWebsocketClientOptions {
|
|
8
|
-
websocket: Pick<WebSocket, 'addEventListener' | 'send'>;
|
|
8
|
+
websocket: Pick<WebSocket, 'addEventListener' | 'send' | 'readyState'>;
|
|
9
9
|
}
|
|
10
10
|
declare class experimental_LinkWebsocketClient<T extends ClientContext> implements StandardLinkClient<T> {
|
|
11
11
|
private readonly peer;
|
|
@@ -5,7 +5,7 @@ import { f as StandardRPCLinkOptions, g as StandardRPCLink } from '../../shared/
|
|
|
5
5
|
import '@orpc/shared';
|
|
6
6
|
|
|
7
7
|
interface experimental_LinkWebsocketClientOptions {
|
|
8
|
-
websocket: Pick<WebSocket, 'addEventListener' | 'send'>;
|
|
8
|
+
websocket: Pick<WebSocket, 'addEventListener' | 'send' | 'readyState'>;
|
|
9
9
|
}
|
|
10
10
|
declare class experimental_LinkWebsocketClient<T extends ClientContext> implements StandardLinkClient<T> {
|
|
11
11
|
private readonly peer;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { ClientPeer } from '@orpc/standard-server-peer';
|
|
2
2
|
import '@orpc/shared';
|
|
3
|
-
import { c as StandardRPCLink } from '../../shared/client.
|
|
3
|
+
import { c as StandardRPCLink } from '../../shared/client.DwfV9Oyl.mjs';
|
|
4
4
|
import '@orpc/standard-server';
|
|
5
|
-
import '../../shared/client.
|
|
5
|
+
import '../../shared/client.DHOfWE0c.mjs';
|
|
6
6
|
|
|
7
7
|
class experimental_LinkWebsocketClient {
|
|
8
8
|
peer;
|
|
9
9
|
constructor(options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const untilOpen = new Promise((resolve) => {
|
|
11
|
+
if (options.websocket.readyState === 0) {
|
|
12
|
+
options.websocket.addEventListener("open", () => {
|
|
13
|
+
resolve();
|
|
14
|
+
}, { once: true });
|
|
15
|
+
} else {
|
|
16
|
+
resolve();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
this.peer = new ClientPeer(async (message) => {
|
|
20
|
+
await untilOpen;
|
|
21
|
+
return options.websocket.send(message);
|
|
22
|
+
});
|
|
23
|
+
options.websocket.addEventListener("message", async (event) => {
|
|
24
|
+
const message = event.data instanceof Blob ? await event.data.arrayBuffer() : event.data;
|
|
25
|
+
this.peer.message(message);
|
|
13
26
|
});
|
|
14
27
|
options.websocket.addEventListener("close", () => {
|
|
15
28
|
this.peer.close();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientContext, b as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.4TS_0JaO.mjs';
|
|
2
2
|
export { f as Client, e as ClientRest, d as HTTPMethod, H as HTTPPath } from './shared/client.4TS_0JaO.mjs';
|
|
3
|
-
import { Promisable, MaybeOptionalOptions, ThrowableError } from '@orpc/shared';
|
|
4
|
-
export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
3
|
+
import { Promisable, MaybeOptionalOptions, AsyncIteratorClass, ThrowableError } from '@orpc/shared';
|
|
4
|
+
export { EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
5
5
|
export { ErrorEvent } from '@orpc/standard-server';
|
|
6
6
|
|
|
7
7
|
interface createORPCClientOptions {
|
|
@@ -138,7 +138,7 @@ declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(jso
|
|
|
138
138
|
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
139
139
|
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
140
140
|
error: (error: unknown) => Promise<unknown>;
|
|
141
|
-
}):
|
|
141
|
+
}): AsyncIteratorClass<TMap, TMap, TNext>;
|
|
142
142
|
|
|
143
143
|
type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
144
144
|
error: null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientContext, b as ClientOptions, c as ClientPromiseResult, F as FriendlyClientOptions } from './shared/client.4TS_0JaO.js';
|
|
2
2
|
export { f as Client, e as ClientRest, d as HTTPMethod, H as HTTPPath } from './shared/client.4TS_0JaO.js';
|
|
3
|
-
import { Promisable, MaybeOptionalOptions, ThrowableError } from '@orpc/shared';
|
|
4
|
-
export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
3
|
+
import { Promisable, MaybeOptionalOptions, AsyncIteratorClass, ThrowableError } from '@orpc/shared';
|
|
4
|
+
export { EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
5
5
|
export { ErrorEvent } from '@orpc/standard-server';
|
|
6
6
|
|
|
7
7
|
interface createORPCClientOptions {
|
|
@@ -138,7 +138,7 @@ declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(jso
|
|
|
138
138
|
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
139
139
|
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
140
140
|
error: (error: unknown) => Promise<unknown>;
|
|
141
|
-
}):
|
|
141
|
+
}): AsyncIteratorClass<TMap, TMap, TNext>;
|
|
142
142
|
|
|
143
143
|
type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
144
144
|
error: null;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as isDefinedError } from './shared/client.
|
|
2
|
-
export { C as COMMON_ORPC_ERROR_DEFS, O as ORPCError, d as createORPCErrorFromJson, a as fallbackORPCErrorMessage, f as fallbackORPCErrorStatus, c as isORPCErrorJson, b as isORPCErrorStatus, m as mapEventIterator, t as toORPCError } from './shared/client.
|
|
3
|
-
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
1
|
+
import { i as isDefinedError } from './shared/client.DHOfWE0c.mjs';
|
|
2
|
+
export { C as COMMON_ORPC_ERROR_DEFS, O as ORPCError, d as createORPCErrorFromJson, a as fallbackORPCErrorMessage, f as fallbackORPCErrorStatus, c as isORPCErrorJson, b as isORPCErrorStatus, m as mapEventIterator, t as toORPCError } from './shared/client.DHOfWE0c.mjs';
|
|
3
|
+
export { EventPublisher, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
|
4
4
|
export { ErrorEvent } from '@orpc/standard-server';
|
|
5
5
|
|
|
6
6
|
async function safe(promise) {
|
|
@@ -27,7 +27,7 @@ async function safe(promise) {
|
|
|
27
27
|
function resolveFriendlyClientOptions(options) {
|
|
28
28
|
return {
|
|
29
29
|
...options,
|
|
30
|
-
context: options
|
|
30
|
+
context: options.context ?? {}
|
|
31
31
|
// Context only optional if all fields are optional
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -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,35 +141,32 @@ function createORPCErrorFromJson(json, options = {}) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
function mapEventIterator(iterator, maps) {
|
|
144
|
-
return async
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
return new AsyncIteratorClass(async () => {
|
|
145
|
+
const { done, value } = await (async () => {
|
|
146
|
+
try {
|
|
147
|
+
return await iterator.next();
|
|
148
|
+
} catch (error) {
|
|
149
|
+
let mappedError = await maps.error(error);
|
|
150
|
+
if (mappedError !== error) {
|
|
151
|
+
const meta = getEventMeta(error);
|
|
152
|
+
if (meta && isTypescriptObject(mappedError)) {
|
|
153
|
+
mappedError = withEventMeta(mappedError, meta);
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
-
return mappedValue;
|
|
157
|
-
}
|
|
158
|
-
yield mappedValue;
|
|
156
|
+
throw mappedError;
|
|
159
157
|
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
158
|
+
})();
|
|
159
|
+
let mappedValue = await maps.value(value, done);
|
|
160
|
+
if (mappedValue !== value) {
|
|
161
|
+
const meta = getEventMeta(value);
|
|
162
|
+
if (meta && isTypescriptObject(mappedValue)) {
|
|
163
|
+
mappedValue = withEventMeta(mappedValue, meta);
|
|
167
164
|
}
|
|
168
|
-
throw mappedError;
|
|
169
|
-
} finally {
|
|
170
|
-
await iterator.return?.();
|
|
171
165
|
}
|
|
172
|
-
|
|
166
|
+
return { done, value: mappedValue };
|
|
167
|
+
}, async () => {
|
|
168
|
+
await iterator.return?.();
|
|
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
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.
|
|
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.DHOfWE0c.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.
|
|
4
|
+
"version": "0.0.0-next.dda04c5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"dist"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@orpc/shared": "0.0.0-next.
|
|
53
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
54
|
-
"@orpc/standard-server-
|
|
55
|
-
"@orpc/standard-server-
|
|
52
|
+
"@orpc/shared": "0.0.0-next.dda04c5",
|
|
53
|
+
"@orpc/standard-server": "0.0.0-next.dda04c5",
|
|
54
|
+
"@orpc/standard-server-fetch": "0.0.0-next.dda04c5",
|
|
55
|
+
"@orpc/standard-server-peer": "0.0.0-next.dda04c5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"zod": "^3.25.
|
|
58
|
+
"zod": "^3.25.67"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|