@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.
@@ -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 | undefined;
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 | undefined;
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 | undefined;
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: null;
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 | undefined;
363
- data: string | number | Object | null | undefined;
364
- message: string | undefined;
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 | undefined;
381
- data: string | number | Object | null | undefined;
382
- message: string | undefined;
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> | undefined;
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> | undefined;
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: (ctx: RouteContext<C>, type?: 'auth' | 'auth-admin' | 'auth-can') => any): Promise<void>;
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 | undefined;
626
- get path(): string | undefined;
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, MockProcess, QueryRouter, QueryRouterServer, QueryUtil, Route, createSchema, createSkill, define, fromJSONSchema, toJSONSchema, tool, util };
681
- export type { ListenProcessParams, ListenProcessResponse, RouteArray, RouteContext, RouteInfo, RouteMiddleware, RouteObject, RouteOpts, Rule, Run, Schema, Skill };
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 };