@arrirpc/client 0.67.0 → 0.69.0
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/dist/index.cjs +12 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +12 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -116,16 +116,20 @@ async function arriRequest(opts) {
|
|
|
116
116
|
return opts.responseFromJson(result);
|
|
117
117
|
} catch (err) {
|
|
118
118
|
const error = err;
|
|
119
|
+
let arriError;
|
|
119
120
|
if (isArriError(error.data)) {
|
|
120
|
-
|
|
121
|
+
arriError = new ArriErrorInstance(error.data);
|
|
121
122
|
} else {
|
|
122
|
-
|
|
123
|
+
arriError = new ArriErrorInstance({
|
|
123
124
|
code: error.statusCode ?? 500,
|
|
124
125
|
message: error.statusMessage ?? error.message ?? `Error connecting to ${url}`,
|
|
125
126
|
data: error.data,
|
|
126
127
|
stack: error.stack
|
|
127
128
|
});
|
|
128
129
|
}
|
|
130
|
+
if (opts.onError)
|
|
131
|
+
opts.onError(arriError);
|
|
132
|
+
throw arriError;
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
async function arriSafeRequest(opts) {
|
|
@@ -235,6 +239,9 @@ function arriSseRequest(opts, options) {
|
|
|
235
239
|
options.onRequest?.(context);
|
|
236
240
|
},
|
|
237
241
|
onRequestError(context) {
|
|
242
|
+
if (opts.onError) {
|
|
243
|
+
opts.onError(context.error);
|
|
244
|
+
}
|
|
238
245
|
options.onRequestError?.({
|
|
239
246
|
...context,
|
|
240
247
|
error: new ArriErrorInstance({
|
|
@@ -248,6 +255,9 @@ function arriSseRequest(opts, options) {
|
|
|
248
255
|
options.onResponse?.(context);
|
|
249
256
|
},
|
|
250
257
|
async onResponseError(context) {
|
|
258
|
+
if (opts.onError) {
|
|
259
|
+
opts.onError(context.error);
|
|
260
|
+
}
|
|
251
261
|
if (!options.onResponseError) {
|
|
252
262
|
return;
|
|
253
263
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -35,6 +35,7 @@ interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined =
|
|
|
35
35
|
params?: TParams;
|
|
36
36
|
responseFromJson: (input: Record<string, unknown>) => TType;
|
|
37
37
|
responseFromString: (input: string) => TType;
|
|
38
|
+
onError?: (err: unknown) => void;
|
|
38
39
|
serializer: (input: TParams) => TParams extends undefined ? undefined : string;
|
|
39
40
|
clientVersion: string;
|
|
40
41
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,7 @@ interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined =
|
|
|
35
35
|
params?: TParams;
|
|
36
36
|
responseFromJson: (input: Record<string, unknown>) => TType;
|
|
37
37
|
responseFromString: (input: string) => TType;
|
|
38
|
+
onError?: (err: unknown) => void;
|
|
38
39
|
serializer: (input: TParams) => TParams extends undefined ? undefined : string;
|
|
39
40
|
clientVersion: string;
|
|
40
41
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined =
|
|
|
35
35
|
params?: TParams;
|
|
36
36
|
responseFromJson: (input: Record<string, unknown>) => TType;
|
|
37
37
|
responseFromString: (input: string) => TType;
|
|
38
|
+
onError?: (err: unknown) => void;
|
|
38
39
|
serializer: (input: TParams) => TParams extends undefined ? undefined : string;
|
|
39
40
|
clientVersion: string;
|
|
40
41
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -111,16 +111,20 @@ async function arriRequest(opts) {
|
|
|
111
111
|
return opts.responseFromJson(result);
|
|
112
112
|
} catch (err) {
|
|
113
113
|
const error = err;
|
|
114
|
+
let arriError;
|
|
114
115
|
if (isArriError(error.data)) {
|
|
115
|
-
|
|
116
|
+
arriError = new ArriErrorInstance(error.data);
|
|
116
117
|
} else {
|
|
117
|
-
|
|
118
|
+
arriError = new ArriErrorInstance({
|
|
118
119
|
code: error.statusCode ?? 500,
|
|
119
120
|
message: error.statusMessage ?? error.message ?? `Error connecting to ${url}`,
|
|
120
121
|
data: error.data,
|
|
121
122
|
stack: error.stack
|
|
122
123
|
});
|
|
123
124
|
}
|
|
125
|
+
if (opts.onError)
|
|
126
|
+
opts.onError(arriError);
|
|
127
|
+
throw arriError;
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
async function arriSafeRequest(opts) {
|
|
@@ -230,6 +234,9 @@ function arriSseRequest(opts, options) {
|
|
|
230
234
|
options.onRequest?.(context);
|
|
231
235
|
},
|
|
232
236
|
onRequestError(context) {
|
|
237
|
+
if (opts.onError) {
|
|
238
|
+
opts.onError(context.error);
|
|
239
|
+
}
|
|
233
240
|
options.onRequestError?.({
|
|
234
241
|
...context,
|
|
235
242
|
error: new ArriErrorInstance({
|
|
@@ -243,6 +250,9 @@ function arriSseRequest(opts, options) {
|
|
|
243
250
|
options.onResponse?.(context);
|
|
244
251
|
},
|
|
245
252
|
async onResponseError(context) {
|
|
253
|
+
if (opts.onError) {
|
|
254
|
+
opts.onError(context.error);
|
|
255
|
+
}
|
|
246
256
|
if (!options.onResponseError) {
|
|
247
257
|
return;
|
|
248
258
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"event-source-plus": "^0.1.8",
|
|
26
26
|
"ofetch": "^1.4.1",
|
|
27
27
|
"ws": "^8.18.0",
|
|
28
|
-
"@arrirpc/schema": "0.
|
|
28
|
+
"@arrirpc/schema": "0.69.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.5.13"
|