@orpc/client 0.0.0-next.c72b962 → 0.0.0-next.c79fd64
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 +72 -0
- package/dist/adapters/standard/index.d.mts +6 -5
- package/dist/adapters/standard/index.d.ts +6 -5
- package/dist/adapters/standard/index.mjs +3 -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 +46 -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 +75 -16
- package/dist/plugins/index.d.ts +75 -16
- package/dist/plugins/index.mjs +139 -29
- package/dist/shared/{client.DUjXqpDq.d.ts → client.BG98rYdO.d.ts} +13 -15
- package/dist/shared/{client.CipPQkhk.d.ts → client.BOYsZIRq.d.mts} +2 -2
- package/dist/shared/{client.CipPQkhk.d.mts → client.BOYsZIRq.d.ts} +2 -2
- package/dist/shared/{client.vy3P78P6.mjs → client.Bp1jlnBk.mjs} +71 -22
- package/dist/shared/{client.2CWETx1V.d.mts → client.Bwgm6dgk.d.mts} +13 -15
- package/dist/shared/{client.BCCZFC-T.d.ts → client.CVVVqf1Y.d.ts} +13 -9
- package/dist/shared/{client.DcDnlyRo.d.mts → client._Y_enhib.d.mts} +13 -9
- package/dist/shared/{client.CRWEpqLB.mjs → client.txdq_i5V.mjs} +37 -32
- package/package.json +16 -5
|
@@ -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.c79fd64",
|
|
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.
|
|
43
|
-
"@orpc/standard-server
|
|
44
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
52
|
+
"@orpc/shared": "0.0.0-next.c79fd64",
|
|
53
|
+
"@orpc/standard-server": "0.0.0-next.c79fd64",
|
|
54
|
+
"@orpc/standard-server-fetch": "0.0.0-next.c79fd64",
|
|
55
|
+
"@orpc/standard-server-peer": "0.0.0-next.c79fd64"
|
|
45
56
|
},
|
|
46
57
|
"devDependencies": {
|
|
47
|
-
"zod": "^
|
|
58
|
+
"zod": "^4.1.5"
|
|
48
59
|
},
|
|
49
60
|
"scripts": {
|
|
50
61
|
"build": "unbuild",
|