@arrirpc/server 0.63.2 → 0.64.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 +9 -9
- package/dist/index.d.cts +7 -7
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +8 -8
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ var __publicField$5 = (obj, key, value) => {
|
|
|
11
11
|
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
12
12
|
return value;
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class arriError extends Error {
|
|
15
15
|
constructor(err) {
|
|
16
16
|
super(err.message);
|
|
17
17
|
__publicField$5(this, "code");
|
|
@@ -23,7 +23,7 @@ class ArriServerError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const arriErrorResponse = schema.a.object({
|
|
27
27
|
code: schema.a.int16(),
|
|
28
28
|
message: schema.a.string(),
|
|
29
29
|
stack: schema.a.optional(schema.a.array(schema.a.string())),
|
|
@@ -31,7 +31,7 @@ const ArriServerErrorResponse = schema.a.object({
|
|
|
31
31
|
});
|
|
32
32
|
function defineError(statusCode, input = {}) {
|
|
33
33
|
const defaultVals = errorResponseDefaults[statusCode];
|
|
34
|
-
return new
|
|
34
|
+
return new arriError({
|
|
35
35
|
code: statusCode,
|
|
36
36
|
message: input.message ?? defaultVals?.message ?? "An unknown error occurred",
|
|
37
37
|
data: input.data
|
|
@@ -205,24 +205,24 @@ const errorResponseDefaults = {
|
|
|
205
205
|
};
|
|
206
206
|
async function handleH3Error(err, event, onError, debug) {
|
|
207
207
|
let arriErr;
|
|
208
|
-
if (err instanceof
|
|
208
|
+
if (err instanceof arriError) {
|
|
209
209
|
arriErr = err;
|
|
210
210
|
} else if (h3.isError(err)) {
|
|
211
|
-
arriErr = new
|
|
211
|
+
arriErr = new arriError({
|
|
212
212
|
code: err.statusCode,
|
|
213
213
|
message: err.message,
|
|
214
214
|
stack: err.stack,
|
|
215
215
|
data: err.data
|
|
216
216
|
});
|
|
217
217
|
} else if (err instanceof Error) {
|
|
218
|
-
arriErr = new
|
|
218
|
+
arriErr = new arriError({
|
|
219
219
|
code: 500,
|
|
220
220
|
message: err.message,
|
|
221
221
|
data: err,
|
|
222
222
|
stack: err.stack
|
|
223
223
|
});
|
|
224
224
|
} else {
|
|
225
|
-
arriErr = new
|
|
225
|
+
arriErr = new arriError({
|
|
226
226
|
code: 500,
|
|
227
227
|
message: `An unknown error occurred`,
|
|
228
228
|
data: err
|
|
@@ -1128,11 +1128,11 @@ const defineMiddleware = (middleware) => middleware;
|
|
|
1128
1128
|
|
|
1129
1129
|
exports.ArriApp = ArriApp;
|
|
1130
1130
|
exports.ArriRouter = ArriRouter;
|
|
1131
|
-
exports.ArriServerError = ArriServerError;
|
|
1132
|
-
exports.ArriServerErrorResponse = ArriServerErrorResponse;
|
|
1133
1131
|
exports.ArriService = ArriService;
|
|
1134
1132
|
exports.EventStreamConnection = EventStreamConnection;
|
|
1135
1133
|
exports.WsPeer = WsPeer;
|
|
1134
|
+
exports.arriError = arriError;
|
|
1135
|
+
exports.arriErrorResponse = arriErrorResponse;
|
|
1136
1136
|
exports.createAppDefinition = createAppDefinition;
|
|
1137
1137
|
exports.createHttpRpcDefinition = createHttpRpcDefinition;
|
|
1138
1138
|
exports.createWsRpcDefinition = createWsRpcDefinition;
|
package/dist/index.d.cts
CHANGED
|
@@ -38,7 +38,7 @@ type RequestHookContext = ArriEventContext & {
|
|
|
38
38
|
response?: unknown;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
declare class
|
|
41
|
+
declare class arriError extends Error {
|
|
42
42
|
code: number;
|
|
43
43
|
data?: any;
|
|
44
44
|
constructor(err: {
|
|
@@ -48,14 +48,14 @@ declare class ArriServerError extends Error {
|
|
|
48
48
|
stack?: string;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
declare const
|
|
51
|
+
declare const arriErrorResponse: AObjectSchema<{
|
|
52
52
|
code: number;
|
|
53
53
|
message: string;
|
|
54
54
|
stack?: string[];
|
|
55
55
|
data?: any;
|
|
56
56
|
}>;
|
|
57
|
-
type
|
|
58
|
-
declare function defineError(statusCode: StatusCode, input?: Partial<Omit<
|
|
57
|
+
type arriErrorResponse = a.infer<typeof arriErrorResponse>;
|
|
58
|
+
declare function defineError(statusCode: StatusCode, input?: Partial<Omit<arriErrorResponse, "code" | "stack">>): arriError;
|
|
59
59
|
declare function errorResponseFromValidationErrors(errors: ValidationError["errors"], prefixText?: string): H3Error;
|
|
60
60
|
declare function handleH3Error(err: unknown, event: H3Event, onError: ArriOptions["onError"], debug: boolean): Promise<void>;
|
|
61
61
|
|
|
@@ -171,7 +171,7 @@ declare class WsPeer<TResponse> {
|
|
|
171
171
|
url: string;
|
|
172
172
|
constructor(peer: Peer, opts: WsPeerOpts<TResponse>);
|
|
173
173
|
send(data: TResponse): number | void;
|
|
174
|
-
sendError(err:
|
|
174
|
+
sendError(err: arriErrorResponse): number | void | undefined;
|
|
175
175
|
close(): void;
|
|
176
176
|
subscribe(channel: string): void;
|
|
177
177
|
unsubscribe(channel: string): void;
|
|
@@ -292,10 +292,10 @@ interface ArriOptions {
|
|
|
292
292
|
onRequest?: (event: MiddlewareEvent) => void | Promise<void>;
|
|
293
293
|
onAfterResponse?: (event: RequestHookEvent) => void | Promise<void>;
|
|
294
294
|
onBeforeResponse?: (event: RequestHookEvent) => void | Promise<void>;
|
|
295
|
-
onError?: (error:
|
|
295
|
+
onError?: (error: arriError, event: RequestHookEvent) => void | Promise<void>;
|
|
296
296
|
}
|
|
297
297
|
interface RequestHookEvent extends Omit<H3Event, "context"> {
|
|
298
298
|
context: RequestHookContext;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
export { ArriApp, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter,
|
|
301
|
+
export { ArriApp, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter, ArriService, type DefinitionMap, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type HttpRpc, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type NamedHttpRpc, type NamedWebsocketRpc, type PostRouteEvent, type RequestHookContext, type RequestHookEvent, type RouteEvent, type RouteEventContext, type RouteOptions, type RoutePostEventContext, type Rpc, type RpcEvent, type RpcEventContext, type RpcHandler, type RpcParamSchema, type RpcPostEvent, type RpcPostEventContext, type RpcPostHandler, type SsePushResult, type WebSocketRpcHandler, type WebsocketRpc, WsPeer, type WsPeerContext, arriError, arriErrorResponse, createAppDefinition, createHttpRpcDefinition, createWsRpcDefinition, defineError, defineEventStreamRpc, defineMiddleware, defineRoute, defineRpc, defineService, defineWebsocketRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, getSchemaValidator, handleH3Error, handleRoute, isEventStreamRpc, isRpc, isRpcParamSchema, registerEventStreamRpc, registerRoute, registerRpc, registerWebsocketRpc, validateRpcRequestInput };
|
package/dist/index.d.mts
CHANGED
|
@@ -38,7 +38,7 @@ type RequestHookContext = ArriEventContext & {
|
|
|
38
38
|
response?: unknown;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
declare class
|
|
41
|
+
declare class arriError extends Error {
|
|
42
42
|
code: number;
|
|
43
43
|
data?: any;
|
|
44
44
|
constructor(err: {
|
|
@@ -48,14 +48,14 @@ declare class ArriServerError extends Error {
|
|
|
48
48
|
stack?: string;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
declare const
|
|
51
|
+
declare const arriErrorResponse: AObjectSchema<{
|
|
52
52
|
code: number;
|
|
53
53
|
message: string;
|
|
54
54
|
stack?: string[];
|
|
55
55
|
data?: any;
|
|
56
56
|
}>;
|
|
57
|
-
type
|
|
58
|
-
declare function defineError(statusCode: StatusCode, input?: Partial<Omit<
|
|
57
|
+
type arriErrorResponse = a.infer<typeof arriErrorResponse>;
|
|
58
|
+
declare function defineError(statusCode: StatusCode, input?: Partial<Omit<arriErrorResponse, "code" | "stack">>): arriError;
|
|
59
59
|
declare function errorResponseFromValidationErrors(errors: ValidationError["errors"], prefixText?: string): H3Error;
|
|
60
60
|
declare function handleH3Error(err: unknown, event: H3Event, onError: ArriOptions["onError"], debug: boolean): Promise<void>;
|
|
61
61
|
|
|
@@ -171,7 +171,7 @@ declare class WsPeer<TResponse> {
|
|
|
171
171
|
url: string;
|
|
172
172
|
constructor(peer: Peer, opts: WsPeerOpts<TResponse>);
|
|
173
173
|
send(data: TResponse): number | void;
|
|
174
|
-
sendError(err:
|
|
174
|
+
sendError(err: arriErrorResponse): number | void | undefined;
|
|
175
175
|
close(): void;
|
|
176
176
|
subscribe(channel: string): void;
|
|
177
177
|
unsubscribe(channel: string): void;
|
|
@@ -292,10 +292,10 @@ interface ArriOptions {
|
|
|
292
292
|
onRequest?: (event: MiddlewareEvent) => void | Promise<void>;
|
|
293
293
|
onAfterResponse?: (event: RequestHookEvent) => void | Promise<void>;
|
|
294
294
|
onBeforeResponse?: (event: RequestHookEvent) => void | Promise<void>;
|
|
295
|
-
onError?: (error:
|
|
295
|
+
onError?: (error: arriError, event: RequestHookEvent) => void | Promise<void>;
|
|
296
296
|
}
|
|
297
297
|
interface RequestHookEvent extends Omit<H3Event, "context"> {
|
|
298
298
|
context: RequestHookContext;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
export { ArriApp, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter,
|
|
301
|
+
export { ArriApp, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter, ArriService, type DefinitionMap, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type HttpRpc, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type NamedHttpRpc, type NamedWebsocketRpc, type PostRouteEvent, type RequestHookContext, type RequestHookEvent, type RouteEvent, type RouteEventContext, type RouteOptions, type RoutePostEventContext, type Rpc, type RpcEvent, type RpcEventContext, type RpcHandler, type RpcParamSchema, type RpcPostEvent, type RpcPostEventContext, type RpcPostHandler, type SsePushResult, type WebSocketRpcHandler, type WebsocketRpc, WsPeer, type WsPeerContext, arriError, arriErrorResponse, createAppDefinition, createHttpRpcDefinition, createWsRpcDefinition, defineError, defineEventStreamRpc, defineMiddleware, defineRoute, defineRpc, defineService, defineWebsocketRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, getSchemaValidator, handleH3Error, handleRoute, isEventStreamRpc, isRpc, isRpcParamSchema, registerEventStreamRpc, registerRoute, registerRpc, registerWebsocketRpc, validateRpcRequestInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ type RequestHookContext = ArriEventContext & {
|
|
|
38
38
|
response?: unknown;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
declare class
|
|
41
|
+
declare class arriError extends Error {
|
|
42
42
|
code: number;
|
|
43
43
|
data?: any;
|
|
44
44
|
constructor(err: {
|
|
@@ -48,14 +48,14 @@ declare class ArriServerError extends Error {
|
|
|
48
48
|
stack?: string;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
declare const
|
|
51
|
+
declare const arriErrorResponse: AObjectSchema<{
|
|
52
52
|
code: number;
|
|
53
53
|
message: string;
|
|
54
54
|
stack?: string[];
|
|
55
55
|
data?: any;
|
|
56
56
|
}>;
|
|
57
|
-
type
|
|
58
|
-
declare function defineError(statusCode: StatusCode, input?: Partial<Omit<
|
|
57
|
+
type arriErrorResponse = a.infer<typeof arriErrorResponse>;
|
|
58
|
+
declare function defineError(statusCode: StatusCode, input?: Partial<Omit<arriErrorResponse, "code" | "stack">>): arriError;
|
|
59
59
|
declare function errorResponseFromValidationErrors(errors: ValidationError["errors"], prefixText?: string): H3Error;
|
|
60
60
|
declare function handleH3Error(err: unknown, event: H3Event, onError: ArriOptions["onError"], debug: boolean): Promise<void>;
|
|
61
61
|
|
|
@@ -171,7 +171,7 @@ declare class WsPeer<TResponse> {
|
|
|
171
171
|
url: string;
|
|
172
172
|
constructor(peer: Peer, opts: WsPeerOpts<TResponse>);
|
|
173
173
|
send(data: TResponse): number | void;
|
|
174
|
-
sendError(err:
|
|
174
|
+
sendError(err: arriErrorResponse): number | void | undefined;
|
|
175
175
|
close(): void;
|
|
176
176
|
subscribe(channel: string): void;
|
|
177
177
|
unsubscribe(channel: string): void;
|
|
@@ -292,10 +292,10 @@ interface ArriOptions {
|
|
|
292
292
|
onRequest?: (event: MiddlewareEvent) => void | Promise<void>;
|
|
293
293
|
onAfterResponse?: (event: RequestHookEvent) => void | Promise<void>;
|
|
294
294
|
onBeforeResponse?: (event: RequestHookEvent) => void | Promise<void>;
|
|
295
|
-
onError?: (error:
|
|
295
|
+
onError?: (error: arriError, event: RequestHookEvent) => void | Promise<void>;
|
|
296
296
|
}
|
|
297
297
|
interface RequestHookEvent extends Omit<H3Event, "context"> {
|
|
298
298
|
context: RequestHookContext;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
export { ArriApp, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter,
|
|
301
|
+
export { ArriApp, type ArriEventContext, type ArriOptions, type ArriRoute, ArriRouter, ArriService, type DefinitionMap, EventStreamConnection, type EventStreamConnectionOptions, type EventStreamRpc, type EventStreamRpcHandler, type EventStreamRpcHandlerContext, type ExtractParam, type ExtractParams, type HttpRpc, type Middleware, type MiddlewareEvent, type MiddlewareEventContext, type NamedHttpRpc, type NamedWebsocketRpc, type PostRouteEvent, type RequestHookContext, type RequestHookEvent, type RouteEvent, type RouteEventContext, type RouteOptions, type RoutePostEventContext, type Rpc, type RpcEvent, type RpcEventContext, type RpcHandler, type RpcParamSchema, type RpcPostEvent, type RpcPostEventContext, type RpcPostHandler, type SsePushResult, type WebSocketRpcHandler, type WebsocketRpc, WsPeer, type WsPeerContext, arriError, arriErrorResponse, createAppDefinition, createHttpRpcDefinition, createWsRpcDefinition, defineError, defineEventStreamRpc, defineMiddleware, defineRoute, defineRpc, defineService, defineWebsocketRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, getSchemaValidator, handleH3Error, handleRoute, isEventStreamRpc, isRpc, isRpcParamSchema, registerEventStreamRpc, registerRoute, registerRpc, registerWebsocketRpc, validateRpcRequestInput };
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ var __publicField$5 = (obj, key, value) => {
|
|
|
10
10
|
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
11
|
return value;
|
|
12
12
|
};
|
|
13
|
-
class
|
|
13
|
+
class arriError extends Error {
|
|
14
14
|
constructor(err) {
|
|
15
15
|
super(err.message);
|
|
16
16
|
__publicField$5(this, "code");
|
|
@@ -22,7 +22,7 @@ class ArriServerError extends Error {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const arriErrorResponse = a.object({
|
|
26
26
|
code: a.int16(),
|
|
27
27
|
message: a.string(),
|
|
28
28
|
stack: a.optional(a.array(a.string())),
|
|
@@ -30,7 +30,7 @@ const ArriServerErrorResponse = a.object({
|
|
|
30
30
|
});
|
|
31
31
|
function defineError(statusCode, input = {}) {
|
|
32
32
|
const defaultVals = errorResponseDefaults[statusCode];
|
|
33
|
-
return new
|
|
33
|
+
return new arriError({
|
|
34
34
|
code: statusCode,
|
|
35
35
|
message: input.message ?? defaultVals?.message ?? "An unknown error occurred",
|
|
36
36
|
data: input.data
|
|
@@ -204,24 +204,24 @@ const errorResponseDefaults = {
|
|
|
204
204
|
};
|
|
205
205
|
async function handleH3Error(err, event, onError, debug) {
|
|
206
206
|
let arriErr;
|
|
207
|
-
if (err instanceof
|
|
207
|
+
if (err instanceof arriError) {
|
|
208
208
|
arriErr = err;
|
|
209
209
|
} else if (isError(err)) {
|
|
210
|
-
arriErr = new
|
|
210
|
+
arriErr = new arriError({
|
|
211
211
|
code: err.statusCode,
|
|
212
212
|
message: err.message,
|
|
213
213
|
stack: err.stack,
|
|
214
214
|
data: err.data
|
|
215
215
|
});
|
|
216
216
|
} else if (err instanceof Error) {
|
|
217
|
-
arriErr = new
|
|
217
|
+
arriErr = new arriError({
|
|
218
218
|
code: 500,
|
|
219
219
|
message: err.message,
|
|
220
220
|
data: err,
|
|
221
221
|
stack: err.stack
|
|
222
222
|
});
|
|
223
223
|
} else {
|
|
224
|
-
arriErr = new
|
|
224
|
+
arriErr = new arriError({
|
|
225
225
|
code: 500,
|
|
226
226
|
message: `An unknown error occurred`,
|
|
227
227
|
data: err
|
|
@@ -1125,4 +1125,4 @@ class ArriApp {
|
|
|
1125
1125
|
|
|
1126
1126
|
const defineMiddleware = (middleware) => middleware;
|
|
1127
1127
|
|
|
1128
|
-
export { ArriApp, ArriRouter,
|
|
1128
|
+
export { ArriApp, ArriRouter, ArriService, EventStreamConnection, WsPeer, arriError, arriErrorResponse, createAppDefinition, createHttpRpcDefinition, createWsRpcDefinition, defineError, defineEventStreamRpc, defineMiddleware, defineRoute, defineRpc, defineService, defineWebsocketRpc, errorResponseFromValidationErrors, getRpcParamName, getRpcPath, getRpcResponseName, getSchemaValidator, handleH3Error, handleRoute, isEventStreamRpc, isRpc, isRpcParamSchema, registerEventStreamRpc, registerRoute, registerRpc, registerWebsocketRpc, validateRpcRequestInput };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"scule": "^1.3.0",
|
|
29
29
|
"source-map-support": "^0.5.21",
|
|
30
30
|
"uncrypto": "^0.1.3",
|
|
31
|
-
"@arrirpc/codegen-dart": "0.
|
|
32
|
-
"@arrirpc/codegen-kotlin": "0.
|
|
33
|
-
"@arrirpc/codegen-
|
|
34
|
-
"@arrirpc/
|
|
35
|
-
"arri": "0.
|
|
36
|
-
"@arrirpc/
|
|
31
|
+
"@arrirpc/codegen-dart": "0.64.0",
|
|
32
|
+
"@arrirpc/codegen-kotlin": "0.64.0",
|
|
33
|
+
"@arrirpc/codegen-utils": "0.64.0",
|
|
34
|
+
"@arrirpc/schema": "0.64.0",
|
|
35
|
+
"arri": "0.64.0",
|
|
36
|
+
"@arrirpc/codegen-ts": "0.64.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"bun-types": "^1.1.
|
|
39
|
+
"bun-types": "^1.1.34"
|
|
40
40
|
}
|
|
41
41
|
}
|