@orpc/client 0.0.0-next.d760838 → 0.0.0-next.d7c4772
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 +19 -22
- package/dist/adapters/fetch/index.d.mts +31 -11
- package/dist/adapters/fetch/index.d.ts +31 -11
- package/dist/adapters/fetch/index.mjs +26 -13
- package/dist/adapters/message-port/index.d.mts +59 -0
- package/dist/adapters/message-port/index.d.ts +59 -0
- package/dist/adapters/message-port/index.mjs +71 -0
- package/dist/adapters/standard/index.d.mts +3 -3
- package/dist/adapters/standard/index.d.ts +3 -3
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.d.mts +29 -0
- package/dist/adapters/websocket/index.d.ts +29 -0
- package/dist/adapters/websocket/index.mjs +45 -0
- package/dist/index.d.mts +51 -21
- package/dist/index.d.ts +51 -21
- package/dist/index.mjs +25 -8
- package/dist/plugins/index.d.mts +103 -13
- package/dist/plugins/index.d.ts +103 -13
- package/dist/plugins/index.mjs +173 -29
- package/dist/shared/{client.C7z5zk4v.d.mts → client.BG98rYdO.d.ts} +16 -11
- package/dist/shared/{client.CipPQkhk.d.mts → client.BOYsZIRq.d.mts} +2 -2
- package/dist/shared/{client.CipPQkhk.d.ts → client.BOYsZIRq.d.ts} +2 -2
- package/dist/shared/{client.p3ON_yzu.d.ts → client.Bwgm6dgk.d.mts} +16 -11
- package/dist/shared/{client.CDvsX60w.d.ts → client.C176log5.d.ts} +13 -9
- package/dist/shared/{client.OLTJgDL8.mjs → client.DKmRtVO2.mjs} +74 -21
- package/dist/shared/{client.CUq1_W_X.d.mts → client.Ycwr4Tuo.d.mts} +13 -9
- package/dist/shared/{client.CRWEpqLB.mjs → client.txdq_i5V.mjs} +37 -32
- package/package.json +16 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as StandardLinkCodec, b as StandardLinkOptions } from './client.
|
|
3
|
-
import { Segment, Value } from '@orpc/shared';
|
|
1
|
+
import { b as ClientContext, c as ClientOptions, f as HTTPMethod } from './client.BOYsZIRq.mjs';
|
|
2
|
+
import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.Bwgm6dgk.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
|
|
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
|
|
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
|
|
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;
|
|
@@ -83,5 +83,9 @@ declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardL
|
|
|
83
83
|
|
|
84
84
|
interface StandardRPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardRPCLinkCodecOptions<T>, StandardRPCJsonSerializerOptions {
|
|
85
85
|
}
|
|
86
|
+
declare class StandardRPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
87
|
+
constructor(linkClient: StandardLinkClient<T>, options: StandardRPCLinkOptions<T>);
|
|
88
|
+
}
|
|
86
89
|
|
|
87
|
-
export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S,
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { isObject, isTypescriptObject } from '@orpc/shared';
|
|
1
|
+
import { resolveMaybeOptionalOptions, isObject, AsyncIteratorClass, isTypescriptObject } from '@orpc/shared';
|
|
2
2
|
import { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
|
3
3
|
|
|
4
4
|
const COMMON_ORPC_ERROR_DEFS = {
|
|
@@ -90,16 +90,17 @@ class ORPCError extends Error {
|
|
|
90
90
|
code;
|
|
91
91
|
status;
|
|
92
92
|
data;
|
|
93
|
-
constructor(code, ...
|
|
94
|
-
|
|
93
|
+
constructor(code, ...rest) {
|
|
94
|
+
const options = resolveMaybeOptionalOptions(rest);
|
|
95
|
+
if (options.status !== void 0 && !isORPCErrorStatus(options.status)) {
|
|
95
96
|
throw new Error("[ORPCError] Invalid error status code.");
|
|
96
97
|
}
|
|
97
|
-
const message = fallbackORPCErrorMessage(code, options
|
|
98
|
+
const message = fallbackORPCErrorMessage(code, options.message);
|
|
98
99
|
super(message, options);
|
|
99
100
|
this.code = code;
|
|
100
|
-
this.status = fallbackORPCErrorStatus(code, options
|
|
101
|
-
this.defined = options
|
|
102
|
-
this.data = options
|
|
101
|
+
this.status = fallbackORPCErrorStatus(code, options.status);
|
|
102
|
+
this.defined = options.defined ?? false;
|
|
103
|
+
this.data = options.data;
|
|
103
104
|
}
|
|
104
105
|
toJSON() {
|
|
105
106
|
return {
|
|
@@ -141,35 +142,39 @@ function createORPCErrorFromJson(json, options = {}) {
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
function mapEventIterator(iterator, maps) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const meta = getEventMeta(value);
|
|
151
|
-
if (meta && isTypescriptObject(mappedValue)) {
|
|
152
|
-
mappedValue = withEventMeta(mappedValue, meta);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (done) {
|
|
156
|
-
return mappedValue;
|
|
157
|
-
}
|
|
158
|
-
yield mappedValue;
|
|
145
|
+
const mapError = async (error) => {
|
|
146
|
+
let mappedError = await maps.error(error);
|
|
147
|
+
if (mappedError !== error) {
|
|
148
|
+
const meta = getEventMeta(error);
|
|
149
|
+
if (meta && isTypescriptObject(mappedError)) {
|
|
150
|
+
mappedError = withEventMeta(mappedError, meta);
|
|
159
151
|
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
152
|
+
}
|
|
153
|
+
return mappedError;
|
|
154
|
+
};
|
|
155
|
+
return new AsyncIteratorClass(async () => {
|
|
156
|
+
const { done, value } = await (async () => {
|
|
157
|
+
try {
|
|
158
|
+
return await iterator.next();
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw await mapError(error);
|
|
161
|
+
}
|
|
162
|
+
})();
|
|
163
|
+
let mappedValue = await maps.value(value, done);
|
|
164
|
+
if (mappedValue !== value) {
|
|
165
|
+
const meta = getEventMeta(value);
|
|
166
|
+
if (meta && isTypescriptObject(mappedValue)) {
|
|
167
|
+
mappedValue = withEventMeta(mappedValue, meta);
|
|
167
168
|
}
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
}
|
|
170
|
+
return { done, value: mappedValue };
|
|
171
|
+
}, async () => {
|
|
172
|
+
try {
|
|
170
173
|
await iterator.return?.();
|
|
174
|
+
} catch (error) {
|
|
175
|
+
throw await mapError(error);
|
|
171
176
|
}
|
|
172
|
-
}
|
|
177
|
+
});
|
|
173
178
|
}
|
|
174
179
|
|
|
175
180
|
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 };
|
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.d7c4772",
|
|
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/
|
|
43
|
-
"@orpc/
|
|
44
|
-
"@orpc/standard-server-fetch": "0.0.0-next.
|
|
52
|
+
"@orpc/standard-server": "0.0.0-next.d7c4772",
|
|
53
|
+
"@orpc/shared": "0.0.0-next.d7c4772",
|
|
54
|
+
"@orpc/standard-server-fetch": "0.0.0-next.d7c4772",
|
|
55
|
+
"@orpc/standard-server-peer": "0.0.0-next.d7c4772"
|
|
45
56
|
},
|
|
46
57
|
"devDependencies": {
|
|
47
|
-
"zod": "^
|
|
58
|
+
"zod": "^4.0.17"
|
|
48
59
|
},
|
|
49
60
|
"scripts": {
|
|
50
61
|
"build": "unbuild",
|