@kevisual/router 0.2.4 → 0.2.6
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 +13 -12
- package/dist/app.js +131 -119
- package/dist/commander.d.ts +31 -14
- package/dist/commander.js +134 -122
- package/dist/opencode.d.ts +22 -12
- package/dist/opencode.js +84 -84
- package/dist/router-browser.d.ts +24 -33
- package/dist/router-browser.js +93 -93
- package/dist/router-define.d.ts +20 -13
- package/dist/router-simple.d.ts +3 -2
- package/dist/router-simple.js +193 -177
- package/dist/router.d.ts +32 -35
- package/dist/router.js +127 -116
- package/dist/ws.d.ts +22 -12
- package/dist/ws.js +34 -23
- package/package.json +7 -7
- package/src/auto/listen/server-time.ts +1 -1
- package/src/browser.ts +0 -2
- package/src/commander.ts +49 -37
- package/src/index.ts +0 -2
- package/src/route.ts +12 -11
- package/src/router-simple.ts +1 -1
- package/src/test/api.d.ts +72 -0
- package/src/test/api.js +1 -0
- package/src/test/cli.ts +0 -0
- package/src/test/mini.ts +11 -3
- package/src/test/route-ts.ts +1 -1
- package/src/test/run-schema.ts +2 -1
- package/src/test/static.ts +1 -1
- package/src/test/ws.ts +1 -0
- package/src/utils/listen-process.ts +1 -1
- package/src/test/define.ts +0 -14
- package/src/test/listen-ip.ts +0 -18
- package/src/test/schema.ts +0 -14
package/dist/router-browser.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare class CustomError extends Error {
|
|
|
16
16
|
static fromCode(code?: number): CustomError;
|
|
17
17
|
static fromErrorData(code?: number, data?: any): CustomError;
|
|
18
18
|
static parseError(e: CustomError): {
|
|
19
|
-
code: number
|
|
19
|
+
code: number;
|
|
20
20
|
data: any;
|
|
21
21
|
message: string;
|
|
22
22
|
};
|
|
@@ -30,7 +30,7 @@ declare class CustomError extends Error {
|
|
|
30
30
|
static throw(code?: number | string, opts?: CustomErrorOptions): void;
|
|
31
31
|
static throw(opts?: CustomErrorOptions): void;
|
|
32
32
|
parse(e?: CustomError): {
|
|
33
|
-
code: number
|
|
33
|
+
code: number;
|
|
34
34
|
data: any;
|
|
35
35
|
message: string;
|
|
36
36
|
};
|
|
@@ -53,22 +53,6 @@ declare class MockProcess {
|
|
|
53
53
|
on(fn: (msg?: any) => any): void;
|
|
54
54
|
desctroy(): void;
|
|
55
55
|
}
|
|
56
|
-
type ListenProcessParams = {
|
|
57
|
-
message?: RunMessage;
|
|
58
|
-
context?: any;
|
|
59
|
-
};
|
|
60
|
-
type ListenProcessResponse = {
|
|
61
|
-
success?: boolean;
|
|
62
|
-
data?: {
|
|
63
|
-
code?: number;
|
|
64
|
-
data?: any;
|
|
65
|
-
message?: string;
|
|
66
|
-
[key: string]: any;
|
|
67
|
-
};
|
|
68
|
-
error?: any;
|
|
69
|
-
timestamp?: string;
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
};
|
|
72
56
|
|
|
73
57
|
type RouterContextT = {
|
|
74
58
|
code?: number;
|
|
@@ -226,7 +210,7 @@ declare class Route<M extends SimpleObject$1 = SimpleObject$1, U extends SimpleO
|
|
|
226
210
|
description?: string;
|
|
227
211
|
metadata?: M;
|
|
228
212
|
middleware?: RouteMiddleware[];
|
|
229
|
-
type?: string
|
|
213
|
+
type?: string;
|
|
230
214
|
/**
|
|
231
215
|
* 是否开启debug,开启后会打印错误信息
|
|
232
216
|
*/
|
|
@@ -319,6 +303,7 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
319
303
|
path: string;
|
|
320
304
|
key?: string;
|
|
321
305
|
payload?: any;
|
|
306
|
+
args?: any;
|
|
322
307
|
}, ctx?: RouteContext<T> & {
|
|
323
308
|
[key: string]: any;
|
|
324
309
|
}): Promise<RouteContext<T, {}, {
|
|
@@ -335,13 +320,14 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
335
320
|
path?: string;
|
|
336
321
|
key?: string;
|
|
337
322
|
payload?: any;
|
|
323
|
+
args?: any;
|
|
338
324
|
}, ctx?: RouteContext<T> & {
|
|
339
325
|
[key: string]: any;
|
|
340
326
|
}): Promise<RouteContext<T, {}, {
|
|
341
327
|
[key: string]: any;
|
|
342
328
|
}> | {
|
|
343
329
|
code: number;
|
|
344
|
-
body:
|
|
330
|
+
body: any;
|
|
345
331
|
message: string;
|
|
346
332
|
}>;
|
|
347
333
|
/**
|
|
@@ -356,12 +342,13 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
356
342
|
path: string;
|
|
357
343
|
key?: string;
|
|
358
344
|
payload?: any;
|
|
345
|
+
args?: any;
|
|
359
346
|
}, ctx?: RouteContext & {
|
|
360
347
|
[key: string]: any;
|
|
361
348
|
}): Promise<{
|
|
362
|
-
code: number
|
|
363
|
-
data:
|
|
364
|
-
message: string
|
|
349
|
+
code: number;
|
|
350
|
+
data: any;
|
|
351
|
+
message: string;
|
|
365
352
|
}>;
|
|
366
353
|
/**
|
|
367
354
|
* Router Run获取数据
|
|
@@ -374,12 +361,13 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
374
361
|
path?: string;
|
|
375
362
|
key?: string;
|
|
376
363
|
payload?: any;
|
|
364
|
+
args?: any;
|
|
377
365
|
}, ctx?: RouteContext<T> & {
|
|
378
366
|
[key: string]: any;
|
|
379
367
|
}): Promise<{
|
|
380
|
-
code: number
|
|
381
|
-
data:
|
|
382
|
-
message: string
|
|
368
|
+
code: number;
|
|
369
|
+
data: any;
|
|
370
|
+
message: string;
|
|
383
371
|
}>;
|
|
384
372
|
/**
|
|
385
373
|
* 设置上下文
|
|
@@ -414,12 +402,12 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
414
402
|
importRoutes(routes: Route[]): void;
|
|
415
403
|
importRouter(router: QueryRouter): void;
|
|
416
404
|
throw(...args: any[]): void;
|
|
417
|
-
hasRoute(path: string, key?: string): Route<SimpleObject$1, SimpleObject$1
|
|
405
|
+
hasRoute(path: string, key?: string): Route<SimpleObject$1, SimpleObject$1>;
|
|
418
406
|
findRoute(opts?: {
|
|
419
407
|
path?: string;
|
|
420
408
|
key?: string;
|
|
421
409
|
rid?: string;
|
|
422
|
-
}): Route<SimpleObject$1, SimpleObject$1
|
|
410
|
+
}): Route<SimpleObject$1, SimpleObject$1>;
|
|
423
411
|
createRouteList(opts?: {
|
|
424
412
|
force?: boolean;
|
|
425
413
|
filter?: (route: Route) => boolean;
|
|
@@ -513,6 +501,7 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
|
|
|
513
501
|
path?: string;
|
|
514
502
|
key?: string;
|
|
515
503
|
payload?: any;
|
|
504
|
+
args?: any;
|
|
516
505
|
token?: string;
|
|
517
506
|
data?: any;
|
|
518
507
|
}, ctx?: Partial<RouteContext<C>>): Promise<any>;
|
|
@@ -528,7 +517,9 @@ declare class QueryRouterServer<C extends SimpleObject$1 = SimpleObject$1> exten
|
|
|
528
517
|
* 创建认证相关的中间件,默认是 auth, auth-admin, auth-can 三个中间件
|
|
529
518
|
* @param fun 认证函数,接收 RouteContext 和认证类型
|
|
530
519
|
*/
|
|
531
|
-
createAuth(fun
|
|
520
|
+
createAuth(fun?: (ctx: RouteContext<C>, type?: 'auth' | 'auth-admin' | 'auth-can') => any, opts?: {
|
|
521
|
+
overwrite?: boolean;
|
|
522
|
+
}): Promise<void>;
|
|
532
523
|
}
|
|
533
524
|
declare class Mini extends QueryRouterServer {
|
|
534
525
|
}
|
|
@@ -622,8 +613,8 @@ declare class Chain {
|
|
|
622
613
|
object: RouteOpts;
|
|
623
614
|
app?: QueryRouterServer;
|
|
624
615
|
constructor(object: RouteOpts, opts?: ChainOptions);
|
|
625
|
-
get key(): string
|
|
626
|
-
get path(): string
|
|
616
|
+
get key(): string;
|
|
617
|
+
get path(): string;
|
|
627
618
|
setDescription(desc: string): this;
|
|
628
619
|
setMeta(metadata: {
|
|
629
620
|
[key: string]: any;
|
|
@@ -677,5 +668,5 @@ declare class QueryUtil<T extends RouteObject = RouteObject> {
|
|
|
677
668
|
|
|
678
669
|
declare const App: typeof QueryRouterServer;
|
|
679
670
|
|
|
680
|
-
export { App, CustomError, Mini,
|
|
681
|
-
export type {
|
|
671
|
+
export { App, CustomError, Mini, QueryRouter, QueryRouterServer, QueryUtil, Route, createSchema, createSkill, define, fromJSONSchema, toJSONSchema, tool, util };
|
|
672
|
+
export type { RouteArray, RouteContext, RouteInfo, RouteMiddleware, RouteObject, RouteOpts, Rule, Run, Schema, Skill };
|