@kevisual/router 0.0.71 → 0.0.73

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/router.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { z } from 'zod';
3
- import { RouteOpts as RouteOpts$1, QueryRouterServer as QueryRouterServer$1, RouteMiddleware as RouteMiddleware$1, Run as Run$1 } from '@kevisual/router';
4
3
  import { Query, DataOpts, Result } from '@kevisual/query/query';
5
4
  import * as http from 'node:http';
6
5
  import http__default, { IncomingMessage, ServerResponse } from 'node:http';
@@ -204,7 +203,7 @@ declare class Route<U = {
204
203
  define<T extends {
205
204
  [key: string]: any;
206
205
  } = RouterContextT>(path: string, key: string, fn: Run<T & U>): this;
207
- update(opts: DefineRouteOpts, checkList?: string[]): this;
206
+ update(opts: DefineRouteOpts, onlyUpdateList?: string[]): this;
208
207
  addTo(router: QueryRouter | {
209
208
  add: (route: Route) => void;
210
209
  [key: string]: any;
@@ -244,7 +243,7 @@ declare class QueryRouter {
244
243
  * remove route by id
245
244
  * @param uniqueId
246
245
  */
247
- removeById(unique: string): void;
246
+ removeById(uniqueId: string): void;
248
247
  /**
249
248
  * 执行route
250
249
  * @param path
@@ -362,7 +361,11 @@ declare class QueryRouter {
362
361
  }): Route<{
363
362
  [key: string]: any;
364
363
  }, SimpleObject$1>;
365
- createRouteList(force?: boolean, filter?: (route: Route) => boolean): void;
364
+ createRouteList(opts?: {
365
+ force?: boolean;
366
+ filter?: (route: Route) => boolean;
367
+ middleware?: string[];
368
+ }): void;
366
369
  /**
367
370
  * 等待程序运行, 获取到message的数据,就执行
368
371
  * params 是预设参数
@@ -379,6 +382,7 @@ declare class QueryRouter {
379
382
  getList?: boolean;
380
383
  force?: boolean;
381
384
  filter?: (route: Route) => boolean;
385
+ routeListMiddleware?: string[];
382
386
  }): Promise<void>;
383
387
  toJSONSchema: (route: RouteInfo) => Pick<RouteInfo, "path" | "key" | "id" | "description" | "type" | "middleware" | "metadata">;
384
388
  fromJSONSchema: (route: RouteInfo) => RouteInfo;
@@ -501,20 +505,20 @@ declare class CustomError extends Error {
501
505
  }
502
506
 
503
507
  type RouteObject = {
504
- [key: string]: RouteOpts$1;
508
+ [key: string]: RouteOpts;
505
509
  };
506
510
  type SimpleObject = Record<string, any>;
507
- declare function define<T extends Record<string, RouteOpts$1>>(value: T): {
508
- [K in keyof T]: T[K] & RouteOpts$1;
511
+ declare function define<T extends Record<string, RouteOpts>>(value: T): {
512
+ [K in keyof T]: T[K] & RouteOpts;
509
513
  };
510
- type RouteArray = RouteOpts$1[];
514
+ type RouteArray = RouteOpts[];
511
515
  type ChainOptions = {
512
- app: QueryRouterServer$1;
516
+ app: QueryRouterServer;
513
517
  };
514
518
  declare class Chain {
515
- object: RouteOpts$1;
516
- app?: QueryRouterServer$1;
517
- constructor(object: RouteOpts$1, opts?: ChainOptions);
519
+ object: RouteOpts;
520
+ app?: QueryRouterServer;
521
+ constructor(object: RouteOpts, opts?: ChainOptions);
518
522
  get key(): string;
519
523
  get path(): string;
520
524
  setDescription(desc: string): this;
@@ -522,11 +526,11 @@ declare class Chain {
522
526
  [key: string]: any;
523
527
  }): this;
524
528
  setPath(path: string): this;
525
- setMiddleware(middleware: RouteMiddleware$1[]): this;
529
+ setMiddleware(middleware: RouteMiddleware[]): this;
526
530
  setKey(key: string): this;
527
531
  setId(key: string): this;
528
- setRun<U extends SimpleObject = {}>(run: Run$1<U>): this;
529
- define<U extends SimpleObject = {}>(run: Run$1<U>): this;
532
+ setRun<U extends SimpleObject = {}>(run: Run<U>): this;
533
+ define<U extends SimpleObject = {}>(run: Run<U>): this;
530
534
  createRoute(): this;
531
535
  }
532
536
  type QueryChainOptions = {
@@ -546,21 +550,21 @@ declare class QueryChain {
546
550
  * @param queryData
547
551
  * @returns
548
552
  */
549
- getKey(queryData?: SimpleObject): Pick<RouteOpts$1, 'path' | 'key' | 'metadata' | 'description'>;
553
+ getKey(queryData?: SimpleObject): Pick<RouteOpts, 'path' | 'key' | 'metadata' | 'description'>;
550
554
  post<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
551
555
  get<R = SimpleObject, P = SimpleObject>(data: P, options?: DataOpts): Promise<Result<R>>;
552
556
  }
553
557
  declare const util: {
554
- getChain: (obj: RouteOpts$1, opts?: ChainOptions) => Chain;
558
+ getChain: (obj: RouteOpts, opts?: ChainOptions) => Chain;
555
559
  };
556
560
  declare class QueryUtil<T extends RouteObject = RouteObject> {
557
561
  obj: T;
558
- app: QueryRouterServer$1;
562
+ app: QueryRouterServer;
559
563
  query: Query;
560
564
  constructor(object: T, opts?: ChainOptions & QueryChainOptions);
561
565
  static createFormObj<U extends RouteObject>(object: U, opts?: ChainOptions): QueryUtil<U>;
562
- static create<U extends Record<string, RouteOpts$1>>(value: U, opts?: ChainOptions): QueryUtil<U>;
563
- get<K extends keyof T>(key: K): RouteOpts$1;
566
+ static create<U extends Record<string, RouteOpts>>(value: U, opts?: ChainOptions): QueryUtil<U>;
567
+ get<K extends keyof T>(key: K): RouteOpts;
564
568
  chain<K extends keyof T>(key: K, opts?: ChainOptions): Chain;
565
569
  queryChain<K extends keyof T>(key: K, opts?: QueryChainOptions): QueryChain;
566
570
  static Chain: typeof Chain;
@@ -978,4 +982,4 @@ declare class App<U = {}> extends QueryRouter {
978
982
  }
979
983
 
980
984
  export { App, CustomError, Mini, MockProcess, QueryRouter, QueryRouterServer, QueryUtil, Route, ServerNode, createSchema, createSkill, define, fromJSONSchema, handleServer, toJSONSchema, tool, util };
981
- export type { HttpListenerFun, ListenProcessParams, ListenProcessResponse, Listener, OnListener, OnWebSocketFn, RouteArray, RouteContext, RouteMiddleware, RouteObject, RouteOpts, RouterReq, RouterRes, Rule, Run, Schema, Skill, WS, WebSocketListenerFun, WebSocketReq, WebSocketRes };
985
+ export type { HttpListenerFun, ListenProcessParams, ListenProcessResponse, Listener, OnListener, OnWebSocketFn, RouteArray, RouteContext, RouteInfo, RouteMiddleware, RouteObject, RouteOpts, RouterReq, RouterRes, Rule, Run, Schema, Skill, WS, WebSocketListenerFun, WebSocketReq, WebSocketRes };